Skip to content

Commit

Permalink
Add device id claim to "update cp/authapp" tests (#1954)
Browse files Browse the repository at this point in the history
Increase the coverage of the upgrade scenario - by making them do
WPJ+PRT set up.

This will make sure that WPJ+PRT artifacts are still intact after
upgrade (or after turning the broker discovery on).

![Screenshot 2023-11-15 at 2 54
10 PM](https://github.com/AzureAD/microsoft-authentication-library-for-android/assets/19558668/5c12671d-bdfc-466b-8d58-02f6a65f1e26)
  • Loading branch information
rpdome authored Nov 21, 2023
1 parent a6444c5 commit 6bd85f5
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
package com.microsoft.identity.client.msal.automationapp.testpass.msalonly.update

import com.microsoft.identity.client.Prompt
import com.microsoft.identity.client.claims.ClaimsRequest
import com.microsoft.identity.client.claims.RequestedClaimAdditionalInformation
import com.microsoft.identity.client.msal.automationapp.R
import com.microsoft.identity.client.msal.automationapp.sdk.MsalAuthResult
import com.microsoft.identity.client.msal.automationapp.sdk.MsalAuthTestParams
Expand Down Expand Up @@ -55,13 +57,20 @@ class TestCaseUpdateAuthenticator : AbstractMsalCustomBrokerInstallationTest() {

val mAuthenticator: BrokerMicrosoftAuthenticator = installOldAuthenticator()

// request the deviceid claim in ID Token
val claimsRequest = ClaimsRequest()
val requestedClaimAdditionalInformation = RequestedClaimAdditionalInformation()
requestedClaimAdditionalInformation.essential = true
claimsRequest.requestClaimInIdToken("deviceid", requestedClaimAdditionalInformation)

val msalSdk = MsalSdk()
val authTestParams = MsalAuthTestParams.builder()
.activity(mActivity)
.loginHint(username)
.scopes(Arrays.asList(*mScopes))
.scopes(listOf(*mScopes))
.promptParameter(Prompt.LOGIN)
.authScheme(AuthScheme.BEARER)
.claims(claimsRequest)
.msalConfigResourceId(configFileResourceId)
.build()

Expand All @@ -72,6 +81,7 @@ class TestCaseUpdateAuthenticator : AbstractMsalCustomBrokerInstallationTest() {
.sessionExpected(false)
.consentPageExpected(false)
.speedBumpExpected(false)
.registerPageExpected(true)
.broker(mAuthenticator)
.expectingBrokerAccountChooserActivity(false)
.build()
Expand All @@ -92,6 +102,7 @@ class TestCaseUpdateAuthenticator : AbstractMsalCustomBrokerInstallationTest() {
.scopes(Arrays.asList(*mScopes))
.authority(authority)
.authScheme(AuthScheme.BEARER)
.claims(claimsRequest)
.msalConfigResourceId(configFileResourceId)
.build()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
package com.microsoft.identity.client.msal.automationapp.testpass.msalonly.update

import com.microsoft.identity.client.Prompt
import com.microsoft.identity.client.claims.ClaimsRequest
import com.microsoft.identity.client.claims.RequestedClaimAdditionalInformation
import com.microsoft.identity.client.msal.automationapp.R
import com.microsoft.identity.client.msal.automationapp.sdk.MsalAuthResult
import com.microsoft.identity.client.msal.automationapp.sdk.MsalAuthTestParams
Expand Down Expand Up @@ -55,13 +57,20 @@ class TestCaseUpdateCompanyPortal : AbstractMsalCustomBrokerInstallationTest() {

val mCompanyPortal: BrokerCompanyPortal = installOldCompanyPortal()

// request the deviceid claim in ID Token
val claimsRequest = ClaimsRequest()
val requestedClaimAdditionalInformation = RequestedClaimAdditionalInformation()
requestedClaimAdditionalInformation.essential = true
claimsRequest.requestClaimInIdToken("deviceid", requestedClaimAdditionalInformation)

val msalSdk = MsalSdk()
val authTestParams = MsalAuthTestParams.builder()
.activity(mActivity)
.loginHint(username)
.scopes(Arrays.asList(*mScopes))
.scopes(listOf(*mScopes))
.promptParameter(Prompt.LOGIN)
.authScheme(AuthScheme.BEARER)
.claims(claimsRequest)
.msalConfigResourceId(configFileResourceId)
.build()

Expand All @@ -72,6 +81,7 @@ class TestCaseUpdateCompanyPortal : AbstractMsalCustomBrokerInstallationTest() {
.sessionExpected(false)
.consentPageExpected(false)
.speedBumpExpected(false)
.registerPageExpected(true)
.broker(mCompanyPortal)
.expectingBrokerAccountChooserActivity(false)
.build()
Expand All @@ -92,6 +102,7 @@ class TestCaseUpdateCompanyPortal : AbstractMsalCustomBrokerInstallationTest() {
.scopes(Arrays.asList(*mScopes))
.authority(authority)
.authScheme(AuthScheme.BEARER)
.claims(claimsRequest)
.msalConfigResourceId(configFileResourceId)
.build()

Expand Down

0 comments on commit 6bd85f5

Please sign in to comment.