Skip to content

Commit 35a158a

Browse files
Copilotrujche
andauthored
Update CHANGELOG to mention Redis; add Redis cloud-type scope tests
Agent-Logs-Url: https://github.com/Azure/azure-sdk-for-java/sessions/40b2a63f-fac7-442b-a70a-f33b4e2a67a3 Co-authored-by: rujche <171773178+rujche@users.noreply.github.com>
1 parent 2919235 commit 35a158a

2 files changed

Lines changed: 62 additions & 1 deletion

File tree

sdk/spring/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ This section includes changes in `spring-cloud-azure-autoconfigure` module.
77

88
#### Bugs Fixed
99

10-
- Fixed JDBC/Azure Database passwordless connection scope defaulting using the wrong `azure.scopes` value for Azure China and Azure US Government when `spring.cloud.azure.profile.cloud-type` is set to `azure_china` or `azure_us_government`. The scopes are now correctly derived from the merged cloud type. ([#47096](https://github.com/Azure/azure-sdk-for-java/issues/47096))
10+
- Fixed JDBC/Azure Database and Redis passwordless connection scope defaulting using the wrong `azure.scopes` value for Azure China and Azure US Government when `spring.cloud.azure.profile.cloud-type` is set to `azure_china` or `azure_us_government`. The scopes are now correctly derived from the merged cloud type. ([#47096](https://github.com/Azure/azure-sdk-for-java/issues/47096))
1111

1212
## 7.2.0 (2026-04-17)
1313
- This release is compatible with Spring Boot 4.0.0-4.0.5. (Note: 4.0.x (x>5) should be supported, but they aren't tested with this release.)

sdk/spring/spring-cloud-azure-autoconfigure/src/test/java/com/azure/spring/cloud/autoconfigure/implementation/passwordless/MergeAzureCommonPropertiesTest.java

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import com.azure.spring.cloud.autoconfigure.implementation.context.properties.AzureGlobalProperties;
77
import com.azure.spring.cloud.autoconfigure.implementation.jms.properties.AzureServiceBusJmsProperties;
88
import com.azure.spring.cloud.autoconfigure.implementation.passwordless.properties.AzureJdbcPasswordlessProperties;
9+
import com.azure.spring.cloud.autoconfigure.implementation.passwordless.properties.AzureRedisPasswordlessProperties;
910
import com.azure.spring.cloud.core.implementation.util.AzurePasswordlessPropertiesUtils;
1011
import com.azure.spring.cloud.core.provider.AzureProfileOptionsProvider;
1112
import com.azure.identity.extensions.implementation.enums.AuthProperty;
@@ -158,4 +159,64 @@ void testJdbcPropertiesExplicitScopesOverridesDefault() {
158159
assertEquals("https://custom-scope/.default",
159160
result.toPasswordlessProperties().getProperty(AuthProperty.SCOPES.getPropertyKey()));
160161
}
162+
163+
@Test
164+
void testRedisPropertiesGetCorrectScopeFromChinaCloudTypeInGlobalProperties() {
165+
AzureGlobalProperties globalProperties = new AzureGlobalProperties();
166+
globalProperties.getProfile().setCloudType(AzureProfileOptionsProvider.CloudType.AZURE_CHINA);
167+
168+
AzureRedisPasswordlessProperties redisProperties = new AzureRedisPasswordlessProperties();
169+
// User has not explicitly set scopes
170+
171+
AzureRedisPasswordlessProperties result = new AzureRedisPasswordlessProperties();
172+
AzurePasswordlessPropertiesUtils.mergeAzureCommonProperties(globalProperties, redisProperties, result);
173+
174+
// scopes field should be null (not explicitly set)
175+
assertNull(result.getScopes());
176+
// effective scopes should use the merged cloud type (AZURE_CHINA)
177+
assertEquals("https://*.cacheinfra.windows.net.china:10225/appid/.default", result.getEffectiveScopes());
178+
// toPasswordlessProperties should include the correct cloud-type-aware scope
179+
assertEquals("https://*.cacheinfra.windows.net.china:10225/appid/.default",
180+
result.toPasswordlessProperties().getProperty(AuthProperty.SCOPES.getPropertyKey()));
181+
assertEquals(AzureProfileOptionsProvider.CloudType.AZURE_CHINA, result.getProfile().getCloudType());
182+
}
183+
184+
@Test
185+
void testRedisPropertiesGetCorrectScopeFromUsGovCloudTypeInGlobalProperties() {
186+
AzureGlobalProperties globalProperties = new AzureGlobalProperties();
187+
globalProperties.getProfile().setCloudType(AzureProfileOptionsProvider.CloudType.AZURE_US_GOVERNMENT);
188+
189+
AzureRedisPasswordlessProperties redisProperties = new AzureRedisPasswordlessProperties();
190+
// User has not explicitly set scopes
191+
192+
AzureRedisPasswordlessProperties result = new AzureRedisPasswordlessProperties();
193+
AzurePasswordlessPropertiesUtils.mergeAzureCommonProperties(globalProperties, redisProperties, result);
194+
195+
// scopes field should be null (not explicitly set)
196+
assertNull(result.getScopes());
197+
// effective scopes should use the merged cloud type (AZURE_US_GOVERNMENT)
198+
assertEquals("https://*.cacheinfra.windows.us.government.net:10225/appid/.default", result.getEffectiveScopes());
199+
// toPasswordlessProperties should include the correct cloud-type-aware scope
200+
assertEquals("https://*.cacheinfra.windows.us.government.net:10225/appid/.default",
201+
result.toPasswordlessProperties().getProperty(AuthProperty.SCOPES.getPropertyKey()));
202+
assertEquals(AzureProfileOptionsProvider.CloudType.AZURE_US_GOVERNMENT, result.getProfile().getCloudType());
203+
}
204+
205+
@Test
206+
void testRedisPropertiesExplicitScopesOverridesDefault() {
207+
AzureGlobalProperties globalProperties = new AzureGlobalProperties();
208+
globalProperties.getProfile().setCloudType(AzureProfileOptionsProvider.CloudType.AZURE_CHINA);
209+
210+
AzureRedisPasswordlessProperties redisProperties = new AzureRedisPasswordlessProperties();
211+
redisProperties.setScopes("https://custom-redis-scope/.default");
212+
213+
AzureRedisPasswordlessProperties result = new AzureRedisPasswordlessProperties();
214+
AzurePasswordlessPropertiesUtils.mergeAzureCommonProperties(globalProperties, redisProperties, result);
215+
216+
// Explicit scopes should be preserved
217+
assertEquals("https://custom-redis-scope/.default", result.getScopes());
218+
assertEquals("https://custom-redis-scope/.default", result.getEffectiveScopes());
219+
assertEquals("https://custom-redis-scope/.default",
220+
result.toPasswordlessProperties().getProperty(AuthProperty.SCOPES.getPropertyKey()));
221+
}
161222
}

0 commit comments

Comments
 (0)