Skip to content

Commit fd961e3

Browse files
authored
Adding authentication type configuration key and fixing system default authentication type (Azure#28074)
* Adding authentication type as configuration key and setting the system default authentication type to NONE * Updated unit test to check system default auth type is not null and Updated changelog
1 parent 7e72f82 commit fd961e3

File tree

4 files changed

+34
-11
lines changed

4 files changed

+34
-11
lines changed

sdk/core/azure-core-amqp/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
### Breaking Changes
88

99
### Bugs Fixed
10+
- Fixed proxy authentication type not being read from configuration. ([#28073](https://github.com/Azure/azure-sdk-for-java/issues/28073))
11+
- Updated ProxyOptions.SYSTEM_DEFAULTS to use ProxyAuthenticationType.NONE
1012

1113
### Other Changes
1214

sdk/core/azure-core-amqp/src/main/java/com/azure/core/amqp/ProxyOptions.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,15 @@ public class ProxyOptions implements AutoCloseable {
2424
* The configuration key for containing the password for the username who authenticates with the proxy.
2525
*/
2626
public static final String PROXY_PASSWORD = "PROXY_PASSWORD";
27+
/**
28+
* The configuration key for containing the authentication type to be used by the proxy.
29+
* This can one of three values -
30+
* - NONE
31+
* - BASIC
32+
* - DIGEST
33+
* as defined in ProxyAuthenticationType
34+
*/
35+
public static final String PROXY_AUTHENTICATION_TYPE = "PROXY_AUTHENTICATION_TYPE";
2736

2837
private static final ClientLogger LOGGER = new ClientLogger(ProxyOptions.class);
2938
private final PasswordAuthentication credentials;
@@ -38,7 +47,7 @@ public class ProxyOptions implements AutoCloseable {
3847
private ProxyOptions() {
3948
this.credentials = null;
4049
this.proxyAddress = null;
41-
this.authentication = null;
50+
this.authentication = ProxyAuthenticationType.NONE;
4251
}
4352

4453
/**
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
package com.azure.core.amqp;
5+
6+
import org.junit.jupiter.api.Assertions;
7+
import org.junit.jupiter.api.Test;
8+
9+
import static com.azure.core.amqp.ProxyOptions.SYSTEM_DEFAULTS;
10+
11+
public class ProxyOptionsTest {
12+
13+
/**
14+
* Test System default proxy configuration properties are set
15+
*/
16+
@Test
17+
public void systemDefaultProxyConfiguration() {
18+
Assertions.assertEquals(ProxyAuthenticationType.NONE, SYSTEM_DEFAULTS.getAuthentication());
19+
Assertions.assertNull(SYSTEM_DEFAULTS.getCredential());
20+
Assertions.assertNull(SYSTEM_DEFAULTS.getProxyAddress());
21+
}
22+
}

sdk/eventhubs/azure-messaging-eventhubs/src/test/java/com/azure/messaging/eventhubs/models/ProxyOptionsTest.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,12 @@
66
import com.azure.core.amqp.ProxyAuthenticationType;
77
import com.azure.core.amqp.ProxyOptions;
88
import org.junit.jupiter.api.Assertions;
9-
import org.junit.jupiter.api.Test;
109
import org.junit.jupiter.params.ParameterizedTest;
1110
import org.junit.jupiter.params.provider.EnumSource;
1211

1312
import java.net.InetSocketAddress;
1413
import java.net.Proxy;
1514

16-
import static com.azure.core.amqp.ProxyOptions.SYSTEM_DEFAULTS;
17-
1815
public class ProxyOptionsTest {
1916

2017
private static final String PROXY_HOST = "127.0.0.1";
@@ -25,13 +22,6 @@ public class ProxyOptionsTest {
2522

2623
private static Proxy proxyAddress = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(PROXY_HOST, Integer.parseInt(PROXY_PORT)));
2724

28-
@Test
29-
public void nullProxyConfiguration() {
30-
Assertions.assertNull(SYSTEM_DEFAULTS.getAuthentication());
31-
Assertions.assertNull(SYSTEM_DEFAULTS.getCredential());
32-
Assertions.assertNull(SYSTEM_DEFAULTS.getProxyAddress());
33-
}
34-
3525
@ParameterizedTest
3626
@EnumSource(ProxyAuthenticationType.class)
3727
public void validateProxyConfiguration(ProxyAuthenticationType proxyAuthenticationType) {

0 commit comments

Comments
 (0)