Skip to content
This repository was archived by the owner on May 3, 2024. It is now read-only.

Commit 9072091

Browse files
committed
fix failing tests
1 parent 0502405 commit 9072091

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import { PublicClientApplication } from "@azure/msal-browser";
2+
3+
describe('Sanitize configuration object', () => {
4+
beforeAll(() => {
5+
global.msalConfig = require('./authConfig.js').msalConfig;
6+
});
7+
8+
it('should define the config object', () => {
9+
expect(msalConfig).toBeDefined();
10+
});
11+
12+
it('should not contain credentials', () => {
13+
const regexGuid = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
14+
expect(regexGuid.test(msalConfig.auth.clientId)).toBe(false);
15+
});
16+
17+
it('should contain authority uri', () => {
18+
const regexUri = /[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)?/gi;
19+
expect(regexUri.test(msalConfig.auth.authority)).toBe(true);
20+
});
21+
22+
it('should not contain tenant id', () => {
23+
const regexGuid = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
24+
expect(regexGuid.test(msalConfig.auth.authority.split(".com/")[1])).toBe(false);
25+
});
26+
27+
it('should define a redirect uri', () => {
28+
expect(msalConfig.auth.redirectUri).toBeDefined();
29+
});
30+
});
31+
32+
describe('Ensure that the msal instantiates', () => {
33+
beforeAll(() => {
34+
global.crypto = require('crypto');
35+
global.msalConfig = require('./authConfig.js').msalConfig;
36+
});
37+
38+
it('should instantiate msal', () => {
39+
const msalInstance = new PublicClientApplication(msalConfig);
40+
41+
expect(msalInstance).toBeDefined();
42+
expect(msalInstance).toBeInstanceOf(PublicClientApplication);
43+
});
44+
});

0 commit comments

Comments
 (0)