From 40e0b4d3637870c9b391a98b596b9230af296fb2 Mon Sep 17 00:00:00 2001 From: Bill Wert Date: Wed, 28 Feb 2024 12:51:04 -0800 Subject: [PATCH] IdentityClientOptions clone method mistakenly enables probing for broker support (#39002) --- .../identity/implementation/IdentityClientOptions.java | 9 ++++++--- .../implementation/IdentityClientOptionsTest.java | 9 +++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/sdk/identity/azure-identity/src/main/java/com/azure/identity/implementation/IdentityClientOptions.java b/sdk/identity/azure-identity/src/main/java/com/azure/identity/implementation/IdentityClientOptions.java index de52785488d60..4350bb5e9ebe1 100644 --- a/sdk/identity/azure-identity/src/main/java/com/azure/identity/implementation/IdentityClientOptions.java +++ b/sdk/identity/azure-identity/src/main/java/com/azure/identity/implementation/IdentityClientOptions.java @@ -837,9 +837,12 @@ public IdentityClientOptions clone() { .setPerCallPolicies(this.perCallPolicies) .setPerRetryPolicies(this.perRetryPolicies) .setBrowserCustomizationOptions(this.browserCustomizationOptions) - .setChained(this.isChained) - .setBrokerWindowHandle(this.brokerWindowHandle) - .setEnableLegacyMsaPassthrough(this.enableMsaPassthrough); + .setChained(this.isChained); + + if (isBrokerEnabled()) { + clone.setBrokerWindowHandle(this.brokerWindowHandle); + clone.setEnableLegacyMsaPassthrough(this.enableMsaPassthrough); + } if (!isInstanceDiscoveryEnabled()) { clone.disableInstanceDiscovery(); } diff --git a/sdk/identity/azure-identity/src/test/java/com/azure/identity/implementation/IdentityClientOptionsTest.java b/sdk/identity/azure-identity/src/test/java/com/azure/identity/implementation/IdentityClientOptionsTest.java index 60f6b7bf734f6..7e1b47abcbc57 100644 --- a/sdk/identity/azure-identity/src/test/java/com/azure/identity/implementation/IdentityClientOptionsTest.java +++ b/sdk/identity/azure-identity/src/test/java/com/azure/identity/implementation/IdentityClientOptionsTest.java @@ -42,4 +42,13 @@ public void testDisableAuthorityValidationAndInstanceDiscovery() { identityClientOptions.disableInstanceDiscovery(); Assertions.assertFalse(identityClientOptions.isInstanceDiscoveryEnabled()); } + + @Test + public void testCloneDoesNotEnableThingsItShouldNot() { + IdentityClientOptions identityClientOptions = new IdentityClientOptions(); + + IdentityClientOptions clonedOptions = identityClientOptions.clone(); + Assertions.assertFalse(clonedOptions.isBrokerEnabled()); + Assertions.assertFalse(clonedOptions.isUnsafeSupportLoggingEnabled()); + } }