forked from Azure/azure-sdk-for-java
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactorInsecureConnectionConfig (Azure#42972)
* refactor insecure connection config --------- Co-authored-by: annie-mac <[email protected]>
- Loading branch information
Showing
18 changed files
with
212 additions
and
37 deletions.
There are no files selected for viewing
This file contains 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 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 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
38 changes: 38 additions & 0 deletions
38
...azure-cosmos-tests/src/test/java/com/azure/cosmos/ClientBuilderConnectionPolicyTests.java
This file contains 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,38 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
package com.azure.cosmos; | ||
|
||
import org.testng.annotations.DataProvider; | ||
import org.testng.annotations.Test; | ||
|
||
import static org.assertj.core.api.AssertionsForClassTypes.assertThat; | ||
|
||
public class ClientBuilderConnectionPolicyTests { | ||
@DataProvider(name = "endpointArgProvider") | ||
public static Object[][] endpointArgProvider() { | ||
return new Object[][]{ | ||
{ "https://localhost", true }, | ||
{ "https://Localhost", true }, | ||
{ "http://Localhost", true }, | ||
{ "https://127.0.0.1", true }, | ||
{ "https://[::1]", true }, | ||
{ "https://[0:0:0:0:0:0:0:1]", true }, | ||
{ "https://random", false} | ||
}; | ||
} | ||
|
||
@Test(groups = "emulator", dataProvider = "endpointArgProvider") | ||
public void clientWithServerCertValidationDisabled(String endPoint, boolean isEmulatorHost) { | ||
System.setProperty("COSMOS.EMULATOR_SERVER_CERTIFICATE_VALIDATION_DISABLED", "true"); | ||
|
||
try { | ||
CosmosClientBuilder clientBuilder = new CosmosClientBuilder().endpoint(endPoint).key("key"); | ||
clientBuilder.validateConfig(); | ||
clientBuilder.buildConnectionPolicy(); | ||
assertThat(clientBuilder.getConnectionPolicy().isServerCertValidationDisabled()).isEqualTo(isEmulatorHost); | ||
} finally { | ||
System.clearProperty("COSMOS.EMULATOR_SERVER_CERTIFICATE_VALIDATION_DISABLED"); | ||
} | ||
} | ||
} |
This file contains 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 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 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 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 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 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 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.