Skip to content

Commit 6b6236a

Browse files
committed
Merge remote-tracking branch 'origin/dev' into melissaahn/ExtraTokenBodyParameters
dev
2 parents 704140b + a4ff3cb commit 6b6236a

File tree

46 files changed

+750
-1042
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+750
-1042
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Notify on versions.gradle changes
2+
3+
on:
4+
push:
5+
paths:
6+
- 'gradle/versions.gradle'
7+
branches:
8+
- dev
9+
- 'release/**'
10+
pull_request:
11+
paths:
12+
- 'gradle/versions.gradle'
13+
branches:
14+
- dev
15+
- 'release/**'
16+
17+
permissions:
18+
pull-requests: write
19+
20+
jobs:
21+
notify:
22+
runs-on: ubuntu-latest
23+
steps:
24+
- name: Log changes
25+
run: |
26+
echo "Changes detected in the 'gradle/versions.gradle' file."
27+
28+
- name: Comment on PR
29+
if: github.event_name == 'pull_request'
30+
uses: mshick/add-pr-comment@v2
31+
with:
32+
message: "⚠️ **Warning:** Changes detected in the 'versions.gradle' file! ⚠️\n\nPlease refer to [this document](https://dev.azure.com/IdentityDivision/IdentityWiki/_wiki/wikis/IdentityWiki.wiki/82085/Adding-or-Updating-Gradle-Dependencies) for more details."

.github/workflows/validate-pr-ab-id.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,16 @@ jobs:
3333
# Extracts the AB ID from the pull_request body using regex and store the result using outputs
3434
- name: Get AB ID from comment
3535
id: get
36+
env:
37+
PR_BODY: ${{ github.event.pull_request.body }}
3638
run: |
37-
result=$(echo "${{ github.event.pull_request.body }}" | grep -oP '(?<=#)\d+')
38-
echo "id=${result}" >> "$GITHUB_OUTPUT"
39+
# Sanitize PR body by removing backticks to prevent command substitution
40+
clean=$(printf "%s" "$PR_BODY" | tr -d '`')
41+
42+
# Extract AB ID (AB#1234567) - takes first match if multiple exist
43+
result=$(printf "%s" "$clean" | grep -oP '(?<=AB#)\d+' | head -n 1)
44+
45+
echo "id=$result" >> "$GITHUB_OUTPUT"
3946

4047
# Get Pull request ID
4148
get_pr_id:

LabApiUtilities/build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ plugins {
1515

1616
apply from: '../versioning/version_tasks.gradle'
1717

18-
project.ext.vstsUsername = System.getenv("ENV_VSTS_MVN_ANDROIDCOMMON_USERNAME") != null ? System.getenv("ENV_VSTS_MVN_ANDROIDCOMMON_USERNAME") : project.findProperty("vstsUsername")
19-
project.ext.vstsPassword = System.getenv("ENV_VSTS_MVN_ANDROIDCOMMON_ACCESSTOKEN") != null ? System.getenv("ENV_VSTS_MVN_ANDROIDCOMMON_ACCESSTOKEN") : project.findProperty("vstsMavenAccessToken")
18+
project.ext.vstsUsername = System.getenv("ENV_VSTS_MVN_CRED_USERNAME") != null ? System.getenv("ENV_VSTS_MVN_CRED_USERNAME") : project.findProperty("vstsUsername")
19+
project.ext.vstsMavenAccessToken = System.getenv("ENV_VSTS_MVN_CRED_ACCESSTOKEN") != null ? System.getenv("ENV_VSTS_MVN_CRED_ACCESSTOKEN") : project.findProperty("vstsMavenAccessToken")
2020

2121
version = getAppVersionName()
2222

@@ -117,15 +117,15 @@ publishing {
117117
url "https://identitydivision.pkgs.visualstudio.com/_packaging/AndroidADAL/maven/v1"
118118
credentials {
119119
username project.ext.vstsUsername
120-
password project.ext.vstsPassword
120+
password project.ext.vstsMavenAccessToken
121121
}
122122
}
123123
maven {
124124
name "vsts-maven-android"
125125
url 'https://identitydivision.pkgs.visualstudio.com/IDDP/_packaging/Android/maven/v1'
126126
credentials {
127127
username project.vstsUsername
128-
password project.vstsPassword
128+
password project.vstsMavenAccessToken
129129
}
130130
}
131131
}

LabApiUtilities/src/main/com/microsoft/identity/labapi/utilities/authentication/LabApiAuthenticationClient.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ public class LabApiAuthenticationClient implements IAccessTokenSupplier {
5151
private final static int ATTEMPT_RETRY_WAIT = 3;
5252
private final String mLabCredential;
5353
private final String mLabCertPassword;
54-
private final String defaultScope = LabConstants.DEFAULT_LAB_SCOPE;
5554
private final String mClientId;
5655

5756
public LabApiAuthenticationClient(@NonNull final String labSecret) {
@@ -124,7 +123,7 @@ private String getAccessTokenInternal(final String customScope) throws LabApiExc
124123
if (customScope != null) {
125124
authScope = customScope;
126125
} else {
127-
authScope = defaultScope;
126+
authScope = LabConstants.DEFAULT_LAB_SCOPE;
128127
}
129128

130129
final IConfidentialAuthClient confidentialAuthClient = new Msal4jAuthClient();

LabApiUtilities/src/main/com/microsoft/identity/labapi/utilities/client/ILabAccount.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,13 @@ public interface ILabAccount {
5858
*/
5959
String getHomeTenantId();
6060

61+
/**
62+
* Get the object id in home tenant.
63+
*
64+
* @return a String representing the account's object id in home tenant
65+
*/
66+
String getHomeObjectId();
67+
6168
/**
6269
* A client id that can be used alongside this account to get a token.
6370
*

LabApiUtilities/src/main/com/microsoft/identity/labapi/utilities/client/LabAccount.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ public class LabAccount implements ILabAccount {
5252
@NonNull
5353
private final String mHomeTenantId;
5454

55+
@NonNull
56+
private final String mHomeObjectId;
57+
5558
// nullable
5659
// dependency for Nullable annotation not currently added to LabApiUtilities
5760
private final ConfigInfo mConfigInfo;

LabApiUtilities/src/main/com/microsoft/identity/labapi/utilities/client/LabClient.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ private ILabAccount getLabAccountObject(@NonNull final ConfigInfo configInfo) th
144144
.password(password)
145145
.userType(UserType.fromName(configInfo.getUserInfo().getUserType()))
146146
.homeTenantId(configInfo.getUserInfo().getHomeTenantID())
147+
.homeObjectId(configInfo.getUserInfo().getHomeObjectId())
147148
.configInfo(configInfo)
148149
.build();
149150
}
@@ -252,6 +253,7 @@ private ILabAccount createTempAccountInternal(@NonNull final TempUserType tempUs
252253
// all temp users created by Lab Api are currently cloud users
253254
.userType(UserType.CLOUD)
254255
.homeTenantId(tempUser.getTenantId())
256+
.homeObjectId(tempUser.getObjectId())
255257
.build();
256258
}
257259

LabApiUtilities/src/test/com/microsoft/identity/labapi/utilities/client/LabClientTest.java

Lines changed: 24 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
import org.junit.After;
3434
import org.junit.Assert;
3535
import org.junit.Before;
36-
import org.junit.Ignore;
3736
import org.junit.Rule;
3837
import org.junit.Test;
3938

@@ -73,12 +72,7 @@ public void canFetchCloudAccount() {
7372

7473
try {
7574
final ILabAccount labAccount = mLabClient.getLabAccount(query);
76-
Assert.assertNotNull(labAccount);
77-
Assert.assertNotNull(labAccount.getUsername());
78-
Assert.assertNotNull(labAccount.getPassword());
79-
Assert.assertNotNull(labAccount.getUserType());
80-
Assert.assertTrue(labAccount.getUsername().toLowerCase().contains("msidlab4"));
81-
Assert.assertEquals(UserType.CLOUD, labAccount.getUserType());
75+
assertLabAccount(labAccount, UserType.CLOUD, "msidlab4");
8276
} catch (final LabApiException e) {
8377
throw new AssertionError(e);
8478
}
@@ -92,12 +86,7 @@ public void canFetchMSAAccount() {
9286

9387
try {
9488
final ILabAccount labAccount = mLabClient.getLabAccount(query);
95-
Assert.assertNotNull(labAccount);
96-
Assert.assertNotNull(labAccount.getUsername());
97-
Assert.assertNotNull(labAccount.getPassword());
98-
Assert.assertNotNull(labAccount.getUserType());
99-
Assert.assertTrue(labAccount.getUsername().toLowerCase().contains("outlook"));
100-
Assert.assertEquals(UserType.MSA, labAccount.getUserType());
89+
assertLabAccount(labAccount, UserType.MSA, "outlook");
10190
} catch (final LabApiException e) {
10291
throw new AssertionError(e);
10392
}
@@ -111,12 +100,7 @@ public void canFetchGuestAccount() {
111100

112101
try {
113102
final ILabAccount labAccount = mLabClient.getLabAccount(query);
114-
Assert.assertNotNull(labAccount);
115-
Assert.assertNotNull(labAccount.getUsername());
116-
Assert.assertNotNull(labAccount.getPassword());
117-
Assert.assertNotNull(labAccount.getUserType());
118-
Assert.assertTrue(labAccount.getUsername().toLowerCase().contains("msidlab4"));
119-
Assert.assertEquals(UserType.GUEST, labAccount.getUserType());
103+
assertLabAccount(labAccount, UserType.GUEST, "msidlab4");
120104
} catch (final LabApiException e) {
121105
throw new AssertionError(e);
122106
}
@@ -130,12 +114,7 @@ public void canFetchFederatedAccount() {
130114

131115
try {
132116
final ILabAccount labAccount = mLabClient.getLabAccount(query);
133-
Assert.assertNotNull(labAccount);
134-
Assert.assertNotNull(labAccount.getUsername());
135-
Assert.assertNotNull(labAccount.getPassword());
136-
Assert.assertNotNull(labAccount.getUserType());
137-
Assert.assertTrue(labAccount.getUsername().toLowerCase().contains("msidlab4"));
138-
Assert.assertEquals(UserType.FEDERATED, labAccount.getUserType());
117+
assertLabAccount(labAccount, UserType.FEDERATED, "msidlab4");
139118
} catch (final LabApiException e) {
140119
throw new AssertionError(e);
141120
}
@@ -145,12 +124,7 @@ public void canFetchFederatedAccount() {
145124
public void canCreateBasicTempUser() {
146125
try {
147126
final ILabAccount labAccount = mLabClient.createTempAccount(TempUserType.BASIC);
148-
Assert.assertNotNull(labAccount);
149-
Assert.assertNotNull(labAccount.getUsername());
150-
Assert.assertNotNull(labAccount.getPassword());
151-
Assert.assertNotNull(labAccount.getUserType());
152-
Assert.assertTrue(labAccount.getUsername().toLowerCase().contains("msidlab4"));
153-
Assert.assertEquals(UserType.CLOUD, labAccount.getUserType());
127+
assertLabAccount(labAccount, UserType.CLOUD, "msidlab4");
154128
} catch (final LabApiException e) {
155129
throw new AssertionError(e);
156130
}
@@ -160,11 +134,7 @@ public void canCreateBasicTempUser() {
160134
public void canCreateMAMCATempUser() {
161135
try {
162136
final ILabAccount labAccount = mLabClient.createTempAccount(TempUserType.MAM_CA);
163-
Assert.assertNotNull(labAccount);
164-
Assert.assertNotNull(labAccount.getUsername());
165-
Assert.assertNotNull(labAccount.getPassword());
166-
Assert.assertNotNull(labAccount.getUserType());
167-
Assert.assertTrue(labAccount.getUsername().toLowerCase().contains("msidlab4"));
137+
assertLabAccount(labAccount, UserType.CLOUD, "msidlab4");
168138
} catch (final LabApiException e) {
169139
throw new AssertionError(e);
170140
}
@@ -203,4 +173,22 @@ public void canDisablePolicy() {
203173
}
204174
}
205175

176+
177+
// Helper to assert common properties of a lab account
178+
private void assertLabAccount(final ILabAccount labAccount,
179+
final UserType expectedUserType,
180+
final String expectedUsernameContains) {
181+
Assert.assertNotNull(labAccount);
182+
Assert.assertNotNull(labAccount.getUsername());
183+
Assert.assertNotNull(labAccount.getPassword());
184+
Assert.assertNotNull(labAccount.getUserType());
185+
if (expectedUsernameContains != null) {
186+
Assert.assertTrue(labAccount.getUsername().toLowerCase().contains(expectedUsernameContains));
187+
}
188+
if (expectedUserType != null) {
189+
Assert.assertEquals(expectedUserType, labAccount.getUserType());
190+
}
191+
Assert.assertNotNull(labAccount.getHomeObjectId());
192+
Assert.assertNotNull(labAccount.getHomeTenantId());
193+
}
206194
}

azure-pipelines/continuous-delivery/common-cd.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# File: azure-pipelines/continuous-delivery/common-cd.yml
22
# Description: Assemble & publish latest keyvault, labapi, labapiutilities, testutil release to internal vsts feed
3-
# Variable: 'ENV_VSTS_MVN_ANDROIDCOMMON_USERNAME' was defined in the Variables tab
43
# Variable: 'customVersion' overrides the version number of the published libraries
54

65
name: 0.0.$(Date:yyyyMMdd)$(Rev:.r) # $(Build.BuildNumber) = name

azure-pipelines/pull-request-validation/build-consumers.yml

Lines changed: 12 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# File: azure-pipelines\pull-request-validation\build-consumers.yml
22
# Description: Test new common in ADAL / MSAL / Broker (assembleLocal and testLocalDebugUnitTest)
3-
# Variable: 'ENV_VSTS_MVN_ANDROIDADACCOUNTS_USERNAME' was defined in the Variables tab
43
# https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate
54
# Variable: 'commonBranchName' common branch to be used when running the pipeline manually
65
# Variable: 'skipConsumerValidationLabel' PR label used to skip the checks in this pipeline
@@ -36,11 +35,6 @@ resources:
3635
name: AzureAD/ad-accounts-for-android
3736
ref: dev
3837
endpoint: ANDROID_GITHUB
39-
- repository: adal
40-
type: github
41-
name: AzureAD/azure-activedirectory-library-for-android
42-
ref: dev
43-
endpoint: ANDROID_GITHUB
4438

4539
stages:
4640
- stage: getLabel
@@ -121,6 +115,10 @@ stages:
121115
git status
122116
git rev-parse HEAD
123117
workingDirectory: $(Agent.BuildDirectory)/s/common
118+
- bash: |
119+
echo "##vso[task.setvariable variable=ENV_VSTS_MVN_CRED_USERNAME]VSTS"
120+
echo "##vso[task.setvariable variable=ENV_VSTS_MVN_CRED_ACCESSTOKEN]$(System.AccessToken)"
121+
displayName: 'Set VSTS Fields in Environment'
124122
- task: Gradle@3
125123
displayName: Assemble msal
126124
inputs:
@@ -154,6 +152,10 @@ stages:
154152
clean: true
155153
submodules: recursive
156154
persistCredentials: True
155+
- bash: |
156+
echo "##vso[task.setvariable variable=ENV_VSTS_MVN_CRED_USERNAME]VSTS"
157+
echo "##vso[task.setvariable variable=ENV_VSTS_MVN_CRED_ACCESSTOKEN]$(System.AccessToken)"
158+
displayName: 'Set VSTS Fields in Environment'
157159
- template: ../templates/steps/automation-cert.yml
158160
- task: CmdLine@2
159161
displayName: Checkout common submodule $(commonBranch)
@@ -195,6 +197,10 @@ stages:
195197
clean: true
196198
submodules: recursive
197199
persistCredentials: True
200+
- bash: |
201+
echo "##vso[task.setvariable variable=ENV_VSTS_MVN_CRED_USERNAME]VSTS"
202+
echo "##vso[task.setvariable variable=ENV_VSTS_MVN_CRED_ACCESSTOKEN]$(System.AccessToken)"
203+
displayName: 'Set VSTS Fields in Environment'
198204
- task: AzureKeyVault@2
199205
displayName: 'Get Key vault LabAuth'
200206
inputs:
@@ -208,11 +214,6 @@ stages:
208214
inputs:
209215
targetType: inline
210216
script: java -version
211-
- task: CmdLine@1
212-
displayName: Set MVN Access Token in Environment
213-
inputs:
214-
filename: echo
215-
arguments: '##vso[task.setvariable variable=ENV_VSTS_MVN_ANDROIDADACCOUNTS_ACCESSTOKEN]$(System.AccessToken)'
216217
- task: CmdLine@1
217218
displayName: Set Office MVN Access Token in Environment
218219
inputs:
@@ -257,40 +258,3 @@ stages:
257258
testResultsFormat: 'JUnit'
258259
testResultsFiles: '**/TEST-*.xml'
259260
searchFolder: 'LinuxBroker'
260-
# adal
261-
- job: adalValidation
262-
displayName: ADAL
263-
dependsOn:
264-
- setupBranch
265-
variables:
266-
commonBranch: $[ dependencies.setupBranch.outputs['setvarStep.commonBranch'] ] # map in the variable
267-
condition: and( succeeded(), not(contains(variables['prLabels'], variables['skipConsumerValidationLabel'])) )
268-
steps:
269-
- checkout: adal
270-
displayName: Checkout adal repository
271-
clean: true
272-
submodules: recursive
273-
persistCredentials: True
274-
- task: CmdLine@2
275-
displayName: Checkout common submodule $(commonBranch)
276-
inputs:
277-
script: |
278-
git fetch
279-
git checkout $(commonBranch)
280-
git pull
281-
git status
282-
git rev-parse HEAD
283-
workingDirectory: $(Agent.BuildDirectory)/s/common
284-
- template: ../templates/steps/automation-cert.yml
285-
- task: Gradle@3
286-
displayName: Assemble adal
287-
inputs:
288-
tasks: clean adal:assembleLocal
289-
jdkArchitecture: x64
290-
jdkVersionOption: "1.17"
291-
- task: Gradle@3
292-
displayName: Run adal Unit tests
293-
inputs:
294-
tasks: adal:testLocalDebugUnitTest -Plabtest -ProbolectricSdkVersion=${{variables.robolectricSdkVersion}} -PlabSecret=$(LabVaultAppCert)
295-
jdkArchitecture: x64
296-
jdkVersionOption: "1.17"

0 commit comments

Comments
 (0)