Repository navigation
Support disablement of SSL validation for development purposes #214
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Phil Nachreiner (philnach)
merged 37 commits into
AzureCosmosDB:main
from
philnach:vnextemulator
Jan 7, 2026
Merged
Changes from all commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
af27c17
Disabling SSL option for development purposes to work with vnext emul…
philnach 24546e5
Add ability to provide password with PFX
philnach bbd7a88
Merge branch 'main' into vnextemulator
philnach d3e5996
Update Extensions/Cosmos/Cosmos.DataTransfer.CosmosExtension/CosmosEx…
philnach cbd828a
Update Extensions/Cosmos/Cosmos.DataTransfer.CosmosExtension/CosmosEx…
philnach 1752de4
Dispose properly of the X509Chain
philnach 74671a2
Updates to log on failure
philnach d7a2c0c
Add logger to certificates as supposed to writeline
philnach 51c5ac2
remove duplicate cert check
philnach c4c6a20
PR feedback
philnach c2b8dc8
Update Extensions/Cosmos/Cosmos.DataTransfer.CosmosExtension/CosmosEx…
philnach 24205f3
add null check
philnach fbae2e8
add date check to cert
philnach d11b2e3
Update Extensions/Cosmos/Cosmos.DataTransfer.CosmosExtension/CosmosEx…
philnach 1c98b72
Update Extensions/Cosmos/Cosmos.DataTransfer.CosmosExtension/CosmosEx…
philnach 424c5f6
fix build issues
philnach 55a108f
Merge branch 'vnextemulator' of https://github.com/philnach/data-migr…
philnach 3c2af00
Update Extensions/Cosmos/CERTIFICATE_EXAMPLES.md
philnach e5965c3
Update Extensions/Cosmos/Cosmos.DataTransfer.CosmosExtension/CosmosSe…
philnach d4edcfd
Merge branch 'main' into vnextemulator
markjbrown c8170df
Update Extensions/Cosmos/Cosmos.DataTransfer.CosmosExtension/CosmosEx…
philnach a95d075
Update Extensions/Cosmos/Cosmos.DataTransfer.CosmosExtension/CosmosSe…
philnach d2cfecc
Remove all the complexity and simplify to just the disabledsetting
philnach 52a5977
Merge branch 'vnextemulator' of https://github.com/philnach/data-migr…
philnach 7387b3a
missed merge
philnach 8469486
remove examples since we don't support any of them
philnach a1cc6d4
remove vnext mention
philnach f0a53e7
simplify
philnach ccc479f
slight fix on readme
philnach e9b085a
fix last thing copilot was complaining about
philnach 8709b82
Update Extensions/Cosmos/Cosmos.DataTransfer.CosmosExtension/CosmosEx…
philnach 47a50c9
Add AllowBulkExecution
philnach ca8f2f0
Minor wording tweaks
philnach 5169381
Add a test for the SSL disable
philnach a654f9d
Fix broken tests
philnach 9dd7437
Merge branch 'main' into vnextemulator
philnach 5fddf94
Merge branch 'main' into vnextemulator
philnach File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
102 changes: 102 additions & 0 deletions
102
...ons/Cosmos/Cosmos.DataTransfer.CosmosExtension.UnitTests/CertificateConfigurationTests.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| using System.ComponentModel.DataAnnotations; | ||
| using Microsoft.Extensions.Logging; | ||
| using Moq; | ||
|
|
||
| namespace Cosmos.DataTransfer.CosmosExtension.UnitTests | ||
| { | ||
| [TestClass] | ||
| public class CertificateConfigurationTests | ||
| { | ||
| [TestMethod] | ||
| public void CosmosSettingsBase_WithDisableSslValidation_ShouldValidateSuccessfully() | ||
| { | ||
| var settings = new TestableCosmosSettings | ||
| { | ||
| ConnectionString = "AccountEndpoint=https://localhost:8081/;AccountKey=C2y6yDj...", | ||
| Database = "testDb", | ||
| Container = "testContainer", | ||
| DisableSslValidation = true | ||
| }; | ||
|
|
||
| var validationResults = settings.Validate(new ValidationContext(settings)).ToList(); | ||
|
|
||
| Assert.AreEqual(0, validationResults.Count, "Should have no validation errors"); | ||
| } | ||
|
|
||
| [TestMethod] | ||
| public void CosmosSettingsBase_WithDisableSslValidationFalse_ShouldUseDefaultValidation() | ||
| { | ||
| var settings = new TestableCosmosSettings | ||
| { | ||
| ConnectionString = "AccountEndpoint=https://localhost:8081/;AccountKey=C2y6yDj...", | ||
| Database = "testDb", | ||
| Container = "testContainer", | ||
| DisableSslValidation = false | ||
| }; | ||
|
|
||
| var validationResults = settings.Validate(new ValidationContext(settings)).ToList(); | ||
|
|
||
| Assert.AreEqual(0, validationResults.Count, "Settings should validate with DisableSslValidation=false"); | ||
| } | ||
|
|
||
| [TestMethod] | ||
| public void CreateClient_WithDisableSslValidation_LogsWarningAndSetsCallback() | ||
| { | ||
| var loggerMock = new Mock<ILogger>(); | ||
| var settings = new TestableCosmosSettings | ||
| { | ||
| ConnectionString = "AccountEndpoint=https://localhost:8081/;AccountKey=C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==", | ||
| Database = "testDb", | ||
| Container = "testContainer", | ||
| DisableSslValidation = true | ||
| }; | ||
|
|
||
| var client = CosmosExtensionServices.CreateClient(settings, "TestDisplay", loggerMock.Object); | ||
|
|
||
| // Verify warning was logged when DisableSslValidation is true | ||
| loggerMock.Verify( | ||
| x => x.Log( | ||
| LogLevel.Warning, | ||
| It.IsAny<EventId>(), | ||
| It.Is<It.IsAnyType>((v, t) => v.ToString()!.Contains("SSL certificate validation is DISABLED")), | ||
| It.IsAny<Exception?>(), | ||
| It.IsAny<Func<It.IsAnyType, Exception?, string>>()), | ||
| Times.Once); | ||
|
|
||
| // Verify client was created successfully | ||
| Assert.IsNotNull(client, "CosmosClient should be created"); | ||
| } | ||
|
|
||
| [TestMethod] | ||
| public void CreateClient_WithoutDisableSslValidation_DoesNotLogWarning() | ||
| { | ||
| var loggerMock = new Mock<ILogger>(); | ||
| var settings = new TestableCosmosSettings | ||
| { | ||
| ConnectionString = "AccountEndpoint=https://localhost:8081/;AccountKey=C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==", | ||
| Database = "testDb", | ||
| Container = "testContainer", | ||
| DisableSslValidation = false | ||
| }; | ||
|
|
||
| var client = CosmosExtensionServices.CreateClient(settings, "TestDisplay", loggerMock.Object); | ||
|
|
||
| // Verify warning was NOT logged when DisableSslValidation is false | ||
| loggerMock.Verify( | ||
| x => x.Log( | ||
| LogLevel.Warning, | ||
| It.IsAny<EventId>(), | ||
| It.Is<It.IsAnyType>((v, t) => v.ToString()!.Contains("SSL certificate validation is DISABLED")), | ||
| It.IsAny<Exception?>(), | ||
| It.IsAny<Func<It.IsAnyType, Exception?, string>>()), | ||
| Times.Never); | ||
|
|
||
| // Verify client was created successfully | ||
| Assert.IsNotNull(client, "CosmosClient should be created"); | ||
| } | ||
|
|
||
| private class TestableCosmosSettings : CosmosSettingsBase | ||
| { | ||
| } | ||
| } | ||
| } | ||
25 changes: 25 additions & 0 deletions
25
Extensions/Cosmos/Cosmos.DataTransfer.CosmosExtension.UnitTests/CosmosSettingsBaseTests.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
| using Cosmos.DataTransfer.CosmosExtension; | ||
|
|
||
| namespace Cosmos.DataTransfer.CosmosExtension.UnitTests | ||
| { | ||
| [TestClass] | ||
| public class CosmosSettingsBaseTests | ||
| { | ||
| private class TestableCosmosSettings : CosmosSettingsBase { } | ||
|
|
||
| [TestMethod] | ||
| public void AllowBulkExecution_Property_ShouldSetAndGet() | ||
| { | ||
| var settings = new TestableCosmosSettings | ||
| { | ||
| AllowBulkExecution = true | ||
| }; | ||
|
|
||
| Assert.IsTrue(settings.AllowBulkExecution, "AllowBulkExecution should be true when set to true"); | ||
|
|
||
| settings.AllowBulkExecution = false; | ||
| Assert.IsFalse(settings.AllowBulkExecution, "AllowBulkExecution should be false when set to false"); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.