@@ -15,10 +15,10 @@ beforeEach(() => {
15
15
} ;
16
16
17
17
scimHandler = new ScimHandler (
18
- function ( ) { return " https://test-host.auth0.com" } ,
18
+ function ( ) { return ' https://test-host.auth0.com' ; } ,
19
19
{
20
20
getAccessToken : async function ( ) {
21
- return 'mock_access_token'
21
+ return 'mock_access_token' ;
22
22
}
23
23
} ,
24
24
connectionsManagerMock
@@ -29,11 +29,13 @@ describe('ScimHandler', () => {
29
29
describe ( '#isScimStrategy' , ( ) => {
30
30
it ( 'should return true for SCIM strategy' , ( ) => {
31
31
const response = scimHandler . isScimStrategy ( 'samlp' ) ;
32
+ // eslint-disable-next-line no-unused-expressions
32
33
expect ( response ) . to . be . true ;
33
34
} ) ;
34
35
35
36
it ( 'should return false for non-SCIM strategy' , ( ) => {
36
37
const response = scimHandler . isScimStrategy ( 'oauth' ) ;
38
+ // eslint-disable-next-line no-unused-expressions
37
39
expect ( response ) . to . be . false ;
38
40
} ) ;
39
41
} ) ;
@@ -51,9 +53,13 @@ describe('ScimHandler', () => {
51
53
getScimConfigurationStub . withArgs ( { id : 'con_d3tmuoAkaUQgxN1f' } ) . rejects ( { response : { data : { statusCode : 404 } } } ) ;
52
54
53
55
await scimHandler . createIdMap ( connections ) ;
54
-
56
+ // eslint-disable-next-line no-unused-expressions
55
57
expect ( scimHandler . idMap . get ( 'con_KYp633cmKtnEQ31C' ) ) . to . deep . equal ( { strategy : 'samlp' , hasConfig : true } ) ;
58
+
59
+ // eslint-disable-next-line no-unused-expressions
56
60
expect ( scimHandler . idMap . get ( 'con_Njd1bxE3QTqTRwAk' ) ) . to . be . undefined ; // Because, it's a Non-SCIM connection.
61
+
62
+ // eslint-disable-next-line no-unused-expressions
57
63
expect ( scimHandler . idMap . get ( 'con_d3tmuoAkaUQgxN1f' ) ) . to . be . undefined ;
58
64
59
65
getScimConfigurationStub . restore ( ) ;
@@ -74,8 +80,13 @@ describe('ScimHandler', () => {
74
80
75
81
await scimHandler . applyScimConfiguration ( connections ) ;
76
82
83
+ // eslint-disable-next-line no-unused-expressions
77
84
expect ( connections [ 0 ] . scim_configuration ) . to . deep . equal ( { user_id_attribute : 'externalId-1' , mapping : [ { auth0 : 'auth0_key' , scim : 'scim_key' } ] } ) ;
85
+
86
+ // eslint-disable-next-line no-unused-expressions
78
87
expect ( connections [ 1 ] . scim_configuration ) . to . deep . equal ( { user_id_attribute : 'externalId-2' , mapping : [ { auth0 : 'auth0_key' , scim : 'scim_key' } ] } ) ;
88
+
89
+ // eslint-disable-next-line no-unused-expressions
79
90
expect ( connections [ 2 ] . scim_configuration ) . to . be . undefined ;
80
91
81
92
getScimConfigurationStub . restore ( ) ;
@@ -85,14 +96,16 @@ describe('ScimHandler', () => {
85
96
describe ( '#scimHttpRequest' , ( ) => {
86
97
it ( 'should make HTTP request with correct authorization header' , async ( ) => {
87
98
const accessToken = 'mock_access_token' ;
88
- const tokenProviderMock = {
89
- getAccessToken : sinon . stub ( ) . resolves ( accessToken )
90
- } ;
91
99
const axiosStub = sinon . stub ( axios , 'get' ) . resolves ( { data : { } } ) ;
92
100
const response = await scimHandler . scimHttpRequest ( 'get' , [ 'https://mock-domain/api/v2/connections/1/scim-configuration' ] ) ;
93
-
101
+
102
+ // eslint-disable-next-line no-unused-expressions
94
103
expect ( response ) . to . exist ;
104
+
105
+ // eslint-disable-next-line no-unused-expressions
95
106
expect ( axiosStub . calledOnce ) . to . be . true ;
107
+
108
+ // eslint-disable-next-line no-unused-expressions
96
109
expect ( axiosStub . firstCall . args [ 1 ] . headers . Authorization ) . to . equal ( `Bearer ${ accessToken } ` ) ;
97
110
98
111
axiosStub . restore ( ) ;
@@ -101,20 +114,20 @@ describe('ScimHandler', () => {
101
114
102
115
describe ( '#getScimConfiguration' , ( ) => {
103
116
it ( 'should return SCIM configuration for existing connection' , async ( ) => {
104
- const requestParams = { id : 'con_KYp633cmKtnEQ31C' }
117
+ const requestParams = { id : 'con_KYp633cmKtnEQ31C' } ;
105
118
const scimConfiguration = {
106
119
connection_id : 'con_KYp633cmKtnEQ31C' ,
107
120
connection_name : 'okta' ,
108
121
strategy : 'okta' ,
109
122
tenant_name : 'test-tenant' ,
110
- user_id_attribute : " externalId-1" ,
123
+ user_id_attribute : ' externalId-1' ,
111
124
mapping : [
112
125
{
113
- scim : " scim_id" ,
114
- auth0 : " auth0_id"
126
+ scim : ' scim_id' ,
127
+ auth0 : ' auth0_id'
115
128
}
116
129
]
117
- }
130
+ } ;
118
131
119
132
const axiosStub = sinon . stub ( axios , 'get' ) . resolves ( { data : scimConfiguration , status : 201 } ) ;
120
133
const response = await scimHandler . getScimConfiguration ( requestParams ) ;
@@ -160,7 +173,7 @@ describe('ScimHandler', () => {
160
173
...payload ,
161
174
created_at : new Date ( ) . getTime ( ) ,
162
175
updated_on : new Date ( ) . getTime ( )
163
- }
176
+ } ;
164
177
165
178
it ( 'should create new SCIM configuration' , async ( ) => {
166
179
const axiosStub = sinon . stub ( axios , 'post' ) . resolves ( { data : responseBody , status : 201 } ) ;
@@ -197,7 +210,7 @@ describe('ScimHandler', () => {
197
210
...payload ,
198
211
created_at : new Date ( ) . getTime ( ) ,
199
212
updated_on : new Date ( ) . getTime ( )
200
- }
213
+ } ;
201
214
const axiosStub = sinon . stub ( axios , 'patch' ) . resolves ( { data : responseBody , status : 200 } ) ;
202
215
const response = await scimHandler . updateScimConfiguration ( requestParams , payload ) ;
203
216
@@ -214,15 +227,16 @@ describe('ScimHandler', () => {
214
227
const requestParams = {
215
228
id : 'con_PKp644cmKtnEB11J'
216
229
} ;
217
- const axiosStub = sinon . stub ( axios , 'delete' ) . resolves ( { status : 204 } ) ;
230
+ const axiosStub = sinon . stub ( axios , 'delete' ) . resolves ( { data : { } , status : 204 } ) ;
218
231
const response = await scimHandler . deleteScimConfiguration ( requestParams ) ;
232
+ expect ( response ) . to . deep . equal ( { } ) ;
219
233
220
234
axiosStub . restore ( ) ;
221
235
} ) ;
222
236
} ) ;
223
237
224
238
describe ( '#updateOverride' , ( ) => {
225
- it ( 'should " update" connection and " update" SCIM configuration' , async ( ) => {
239
+ it ( 'should \' update\' connection and \' update\' SCIM configuration' , async ( ) => {
226
240
const requestParams = { id : 'con_PKp644cmKtnEB11J' } ;
227
241
const bodyParams = {
228
242
id : 'con_PKp644cmKtnEB11J' ,
@@ -245,17 +259,19 @@ describe('ScimHandler', () => {
245
259
idMapMock . set ( requestParams . id , idMapEntry ) ;
246
260
scimHandler . idMap = idMapMock ;
247
261
248
-
249
262
const updateScimStub = sinon . stub ( scimHandler , 'updateScimConfiguration' ) . resolves ( { data : { } } ) ;
250
263
const response = await scimHandler . updateOverride ( requestParams , bodyParams ) ;
251
264
265
+ // eslint-disable-next-line no-unused-expressions
252
266
expect ( response ) . to . deep . equal ( connectionUpdatePayload ) ;
267
+
268
+ // eslint-disable-next-line no-unused-expressions
253
269
expect ( updateScimStub . calledOnceWith ( requestParams , scimConfiguration ) ) . to . be . true ;
254
270
255
271
updateScimStub . restore ( ) ;
256
272
} ) ;
257
273
258
- it ( 'should " update" connection and " create" SCIM configuration' , async ( ) => {
274
+ it ( 'should \' update\' connection and \' create\' SCIM configuration' , async ( ) => {
259
275
const requestParams = { id : 'con_PKp644cmKtnEB11J' } ;
260
276
const bodyParams = {
261
277
id : 'con_PKp644cmKtnEB11J' ,
@@ -281,13 +297,16 @@ describe('ScimHandler', () => {
281
297
const createScimStub = sinon . stub ( scimHandler , 'createScimConfiguration' ) . resolves ( { data : { } } ) ;
282
298
const response = await scimHandler . updateOverride ( requestParams , bodyParams ) ;
283
299
300
+ // eslint-disable-next-line no-unused-expressions
284
301
expect ( response ) . to . deep . equal ( connectionUpdatePayload ) ;
302
+
303
+ // eslint-disable-next-line no-unused-expressions
285
304
expect ( createScimStub . calledOnceWith ( requestParams , scimConfiguration ) ) . to . be . true ;
286
305
287
306
createScimStub . restore ( ) ;
288
307
} ) ;
289
308
290
- it ( 'should " update" connection and " delete" SCIM configuration' , async ( ) => {
309
+ it ( 'should \' update\' connection and \' delete\' SCIM configuration' , async ( ) => {
291
310
const requestParams = { id : 'con_PKp644cmKtnEB11J' } ;
292
311
const bodyParams = {
293
312
id : 'con_PKp644cmKtnEB11J' ,
@@ -309,15 +328,18 @@ describe('ScimHandler', () => {
309
328
const deleteScimStub = sinon . stub ( scimHandler , 'deleteScimConfiguration' ) . resolves ( { data : { } } ) ;
310
329
const response = await scimHandler . updateOverride ( requestParams , bodyParams ) ;
311
330
331
+ // eslint-disable-next-line no-unused-expressions
312
332
expect ( response ) . to . deep . equal ( connectionUpdatePayload ) ;
333
+
334
+ // eslint-disable-next-line no-unused-expressions
313
335
expect ( deleteScimStub . calledOnceWith ( requestParams ) ) . to . be . true ;
314
336
315
337
deleteScimStub . restore ( ) ;
316
338
} ) ;
317
339
} ) ;
318
340
319
341
describe ( '#createOverride' , ( ) => {
320
- it ( 'should " create" connection and " create" SCIM configuration' , async ( ) => {
342
+ it ( 'should \' create\' connection and \' create\' SCIM configuration' , async ( ) => {
321
343
const requestParams = { id : 'con_PKp644cmKtnEB11J' } ;
322
344
const bodyParams = {
323
345
id : 'con_PKp644cmKtnEB11J' ,
@@ -343,13 +365,16 @@ describe('ScimHandler', () => {
343
365
const createScimStub = sinon . stub ( scimHandler , 'createScimConfiguration' ) . resolves ( { data : { } } ) ;
344
366
const response = await scimHandler . createOverride ( bodyParams ) ;
345
367
368
+ // eslint-disable-next-line no-unused-expressions
346
369
expect ( response ) . to . deep . equal ( connectionCreatePayload ) ;
370
+
371
+ // eslint-disable-next-line no-unused-expressions
347
372
expect ( createScimStub . calledOnceWith ( requestParams , scimConfiguration ) ) . to . be . true ;
348
373
349
374
createScimStub . restore ( ) ;
350
375
} ) ;
351
376
352
- it ( 'should " create" connection without SCIM configuration' , async ( ) => {
377
+ it ( 'should \' create\' connection without SCIM configuration' , async ( ) => {
353
378
const requestParams = { id : 'con_PKp644cmKtnEB11J' } ;
354
379
const bodyParams = {
355
380
id : 'con_PKp644cmKtnEB11J' ,
@@ -367,11 +392,13 @@ describe('ScimHandler', () => {
367
392
idMapMock . set ( requestParams . id , idMapEntry ) ;
368
393
scimHandler . idMap = idMapMock ;
369
394
370
-
371
395
const createScimStub = sinon . stub ( scimHandler , 'createScimConfiguration' ) . resolves ( { data : { } } ) ;
372
396
const response = await scimHandler . createOverride ( requestParams , bodyParams ) ;
373
397
398
+ // eslint-disable-next-line no-unused-expressions
374
399
expect ( response ) . to . deep . equal ( connectionUpdatePayload ) ;
400
+
401
+ // eslint-disable-next-line no-unused-expressions
375
402
expect ( createScimStub . calledOnce ) . to . be . false ;
376
403
377
404
createScimStub . restore ( ) ;
0 commit comments