-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Authority mismatch instrumentation #8212
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
75472a6
Add empty string check to environment validation on account creation
hectormmg 53765a4
Add authority and environment to authority mismatch performance event
hectormmg 6d0a00f
Update lib/msal-browser/src/interaction_client/BaseInteractionClient.ts
hectormmg d04fee6
Merge branch 'dev' into authortiy-mismatch-instrumentation
hectormmg 569d2cd
Fix env checks
hectormmg 71e2596
Add tests for telemetry
hectormmg 9c13448
Change files
hectormmg a632e49
Add changefiles and update tests
hectormmg df4d05b
Update change/@azure-msal-common-adda0fb4-dea9-4116-b965-68b15040c909…
hectormmg 7f8d2c8
Update change/@azure-msal-browser-8d6fcd39-1f3b-4b4d-81e6-b729b83cdd7…
hectormmg 3a4c583
Fix format and API review
hectormmg e91f8e8
Fix format
hectormmg f350dc3
Update lib/msal-common/test/cache/entities/AccountEntity.spec.ts
hectormmg f25a52e
Fix account entity spec
hectormmg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
change/@azure-msal-browser-8d6fcd39-1f3b-4b4d-81e6-b729b83cdd7e.json
This file contains hidden or 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,7 @@ | ||
| { | ||
| "type": "patch", | ||
| "comment": "Authority mismatch instrumentation [#8212](https://github.com/AzureAD/microsoft-authentication-library-for-js/pull/8212)", | ||
| "packageName": "@azure/msal-browser", | ||
| "email": "[email protected]", | ||
| "dependentChangeType": "patch" | ||
| } |
7 changes: 7 additions & 0 deletions
7
change/@azure-msal-common-adda0fb4-dea9-4116-b965-68b15040c909.json
This file contains hidden or 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,7 @@ | ||
| { | ||
| "type": "patch", | ||
| "comment": "Authority mismatch instrumentation [#8212](https://github.com/AzureAD/microsoft-authentication-library-for-js/pull/8212)", | ||
| "packageName": "@azure/msal-common", | ||
| "email": "[email protected]", | ||
| "dependentChangeType": "patch" | ||
| } |
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -269,6 +269,170 @@ describe("BaseInteractionClient", () => { | |
| }); | ||
| }); | ||
|
|
||
| it("Adds telemetry fields when authority mismatch occurs with valid values", async () => { | ||
| const testAccount = { | ||
| homeAccountId: TEST_DATA_CLIENT_INFO.TEST_HOME_ACCOUNT_ID, | ||
| localAccountId: TEST_DATA_CLIENT_INFO.TEST_UID, | ||
| environment: "login.windows-ppe.net", | ||
| tenantId: "3338040d-6c67-4c5b-b112-36a304b66dad", | ||
| username: "[email protected]", | ||
| loginHint: "loginHint", | ||
| }; | ||
|
|
||
| // @ts-ignore | ||
| const addFieldsSpy = jest.spyOn( | ||
| (testClient as any).performanceClient, | ||
| "addFields" | ||
| ); | ||
|
|
||
| await testClient | ||
| // @ts-ignore | ||
| .getDiscoveredAuthority({ | ||
| requestAuthority: | ||
| "https://login.microsoftonline.com/common", | ||
| account: testAccount, | ||
| }) | ||
| .catch((error) => { | ||
| expect(error).toStrictEqual( | ||
| createClientConfigurationError( | ||
| ClientConfigurationErrorCodes.authorityMismatch | ||
| ) | ||
| ); | ||
| }); | ||
|
|
||
| expect(addFieldsSpy).toHaveBeenCalledWith( | ||
| expect.objectContaining({ | ||
| discoveredAuthority: | ||
| "https://login.microsoftonline.com/common/", | ||
| accountEnvironment: "login.windows-ppe.net", | ||
| }), | ||
| expect.any(String) | ||
| ); | ||
| }); | ||
|
|
||
| it("Adds telemetry with normalized values when account environment is undefined", async () => { | ||
| const testAccount = { | ||
| homeAccountId: TEST_DATA_CLIENT_INFO.TEST_HOME_ACCOUNT_ID, | ||
| localAccountId: TEST_DATA_CLIENT_INFO.TEST_UID, | ||
| environment: undefined as any, | ||
| tenantId: "3338040d-6c67-4c5b-b112-36a304b66dad", | ||
| username: "[email protected]", | ||
| loginHint: "loginHint", | ||
| }; | ||
|
|
||
| // @ts-ignore | ||
| const addFieldsSpy = jest.spyOn( | ||
| (testClient as any).performanceClient, | ||
| "addFields" | ||
| ); | ||
|
|
||
| await testClient | ||
| // @ts-ignore | ||
| .getDiscoveredAuthority({ | ||
| requestAuthority: | ||
| "https://login.microsoftonline.com/common", | ||
| account: testAccount, | ||
| }) | ||
| .catch((error) => { | ||
| expect(error).toStrictEqual( | ||
| createClientConfigurationError( | ||
| ClientConfigurationErrorCodes.authorityMismatch | ||
| ) | ||
| ); | ||
| }); | ||
|
|
||
| expect(addFieldsSpy).toHaveBeenCalledWith( | ||
| expect.objectContaining({ | ||
| discoveredAuthority: | ||
| "https://login.microsoftonline.com/common/", | ||
| accountEnvironment: "(undefined)", | ||
| }), | ||
| expect.any(String) | ||
| ); | ||
| }); | ||
|
|
||
| it("Adds telemetry with normalized values when account environment is empty string", async () => { | ||
| const testAccount = { | ||
| homeAccountId: TEST_DATA_CLIENT_INFO.TEST_HOME_ACCOUNT_ID, | ||
| localAccountId: TEST_DATA_CLIENT_INFO.TEST_UID, | ||
| environment: "", | ||
| tenantId: "3338040d-6c67-4c5b-b112-36a304b66dad", | ||
| username: "[email protected]", | ||
| loginHint: "loginHint", | ||
| }; | ||
|
|
||
| // @ts-ignore | ||
| const addFieldsSpy = jest.spyOn( | ||
| (testClient as any).performanceClient, | ||
| "addFields" | ||
| ); | ||
|
|
||
| await testClient | ||
| // @ts-ignore | ||
| .getDiscoveredAuthority({ | ||
| requestAuthority: | ||
| "https://login.microsoftonline.com/common", | ||
| account: testAccount, | ||
| }) | ||
| .catch((error) => { | ||
| expect(error).toStrictEqual( | ||
| createClientConfigurationError( | ||
| ClientConfigurationErrorCodes.authorityMismatch | ||
| ) | ||
| ); | ||
| }); | ||
|
|
||
| expect(addFieldsSpy).toHaveBeenCalledWith( | ||
| expect.objectContaining({ | ||
| discoveredAuthority: | ||
| "https://login.microsoftonline.com/common/", | ||
| accountEnvironment: "(empty string)", | ||
| }), | ||
| expect.any(String) | ||
| ); | ||
| }); | ||
|
|
||
| it("Adds telemetry with normalized values when account environment is whitespace-only", async () => { | ||
| const testAccount = { | ||
| homeAccountId: TEST_DATA_CLIENT_INFO.TEST_HOME_ACCOUNT_ID, | ||
| localAccountId: TEST_DATA_CLIENT_INFO.TEST_UID, | ||
| environment: " ", | ||
| tenantId: "3338040d-6c67-4c5b-b112-36a304b66dad", | ||
| username: "[email protected]", | ||
| loginHint: "loginHint", | ||
| }; | ||
|
|
||
| // @ts-ignore | ||
| const addFieldsSpy = jest.spyOn( | ||
| (testClient as any).performanceClient, | ||
| "addFields" | ||
| ); | ||
|
|
||
| await testClient | ||
| // @ts-ignore | ||
| .getDiscoveredAuthority({ | ||
| requestAuthority: | ||
| "https://login.microsoftonline.com/common", | ||
| account: testAccount, | ||
| }) | ||
| .catch((error) => { | ||
| expect(error).toStrictEqual( | ||
| createClientConfigurationError( | ||
| ClientConfigurationErrorCodes.authorityMismatch | ||
| ) | ||
| ); | ||
| }); | ||
|
|
||
| expect(addFieldsSpy).toHaveBeenCalledWith( | ||
| expect.objectContaining({ | ||
| discoveredAuthority: | ||
| "https://login.microsoftonline.com/common/", | ||
| accountEnvironment: "(empty string)", | ||
| }), | ||
| expect.any(String) | ||
| ); | ||
| }); | ||
|
|
||
| it("Does not throw error when authority in request or MSAL config matches with environment set for account", (done) => { | ||
| const testAccount = { | ||
| homeAccountId: TEST_DATA_CLIENT_INFO.TEST_HOME_ACCOUNT_ID, | ||
|
|
||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.