-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Fix azure.scopes defaulting to Azure Global when cloud-type=azure_china/azure_us_government #48683
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -5,11 +5,13 @@ | |||||
|
|
||||||
| import com.azure.spring.cloud.autoconfigure.implementation.context.properties.AzureGlobalProperties; | ||||||
| import com.azure.spring.cloud.autoconfigure.implementation.jms.properties.AzureServiceBusJmsProperties; | ||||||
| import com.azure.spring.cloud.autoconfigure.implementation.passwordless.properties.AzureJdbcPasswordlessProperties; | ||||||
| import com.azure.spring.cloud.core.implementation.util.AzurePasswordlessPropertiesUtils; | ||||||
| import com.azure.spring.cloud.core.provider.AzureProfileOptionsProvider; | ||||||
| import org.junit.jupiter.api.Test; | ||||||
|
|
||||||
| import static org.junit.jupiter.api.Assertions.assertEquals; | ||||||
| import static org.junit.jupiter.api.Assertions.assertNull; | ||||||
| import static org.junit.jupiter.api.Assertions.assertTrue; | ||||||
|
|
||||||
| class MergeAzureCommonPropertiesTest { | ||||||
|
|
@@ -116,4 +118,43 @@ void testGetPropertiesFromGlobalAndPasswordlessProperties() { | |||||
| assertEquals("sub", result.getProfile().getSubscriptionId()); | ||||||
| assertEquals("global-tenant-id", result.getProfile().getTenantId()); | ||||||
| } | ||||||
|
|
||||||
| @Test | ||||||
| void testJdbcPropertiesGetCorrectScopeFromGlobalCloudType() { | ||||||
|
||||||
| void testJdbcPropertiesGetCorrectScopeFromGlobalCloudType() { | |
| void testJdbcPropertiesGetCorrectScopeFromChinaCloudTypeInGlobalProperties() { |
Copilot
AI
Apr 3, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test uses the hard-coded property key string "azure.scopes". To reduce brittleness if the underlying key changes, prefer using the canonical constant (e.g., AuthProperty.SCOPES.getPropertyKey()) when reading from the Properties produced by toPasswordlessProperties().
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -51,7 +51,9 @@ public static <T extends PasswordlessProperties> void copyAzureCommonPropertiesI | |||||||||||
| copyPropertiesIgnoreNull(source.getProfile().getEnvironment(), target.getProfile().getEnvironment()); | ||||||||||||
| copyPropertiesIgnoreNull(source.getCredential(), target.getCredential()); | ||||||||||||
|
|
||||||||||||
| target.setScopes(source.getScopes()); | ||||||||||||
| if (source.getScopes() != null) { | ||||||||||||
| target.setScopes(source.getScopes()); | ||||||||||||
|
Comment on lines
+54
to
+55
|
||||||||||||
| if (source.getScopes() != null) { | |
| target.setScopes(source.getScopes()); | |
| String[] scopes = source.getScopes(); | |
| if (scopes != null) { | |
| target.setScopes(scopes); |
Copilot
AI
Apr 3, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new null-guard relies on source.getScopes() returning null when scopes were not explicitly configured. Some PasswordlessProperties implementations compute a non-null default in getScopes() when the backing field is null (e.g., AzureRedisPasswordlessProperties#getScopes), so merging can still overwrite the target’s cloud-type-aware default with an Azure-global scope when the per-service profile.cloudType isn’t set. Consider using a way to distinguish “explicitly set scopes” vs “computed default” (or aligning other implementations with the raw/effective scopes split used for JDBC).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The issue link in this new changelog entry points to #44945, but the PR description indicates this change is intended to fix issue #47096. Please update the changelog link/issue number so it references the correct issue.