diff --git a/change/@azure-msal-node-a94b317f-be47-480c-ab4b-8f1cbe823fd0.json b/change/@azure-msal-node-a94b317f-be47-480c-ab4b-8f1cbe823fd0.json new file mode 100644 index 0000000000..fe0f3ac0b3 --- /dev/null +++ b/change/@azure-msal-node-a94b317f-be47-480c-ab4b-8f1cbe823fd0.json @@ -0,0 +1,7 @@ +{ + "type": "none", + "comment": "Unit tests for broker flow #5910", + "packageName": "@azure/msal-node", + "email": "thomas.norling@microsoft.com", + "dependentChangeType": "none" +} diff --git a/lib/msal-node/test/client/PublicClientApplication.spec.ts b/lib/msal-node/test/client/PublicClientApplication.spec.ts index 012afe7912..d3578729ed 100644 --- a/lib/msal-node/test/client/PublicClientApplication.spec.ts +++ b/lib/msal-node/test/client/PublicClientApplication.spec.ts @@ -1,8 +1,11 @@ import { ID_TOKEN_CLAIMS, + mockNativeAccountInfo, mockAuthenticationResult, + mockNativeAuthenticationResult, TEST_CONSTANTS, TEST_DATA_CLIENT_INFO, + mockAccountInfo, } from "../utils/TestConstants"; import { ClientConfiguration, @@ -16,6 +19,9 @@ import { ClientAuthError, AccountInfo, ServerAuthorizationCodeResponse, + InteractionRequiredAuthError, + AccountEntity, + IdToken } from "@azure/msal-common"; import { Configuration, @@ -44,6 +50,8 @@ import { import { getMsalCommonAutoMock, MSALCommonModule } from "../utils/MockUtils"; import { version, name } from "../../package.json"; +import { MockNativeBrokerPlugin } from "../utils/MockNativeBrokerPlugin"; +import { SignOutRequest } from "../../src/request/SignOutRequest"; const msalCommon: MSALCommonModule = jest.requireActual("@azure/msal-common"); @@ -223,156 +231,371 @@ describe("PublicClientApplication", () => { ); }); - test("acquireTokenSilent", async () => { - const account: AccountInfo = { - homeAccountId: "", - environment: "", - tenantId: "", - username: "", - localAccountId: "", - name: "", - idTokenClaims: ID_TOKEN_CLAIMS, - }; - const request: SilentFlowRequest = { - account: account, - scopes: TEST_CONSTANTS.DEFAULT_GRAPH_SCOPE, - }; + describe("acquireTokenSilent tests", () => { + test("acquireTokenSilent succeeds", async () => { + const request: SilentFlowRequest = { + account: mockAccountInfo, + scopes: TEST_CONSTANTS.DEFAULT_GRAPH_SCOPE, + }; + + const silentFlowClient = getMsalCommonAutoMock().SilentFlowClient; + jest.spyOn(msalCommon, "SilentFlowClient").mockImplementation( + (config) => new silentFlowClient(config) + ); + + const authApp = new PublicClientApplication(appConfig); + await authApp.acquireTokenSilent(request); + expect(SilentFlowClient).toHaveBeenCalledTimes(1); + expect(SilentFlowClient).toHaveBeenCalledWith( + expect.objectContaining(expectedConfig) + ); + }); - const silentFlowClient = getMsalCommonAutoMock().SilentFlowClient; - jest.spyOn(msalCommon, "SilentFlowClient").mockImplementation( - (config) => new silentFlowClient(config) - ); + test("acquireTokenSilent calls into NativeBrokerPlugin and returns result", async () => { + const authApp = new PublicClientApplication({ + ...appConfig, + broker: { + nativeBrokerPlugin: new MockNativeBrokerPlugin() + } + }); - const authApp = new PublicClientApplication(appConfig); - await authApp.acquireTokenSilent(request); - expect(SilentFlowClient).toHaveBeenCalledTimes(1); - expect(SilentFlowClient).toHaveBeenCalledWith( - expect.objectContaining(expectedConfig) - ); - }); + const request: SilentFlowRequest = { + account: mockNativeAccountInfo, + scopes: TEST_CONSTANTS.DEFAULT_GRAPH_SCOPE + }; + const brokerSpy = jest.spyOn(MockNativeBrokerPlugin.prototype, "acquireTokenSilent"); + const response = await authApp.acquireTokenSilent(request); + expect(brokerSpy).toHaveBeenCalled(); + expect(response.idToken).toEqual(mockNativeAuthenticationResult.idToken); + expect(response.accessToken).toEqual(mockNativeAuthenticationResult.accessToken); + expect(response.account).toEqual(mockNativeAuthenticationResult.account); + }); - test("acquireTokenInteractive", async () => { - const authApp = new PublicClientApplication(appConfig); + test("acquireTokenSilent - calls into NativeBrokerPlugin and throws", (done) => { + const authApp = new PublicClientApplication({ + ...appConfig, + broker: { + nativeBrokerPlugin: new MockNativeBrokerPlugin() + } + }); + + const request: SilentFlowRequest = { + scopes: TEST_CONSTANTS.DEFAULT_GRAPH_SCOPE, + account: mockNativeAccountInfo + }; + + const testError = new InteractionRequiredAuthError("interaction_required", ); + const brokerSpy = jest.spyOn(MockNativeBrokerPlugin.prototype, "acquireTokenSilent").mockImplementation(() => { + return Promise.reject(testError); + }); + authApp.acquireTokenSilent(request).catch(e => { + expect(brokerSpy).toHaveBeenCalled(); + expect(e).toBe(testError); + done(); + }); + }); - let redirectUri: string; + }); - const openBrowser = (url: string) => { - expect(url.startsWith("https://login.microsoftonline.com")).toBe( - true + + describe("acquireTokenInteractive tests", () => { + + test("acquireTokenInteractive succeeds", async () => { + const authApp = new PublicClientApplication(appConfig); + + let redirectUri: string; + + const openBrowser = (url: string) => { + expect(url.startsWith("https://login.microsoftonline.com")).toBe( + true + ); + http.get( + `${redirectUri}?code=${TEST_CONSTANTS.AUTHORIZATION_CODE}` + ); + return Promise.resolve(); + }; + const request: InteractiveRequest = { + scopes: TEST_CONSTANTS.DEFAULT_GRAPH_SCOPE, + openBrowser: openBrowser, + }; + + const MockAuthorizationCodeClient = + getMsalCommonAutoMock().AuthorizationCodeClient; + jest.spyOn(msalCommon, "AuthorizationCodeClient").mockImplementation( + (config) => new MockAuthorizationCodeClient(config) ); - http.get( - `${redirectUri}?code=${TEST_CONSTANTS.AUTHORIZATION_CODE}` + + jest.spyOn( + MockAuthorizationCodeClient.prototype, + "getAuthCodeUrl" + ).mockImplementation((req) => { + redirectUri = req.redirectUri; + return Promise.resolve(TEST_CONSTANTS.AUTH_CODE_URL); + }); + + jest.spyOn( + MockAuthorizationCodeClient.prototype, + "acquireToken" + ).mockImplementation((tokenRequest) => { + expect(tokenRequest.scopes).toEqual([ + ...TEST_CONSTANTS.DEFAULT_GRAPH_SCOPE, + ...TEST_CONSTANTS.DEFAULT_OIDC_SCOPES, + ]); + return Promise.resolve(mockAuthenticationResult); + }); + + const response = await authApp.acquireTokenInteractive(request); + expect(response.idToken).toEqual(mockAuthenticationResult.idToken); + expect(response.accessToken).toEqual( + mockAuthenticationResult.accessToken ); - return Promise.resolve(); - }; - const request: InteractiveRequest = { - scopes: TEST_CONSTANTS.DEFAULT_GRAPH_SCOPE, - openBrowser: openBrowser, - }; + expect(response.account).toEqual(mockAuthenticationResult.account); + }); + + test("acquireTokenInteractive - with custom loopback client succeeds", async () => { + const authApp = new PublicClientApplication(appConfig); + + const openBrowser = (url: string) => { + expect(url.startsWith("https://login.microsoftonline.com")).toBe( + true + ); + return Promise.resolve(); + }; + + const testServerCodeResponse: ServerAuthorizationCodeResponse = { + code: TEST_CONSTANTS.AUTHORIZATION_CODE, + client_info: TEST_DATA_CLIENT_INFO.TEST_DECODED_CLIENT_INFO, + state: "123", + }; + + const mockListenForAuthCode = jest.fn(() => { + return new Promise((resolve) => { + resolve(testServerCodeResponse); + }); + }); + const mockGetRedirectUri = jest.fn(() => TEST_CONSTANTS.REDIRECT_URI); + const mockCloseServer = jest.fn(() => {}); + + const customLoopbackClient: ILoopbackClient = { + listenForAuthCode: mockListenForAuthCode, + getRedirectUri: mockGetRedirectUri, + closeServer: mockCloseServer, + }; + + const request: InteractiveRequest = { + scopes: TEST_CONSTANTS.DEFAULT_GRAPH_SCOPE, + openBrowser: openBrowser, + loopbackClient: customLoopbackClient, + }; + + const MockAuthorizationCodeClient = + getMsalCommonAutoMock().AuthorizationCodeClient; + jest.spyOn(msalCommon, "AuthorizationCodeClient").mockImplementation( + (config) => new MockAuthorizationCodeClient(config) + ); + + jest.spyOn( + MockAuthorizationCodeClient.prototype, + "getAuthCodeUrl" + ).mockImplementation((req) => { + expect(req.redirectUri).toEqual(TEST_CONSTANTS.REDIRECT_URI); + return Promise.resolve(TEST_CONSTANTS.AUTH_CODE_URL); + }); + + jest.spyOn( + MockAuthorizationCodeClient.prototype, + "acquireToken" + ).mockImplementation((tokenRequest) => { + expect(tokenRequest.scopes).toEqual([ + ...TEST_CONSTANTS.DEFAULT_GRAPH_SCOPE, + ...TEST_CONSTANTS.DEFAULT_OIDC_SCOPES, + ]); + return Promise.resolve(mockAuthenticationResult); + }); + + const response = await authApp.acquireTokenInteractive(request); + expect(response.idToken).toEqual(mockAuthenticationResult.idToken); + expect(response.accessToken).toEqual( + mockAuthenticationResult.accessToken + ); + expect(response.account).toEqual(mockAuthenticationResult.account); + expect(mockListenForAuthCode).toHaveBeenCalledTimes(1); + expect(mockGetRedirectUri).toHaveBeenCalledTimes(1); + expect(mockCloseServer).toHaveBeenCalledTimes(1); + }); - const MockAuthorizationCodeClient = - getMsalCommonAutoMock().AuthorizationCodeClient; - jest.spyOn(msalCommon, "AuthorizationCodeClient").mockImplementation( - (config) => new MockAuthorizationCodeClient(config) - ); + test("acquireTokenInteractive - calls into NativeBrokerPlugin and returns result", async () => { + const authApp = new PublicClientApplication({ + ...appConfig, + broker: { + nativeBrokerPlugin: new MockNativeBrokerPlugin() + } + }); - jest.spyOn( - MockAuthorizationCodeClient.prototype, - "getAuthCodeUrl" - ).mockImplementation((req) => { - redirectUri = req.redirectUri; - return Promise.resolve(TEST_CONSTANTS.AUTH_CODE_URL); - }); + const openBrowser = (url: string) => { + expect(url.startsWith("https://login.microsoftonline.com")).toBe(true); + return Promise.resolve(); + }; - jest.spyOn( - MockAuthorizationCodeClient.prototype, - "acquireToken" - ).mockImplementation((tokenRequest) => { - expect(tokenRequest.scopes).toEqual([ - ...TEST_CONSTANTS.DEFAULT_GRAPH_SCOPE, - ...TEST_CONSTANTS.DEFAULT_OIDC_SCOPES, - ]); - return Promise.resolve(mockAuthenticationResult); + const request: InteractiveRequest = { + scopes: TEST_CONSTANTS.DEFAULT_GRAPH_SCOPE, + openBrowser + }; + const brokerSpy = jest.spyOn(MockNativeBrokerPlugin.prototype, "acquireTokenInteractive"); + const response = await authApp.acquireTokenInteractive(request); + expect(brokerSpy).toHaveBeenCalled(); + expect(response.idToken).toEqual(mockNativeAuthenticationResult.idToken); + expect(response.accessToken).toEqual(mockNativeAuthenticationResult.accessToken); + expect(response.account).toEqual(mockNativeAuthenticationResult.account); }); - const response = await authApp.acquireTokenInteractive(request); - expect(response.idToken).toEqual(mockAuthenticationResult.idToken); - expect(response.accessToken).toEqual( - mockAuthenticationResult.accessToken - ); - expect(response.account).toEqual(mockAuthenticationResult.account); + test("acquireTokenInteractive - calls into NativeBrokerPlugin and throws", (done) => { + const authApp = new PublicClientApplication({ + ...appConfig, + broker: { + nativeBrokerPlugin: new MockNativeBrokerPlugin() + } + }); + + const openBrowser = (url: string) => { + expect(url.startsWith("https://login.microsoftonline.com")).toBe(true); + return Promise.resolve(); + }; + + const request: InteractiveRequest = { + scopes: TEST_CONSTANTS.DEFAULT_GRAPH_SCOPE, + openBrowser + }; + + const testError = ClientAuthError.createUserCanceledError(); + const brokerSpy = jest.spyOn(MockNativeBrokerPlugin.prototype, "acquireTokenInteractive").mockImplementation(() => { + return Promise.reject(testError); + }); + authApp.acquireTokenInteractive(request).catch(e => { + expect(brokerSpy).toHaveBeenCalled(); + expect(e).toBe(testError); + done(); + }); + }); }); - test("acquireTokenInteractive - with custom loopback client", async () => { - const authApp = new PublicClientApplication(appConfig); + describe("signOut tests", () => { + test("signOut clears account from local cache", async () => { + const authApp = new PublicClientApplication({ + ...appConfig + }); - const openBrowser = (url: string) => { - expect(url.startsWith("https://login.microsoftonline.com")).toBe( - true + const cryptoProvider = new CryptoProvider(); + const accountEntity: AccountEntity = AccountEntity.createAccount( + TEST_DATA_CLIENT_INFO.TEST_RAW_CLIENT_INFO, + mockAccountInfo.homeAccountId, + new IdToken(mockAuthenticationResult.idToken, cryptoProvider), + fakeAuthority ); - return Promise.resolve(); - }; - const testServerCodeResponse: ServerAuthorizationCodeResponse = { - code: TEST_CONSTANTS.AUTHORIZATION_CODE, - client_info: TEST_DATA_CLIENT_INFO.TEST_DECODED_CLIENT_INFO, - state: "123", - }; + // @ts-ignore + authApp.storage.setAccount(accountEntity); - const mockListenForAuthCode = jest.fn(() => { - return new Promise((resolve) => { - resolve(testServerCodeResponse); + const accountsBefore = await authApp.getAllAccounts(); + expect(accountsBefore.length).toBe(1); + + await authApp.signOut({ account: mockAccountInfo }); + const accountsAfter = await authApp.getAllAccounts(); + expect(accountsAfter.length).toBe(0); + }); + + test("signOut calls NativeBrokerPlugin and resolves", async () => { + const authApp = new PublicClientApplication({ + ...appConfig, + broker: { + nativeBrokerPlugin: new MockNativeBrokerPlugin() + } }); + + const request: SignOutRequest = { + account: mockNativeAccountInfo + }; + const brokerSpy = jest.spyOn(MockNativeBrokerPlugin.prototype, "signOut"); + await authApp.signOut(request); + expect(brokerSpy).toHaveBeenCalled(); }); - const mockGetRedirectUri = jest.fn(() => TEST_CONSTANTS.REDIRECT_URI); - const mockCloseServer = jest.fn(() => {}); - const customLoopbackClient: ILoopbackClient = { - listenForAuthCode: mockListenForAuthCode, - getRedirectUri: mockGetRedirectUri, - closeServer: mockCloseServer, - }; + test("signOut calls NativeBrokerPlugin and rejects with error thrown", (done) => { + const authApp = new PublicClientApplication({ + ...appConfig, + broker: { + nativeBrokerPlugin: new MockNativeBrokerPlugin() + } + }); - const request: InteractiveRequest = { - scopes: TEST_CONSTANTS.DEFAULT_GRAPH_SCOPE, - openBrowser: openBrowser, - loopbackClient: customLoopbackClient, - }; + const request: SignOutRequest = { + account: mockNativeAccountInfo + }; + const testError = ClientAuthError.createNoAccountFoundError(); + const brokerSpy = jest.spyOn(MockNativeBrokerPlugin.prototype, "signOut").mockImplementation(() => { + return Promise.reject(testError); + }); + authApp.signOut(request).catch((e) => { + expect(brokerSpy).toHaveBeenCalled(); + expect(e).toBe(testError); + done(); + }); + }); + }); - const MockAuthorizationCodeClient = - getMsalCommonAutoMock().AuthorizationCodeClient; - jest.spyOn(msalCommon, "AuthorizationCodeClient").mockImplementation( - (config) => new MockAuthorizationCodeClient(config) - ); + describe("getAllAccounts tests", () => { + test("getAllAccounts returns an array of accounts found in the cache", async () => { + const authApp = new PublicClientApplication({ + ...appConfig + }); - jest.spyOn( - MockAuthorizationCodeClient.prototype, - "getAuthCodeUrl" - ).mockImplementation((req) => { - expect(req.redirectUri).toEqual(TEST_CONSTANTS.REDIRECT_URI); - return Promise.resolve(TEST_CONSTANTS.AUTH_CODE_URL); + const cryptoProvider = new CryptoProvider(); + const accountEntity: AccountEntity = AccountEntity.createAccount( + TEST_DATA_CLIENT_INFO.TEST_RAW_CLIENT_INFO, + mockAccountInfo.homeAccountId, + new IdToken(mockAuthenticationResult.idToken, cryptoProvider), + fakeAuthority + ); + + // @ts-ignore + authApp.storage.setAccount(accountEntity); + + const accounts = await authApp.getAllAccounts(); + expect(accounts).toStrictEqual([mockAccountInfo]); }); - jest.spyOn( - MockAuthorizationCodeClient.prototype, - "acquireToken" - ).mockImplementation((tokenRequest) => { - expect(tokenRequest.scopes).toEqual([ - ...TEST_CONSTANTS.DEFAULT_GRAPH_SCOPE, - ...TEST_CONSTANTS.DEFAULT_OIDC_SCOPES, - ]); - return Promise.resolve(mockAuthenticationResult); + test("getAllAccounts calls NativeBrokerPlugin and resolves", async () => { + const authApp = new PublicClientApplication({ + ...appConfig, + broker: { + nativeBrokerPlugin: new MockNativeBrokerPlugin() + } + }); + + const brokerSpy = jest.spyOn(MockNativeBrokerPlugin.prototype, "getAllAccounts"); + const accounts = await authApp.getAllAccounts(); + expect(brokerSpy).toHaveBeenCalled(); + expect(accounts).toStrictEqual([mockNativeAccountInfo]); }); - const response = await authApp.acquireTokenInteractive(request); - expect(response.idToken).toEqual(mockAuthenticationResult.idToken); - expect(response.accessToken).toEqual( - mockAuthenticationResult.accessToken - ); - expect(response.account).toEqual(mockAuthenticationResult.account); - expect(mockListenForAuthCode).toHaveBeenCalledTimes(1); - expect(mockGetRedirectUri).toHaveBeenCalledTimes(1); - expect(mockCloseServer).toHaveBeenCalledTimes(1); + test("getAllAccounts calls NativeBrokerPlugin and rejects with error thrown", (done) => { + const authApp = new PublicClientApplication({ + ...appConfig, + broker: { + nativeBrokerPlugin: new MockNativeBrokerPlugin() + } + }); + + const testError = ClientAuthError.createNoAccountFoundError(); + const brokerSpy = jest.spyOn(MockNativeBrokerPlugin.prototype, "getAllAccounts").mockImplementation(() => { + return Promise.reject(testError); + }); + authApp.getAllAccounts().catch((e) => { + expect(brokerSpy).toHaveBeenCalled(); + expect(e).toBe(testError); + done(); + }); + }); }); test("initializeBaseRequest passes a claims hash to acquireToken", async () => { diff --git a/lib/msal-node/test/client/test-fixtures.ts b/lib/msal-node/test/client/test-fixtures.ts index 24de6ed56c..a8d72c7a31 100644 --- a/lib/msal-node/test/client/test-fixtures.ts +++ b/lib/msal-node/test/client/test-fixtures.ts @@ -1,3 +1,8 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. + */ + import { ServerTelemetryManager, Authority, @@ -5,6 +10,7 @@ import { } from "@azure/msal-common"; import * as msalCommon from "@azure/msal-common"; +import { TEST_CONSTANTS } from "../utils/TestConstants"; // @ts-ignore const mockServerTelemetryManager: ServerTelemetryManager = { @@ -53,11 +59,14 @@ export const fakeAuthority: Authority = { discoveryComplete: () => { return true; }, + getPreferredCache: () => { + return TEST_CONSTANTS.PREFERRED_CACHE; + } } as unknown as Authority; export const setupAuthorityFactory_createDiscoveredInstance_mock = ( authority = fakeAuthority -) => { +): jest.SpyInstance => { return jest .spyOn(AuthorityFactory, "createDiscoveredInstance") .mockReturnValue(Promise.resolve(authority)); diff --git a/lib/msal-node/test/utils/MockNativeBrokerPlugin.ts b/lib/msal-node/test/utils/MockNativeBrokerPlugin.ts new file mode 100644 index 0000000000..ee34a18182 --- /dev/null +++ b/lib/msal-node/test/utils/MockNativeBrokerPlugin.ts @@ -0,0 +1,36 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. + */ + +import { AccountInfo, AuthenticationResult, INativeBrokerPlugin } from "@azure/msal-common"; +import { mockNativeAuthenticationResult, mockNativeAccountInfo } from "./TestConstants"; + +export class MockNativeBrokerPlugin implements INativeBrokerPlugin { + isBrokerAvailable: boolean = true; + + setLogger(): void { + return; + } + + getAccountById(): Promise { + return Promise.resolve(mockNativeAccountInfo); + } + + getAllAccounts(): Promise { + return Promise.resolve([mockNativeAccountInfo]); + } + + acquireTokenSilent(): Promise { + return Promise.resolve(mockNativeAuthenticationResult); + } + + acquireTokenInteractive(): Promise { + return Promise.resolve(mockNativeAuthenticationResult); + } + + signOut(): Promise { + return Promise.resolve(); + } + +} diff --git a/lib/msal-node/test/utils/TestConstants.ts b/lib/msal-node/test/utils/TestConstants.ts index 22b252dcec..50a647b427 100644 --- a/lib/msal-node/test/utils/TestConstants.ts +++ b/lib/msal-node/test/utils/TestConstants.ts @@ -3,7 +3,7 @@ * Licensed under the MIT License. */ -import { +import { AccountInfo , ICrypto, AuthError, PkceCodes, @@ -241,27 +241,42 @@ export const TEST_CRYPTO_VALUES = { TEST_SHA256_HASH: "vdluSPGh34Y-nFDCbX7CudVKZIXRG1rquljNBbn7xuE", }; +export const mockAccountInfo: AccountInfo = { + homeAccountId: TEST_DATA_CLIENT_INFO.TEST_DECODED_HOME_ACCOUNT_ID, + environment: TEST_CONSTANTS.PREFERRED_CACHE, + localAccountId: ID_TOKEN_CLAIMS.oid, + tenantId: ID_TOKEN_CLAIMS.tid, + username: ID_TOKEN_CLAIMS.preferred_username, + idTokenClaims: ID_TOKEN_CLAIMS, + name: ID_TOKEN_CLAIMS.name, + nativeAccountId: undefined +}; + +export const mockNativeAccountInfo: AccountInfo = { + ...mockAccountInfo, + nativeAccountId: "test-nativeAccountId" +} + export const mockAuthenticationResult: AuthenticationResult = { authority: TEST_CONSTANTS.DEFAULT_AUTHORITY, uniqueId: TEST_DATA_CLIENT_INFO.TEST_UID, tenantId: TEST_DATA_CLIENT_INFO.TEST_UTID, scopes: TEST_CONSTANTS.DEFAULT_GRAPH_SCOPE, - account: { - homeAccountId: TEST_DATA_CLIENT_INFO.TEST_DECODED_HOME_ACCOUNT_ID, - environment: TEST_CONSTANTS.PREFERRED_CACHE, - localAccountId: TEST_DATA_CLIENT_INFO.TEST_LOCAL_ACCOUNT_ID, - tenantId: TEST_DATA_CLIENT_INFO.TEST_UTID, - username: ID_TOKEN_CLAIMS.preferred_username, - }, + account: mockAccountInfo, idToken: TEST_CONSTANTS.ID_TOKEN, idTokenClaims: ID_TOKEN_CLAIMS, accessToken: TEST_CONSTANTS.ACCESS_TOKEN, fromCache: false, expiresOn: new Date(), tokenType: "BEARER", - correlationId: "test-correlationId", + correlationId: "test-correlationId" }; +export const mockNativeAuthenticationResult: AuthenticationResult = { + ...mockAuthenticationResult, + account: mockNativeAccountInfo +} + export type MockedMetadataResponse = { tenant_discovery_endpoint: string; token_endpoint: string;