-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update azure service proxy configuration in Spring tier (#24810)
Update azure proxy configuration properties and configure Azure SDK service builder
- Loading branch information
Moary Chen
authored
Oct 28, 2021
1 parent
e49b5a6
commit 876e9af
Showing
16 changed files
with
867 additions
and
25 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
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
19 changes: 19 additions & 0 deletions
19
...-azure-core/src/main/java/com/azure/spring/core/properties/proxy/HttpProxyProperties.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,19 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
package com.azure.spring.core.properties.proxy; | ||
|
||
/** | ||
* Extend the proxy properties for HTTP connection | ||
*/ | ||
public class HttpProxyProperties extends ProxyProperties { | ||
private String nonProxyHosts; | ||
|
||
public String getNonProxyHosts() { | ||
return nonProxyHosts; | ||
} | ||
|
||
public void setNonProxyHosts(String nonProxyHosts) { | ||
this.nonProxyHosts = nonProxyHosts; | ||
} | ||
} |
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
61 changes: 61 additions & 0 deletions
61
...service/src/test/java/com/azure/spring/service/cosmos/CosmosClientBuilderFactoryTest.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,61 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
package com.azure.spring.service.cosmos; | ||
|
||
import com.azure.cosmos.ConnectionMode; | ||
import com.azure.cosmos.CosmosClientBuilder; | ||
import com.azure.cosmos.DirectConnectionConfig; | ||
import com.azure.cosmos.GatewayConnectionConfig; | ||
import com.azure.spring.service.AzureServiceClientBuilderFactoryTestBase; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.mockito.ArgumentMatchers.any; | ||
import static org.mockito.Mockito.verify; | ||
import static org.mockito.Mockito.times; | ||
import static org.mockito.Mockito.mock; | ||
|
||
public class CosmosClientBuilderFactoryTest extends AzureServiceClientBuilderFactoryTestBase<CosmosClientBuilder, | ||
TestAzureCosmosProperties, CosmosClientBuilderFactory> { | ||
|
||
private static final String ENDPOINT = "https://test.documents.azure.com:443/"; | ||
|
||
@Test | ||
void testGatewayConnectionModeConfigured() { | ||
TestAzureCosmosProperties properties = createMinimalServiceProperties(); | ||
properties.setConnectionMode(ConnectionMode.GATEWAY); | ||
final CosmosClientBuilderFactoryExt factoryExt = new CosmosClientBuilderFactoryExt(properties); | ||
final CosmosClientBuilder builder = factoryExt.build(); | ||
verify(builder, times(1)).gatewayMode(any(GatewayConnectionConfig.class)); | ||
verify(builder, times(0)).directMode(any(DirectConnectionConfig.class)); | ||
} | ||
|
||
@Test | ||
void testDirectConnectionModeConfigured() { | ||
TestAzureCosmosProperties properties = createMinimalServiceProperties(); | ||
properties.setConnectionMode(ConnectionMode.DIRECT); | ||
final CosmosClientBuilderFactoryExt factoryExt = new CosmosClientBuilderFactoryExt(properties); | ||
final CosmosClientBuilder builder = factoryExt.build(); | ||
verify(builder, times(0)).gatewayMode(any(GatewayConnectionConfig.class)); | ||
verify(builder, times(1)).directMode(any(DirectConnectionConfig.class), any(GatewayConnectionConfig.class)); | ||
} | ||
|
||
@Override | ||
protected TestAzureCosmosProperties createMinimalServiceProperties() { | ||
TestAzureCosmosProperties cosmosProperties = new TestAzureCosmosProperties(); | ||
cosmosProperties.setEndpoint(ENDPOINT); | ||
return cosmosProperties; | ||
} | ||
|
||
static class CosmosClientBuilderFactoryExt extends CosmosClientBuilderFactory { | ||
|
||
CosmosClientBuilderFactoryExt(TestAzureCosmosProperties cosmosProperties) { | ||
super(cosmosProperties); | ||
} | ||
|
||
@Override | ||
protected CosmosClientBuilder createBuilderInstance() { | ||
return mock(CosmosClientBuilder.class); | ||
} | ||
} | ||
} |
Oops, something went wrong.