|
1 | 1 | import * as Mocha from "mocha";
|
2 | 2 | import chai from "chai";
|
3 | 3 | import chaiAsPromised from "chai-as-promised";
|
| 4 | + |
4 | 5 | chai.use(chaiAsPromised);
|
5 | 6 | const expect = chai.expect;
|
6 | 7 | import { PublicClientApplication } from "../../src/app/PublicClientApplication";
|
7 |
| -import { TEST_CONFIG, TEST_URIS, TEST_HASHES, TEST_TOKENS, TEST_DATA_CLIENT_INFO, TEST_TOKEN_LIFETIMES, RANDOM_TEST_GUID, DEFAULT_OPENID_CONFIG_RESPONSE, testNavUrl, testLogoutUrl } from "../utils/StringConstants"; |
8 |
| -import { AuthError, ServerError, AuthResponse, LogLevel, Constants, TemporaryCacheKeys, TokenResponse, Account, TokenExchangeParameters, IdTokenClaims, SPAClient, PromptValue, AuthenticationParameters } from "@azure/msal-common"; |
| 8 | +import { |
| 9 | + TEST_CONFIG, |
| 10 | + TEST_URIS, |
| 11 | + TEST_HASHES, |
| 12 | + TEST_TOKENS, |
| 13 | + TEST_DATA_CLIENT_INFO, |
| 14 | + TEST_TOKEN_LIFETIMES, |
| 15 | + RANDOM_TEST_GUID, |
| 16 | + DEFAULT_OPENID_CONFIG_RESPONSE, |
| 17 | + testNavUrl, |
| 18 | + testLogoutUrl |
| 19 | +} from "../utils/StringConstants"; |
| 20 | +import { |
| 21 | + AuthError, |
| 22 | + ServerError, |
| 23 | + AuthResponse, |
| 24 | + LogLevel, |
| 25 | + Constants, |
| 26 | + TemporaryCacheKeys, |
| 27 | + TokenResponse, |
| 28 | + Account, |
| 29 | + TokenExchangeParameters, |
| 30 | + IdTokenClaims, |
| 31 | + SPAClient, |
| 32 | + PromptValue, |
| 33 | + AuthenticationParameters, ClientAuthError, ClientAuthErrorMessage |
| 34 | +} from "@azure/msal-common"; |
9 | 35 | import { AuthCallback } from "../../src/types/AuthCallback";
|
10 |
| -import { BrowserConfigurationAuthErrorMessage, BrowserConfigurationAuthError } from "../../src/error/BrowserConfigurationAuthError"; |
| 36 | +import { |
| 37 | + BrowserConfigurationAuthErrorMessage, |
| 38 | + BrowserConfigurationAuthError |
| 39 | +} from "../../src/error/BrowserConfigurationAuthError"; |
11 | 40 | import sinon from "sinon";
|
12 | 41 | import { BrowserUtils } from "../../src/utils/BrowserUtils";
|
13 | 42 | import { BrowserConstants } from "../../src/utils/BrowserConstants";
|
@@ -74,6 +103,20 @@ describe("PublicClientApplication.ts Class Unit Tests", () => {
|
74 | 103 | });
|
75 | 104 | expect(window.sessionStorage.getItem(`${Constants.CACHE_PREFIX}.${TEST_CONFIG.MSAL_CLIENT_ID}.${TemporaryCacheKeys.URL_HASH}`)).to.be.eq(TEST_HASHES.TEST_SUCCESS_CODE_HASH);
|
76 | 105 | });
|
| 106 | + |
| 107 | + it("ADFS authority throws error", () => { |
| 108 | + |
| 109 | + expect(() =>{ |
| 110 | + new PublicClientApplication({ |
| 111 | + auth: { |
| 112 | + clientId: TEST_CONFIG.MSAL_CLIENT_ID, |
| 113 | + authority: TEST_CONFIG.ADFS_AUTHORITY |
| 114 | + } |
| 115 | + }); |
| 116 | + |
| 117 | + }).to.throw(ClientAuthErrorMessage.invalidAuthorityType.desc); |
| 118 | + |
| 119 | + }); |
77 | 120 | });
|
78 | 121 |
|
79 | 122 | describe("Redirect Flow Unit tests", () => {
|
@@ -110,7 +153,7 @@ describe("PublicClientApplication.ts Class Unit Tests", () => {
|
110 | 153 | const testServerTokenResponse = {
|
111 | 154 | headers: null,
|
112 | 155 | status: 200,
|
113 |
| - body : { |
| 156 | + body: { |
114 | 157 | token_type: TEST_CONFIG.TOKEN_TYPE_BEARER,
|
115 | 158 | scope: TEST_CONFIG.DEFAULT_SCOPES.join(" "),
|
116 | 159 | expires_in: TEST_TOKEN_LIFETIMES.DEFAULT_EXPIRES_IN,
|
@@ -213,7 +256,7 @@ describe("PublicClientApplication.ts Class Unit Tests", () => {
|
213 | 256 | const testServerTokenResponse = {
|
214 | 257 | headers: null,
|
215 | 258 | status: 200,
|
216 |
| - body : { |
| 259 | + body: { |
217 | 260 | token_type: TEST_CONFIG.TOKEN_TYPE_BEARER,
|
218 | 261 | scope: TEST_CONFIG.DEFAULT_SCOPES.join(" "),
|
219 | 262 | expires_in: TEST_TOKEN_LIFETIMES.DEFAULT_EXPIRES_IN,
|
@@ -561,7 +604,7 @@ describe("PublicClientApplication.ts Class Unit Tests", () => {
|
561 | 604 | refreshToken: testServerTokenResponse.refresh_token,
|
562 | 605 | expiresOn: new Date(Date.now() + (testServerTokenResponse.expires_in * 1000)),
|
563 | 606 | account: testAccount,
|
564 |
| - userRequestState: "" |
| 607 | + userRequestState: "" |
565 | 608 | };
|
566 | 609 | sinon.stub(SPAClient.prototype, "createLoginUrl").resolves(testNavUrl);
|
567 | 610 | const loadFrameSyncSpy = sinon.spy(SilentHandler.prototype, <any>"loadFrameSync");
|
@@ -666,7 +709,7 @@ describe("PublicClientApplication.ts Class Unit Tests", () => {
|
666 | 709 | refreshToken: testServerTokenResponse.refresh_token,
|
667 | 710 | expiresOn: new Date(Date.now() + (testServerTokenResponse.expires_in * 1000)),
|
668 | 711 | account: testAccount,
|
669 |
| - userRequestState: "" |
| 712 | + userRequestState: "" |
670 | 713 | };
|
671 | 714 | const createAcqTokenStub = sinon.stub(SPAClient.prototype, "createAcquireTokenUrl").resolves(testNavUrl);
|
672 | 715 | const silentTokenHelperStub = sinon.stub(pca, <any>"silentTokenHelper").resolves(testTokenResponse);
|
|
0 commit comments