-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Native auth: Add support for claims request, AB#3117218, Fixes AB#311…
…7218 (#2572) Adding support on native authentication for claims request. During sign-in, native authentication users can now specify claims requests, which will be sent to the /token endpoint. This enhancement specifically supports authentication context. MSAL PR: AzureAD/microsoft-authentication-library-for-android#2246 [AB#3117218](https://identitydivision.visualstudio.com/Engineering/_workitems/edit/3117218)
- Loading branch information
Showing
13 changed files
with
203 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
...n/src/test/java/com/microsoft/identity/common/nativeauth/internal/util/CommandUtilTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package com.microsoft.identity.common.nativeauth.internal.util | ||
|
||
import android.content.Context | ||
import androidx.test.core.app.ApplicationProvider | ||
import com.microsoft.identity.common.components.AndroidPlatformComponentsFactory | ||
import com.microsoft.identity.common.java.interfaces.IPlatformComponents | ||
import com.microsoft.identity.common.java.nativeauth.commands.parameters.MFASubmitChallengeCommandParameters | ||
import com.microsoft.identity.common.java.nativeauth.commands.parameters.SignInStartCommandParameters | ||
import org.junit.Before | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import org.mockito.MockitoAnnotations | ||
import org.robolectric.RobolectricTestRunner | ||
import java.util.UUID | ||
|
||
/** | ||
* Tests for [CommandUtil]. | ||
*/ | ||
@RunWith(RobolectricTestRunner::class) | ||
class CommandUtilTest { | ||
|
||
private lateinit var platformComponents: IPlatformComponents | ||
private lateinit var context: Context | ||
|
||
@Before | ||
fun setup() { | ||
MockitoAnnotations.initMocks(this) | ||
context = ApplicationProvider.getApplicationContext() | ||
platformComponents = AndroidPlatformComponentsFactory.createFromContext( | ||
context | ||
) | ||
} | ||
|
||
@Test | ||
fun testCreateSignInSubmitPasswordCommandParameters_containsCorrectInfo() { | ||
val correlationId = UUID.randomUUID().toString() | ||
val continuationToken = "continuation" | ||
val signInStartParams = SignInStartCommandParameters.builder() | ||
.password("test".toCharArray()) | ||
.claimsRequestJson("claimsRequestJson") | ||
.clientId("clientId") | ||
.challengeType(arrayListOf("OOB")) | ||
.redirectUri("redirectUri") | ||
.username("username") | ||
.platformComponents(platformComponents) | ||
.build() | ||
val submitPasswordParams = CommandUtil.createSignInSubmitPasswordCommandParameters(signInStartParams, correlationId, continuationToken) | ||
|
||
assert(submitPasswordParams.getPassword().contentEquals(signInStartParams.getPassword())) | ||
assert(submitPasswordParams.getContinuationToken().contentEquals(continuationToken)) | ||
assert(submitPasswordParams.correlationId?.contentEquals(correlationId) == true) | ||
assert(submitPasswordParams.getClaimsRequestJson().contentEquals(signInStartParams.getClaimsRequestJson())) | ||
assert(submitPasswordParams.clientId?.contentEquals(signInStartParams.clientId) == true) | ||
assert(submitPasswordParams.getChallengeType()?.equals(signInStartParams.getChallengeType()) == true) | ||
assert(submitPasswordParams.redirectUri?.equals(signInStartParams.redirectUri) == true) | ||
} | ||
|
||
@Test | ||
fun testCreateSignInSubmitCodeCommandParameters_containsCorrectInfo() { | ||
val mfaSubmitChallengeParams = MFASubmitChallengeCommandParameters.builder() | ||
.claimsRequestJson("claimsRequestJson") | ||
.clientId("clientId") | ||
.challengeType(arrayListOf("OOB")) | ||
.redirectUri("redirectUri") | ||
.platformComponents(platformComponents) | ||
.challenge("123456") | ||
.continuationToken("continuationToken") | ||
.correlationId(UUID.randomUUID().toString()) | ||
.build() | ||
val submitCodeParams = CommandUtil.createSignInSubmitCodeCommandParameters(mfaSubmitChallengeParams) | ||
|
||
assert(submitCodeParams.getContinuationToken().contentEquals(mfaSubmitChallengeParams.getContinuationToken())) | ||
assert(submitCodeParams.correlationId?.contentEquals(mfaSubmitChallengeParams.correlationId) == true) | ||
assert(submitCodeParams.getClaimsRequestJson().contentEquals(mfaSubmitChallengeParams.getClaimsRequestJson())) | ||
assert(submitCodeParams.clientId?.contentEquals(mfaSubmitChallengeParams.clientId) == true) | ||
assert(submitCodeParams.getChallengeType()?.equals(mfaSubmitChallengeParams.getChallengeType()) == true) | ||
assert(submitCodeParams.getCode() == mfaSubmitChallengeParams.getChallenge()) | ||
assert(submitCodeParams.redirectUri?.equals(mfaSubmitChallengeParams.redirectUri) == true) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters