From a28a3f79809110d434ec62e896ac5641463398ac Mon Sep 17 00:00:00 2001 From: Robert McCahill Date: Thu, 20 Jun 2024 15:22:30 +0100 Subject: [PATCH 01/20] Add check for empty correlation ID when setting request headers, update tests --- .../providers/NativeAuthRequestProvider.kt | 7 +- .../providers/NativeAuthRequestHandlerTest.kt | 271 ++++++++++++++++-- 2 files changed, 261 insertions(+), 17 deletions(-) diff --git a/common4j/src/main/com/microsoft/identity/common/java/nativeauth/providers/NativeAuthRequestProvider.kt b/common4j/src/main/com/microsoft/identity/common/java/nativeauth/providers/NativeAuthRequestProvider.kt index 37db8d0630..1b0aa59a86 100644 --- a/common4j/src/main/com/microsoft/identity/common/java/nativeauth/providers/NativeAuthRequestProvider.kt +++ b/common4j/src/main/com/microsoft/identity/common/java/nativeauth/providers/NativeAuthRequestProvider.kt @@ -50,6 +50,7 @@ import com.microsoft.identity.common.java.nativeauth.providers.requests.signup.S import com.microsoft.identity.common.java.nativeauth.providers.requests.signup.SignUpContinueRequest import com.microsoft.identity.common.java.nativeauth.providers.requests.signup.SignUpStartRequest import com.microsoft.identity.common.java.platform.Device +import com.microsoft.identity.common.java.util.StringUtil import java.util.TreeMap /** @@ -310,7 +311,11 @@ class NativeAuthRequestProvider(private val config: NativeAuthOAuth2Configuratio //region helpers private fun getRequestHeaders(correlationId: String): Map { val headers: MutableMap = TreeMap() - headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID] = correlationId + + if (correlationId != "UNSET") { + headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID] = correlationId + } + headers[AuthenticationConstants.SdkPlatformFields.PRODUCT] = DiagnosticContext.INSTANCE.requestContext[AuthenticationConstants.SdkPlatformFields.PRODUCT] headers[AuthenticationConstants.SdkPlatformFields.VERSION] = Device.getProductVersion() headers.putAll(Device.getPlatformIdParameters()) diff --git a/common4j/src/test/com/microsoft/identity/common/java/nativeauth/providers/NativeAuthRequestHandlerTest.kt b/common4j/src/test/com/microsoft/identity/common/java/nativeauth/providers/NativeAuthRequestHandlerTest.kt index 9c8e52faa9..8dac943df3 100644 --- a/common4j/src/test/com/microsoft/identity/common/java/nativeauth/providers/NativeAuthRequestHandlerTest.kt +++ b/common4j/src/test/com/microsoft/identity/common/java/nativeauth/providers/NativeAuthRequestHandlerTest.kt @@ -22,6 +22,7 @@ // THE SOFTWARE. package com.microsoft.identity.common.java.nativeauth.providers +import com.microsoft.identity.common.java.AuthenticationConstants import com.microsoft.identity.common.java.nativeauth.commands.parameters.ResetPasswordStartCommandParameters import com.microsoft.identity.common.java.nativeauth.commands.parameters.ResetPasswordSubmitCodeCommandParameters import com.microsoft.identity.common.java.nativeauth.commands.parameters.ResetPasswordSubmitNewPasswordCommandParameters @@ -41,6 +42,7 @@ import io.mockk.every import io.mockk.mockk import org.junit.Assert import org.junit.Assert.assertEquals +import org.junit.Assert.assertNull import org.junit.Test import org.mockito.kotlin.mock import java.net.URL @@ -100,6 +102,7 @@ class NativeAuthRequestHandlerTest { ) } + @Test fun testSignUpStartWithEmptyPasswordShouldNotThrowException() { val commandParameters = SignUpStartCommandParameters.builder() .platformComponents(mock()) @@ -148,6 +151,22 @@ class NativeAuthRequestHandlerTest { ) } + @Test + fun testSignUpStartWithUnsetCorrelationIdShouldHaveNilHeader() { + val commandParameters = SignUpStartCommandParameters.builder() + .platformComponents(mock()) + .username(username) + .clientId(clientId) + .correlationId("UNSET") + .build() + + val result = nativeAuthRequestProvider.createSignUpStartRequest( + commandParameters = commandParameters + ) + + assertNull(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID]) + } + @Test fun testSignUpStartSuccess() { val commandParameters = SignUpStartCommandParameters.builder() @@ -167,6 +186,7 @@ class NativeAuthRequestHandlerTest { assertEquals(challengeType, result.parameters.challengeType) assertEquals(ApiConstants.MockApi.signUpStartRequestUrl, result.requestUrl) assertEquals(userAttributes.toJsonString(userAttributes), result.parameters.attributes) + assertEquals(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID], correlationId) } @Test @@ -189,6 +209,24 @@ class NativeAuthRequestHandlerTest { assertEquals(challengeType, result.parameters.challengeType) assertEquals(ApiConstants.MockApi.signUpStartRequestUrl, result.requestUrl) assertEquals(userAttributes.toJsonString(userAttributes), result.parameters.attributes) + assertEquals(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID], correlationId) + } + + @Test + fun testSignUpSubmitCodeWithUnsetCorrelationIdShouldHaveNilHeader() { + val commandParameters = SignUpSubmitCodeCommandParameters.builder() + .platformComponents(mock()) + .continuationToken(continuationToken) + .code(oobCode) + .clientId(clientId) + .correlationId("UNSET") + .build() + + val result = nativeAuthRequestProvider.createSignUpSubmitCodeRequest( + commandParameters = commandParameters + ) + + assertNull(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID]) } @Test @@ -209,6 +247,24 @@ class NativeAuthRequestHandlerTest { assertEquals(continuationToken, result.parameters.continuationToken) assertEquals(oobGrantType, result.parameters.grantType) assertEquals(ApiConstants.MockApi.signUpContinueRequestUrl, result.requestUrl) + assertEquals(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID], correlationId) + } + + @Test + fun testSignUpSubmitPasswordWithUnsetCorrelationIdShouldHaveNilHeader() { + val commandParameters = SignUpSubmitPasswordCommandParameters.builder() + .platformComponents(mock()) + .continuationToken(continuationToken) + .password(password) + .clientId(clientId) + .correlationId("UNSET") + .build() + + val result = nativeAuthRequestProvider.createSignUpSubmitPasswordRequest( + commandParameters = commandParameters + ) + + assertNull(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID]) } @Test @@ -229,6 +285,24 @@ class NativeAuthRequestHandlerTest { assertEquals(continuationToken, result.parameters.continuationToken) assertEquals(passwordGrantType, result.parameters.grantType) assertEquals(ApiConstants.MockApi.signUpContinueRequestUrl, result.requestUrl) + assertEquals(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID], correlationId) + } + + @Test + fun testSignUpSubmitUserAttributesWithUnsetCorrelationIdShouldHaveNilHeader() { + val commandParameters = SignUpSubmitUserAttributesCommandParameters.builder() + .platformComponents(mock()) + .continuationToken(continuationToken) + .userAttributes(userAttributes) + .clientId(clientId) + .correlationId("UNSET") + .build() + + val result = nativeAuthRequestProvider.createSignUpSubmitUserAttributesRequest( + commandParameters = commandParameters + ) + + assertNull(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID]) } @Test @@ -248,10 +322,11 @@ class NativeAuthRequestHandlerTest { assertEquals(userAttributes.toJsonString(userAttributes), result.parameters.attributes) assertEquals(continuationToken, result.parameters.continuationToken) assertEquals(ApiConstants.MockApi.signUpContinueRequestUrl, result.requestUrl) + assertEquals(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID], correlationId) } @Test(expected = ClientException::class) - fun testSignUpSubmitEmptyUserAttributesShouldThrowExceptionSuccess() { + fun testSignUpSubmitEmptyUserAttributesShouldThrowException() { val commandParameters = SignUpSubmitUserAttributesCommandParameters.builder() .platformComponents(mock()) .continuationToken(continuationToken) @@ -266,7 +341,7 @@ class NativeAuthRequestHandlerTest { } @Test(expected = ClientException::class) - fun testSignUpSubmitEmptyPasswordShouldThrowExceptionSuccess() { + fun testSignUpSubmitEmptyPasswordShouldThrowException() { val commandParameters = SignUpSubmitPasswordCommandParameters.builder() .platformComponents(mock()) .continuationToken(continuationToken) @@ -281,7 +356,7 @@ class NativeAuthRequestHandlerTest { } @Test(expected = ClientException::class) - fun testSignUpSubmitEmptyCodedShouldThrowExceptionSuccess() { + fun testSignUpSubmitEmptyCodedShouldThrowException() { val commandParameters = SignUpSubmitCodeCommandParameters.builder() .platformComponents(mock()) .continuationToken(continuationToken) @@ -298,11 +373,6 @@ class NativeAuthRequestHandlerTest { // signup challenge tests @Test fun testSignUpChallengeSuccess() { - nativeAuthRequestProvider.createSignUpChallengeRequest( - continuationToken = continuationToken, - correlationId = correlationId - ) - val result = nativeAuthRequestProvider.createSignUpChallengeRequest( continuationToken = continuationToken, correlationId = correlationId @@ -311,6 +381,17 @@ class NativeAuthRequestHandlerTest { assertEquals(challengeType, result.parameters.challengeType) assertEquals(continuationToken, result.parameters.continuationToken) assertEquals(ApiConstants.MockApi.signUpChallengeRequestUrl, result.requestUrl) + assertEquals(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID], correlationId) + } + + @Test + fun testSignUpChallengeWithUnsetCorrelationIdShouldHaveNilHeader() { + val result = nativeAuthRequestProvider.createSignUpChallengeRequest( + continuationToken = continuationToken, + correlationId = "UNSET" + ) + + assertNull(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID]) } @Test(expected = ClientException::class) @@ -355,6 +436,21 @@ class NativeAuthRequestHandlerTest { ) } + @Test + fun testSignInInitiateWithUnsetCorrelationIdShouldHaveNilHeader() { + val commandParameters = SignInStartCommandParameters.builder() + .platformComponents(mock()) + .username(emptyString) + .correlationId("UNSET") + .build() + + val result = nativeAuthRequestProvider.createSignInInitiateRequest( + commandParameters = commandParameters + ) + + assertNull(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID]) + } + @Test(expected = ClientException::class) fun testSignInInitiateWithEmptyClientIdShouldThrowException() { every { mockConfig.clientId } returns emptyString @@ -401,6 +497,7 @@ class NativeAuthRequestHandlerTest { assertEquals(clientId, result.parameters.clientId) assertEquals(challengeType, result.parameters.challengeType) assertEquals(ApiConstants.MockApi.signInInitiateRequestUrl, result.requestUrl) + assertEquals(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID], correlationId) } @Test(expected = ClientException::class) @@ -431,6 +528,16 @@ class NativeAuthRequestHandlerTest { ) } + @Test + fun testSignInChallengeWithUnsetCorrelationIdShouldHaveNilHeader() { + val result = nativeAuthRequestProvider.createSignInChallengeRequest( + continuationToken = continuationToken, + correlationId = "UNSET" + ) + + assertNull(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID]) + } + @Test fun testSignInChallengeSuccess() { val result = nativeAuthRequestProvider.createSignInChallengeRequest( @@ -441,6 +548,7 @@ class NativeAuthRequestHandlerTest { assertEquals(clientId, result.parameters.clientId) assertEquals(continuationToken, result.parameters.continuationToken) assertEquals(ApiConstants.MockApi.signInChallengeRequestUrl, result.requestUrl) + assertEquals(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID], correlationId) } @Test(expected = ClientException::class) @@ -505,6 +613,22 @@ class NativeAuthRequestHandlerTest { ) } + @Test + fun testSignInTokenWithContinuationTokenUnsetCorrelationIdShouldHaveNilHeader() { + val commandParameters = SignInWithContinuationTokenCommandParameters.builder() + .platformComponents(mock()) + .continuationToken(continuationToken) + .username(username) + .correlationId("UNSET") + .build() + + val result = nativeAuthRequestProvider.createContinuationTokenTokenRequest( + commandParameters = commandParameters + ) + + assertNull(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID]) + } + @Test fun testSignInTokenWithContinuationTokenSuccess() { val commandParameters = SignInWithContinuationTokenCommandParameters.builder() @@ -514,9 +638,15 @@ class NativeAuthRequestHandlerTest { .correlationId(correlationId) .build() - nativeAuthRequestProvider.createContinuationTokenTokenRequest( + val result = nativeAuthRequestProvider.createContinuationTokenTokenRequest( commandParameters = commandParameters ) + + assertEquals(username, result.parameters.username) + assertEquals(clientId, result.parameters.clientId) + assertEquals(challengeType, result.parameters.challengeType) + assertEquals(ApiConstants.MockApi.signInTokenRequestUrl, result.requestUrl) + assertEquals(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID], correlationId) } @Test(expected = ClientException::class) @@ -589,6 +719,21 @@ class NativeAuthRequestHandlerTest { ) } + @Test + fun testPasswordTokenRequestWithUnsetCorrelationIdShouldHaveNilHeader() { + val commandParameters = SignInSubmitPasswordCommandParameters.builder() + .platformComponents(mock()) + .password(password) + .continuationToken(continuationToken) + .correlationId("UNSET") + .build() + + val result = nativeAuthRequestProvider.createPasswordTokenRequest( + commandParameters = commandParameters + ) + + assertNull(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID]) + } @Test fun testPasswordTokenRequestSuccess() { val commandParameters = SignInSubmitPasswordCommandParameters.builder() @@ -598,9 +743,14 @@ class NativeAuthRequestHandlerTest { .correlationId(correlationId) .build() - nativeAuthRequestProvider.createPasswordTokenRequest( + val result = nativeAuthRequestProvider.createPasswordTokenRequest( commandParameters = commandParameters ) + + assertEquals(clientId, result.parameters.clientId) + assertEquals(challengeType, result.parameters.challengeType) + assertEquals(ApiConstants.MockApi.signInTokenRequestUrl, result.requestUrl) + assertEquals(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID], correlationId) } @Test(expected = ClientException::class) @@ -677,6 +827,21 @@ class NativeAuthRequestHandlerTest { ) } + @Test + fun testResetPasswordStartWithUnsetCorrelationIdShouldHaveNilHeader() { + val commandParameters = ResetPasswordStartCommandParameters.builder() + .platformComponents(mock()) + .username(username) + .correlationId("UNSET") + .build() + + val result = nativeAuthRequestProvider.createResetPasswordStartRequest( + commandParameters = commandParameters + ) + + assertNull(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID]) + } + @Test fun testResetPasswordStartSuccess() { val commandParameters = ResetPasswordStartCommandParameters.builder() @@ -685,9 +850,15 @@ class NativeAuthRequestHandlerTest { .correlationId(correlationId) .build() - nativeAuthRequestProvider.createResetPasswordStartRequest( + val result = nativeAuthRequestProvider.createResetPasswordStartRequest( commandParameters = commandParameters ) + + assertEquals(username, result.parameters.username) + assertEquals(clientId, result.parameters.clientId) + assertEquals(challengeType, result.parameters.challengeType) + assertEquals(ApiConstants.MockApi.ssprStartRequestUrl, result.requestUrl) + assertEquals(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID], correlationId) } // ResetPassword challenge tests @@ -709,12 +880,26 @@ class NativeAuthRequestHandlerTest { ) } + @Test + fun testResetPasswordChallengeWithUnsetCorrelationIdShouldHaveNilHeader() { + val result = nativeAuthRequestProvider.createResetPasswordChallengeRequest( + continuationToken = continuationToken, + correlationId = "UNSET" + ) + + assertNull(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID]) + } + @Test fun testResetPasswordChallengeSuccess() { - nativeAuthRequestProvider.createResetPasswordChallengeRequest( + val result = nativeAuthRequestProvider.createResetPasswordChallengeRequest( continuationToken = continuationToken, correlationId = correlationId ) + + assertEquals(clientId, result.parameters.clientId) + assertEquals(ApiConstants.MockApi.ssprChallengeRequestUrl, result.requestUrl) + assertEquals(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID], correlationId) } // ResetPassword continue tests @@ -763,7 +948,23 @@ class NativeAuthRequestHandlerTest { } @Test - fun testResetPasswordContinueSucces() { + fun testResetPasswordContinueWithUnsetCorrelationIdShouldHaveNilHeader() { + val commandParameters = ResetPasswordSubmitCodeCommandParameters.builder() + .platformComponents(mock()) + .code(oobCode) + .continuationToken(continuationToken) + .correlationId("UNSET") + .build() + + val result = nativeAuthRequestProvider.createResetPasswordContinueRequest( + commandParameters = commandParameters + ) + + assertNull(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID]) + } + + @Test + fun testResetPasswordContinueSuccess() { val commandParameters = ResetPasswordSubmitCodeCommandParameters.builder() .platformComponents(mock()) .code(oobCode) @@ -771,9 +972,13 @@ class NativeAuthRequestHandlerTest { .correlationId(correlationId) .build() - nativeAuthRequestProvider.createResetPasswordContinueRequest( + val result = nativeAuthRequestProvider.createResetPasswordContinueRequest( commandParameters = commandParameters ) + + assertEquals(clientId, result.parameters.clientId) + assertEquals(ApiConstants.MockApi.ssprContinueRequestUrl, result.requestUrl) + assertEquals(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID], correlationId) } // ResetPassword submit tests @@ -821,6 +1026,22 @@ class NativeAuthRequestHandlerTest { ) } + @Test + fun testResetPasswordSubmitWithUnsetCorrelationIdShouldHaveNilHeader() { + val commandParameters = ResetPasswordSubmitNewPasswordCommandParameters.builder() + .platformComponents(mock()) + .continuationToken(continuationToken) + .newPassword(password) + .correlationId("UNSET") + .build() + + val result = nativeAuthRequestProvider.createResetPasswordSubmitRequest( + commandParameters = commandParameters + ) + + assertNull(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID]) + } + @Test fun testResetPasswordSubmitSuccess() { val commandParameters = ResetPasswordSubmitNewPasswordCommandParameters.builder() @@ -830,9 +1051,13 @@ class NativeAuthRequestHandlerTest { .correlationId(correlationId) .build() - nativeAuthRequestProvider.createResetPasswordSubmitRequest( + val result = nativeAuthRequestProvider.createResetPasswordSubmitRequest( commandParameters = commandParameters ) + + assertEquals(clientId, result.parameters.clientId) + assertEquals(ApiConstants.MockApi.ssprSubmitRequestUrl, result.requestUrl) + assertEquals(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID], correlationId) } // ResetPassword completion poll tests @@ -854,11 +1079,25 @@ class NativeAuthRequestHandlerTest { ) } + @Test + fun testResetPasswordPollCompletionWithUnsetCorrelationIdShouldHaveNilHeader() { + val result = nativeAuthRequestProvider.createResetPasswordPollCompletionRequest( + continuationToken = continuationToken, + correlationId = "UNSET" + ) + + assertNull(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID]) + } + @Test fun testResetPasswordPollCompletionSuccess() { - nativeAuthRequestProvider.createResetPasswordPollCompletionRequest( + val result = nativeAuthRequestProvider.createResetPasswordPollCompletionRequest( continuationToken = continuationToken, correlationId = correlationId ) + + assertEquals(clientId, result.parameters.clientId) + assertEquals(ApiConstants.MockApi.ssprPollCompletionRequestUrl, result.requestUrl) + assertEquals(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID], correlationId) } } From 046593ae9dfc795e19f28ffae836453f2a096129 Mon Sep 17 00:00:00 2001 From: Robert McCahill Date: Thu, 20 Jun 2024 15:32:54 +0100 Subject: [PATCH 02/20] Update changelog --- changelog.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/changelog.txt b/changelog.txt index 8e1a78e5b7..c40488226d 100644 --- a/changelog.txt +++ b/changelog.txt @@ -4,6 +4,7 @@ V.Next - [MINOR] Updating YubiKit and CredMan versions (#2417) - [PATCH] Adding check for OS version for passkeys (#2419) - [MINOR] Platform Specific Extra Query Parameters (#2426) +- [PATCH] Add check for unset correlation ID when sending Native Auth requests (#2435) Version 17.4.0 --------- From 9fe242c869948bd206ae672487455db5ef27c0da Mon Sep 17 00:00:00 2001 From: Robert McCahill Date: Mon, 24 Jun 2024 14:24:01 +0100 Subject: [PATCH 03/20] Update empty header test naming --- .../providers/NativeAuthRequestHandlerTest.kt | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/common4j/src/test/com/microsoft/identity/common/java/nativeauth/providers/NativeAuthRequestHandlerTest.kt b/common4j/src/test/com/microsoft/identity/common/java/nativeauth/providers/NativeAuthRequestHandlerTest.kt index 8dac943df3..d8bd33bb0b 100644 --- a/common4j/src/test/com/microsoft/identity/common/java/nativeauth/providers/NativeAuthRequestHandlerTest.kt +++ b/common4j/src/test/com/microsoft/identity/common/java/nativeauth/providers/NativeAuthRequestHandlerTest.kt @@ -152,7 +152,7 @@ class NativeAuthRequestHandlerTest { } @Test - fun testSignUpStartWithUnsetCorrelationIdShouldHaveNilHeader() { + fun testSignUpStartWithUnsetCorrelationIdShouldNotHaveHeader() { val commandParameters = SignUpStartCommandParameters.builder() .platformComponents(mock()) .username(username) @@ -213,7 +213,7 @@ class NativeAuthRequestHandlerTest { } @Test - fun testSignUpSubmitCodeWithUnsetCorrelationIdShouldHaveNilHeader() { + fun testSignUpSubmitCodeWithUnsetCorrelationIdShouldNotHaveHeader() { val commandParameters = SignUpSubmitCodeCommandParameters.builder() .platformComponents(mock()) .continuationToken(continuationToken) @@ -251,7 +251,7 @@ class NativeAuthRequestHandlerTest { } @Test - fun testSignUpSubmitPasswordWithUnsetCorrelationIdShouldHaveNilHeader() { + fun testSignUpSubmitPasswordWithUnsetCorrelationIdShouldNotHaveHeader() { val commandParameters = SignUpSubmitPasswordCommandParameters.builder() .platformComponents(mock()) .continuationToken(continuationToken) @@ -289,7 +289,7 @@ class NativeAuthRequestHandlerTest { } @Test - fun testSignUpSubmitUserAttributesWithUnsetCorrelationIdShouldHaveNilHeader() { + fun testSignUpSubmitUserAttributesWithUnsetCorrelationIdShouldNotHaveHeader() { val commandParameters = SignUpSubmitUserAttributesCommandParameters.builder() .platformComponents(mock()) .continuationToken(continuationToken) @@ -385,7 +385,7 @@ class NativeAuthRequestHandlerTest { } @Test - fun testSignUpChallengeWithUnsetCorrelationIdShouldHaveNilHeader() { + fun testSignUpChallengeWithUnsetCorrelationIdShouldNotHaveHeader() { val result = nativeAuthRequestProvider.createSignUpChallengeRequest( continuationToken = continuationToken, correlationId = "UNSET" @@ -437,7 +437,7 @@ class NativeAuthRequestHandlerTest { } @Test - fun testSignInInitiateWithUnsetCorrelationIdShouldHaveNilHeader() { + fun testSignInInitiateWithUnsetCorrelationIdShouldNotHaveHeader() { val commandParameters = SignInStartCommandParameters.builder() .platformComponents(mock()) .username(emptyString) @@ -529,7 +529,7 @@ class NativeAuthRequestHandlerTest { } @Test - fun testSignInChallengeWithUnsetCorrelationIdShouldHaveNilHeader() { + fun testSignInChallengeWithUnsetCorrelationIdShouldNotHaveHeader() { val result = nativeAuthRequestProvider.createSignInChallengeRequest( continuationToken = continuationToken, correlationId = "UNSET" @@ -614,7 +614,7 @@ class NativeAuthRequestHandlerTest { } @Test - fun testSignInTokenWithContinuationTokenUnsetCorrelationIdShouldHaveNilHeader() { + fun testSignInTokenWithContinuationTokenUnsetCorrelationIdShouldNotHaveHeader() { val commandParameters = SignInWithContinuationTokenCommandParameters.builder() .platformComponents(mock()) .continuationToken(continuationToken) @@ -720,7 +720,7 @@ class NativeAuthRequestHandlerTest { } @Test - fun testPasswordTokenRequestWithUnsetCorrelationIdShouldHaveNilHeader() { + fun testPasswordTokenRequestWithUnsetCorrelationIdShouldNotHaveHeader() { val commandParameters = SignInSubmitPasswordCommandParameters.builder() .platformComponents(mock()) .password(password) @@ -828,7 +828,7 @@ class NativeAuthRequestHandlerTest { } @Test - fun testResetPasswordStartWithUnsetCorrelationIdShouldHaveNilHeader() { + fun testResetPasswordStartWithUnsetCorrelationIdShouldNotHaveHeader() { val commandParameters = ResetPasswordStartCommandParameters.builder() .platformComponents(mock()) .username(username) @@ -881,7 +881,7 @@ class NativeAuthRequestHandlerTest { } @Test - fun testResetPasswordChallengeWithUnsetCorrelationIdShouldHaveNilHeader() { + fun testResetPasswordChallengeWithUnsetCorrelationIdShouldNotHaveHeader() { val result = nativeAuthRequestProvider.createResetPasswordChallengeRequest( continuationToken = continuationToken, correlationId = "UNSET" @@ -948,7 +948,7 @@ class NativeAuthRequestHandlerTest { } @Test - fun testResetPasswordContinueWithUnsetCorrelationIdShouldHaveNilHeader() { + fun testResetPasswordContinueWithUnsetCorrelationIdShouldNotHaveHeader() { val commandParameters = ResetPasswordSubmitCodeCommandParameters.builder() .platformComponents(mock()) .code(oobCode) @@ -1027,7 +1027,7 @@ class NativeAuthRequestHandlerTest { } @Test - fun testResetPasswordSubmitWithUnsetCorrelationIdShouldHaveNilHeader() { + fun testResetPasswordSubmitWithUnsetCorrelationIdShouldNotHaveHeader() { val commandParameters = ResetPasswordSubmitNewPasswordCommandParameters.builder() .platformComponents(mock()) .continuationToken(continuationToken) @@ -1080,7 +1080,7 @@ class NativeAuthRequestHandlerTest { } @Test - fun testResetPasswordPollCompletionWithUnsetCorrelationIdShouldHaveNilHeader() { + fun testResetPasswordPollCompletionWithUnsetCorrelationIdShouldNotHaveHeader() { val result = nativeAuthRequestProvider.createResetPasswordPollCompletionRequest( continuationToken = continuationToken, correlationId = "UNSET" From f221e24b9fd4c620be88cfd02133b4f18fc3867a Mon Sep 17 00:00:00 2001 From: Robert McCahill Date: Fri, 28 Jun 2024 16:27:19 +0100 Subject: [PATCH 04/20] Update changelog --- changelog.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/changelog.txt b/changelog.txt index 83557f6ab5..97f5cd3b67 100644 --- a/changelog.txt +++ b/changelog.txt @@ -7,6 +7,7 @@ V.Next - [PATCH] Return API error and errorDescription in case of unexpected response (#2431) - [MINOR] Support certificate with password (#2405) - [PATCH] Return API error and errorDescription in case of unexpected response (#2431) +- [PATCH] Add check for unset correlation ID when sending Native Auth requests (#2435) Version 17.5.0 --------- From 2e760acc68e604c10e3d92a591efa23f348c24f8 Mon Sep 17 00:00:00 2001 From: yuxin Date: Mon, 1 Jul 2024 13:34:29 +0100 Subject: [PATCH 05/20] Add argument to pass MSAL consumer test --- azure-pipelines/pull-request-validation/build-consumers.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines/pull-request-validation/build-consumers.yml b/azure-pipelines/pull-request-validation/build-consumers.yml index 371d1cd489..8ede247119 100644 --- a/azure-pipelines/pull-request-validation/build-consumers.yml +++ b/azure-pipelines/pull-request-validation/build-consumers.yml @@ -133,7 +133,7 @@ stages: - task: Gradle@3 displayName: Run msal Unit tests inputs: - tasks: msal:testLocalDebugUnitTest -Plabtest -PlabSecret=$(LabVaultAppCert) -ProbolectricSdkVersion=${{variables.robolectricSdkVersion}} -PmockApiUrl=$(MOCK_API_URL) -PnativeAuthSSPRTestsUsernameValue=$(NativeAuthSSPRTestsUsernameValue) -PnativeAuthSignInTestsUsernameValue=$(NativeAuthSignInTestsUsernameValue) -PnativeAuthLabsEmailPasswordAppIdValue=$(NativeAuthLabsEmailPasswordAppId) -PnativeAuthLabsAuthorityUrlValue=$(NativeAuthLabsAuthorityUrlValue) -PnativeAuthEmployeeWriteAllScopeValue=$(NativeAuthEmployeeWriteAllScopeValue) -PnativeAuthEmployeeReadAllScopeValue=$(NativeAuthEmployeeReadAllScopeValue) -PnativeAuthCustomerWriteAllScopeValue=$(NativeAuthCustomerWriteAllScopeValue) -PnativeAuthCustomerReadAllScopeValue=$(NativeAuthCustomerReadAllScopeValue) -PnativeAuthCustomerReadAllScopeValue=$(NativeAuthCustomerReadAllScopeValue) + tasks: msal:testLocalDebugUnitTest -Plabtest -PlabSecret=$(LabVaultAppCert) -ProbolectricSdkVersion=${{variables.robolectricSdkVersion}} -PmockApiUrl=$(MOCK_API_URL) -PnativeAuthSSPRTestsUsernameValue=$(NativeAuthSSPRTestsUsernameValue) -PnativeAuthSignInTestsUsernameValue=$(NativeAuthSignInTestsUsernameValue) -PnativeAuthLabsEmailPasswordAppIdValue=$(NativeAuthLabsEmailPasswordAppId) -PnativeAuthLabsAuthorityUrlValue=$(NativeAuthLabsAuthorityUrlValue) -PnativeAuthEmployeeWriteAllScopeValue=$(NativeAuthEmployeeWriteAllScopeValue) -PnativeAuthEmployeeReadAllScopeValue=$(NativeAuthEmployeeReadAllScopeValue) -PnativeAuthCustomerWriteAllScopeValue=$(NativeAuthCustomerWriteAllScopeValue) -PnativeAuthCustomerReadAllScopeValue=$(NativeAuthCustomerReadAllScopeValue) -PnativeAuthCustomerReadAllScopeValue=$(NativeAuthCustomerReadAllScopeValue) -PnativeAuthInvalidScopeValue=$(NativeAuthInvalidValue) jdkArchitecture: x64 jdkVersionOption: "1.11" # broker From e6310372eae373697af02677183d7666859bf7cf Mon Sep 17 00:00:00 2001 From: yuxin Date: Tue, 16 Jul 2024 14:29:13 +0100 Subject: [PATCH 06/20] Revert changes to trigger error log --- .../java/nativeauth/providers/NativeAuthRequestProvider.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common4j/src/main/com/microsoft/identity/common/java/nativeauth/providers/NativeAuthRequestProvider.kt b/common4j/src/main/com/microsoft/identity/common/java/nativeauth/providers/NativeAuthRequestProvider.kt index 7e07458447..419f91695e 100644 --- a/common4j/src/main/com/microsoft/identity/common/java/nativeauth/providers/NativeAuthRequestProvider.kt +++ b/common4j/src/main/com/microsoft/identity/common/java/nativeauth/providers/NativeAuthRequestProvider.kt @@ -24,6 +24,7 @@ package com.microsoft.identity.common.java.nativeauth.providers import com.microsoft.identity.common.java.AuthenticationConstants import com.microsoft.identity.common.java.eststelemetry.EstsTelemetry +import com.microsoft.identity.common.java.logging.DiagnosticContext import com.microsoft.identity.common.java.nativeauth.commands.parameters.ResetPasswordStartCommandParameters import com.microsoft.identity.common.java.nativeauth.commands.parameters.ResetPasswordSubmitCodeCommandParameters import com.microsoft.identity.common.java.nativeauth.commands.parameters.ResetPasswordSubmitNewPasswordCommandParameters @@ -34,7 +35,6 @@ import com.microsoft.identity.common.java.nativeauth.commands.parameters.SignUpS import com.microsoft.identity.common.java.nativeauth.commands.parameters.SignUpSubmitCodeCommandParameters import com.microsoft.identity.common.java.nativeauth.commands.parameters.SignUpSubmitPasswordCommandParameters import com.microsoft.identity.common.java.nativeauth.commands.parameters.SignUpSubmitUserAttributesCommandParameters -import com.microsoft.identity.common.java.logging.LibraryInfoHelper import com.microsoft.identity.common.java.nativeauth.commands.parameters.SignInStartCommandParameters import com.microsoft.identity.common.java.net.HttpConstants import com.microsoft.identity.common.java.nativeauth.providers.requests.resetpassword.ResetPasswordChallengeRequest From fed453c3adf9c49bf18fa69f06dc99896f898509 Mon Sep 17 00:00:00 2001 From: yuxin Date: Wed, 17 Jul 2024 08:29:42 +0100 Subject: [PATCH 07/20] getThreadCorrelationId --- .../identity/common/java/logging/DiagnosticContext.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/common4j/src/main/com/microsoft/identity/common/java/logging/DiagnosticContext.java b/common4j/src/main/com/microsoft/identity/common/java/logging/DiagnosticContext.java index 0e02e18bcb..6469789b43 100644 --- a/common4j/src/main/com/microsoft/identity/common/java/logging/DiagnosticContext.java +++ b/common4j/src/main/com/microsoft/identity/common/java/logging/DiagnosticContext.java @@ -22,6 +22,8 @@ // THE SOFTWARE. package com.microsoft.identity.common.java.logging; +import java.util.UUID; + import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; public enum DiagnosticContext { @@ -77,7 +79,7 @@ public String getThreadCorrelationId() { IRequestContext context = getRequestContext(); String correlationId = context.get(DiagnosticContext.CORRELATION_ID); if (correlationId == null) { - correlationId = UNSET; + correlationId = UUID.randomUUID().toString(); } return correlationId; } From c7318476f2066bba8f1df86cb082c23e3b14af52 Mon Sep 17 00:00:00 2001 From: yuxin Date: Wed, 17 Jul 2024 10:27:21 +0100 Subject: [PATCH 08/20] getThreadCorrelationId UNSET --- .../identity/common/java/logging/DiagnosticContext.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common4j/src/main/com/microsoft/identity/common/java/logging/DiagnosticContext.java b/common4j/src/main/com/microsoft/identity/common/java/logging/DiagnosticContext.java index 6469789b43..506d92d332 100644 --- a/common4j/src/main/com/microsoft/identity/common/java/logging/DiagnosticContext.java +++ b/common4j/src/main/com/microsoft/identity/common/java/logging/DiagnosticContext.java @@ -78,7 +78,7 @@ public IRequestContext getRequestContext() { public String getThreadCorrelationId() { IRequestContext context = getRequestContext(); String correlationId = context.get(DiagnosticContext.CORRELATION_ID); - if (correlationId == null) { + if (correlationId == null || correlationId.equals(UNSET)) { correlationId = UUID.randomUUID().toString(); } return correlationId; From 3391582b8a52d85e27b89a6c985fc5d41c561853 Mon Sep 17 00:00:00 2001 From: yuxin Date: Wed, 17 Jul 2024 17:12:41 +0100 Subject: [PATCH 09/20] Inside nativeAuthResponseHandler.getSignInInitiateResultFromHttpResponse(requestCorrelationId = requestCorrelationId),the SDK use the local correlation id rather than the header from the http response. Thus,the filer in the getHeader won't work for this issue. --- .../java/nativeauth/providers/NativeAuthRequestProvider.kt | 6 +----- .../nativeauth/providers/interactors/SignInInteractor.kt | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/common4j/src/main/com/microsoft/identity/common/java/nativeauth/providers/NativeAuthRequestProvider.kt b/common4j/src/main/com/microsoft/identity/common/java/nativeauth/providers/NativeAuthRequestProvider.kt index 419f91695e..28c7b0f836 100644 --- a/common4j/src/main/com/microsoft/identity/common/java/nativeauth/providers/NativeAuthRequestProvider.kt +++ b/common4j/src/main/com/microsoft/identity/common/java/nativeauth/providers/NativeAuthRequestProvider.kt @@ -310,11 +310,7 @@ class NativeAuthRequestProvider(private val config: NativeAuthOAuth2Configuratio //region helpers private fun getRequestHeaders(correlationId: String): Map { val headers: MutableMap = TreeMap() - - if (correlationId != "UNSET") { - headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID] = correlationId - } - + headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID] = correlationId headers[AuthenticationConstants.SdkPlatformFields.PRODUCT] = DiagnosticContext.INSTANCE.requestContext[AuthenticationConstants.SdkPlatformFields.PRODUCT] headers[AuthenticationConstants.SdkPlatformFields.VERSION] = Device.getProductVersion() headers.putAll(Device.getPlatformIdParameters()) diff --git a/common4j/src/main/com/microsoft/identity/common/java/nativeauth/providers/interactors/SignInInteractor.kt b/common4j/src/main/com/microsoft/identity/common/java/nativeauth/providers/interactors/SignInInteractor.kt index 462e1ef531..4b89c333b8 100644 --- a/common4j/src/main/com/microsoft/identity/common/java/nativeauth/providers/interactors/SignInInteractor.kt +++ b/common4j/src/main/com/microsoft/identity/common/java/nativeauth/providers/interactors/SignInInteractor.kt @@ -103,7 +103,7 @@ class SignInInteractor( ) val rawApiResponse = nativeAuthResponseHandler.getSignInInitiateResultFromHttpResponse( - requestCorrelationId = requestCorrelationId, + requestCorrelationId = requestCorrelationId, // Question: should we use the CLIENT_REQUEST_ID header from response here? response = response ) From 26856507e68f1f63f9500a8956cb94f33eefec0c Mon Sep 17 00:00:00 2001 From: yuxin Date: Thu, 18 Jul 2024 11:36:45 +0100 Subject: [PATCH 10/20] Modify the test --- .../java/nativeauth/providers/NativeAuthRequestHandlerTest.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common4j/src/test/com/microsoft/identity/common/java/nativeauth/providers/NativeAuthRequestHandlerTest.kt b/common4j/src/test/com/microsoft/identity/common/java/nativeauth/providers/NativeAuthRequestHandlerTest.kt index d8bd33bb0b..776c5783ca 100644 --- a/common4j/src/test/com/microsoft/identity/common/java/nativeauth/providers/NativeAuthRequestHandlerTest.kt +++ b/common4j/src/test/com/microsoft/identity/common/java/nativeauth/providers/NativeAuthRequestHandlerTest.kt @@ -152,7 +152,7 @@ class NativeAuthRequestHandlerTest { } @Test - fun testSignUpStartWithUnsetCorrelationIdShouldNotHaveHeader() { + fun testSignUpStartWithUnsetCorrelationIdShouldFilterOutToUUID() { val commandParameters = SignUpStartCommandParameters.builder() .platformComponents(mock()) .username(username) @@ -164,7 +164,7 @@ class NativeAuthRequestHandlerTest { commandParameters = commandParameters ) - assertNull(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID]) + Assert.assertNotEquals(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID], "UNSET") } @Test From d0a261842b4d884b38b47838db8176317b88b2c2 Mon Sep 17 00:00:00 2001 From: yuxin Date: Thu, 18 Jul 2024 12:08:06 +0100 Subject: [PATCH 11/20] Modify the remaining test --- .../providers/NativeAuthRequestHandlerTest.kt | 50 +++++++++---------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/common4j/src/test/com/microsoft/identity/common/java/nativeauth/providers/NativeAuthRequestHandlerTest.kt b/common4j/src/test/com/microsoft/identity/common/java/nativeauth/providers/NativeAuthRequestHandlerTest.kt index 776c5783ca..eda7bf5437 100644 --- a/common4j/src/test/com/microsoft/identity/common/java/nativeauth/providers/NativeAuthRequestHandlerTest.kt +++ b/common4j/src/test/com/microsoft/identity/common/java/nativeauth/providers/NativeAuthRequestHandlerTest.kt @@ -213,7 +213,7 @@ class NativeAuthRequestHandlerTest { } @Test - fun testSignUpSubmitCodeWithUnsetCorrelationIdShouldNotHaveHeader() { + fun testSignUpSubmitCodeWithUnsetCorrelationIdShouldFilterOutToUUID() { val commandParameters = SignUpSubmitCodeCommandParameters.builder() .platformComponents(mock()) .continuationToken(continuationToken) @@ -226,7 +226,7 @@ class NativeAuthRequestHandlerTest { commandParameters = commandParameters ) - assertNull(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID]) + Assert.assertNotEquals(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID], "UNSET") } @Test @@ -251,7 +251,7 @@ class NativeAuthRequestHandlerTest { } @Test - fun testSignUpSubmitPasswordWithUnsetCorrelationIdShouldNotHaveHeader() { + fun testSignUpSubmitPasswordWithUnsetCorrelationIdShouldFilterOutToUUID() { val commandParameters = SignUpSubmitPasswordCommandParameters.builder() .platformComponents(mock()) .continuationToken(continuationToken) @@ -264,7 +264,7 @@ class NativeAuthRequestHandlerTest { commandParameters = commandParameters ) - assertNull(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID]) + Assert.assertNotEquals(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID], "UNSET") } @Test @@ -289,7 +289,7 @@ class NativeAuthRequestHandlerTest { } @Test - fun testSignUpSubmitUserAttributesWithUnsetCorrelationIdShouldNotHaveHeader() { + fun testSignUpSubmitUserAttributesWithUnsetCorrelationIdShouldFilterOutToUUID() { val commandParameters = SignUpSubmitUserAttributesCommandParameters.builder() .platformComponents(mock()) .continuationToken(continuationToken) @@ -385,13 +385,13 @@ class NativeAuthRequestHandlerTest { } @Test - fun testSignUpChallengeWithUnsetCorrelationIdShouldNotHaveHeader() { + fun testSignUpChallengeWithUnsetCorrelationIdShouldFilterOutToUUID() { val result = nativeAuthRequestProvider.createSignUpChallengeRequest( continuationToken = continuationToken, correlationId = "UNSET" ) - assertNull(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID]) + Assert.assertNotEquals(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID], "UNSET") } @Test(expected = ClientException::class) @@ -437,7 +437,7 @@ class NativeAuthRequestHandlerTest { } @Test - fun testSignInInitiateWithUnsetCorrelationIdShouldNotHaveHeader() { + fun testSignInInitiateWithUnsetCorrelationIdShouldFilterOutToUUID() { val commandParameters = SignInStartCommandParameters.builder() .platformComponents(mock()) .username(emptyString) @@ -448,7 +448,7 @@ class NativeAuthRequestHandlerTest { commandParameters = commandParameters ) - assertNull(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID]) + Assert.assertNotEquals(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID], "UNSET") } @Test(expected = ClientException::class) @@ -529,13 +529,13 @@ class NativeAuthRequestHandlerTest { } @Test - fun testSignInChallengeWithUnsetCorrelationIdShouldNotHaveHeader() { + fun testSignInChallengeWithUnsetCorrelationIdShouldFilterOutToUUID() { val result = nativeAuthRequestProvider.createSignInChallengeRequest( continuationToken = continuationToken, correlationId = "UNSET" ) - assertNull(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID]) + Assert.assertNotEquals(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID], "UNSET") } @Test @@ -614,7 +614,7 @@ class NativeAuthRequestHandlerTest { } @Test - fun testSignInTokenWithContinuationTokenUnsetCorrelationIdShouldNotHaveHeader() { + fun testSignInTokenWithContinuationTokenUnsetCorrelationIdShouldFilterOutToUUID() { val commandParameters = SignInWithContinuationTokenCommandParameters.builder() .platformComponents(mock()) .continuationToken(continuationToken) @@ -626,7 +626,7 @@ class NativeAuthRequestHandlerTest { commandParameters = commandParameters ) - assertNull(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID]) + Assert.assertNotEquals(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID], "UNSET") } @Test @@ -720,7 +720,7 @@ class NativeAuthRequestHandlerTest { } @Test - fun testPasswordTokenRequestWithUnsetCorrelationIdShouldNotHaveHeader() { + fun testPasswordTokenRequestWithUnsetCorrelationIdShouldFilterOutToUUID() { val commandParameters = SignInSubmitPasswordCommandParameters.builder() .platformComponents(mock()) .password(password) @@ -732,7 +732,7 @@ class NativeAuthRequestHandlerTest { commandParameters = commandParameters ) - assertNull(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID]) + Assert.assertNotEquals(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID], "UNSET") } @Test fun testPasswordTokenRequestSuccess() { @@ -828,7 +828,7 @@ class NativeAuthRequestHandlerTest { } @Test - fun testResetPasswordStartWithUnsetCorrelationIdShouldNotHaveHeader() { + fun testResetPasswordStartWithUnsetCorrelationIdShouldFilterOutToUUID() { val commandParameters = ResetPasswordStartCommandParameters.builder() .platformComponents(mock()) .username(username) @@ -839,7 +839,7 @@ class NativeAuthRequestHandlerTest { commandParameters = commandParameters ) - assertNull(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID]) + Assert.assertNotEquals(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID], "UNSET") } @Test @@ -881,13 +881,13 @@ class NativeAuthRequestHandlerTest { } @Test - fun testResetPasswordChallengeWithUnsetCorrelationIdShouldNotHaveHeader() { + fun testResetPasswordChallengeWithUnsetCorrelationIdShouldFilterOutToUUID() { val result = nativeAuthRequestProvider.createResetPasswordChallengeRequest( continuationToken = continuationToken, correlationId = "UNSET" ) - assertNull(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID]) + Assert.assertNotEquals(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID], "UNSET") } @Test @@ -948,7 +948,7 @@ class NativeAuthRequestHandlerTest { } @Test - fun testResetPasswordContinueWithUnsetCorrelationIdShouldNotHaveHeader() { + fun testResetPasswordContinueWithUnsetCorrelationIdShouldFilterOutToUUID() { val commandParameters = ResetPasswordSubmitCodeCommandParameters.builder() .platformComponents(mock()) .code(oobCode) @@ -960,7 +960,7 @@ class NativeAuthRequestHandlerTest { commandParameters = commandParameters ) - assertNull(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID]) + Assert.assertNotEquals(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID], "UNSET") } @Test @@ -1027,7 +1027,7 @@ class NativeAuthRequestHandlerTest { } @Test - fun testResetPasswordSubmitWithUnsetCorrelationIdShouldNotHaveHeader() { + fun testResetPasswordSubmitWithUnsetCorrelationIdShouldFilterOutToUUID() { val commandParameters = ResetPasswordSubmitNewPasswordCommandParameters.builder() .platformComponents(mock()) .continuationToken(continuationToken) @@ -1039,7 +1039,7 @@ class NativeAuthRequestHandlerTest { commandParameters = commandParameters ) - assertNull(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID]) + Assert.assertNotEquals(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID], "UNSET") } @Test @@ -1080,13 +1080,13 @@ class NativeAuthRequestHandlerTest { } @Test - fun testResetPasswordPollCompletionWithUnsetCorrelationIdShouldNotHaveHeader() { + fun testResetPasswordPollCompletionWithUnsetCorrelationIdShouldFilterOutToUUID() { val result = nativeAuthRequestProvider.createResetPasswordPollCompletionRequest( continuationToken = continuationToken, correlationId = "UNSET" ) - assertNull(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID]) + Assert.assertNotEquals(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID], "UNSET") } @Test From abc12792931b421234c9e1bb39b182becf71a91b Mon Sep 17 00:00:00 2001 From: yuxin Date: Thu, 18 Jul 2024 12:11:44 +0100 Subject: [PATCH 12/20] Modify the remaining test --- .../java/nativeauth/providers/NativeAuthRequestHandlerTest.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common4j/src/test/com/microsoft/identity/common/java/nativeauth/providers/NativeAuthRequestHandlerTest.kt b/common4j/src/test/com/microsoft/identity/common/java/nativeauth/providers/NativeAuthRequestHandlerTest.kt index eda7bf5437..003d01afa9 100644 --- a/common4j/src/test/com/microsoft/identity/common/java/nativeauth/providers/NativeAuthRequestHandlerTest.kt +++ b/common4j/src/test/com/microsoft/identity/common/java/nativeauth/providers/NativeAuthRequestHandlerTest.kt @@ -302,7 +302,7 @@ class NativeAuthRequestHandlerTest { commandParameters = commandParameters ) - assertNull(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID]) + Assert.assertNotEquals(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID], "UNSET") } @Test From 4cf05aa7ce080fd77cf41d28de8cd960556b13ba Mon Sep 17 00:00:00 2001 From: yuxin Date: Thu, 18 Jul 2024 16:56:49 +0100 Subject: [PATCH 13/20] Remove tests related with the request header nativeAuthRequestProvider.createSignUpChallengeRequest(correlationId = "UNSET") --- .../providers/NativeAuthRequestHandlerTest.kt | 40 ------------------- 1 file changed, 40 deletions(-) diff --git a/common4j/src/test/com/microsoft/identity/common/java/nativeauth/providers/NativeAuthRequestHandlerTest.kt b/common4j/src/test/com/microsoft/identity/common/java/nativeauth/providers/NativeAuthRequestHandlerTest.kt index 003d01afa9..7cfea82d4f 100644 --- a/common4j/src/test/com/microsoft/identity/common/java/nativeauth/providers/NativeAuthRequestHandlerTest.kt +++ b/common4j/src/test/com/microsoft/identity/common/java/nativeauth/providers/NativeAuthRequestHandlerTest.kt @@ -384,16 +384,6 @@ class NativeAuthRequestHandlerTest { assertEquals(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID], correlationId) } - @Test - fun testSignUpChallengeWithUnsetCorrelationIdShouldFilterOutToUUID() { - val result = nativeAuthRequestProvider.createSignUpChallengeRequest( - continuationToken = continuationToken, - correlationId = "UNSET" - ) - - Assert.assertNotEquals(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID], "UNSET") - } - @Test(expected = ClientException::class) fun testSignUpChallengeWithEmptyContinuationTokenShouldThrowException() { nativeAuthRequestProvider.createSignUpChallengeRequest( @@ -528,16 +518,6 @@ class NativeAuthRequestHandlerTest { ) } - @Test - fun testSignInChallengeWithUnsetCorrelationIdShouldFilterOutToUUID() { - val result = nativeAuthRequestProvider.createSignInChallengeRequest( - continuationToken = continuationToken, - correlationId = "UNSET" - ) - - Assert.assertNotEquals(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID], "UNSET") - } - @Test fun testSignInChallengeSuccess() { val result = nativeAuthRequestProvider.createSignInChallengeRequest( @@ -880,16 +860,6 @@ class NativeAuthRequestHandlerTest { ) } - @Test - fun testResetPasswordChallengeWithUnsetCorrelationIdShouldFilterOutToUUID() { - val result = nativeAuthRequestProvider.createResetPasswordChallengeRequest( - continuationToken = continuationToken, - correlationId = "UNSET" - ) - - Assert.assertNotEquals(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID], "UNSET") - } - @Test fun testResetPasswordChallengeSuccess() { val result = nativeAuthRequestProvider.createResetPasswordChallengeRequest( @@ -1079,16 +1049,6 @@ class NativeAuthRequestHandlerTest { ) } - @Test - fun testResetPasswordPollCompletionWithUnsetCorrelationIdShouldFilterOutToUUID() { - val result = nativeAuthRequestProvider.createResetPasswordPollCompletionRequest( - continuationToken = continuationToken, - correlationId = "UNSET" - ) - - Assert.assertNotEquals(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID], "UNSET") - } - @Test fun testResetPasswordPollCompletionSuccess() { val result = nativeAuthRequestProvider.createResetPasswordPollCompletionRequest( From a9f32fea398466d61562cafd6df28d8fd0b8dba8 Mon Sep 17 00:00:00 2001 From: yuxin Date: Mon, 22 Jul 2024 21:57:15 +0100 Subject: [PATCH 14/20] Put dev version header into this branch --- .../nativeauth/providers/NativeAuthRequestProvider.kt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/common4j/src/main/com/microsoft/identity/common/java/nativeauth/providers/NativeAuthRequestProvider.kt b/common4j/src/main/com/microsoft/identity/common/java/nativeauth/providers/NativeAuthRequestProvider.kt index 28c7b0f836..fa699f1a1f 100644 --- a/common4j/src/main/com/microsoft/identity/common/java/nativeauth/providers/NativeAuthRequestProvider.kt +++ b/common4j/src/main/com/microsoft/identity/common/java/nativeauth/providers/NativeAuthRequestProvider.kt @@ -24,7 +24,7 @@ package com.microsoft.identity.common.java.nativeauth.providers import com.microsoft.identity.common.java.AuthenticationConstants import com.microsoft.identity.common.java.eststelemetry.EstsTelemetry -import com.microsoft.identity.common.java.logging.DiagnosticContext +import com.microsoft.identity.common.java.logging.LibraryInfoHelper import com.microsoft.identity.common.java.nativeauth.commands.parameters.ResetPasswordStartCommandParameters import com.microsoft.identity.common.java.nativeauth.commands.parameters.ResetPasswordSubmitCodeCommandParameters import com.microsoft.identity.common.java.nativeauth.commands.parameters.ResetPasswordSubmitNewPasswordCommandParameters @@ -310,9 +310,11 @@ class NativeAuthRequestProvider(private val config: NativeAuthOAuth2Configuratio //region helpers private fun getRequestHeaders(correlationId: String): Map { val headers: MutableMap = TreeMap() - headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID] = correlationId - headers[AuthenticationConstants.SdkPlatformFields.PRODUCT] = DiagnosticContext.INSTANCE.requestContext[AuthenticationConstants.SdkPlatformFields.PRODUCT] - headers[AuthenticationConstants.SdkPlatformFields.VERSION] = Device.getProductVersion() + if (correlationId != "UNSET") { + headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID] = correlationId + } + headers[AuthenticationConstants.SdkPlatformFields.PRODUCT] = LibraryInfoHelper.getLibraryName() + headers[AuthenticationConstants.SdkPlatformFields.VERSION] = LibraryInfoHelper.getLibraryVersion() headers.putAll(Device.getPlatformIdParameters()) headers.putAll(EstsTelemetry.getInstance().telemetryHeaders) headers[HttpConstants.HeaderField.CONTENT_TYPE] = "application/x-www-form-urlencoded" From 77d3dd3d6877082db57fd952ce23c0ee85d675c6 Mon Sep 17 00:00:00 2001 From: yuxin Date: Mon, 22 Jul 2024 22:07:45 +0100 Subject: [PATCH 15/20] Only keep the minor changes --- .../identity/common/java/logging/DiagnosticContext.java | 4 ++-- .../java/nativeauth/providers/interactors/SignInInteractor.kt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/common4j/src/main/com/microsoft/identity/common/java/logging/DiagnosticContext.java b/common4j/src/main/com/microsoft/identity/common/java/logging/DiagnosticContext.java index 506d92d332..38945cb413 100644 --- a/common4j/src/main/com/microsoft/identity/common/java/logging/DiagnosticContext.java +++ b/common4j/src/main/com/microsoft/identity/common/java/logging/DiagnosticContext.java @@ -78,8 +78,8 @@ public IRequestContext getRequestContext() { public String getThreadCorrelationId() { IRequestContext context = getRequestContext(); String correlationId = context.get(DiagnosticContext.CORRELATION_ID); - if (correlationId == null || correlationId.equals(UNSET)) { - correlationId = UUID.randomUUID().toString(); + if (correlationId == null) { + correlationId = UNSET; } return correlationId; } diff --git a/common4j/src/main/com/microsoft/identity/common/java/nativeauth/providers/interactors/SignInInteractor.kt b/common4j/src/main/com/microsoft/identity/common/java/nativeauth/providers/interactors/SignInInteractor.kt index 4b89c333b8..462e1ef531 100644 --- a/common4j/src/main/com/microsoft/identity/common/java/nativeauth/providers/interactors/SignInInteractor.kt +++ b/common4j/src/main/com/microsoft/identity/common/java/nativeauth/providers/interactors/SignInInteractor.kt @@ -103,7 +103,7 @@ class SignInInteractor( ) val rawApiResponse = nativeAuthResponseHandler.getSignInInitiateResultFromHttpResponse( - requestCorrelationId = requestCorrelationId, // Question: should we use the CLIENT_REQUEST_ID header from response here? + requestCorrelationId = requestCorrelationId, response = response ) From b4a923f0f1b58da6d7dc9658d6ad84495fb48a54 Mon Sep 17 00:00:00 2001 From: yuxin Date: Wed, 24 Jul 2024 12:45:10 +0100 Subject: [PATCH 16/20] Revert "Remove tests related with the request header nativeAuthRequestProvider.createSignUpChallengeRequest(correlationId = "UNSET")" This reverts commit 4cf05aa7ce080fd77cf41d28de8cd960556b13ba. --- .../providers/NativeAuthRequestHandlerTest.kt | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/common4j/src/test/com/microsoft/identity/common/java/nativeauth/providers/NativeAuthRequestHandlerTest.kt b/common4j/src/test/com/microsoft/identity/common/java/nativeauth/providers/NativeAuthRequestHandlerTest.kt index 7cfea82d4f..003d01afa9 100644 --- a/common4j/src/test/com/microsoft/identity/common/java/nativeauth/providers/NativeAuthRequestHandlerTest.kt +++ b/common4j/src/test/com/microsoft/identity/common/java/nativeauth/providers/NativeAuthRequestHandlerTest.kt @@ -384,6 +384,16 @@ class NativeAuthRequestHandlerTest { assertEquals(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID], correlationId) } + @Test + fun testSignUpChallengeWithUnsetCorrelationIdShouldFilterOutToUUID() { + val result = nativeAuthRequestProvider.createSignUpChallengeRequest( + continuationToken = continuationToken, + correlationId = "UNSET" + ) + + Assert.assertNotEquals(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID], "UNSET") + } + @Test(expected = ClientException::class) fun testSignUpChallengeWithEmptyContinuationTokenShouldThrowException() { nativeAuthRequestProvider.createSignUpChallengeRequest( @@ -518,6 +528,16 @@ class NativeAuthRequestHandlerTest { ) } + @Test + fun testSignInChallengeWithUnsetCorrelationIdShouldFilterOutToUUID() { + val result = nativeAuthRequestProvider.createSignInChallengeRequest( + continuationToken = continuationToken, + correlationId = "UNSET" + ) + + Assert.assertNotEquals(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID], "UNSET") + } + @Test fun testSignInChallengeSuccess() { val result = nativeAuthRequestProvider.createSignInChallengeRequest( @@ -860,6 +880,16 @@ class NativeAuthRequestHandlerTest { ) } + @Test + fun testResetPasswordChallengeWithUnsetCorrelationIdShouldFilterOutToUUID() { + val result = nativeAuthRequestProvider.createResetPasswordChallengeRequest( + continuationToken = continuationToken, + correlationId = "UNSET" + ) + + Assert.assertNotEquals(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID], "UNSET") + } + @Test fun testResetPasswordChallengeSuccess() { val result = nativeAuthRequestProvider.createResetPasswordChallengeRequest( @@ -1049,6 +1079,16 @@ class NativeAuthRequestHandlerTest { ) } + @Test + fun testResetPasswordPollCompletionWithUnsetCorrelationIdShouldFilterOutToUUID() { + val result = nativeAuthRequestProvider.createResetPasswordPollCompletionRequest( + continuationToken = continuationToken, + correlationId = "UNSET" + ) + + Assert.assertNotEquals(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID], "UNSET") + } + @Test fun testResetPasswordPollCompletionSuccess() { val result = nativeAuthRequestProvider.createResetPasswordPollCompletionRequest( From c30e22e18ee8fb7b40e128339f74be35e1e103c7 Mon Sep 17 00:00:00 2001 From: yuxin Date: Wed, 24 Jul 2024 12:46:20 +0100 Subject: [PATCH 17/20] "UNSET" -> UUID.randomUUID().toString() in getThreadCorrelationId() --- .../identity/common/java/logging/DiagnosticContext.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common4j/src/main/com/microsoft/identity/common/java/logging/DiagnosticContext.java b/common4j/src/main/com/microsoft/identity/common/java/logging/DiagnosticContext.java index 38945cb413..dc5bea13d9 100644 --- a/common4j/src/main/com/microsoft/identity/common/java/logging/DiagnosticContext.java +++ b/common4j/src/main/com/microsoft/identity/common/java/logging/DiagnosticContext.java @@ -78,8 +78,8 @@ public IRequestContext getRequestContext() { public String getThreadCorrelationId() { IRequestContext context = getRequestContext(); String correlationId = context.get(DiagnosticContext.CORRELATION_ID); - if (correlationId == null) { - correlationId = UNSET; + if (correlationId == null || correlationId.equals("UNSET")) { + correlationId = UUID.randomUUID().toString(); } return correlationId; } From 8181c6faf9d9dc678f8f6bdcabac25f14947168c Mon Sep 17 00:00:00 2001 From: yuxin Date: Wed, 24 Jul 2024 13:11:49 +0100 Subject: [PATCH 18/20] Revert "Modify the remaining test" This reverts commit d0a261842b4d884b38b47838db8176317b88b2c2. --- .../providers/NativeAuthRequestHandlerTest.kt | 50 +++++++++---------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/common4j/src/test/com/microsoft/identity/common/java/nativeauth/providers/NativeAuthRequestHandlerTest.kt b/common4j/src/test/com/microsoft/identity/common/java/nativeauth/providers/NativeAuthRequestHandlerTest.kt index 003d01afa9..13e39334eb 100644 --- a/common4j/src/test/com/microsoft/identity/common/java/nativeauth/providers/NativeAuthRequestHandlerTest.kt +++ b/common4j/src/test/com/microsoft/identity/common/java/nativeauth/providers/NativeAuthRequestHandlerTest.kt @@ -213,7 +213,7 @@ class NativeAuthRequestHandlerTest { } @Test - fun testSignUpSubmitCodeWithUnsetCorrelationIdShouldFilterOutToUUID() { + fun testSignUpSubmitCodeWithUnsetCorrelationIdShouldNotHaveHeader() { val commandParameters = SignUpSubmitCodeCommandParameters.builder() .platformComponents(mock()) .continuationToken(continuationToken) @@ -226,7 +226,7 @@ class NativeAuthRequestHandlerTest { commandParameters = commandParameters ) - Assert.assertNotEquals(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID], "UNSET") + assertNull(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID]) } @Test @@ -251,7 +251,7 @@ class NativeAuthRequestHandlerTest { } @Test - fun testSignUpSubmitPasswordWithUnsetCorrelationIdShouldFilterOutToUUID() { + fun testSignUpSubmitPasswordWithUnsetCorrelationIdShouldNotHaveHeader() { val commandParameters = SignUpSubmitPasswordCommandParameters.builder() .platformComponents(mock()) .continuationToken(continuationToken) @@ -264,7 +264,7 @@ class NativeAuthRequestHandlerTest { commandParameters = commandParameters ) - Assert.assertNotEquals(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID], "UNSET") + assertNull(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID]) } @Test @@ -289,7 +289,7 @@ class NativeAuthRequestHandlerTest { } @Test - fun testSignUpSubmitUserAttributesWithUnsetCorrelationIdShouldFilterOutToUUID() { + fun testSignUpSubmitUserAttributesWithUnsetCorrelationIdShouldNotHaveHeader() { val commandParameters = SignUpSubmitUserAttributesCommandParameters.builder() .platformComponents(mock()) .continuationToken(continuationToken) @@ -385,13 +385,13 @@ class NativeAuthRequestHandlerTest { } @Test - fun testSignUpChallengeWithUnsetCorrelationIdShouldFilterOutToUUID() { + fun testSignUpChallengeWithUnsetCorrelationIdShouldNotHaveHeader() { val result = nativeAuthRequestProvider.createSignUpChallengeRequest( continuationToken = continuationToken, correlationId = "UNSET" ) - Assert.assertNotEquals(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID], "UNSET") + assertNull(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID]) } @Test(expected = ClientException::class) @@ -437,7 +437,7 @@ class NativeAuthRequestHandlerTest { } @Test - fun testSignInInitiateWithUnsetCorrelationIdShouldFilterOutToUUID() { + fun testSignInInitiateWithUnsetCorrelationIdShouldNotHaveHeader() { val commandParameters = SignInStartCommandParameters.builder() .platformComponents(mock()) .username(emptyString) @@ -448,7 +448,7 @@ class NativeAuthRequestHandlerTest { commandParameters = commandParameters ) - Assert.assertNotEquals(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID], "UNSET") + assertNull(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID]) } @Test(expected = ClientException::class) @@ -529,13 +529,13 @@ class NativeAuthRequestHandlerTest { } @Test - fun testSignInChallengeWithUnsetCorrelationIdShouldFilterOutToUUID() { + fun testSignInChallengeWithUnsetCorrelationIdShouldNotHaveHeader() { val result = nativeAuthRequestProvider.createSignInChallengeRequest( continuationToken = continuationToken, correlationId = "UNSET" ) - Assert.assertNotEquals(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID], "UNSET") + assertNull(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID]) } @Test @@ -614,7 +614,7 @@ class NativeAuthRequestHandlerTest { } @Test - fun testSignInTokenWithContinuationTokenUnsetCorrelationIdShouldFilterOutToUUID() { + fun testSignInTokenWithContinuationTokenUnsetCorrelationIdShouldNotHaveHeader() { val commandParameters = SignInWithContinuationTokenCommandParameters.builder() .platformComponents(mock()) .continuationToken(continuationToken) @@ -626,7 +626,7 @@ class NativeAuthRequestHandlerTest { commandParameters = commandParameters ) - Assert.assertNotEquals(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID], "UNSET") + assertNull(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID]) } @Test @@ -720,7 +720,7 @@ class NativeAuthRequestHandlerTest { } @Test - fun testPasswordTokenRequestWithUnsetCorrelationIdShouldFilterOutToUUID() { + fun testPasswordTokenRequestWithUnsetCorrelationIdShouldNotHaveHeader() { val commandParameters = SignInSubmitPasswordCommandParameters.builder() .platformComponents(mock()) .password(password) @@ -732,7 +732,7 @@ class NativeAuthRequestHandlerTest { commandParameters = commandParameters ) - Assert.assertNotEquals(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID], "UNSET") + assertNull(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID]) } @Test fun testPasswordTokenRequestSuccess() { @@ -828,7 +828,7 @@ class NativeAuthRequestHandlerTest { } @Test - fun testResetPasswordStartWithUnsetCorrelationIdShouldFilterOutToUUID() { + fun testResetPasswordStartWithUnsetCorrelationIdShouldNotHaveHeader() { val commandParameters = ResetPasswordStartCommandParameters.builder() .platformComponents(mock()) .username(username) @@ -839,7 +839,7 @@ class NativeAuthRequestHandlerTest { commandParameters = commandParameters ) - Assert.assertNotEquals(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID], "UNSET") + assertNull(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID]) } @Test @@ -881,13 +881,13 @@ class NativeAuthRequestHandlerTest { } @Test - fun testResetPasswordChallengeWithUnsetCorrelationIdShouldFilterOutToUUID() { + fun testResetPasswordChallengeWithUnsetCorrelationIdShouldNotHaveHeader() { val result = nativeAuthRequestProvider.createResetPasswordChallengeRequest( continuationToken = continuationToken, correlationId = "UNSET" ) - Assert.assertNotEquals(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID], "UNSET") + assertNull(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID]) } @Test @@ -948,7 +948,7 @@ class NativeAuthRequestHandlerTest { } @Test - fun testResetPasswordContinueWithUnsetCorrelationIdShouldFilterOutToUUID() { + fun testResetPasswordContinueWithUnsetCorrelationIdShouldNotHaveHeader() { val commandParameters = ResetPasswordSubmitCodeCommandParameters.builder() .platformComponents(mock()) .code(oobCode) @@ -960,7 +960,7 @@ class NativeAuthRequestHandlerTest { commandParameters = commandParameters ) - Assert.assertNotEquals(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID], "UNSET") + assertNull(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID]) } @Test @@ -1027,7 +1027,7 @@ class NativeAuthRequestHandlerTest { } @Test - fun testResetPasswordSubmitWithUnsetCorrelationIdShouldFilterOutToUUID() { + fun testResetPasswordSubmitWithUnsetCorrelationIdShouldNotHaveHeader() { val commandParameters = ResetPasswordSubmitNewPasswordCommandParameters.builder() .platformComponents(mock()) .continuationToken(continuationToken) @@ -1039,7 +1039,7 @@ class NativeAuthRequestHandlerTest { commandParameters = commandParameters ) - Assert.assertNotEquals(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID], "UNSET") + assertNull(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID]) } @Test @@ -1080,13 +1080,13 @@ class NativeAuthRequestHandlerTest { } @Test - fun testResetPasswordPollCompletionWithUnsetCorrelationIdShouldFilterOutToUUID() { + fun testResetPasswordPollCompletionWithUnsetCorrelationIdShouldNotHaveHeader() { val result = nativeAuthRequestProvider.createResetPasswordPollCompletionRequest( continuationToken = continuationToken, correlationId = "UNSET" ) - Assert.assertNotEquals(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID], "UNSET") + assertNull(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID]) } @Test From 3c74bb2c331c6ddaa46be6fbf8d4c3c0d6567b07 Mon Sep 17 00:00:00 2001 From: yuxin Date: Wed, 24 Jul 2024 13:12:50 +0100 Subject: [PATCH 19/20] Revert "Modify the test" This reverts commit 26856507e68f1f63f9500a8956cb94f33eefec0c. --- .../java/nativeauth/providers/NativeAuthRequestHandlerTest.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common4j/src/test/com/microsoft/identity/common/java/nativeauth/providers/NativeAuthRequestHandlerTest.kt b/common4j/src/test/com/microsoft/identity/common/java/nativeauth/providers/NativeAuthRequestHandlerTest.kt index 13e39334eb..2fbd7f3f94 100644 --- a/common4j/src/test/com/microsoft/identity/common/java/nativeauth/providers/NativeAuthRequestHandlerTest.kt +++ b/common4j/src/test/com/microsoft/identity/common/java/nativeauth/providers/NativeAuthRequestHandlerTest.kt @@ -152,7 +152,7 @@ class NativeAuthRequestHandlerTest { } @Test - fun testSignUpStartWithUnsetCorrelationIdShouldFilterOutToUUID() { + fun testSignUpStartWithUnsetCorrelationIdShouldNotHaveHeader() { val commandParameters = SignUpStartCommandParameters.builder() .platformComponents(mock()) .username(username) @@ -164,7 +164,7 @@ class NativeAuthRequestHandlerTest { commandParameters = commandParameters ) - Assert.assertNotEquals(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID], "UNSET") + assertNull(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID]) } @Test From f0c1be5a7d9c31faa81050cede03cfb2183ea8c8 Mon Sep 17 00:00:00 2001 From: yuxin Date: Wed, 24 Jul 2024 13:13:04 +0100 Subject: [PATCH 20/20] Revert "Modify the remaining test" This reverts commit abc12792931b421234c9e1bb39b182becf71a91b. --- .../java/nativeauth/providers/NativeAuthRequestHandlerTest.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common4j/src/test/com/microsoft/identity/common/java/nativeauth/providers/NativeAuthRequestHandlerTest.kt b/common4j/src/test/com/microsoft/identity/common/java/nativeauth/providers/NativeAuthRequestHandlerTest.kt index 2fbd7f3f94..d8bd33bb0b 100644 --- a/common4j/src/test/com/microsoft/identity/common/java/nativeauth/providers/NativeAuthRequestHandlerTest.kt +++ b/common4j/src/test/com/microsoft/identity/common/java/nativeauth/providers/NativeAuthRequestHandlerTest.kt @@ -302,7 +302,7 @@ class NativeAuthRequestHandlerTest { commandParameters = commandParameters ) - Assert.assertNotEquals(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID], "UNSET") + assertNull(result.headers[AuthenticationConstants.AAD.CLIENT_REQUEST_ID]) } @Test