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 - 9 a - f ] { 8 } - [ 0 - 9 a - f ] { 4 } - [ 1 - 5 ] [ 0 - 9 a - f ] { 3 } - [ 8 9 a b ] [ 0 - 9 a - f ] { 3 } - [ 0 - 9 a - f ] { 12 } $ / i;
14
+ expect ( regexGuid . test ( msalConfig . auth . clientId ) ) . toBe ( false ) ;
15
+ } ) ;
16
+
17
+ it ( 'should contain authority uri' , ( ) => {
18
+ const regexUri = / [ - a - z A - Z 0 - 9 @ : % . _ \+ ~ # = ] { 1 , 256 } \. [ a - z A - Z 0 - 9 ( ) ] { 1 , 6 } \b ( [ - a - z A - Z 0 - 9 ( ) @ : % _ \+ . ~ # ? & / / = ] * ) ? / gi;
19
+ expect ( regexUri . test ( msalConfig . auth . authority ) ) . toBe ( true ) ;
20
+ } ) ;
21
+
22
+ it ( 'should not contain tenant id' , ( ) => {
23
+ const regexGuid = / ^ [ 0 - 9 a - f ] { 8 } - [ 0 - 9 a - f ] { 4 } - [ 1 - 5 ] [ 0 - 9 a - f ] { 3 } - [ 8 9 a b ] [ 0 - 9 a - f ] { 3 } - [ 0 - 9 a - 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