@@ -230,6 +230,218 @@ describe("RequestParameterBuilder unit tests", () => {
230
230
) . toBe ( true ) ;
231
231
} ) ;
232
232
233
+ it ( "Doesn't encode extra params if encodeParams is false and extra params are passed in" , ( ) => {
234
+ const parameters = new Map < string , string > ( ) ;
235
+ RequestParameterBuilder . addResponseType (
236
+ parameters ,
237
+ OAuthResponseType . CODE
238
+ ) ;
239
+ RequestParameterBuilder . addResponseMode (
240
+ parameters ,
241
+ ResponseMode . FORM_POST
242
+ ) ;
243
+ RequestParameterBuilder . addScopes (
244
+ parameters ,
245
+ TEST_CONFIG . DEFAULT_SCOPES
246
+ ) ;
247
+ RequestParameterBuilder . addClientId (
248
+ parameters ,
249
+ TEST_CONFIG . MSAL_CLIENT_ID
250
+ ) ;
251
+ RequestParameterBuilder . addRedirectUri (
252
+ parameters ,
253
+ TEST_URIS . TEST_REDIRECT_URI_LOCALHOST
254
+ ) ;
255
+ RequestParameterBuilder . addDomainHint (
256
+ parameters ,
257
+ TEST_CONFIG . DOMAIN_HINT
258
+ ) ;
259
+ RequestParameterBuilder . addLoginHint (
260
+ parameters ,
261
+ TEST_CONFIG . LOGIN_HINT
262
+ ) ;
263
+ RequestParameterBuilder . addClaims ( parameters , TEST_CONFIG . CLAIMS , [ ] ) ;
264
+ RequestParameterBuilder . addCorrelationId (
265
+ parameters ,
266
+ TEST_CONFIG . CORRELATION_ID
267
+ ) ;
268
+ RequestParameterBuilder . addPrompt (
269
+ parameters ,
270
+ PromptValue . SELECT_ACCOUNT
271
+ ) ;
272
+ RequestParameterBuilder . addState ( parameters , TEST_CONFIG . STATE ) ;
273
+ RequestParameterBuilder . addNonce ( parameters , TEST_CONFIG . NONCE ) ;
274
+ RequestParameterBuilder . addCodeChallengeParams (
275
+ parameters ,
276
+ TEST_CONFIG . TEST_CHALLENGE ,
277
+ TEST_CONFIG . CODE_CHALLENGE_METHOD
278
+ ) ;
279
+ RequestParameterBuilder . addAuthorizationCode (
280
+ parameters ,
281
+ TEST_TOKENS . AUTHORIZATION_CODE
282
+ ) ;
283
+ RequestParameterBuilder . addDeviceCode (
284
+ parameters ,
285
+ DEVICE_CODE_RESPONSE . deviceCode
286
+ ) ;
287
+ RequestParameterBuilder . addCodeVerifier (
288
+ parameters ,
289
+ TEST_CONFIG . TEST_VERIFIER
290
+ ) ;
291
+ RequestParameterBuilder . addGrantType (
292
+ parameters ,
293
+ GrantType . DEVICE_CODE_GRANT
294
+ ) ;
295
+ RequestParameterBuilder . addSid ( parameters , TEST_CONFIG . SID ) ;
296
+ RequestParameterBuilder . addLogoutHint (
297
+ parameters ,
298
+ TEST_CONFIG . LOGIN_HINT
299
+ ) ;
300
+ RequestParameterBuilder . addExtraQueryParameters ( parameters , {
301
+ extra_params : "param1,param2" ,
302
+ } ) ;
303
+
304
+ const requestQueryString = UrlUtils . mapToQueryString (
305
+ parameters ,
306
+ false ,
307
+ {
308
+ extra_params : "param1,param2" ,
309
+ }
310
+ ) ;
311
+ console . log ( requestQueryString ) ;
312
+ console . log (
313
+ `${ AADServerParamKeys . REDIRECT_URI } =${ TEST_URIS . TEST_REDIRECT_URI_LOCALHOST } `
314
+ ) ;
315
+ expect (
316
+ requestQueryString . includes (
317
+ `${ AADServerParamKeys . RESPONSE_TYPE } =${ OAuthResponseType . CODE } `
318
+ )
319
+ ) . toBe ( true ) ;
320
+ expect (
321
+ requestQueryString . includes (
322
+ `${ AADServerParamKeys . RESPONSE_MODE } =${ encodeURIComponent (
323
+ ResponseMode . FORM_POST
324
+ ) } `
325
+ )
326
+ ) . toBe ( true ) ;
327
+ expect (
328
+ requestQueryString . includes (
329
+ `${ AADServerParamKeys . SCOPE } =${ Constants . OPENID_SCOPE } %20${ Constants . PROFILE_SCOPE } %20${ Constants . OFFLINE_ACCESS_SCOPE } `
330
+ )
331
+ ) . toBe ( true ) ;
332
+ expect (
333
+ requestQueryString . includes (
334
+ `${ AADServerParamKeys . CLIENT_ID } =${ TEST_CONFIG . MSAL_CLIENT_ID } `
335
+ )
336
+ ) . toBe ( true ) ;
337
+ expect (
338
+ requestQueryString . includes (
339
+ `${ AADServerParamKeys . REDIRECT_URI } =${ encodeURIComponent (
340
+ TEST_URIS . TEST_REDIRECT_URI_LOCALHOST
341
+ ) } `
342
+ )
343
+ ) . toBe ( true ) ;
344
+ expect (
345
+ requestQueryString . includes (
346
+ `${ AADServerParamKeys . DOMAIN_HINT } =${ encodeURIComponent (
347
+ TEST_CONFIG . DOMAIN_HINT
348
+ ) } `
349
+ )
350
+ ) . toBe ( true ) ;
351
+ expect (
352
+ requestQueryString . includes (
353
+ `${ AADServerParamKeys . LOGIN_HINT } =${ encodeURIComponent (
354
+ TEST_CONFIG . LOGIN_HINT
355
+ ) } `
356
+ )
357
+ ) . toBe ( true ) ;
358
+ expect (
359
+ requestQueryString . includes (
360
+ `${ AADServerParamKeys . CLAIMS } =${ encodeURIComponent (
361
+ TEST_CONFIG . CLAIMS
362
+ ) } `
363
+ )
364
+ ) . toBe ( true ) ;
365
+ expect (
366
+ requestQueryString . includes (
367
+ `${ AADServerParamKeys . CLIENT_REQUEST_ID } =${ encodeURIComponent (
368
+ TEST_CONFIG . CORRELATION_ID
369
+ ) } `
370
+ )
371
+ ) . toBe ( true ) ;
372
+ expect (
373
+ requestQueryString . includes (
374
+ `${ AADServerParamKeys . PROMPT } =${ PromptValue . SELECT_ACCOUNT } `
375
+ )
376
+ ) . toBe ( true ) ;
377
+ expect (
378
+ requestQueryString . includes (
379
+ `${ AADServerParamKeys . STATE } =${ encodeURIComponent (
380
+ TEST_CONFIG . STATE
381
+ ) } `
382
+ )
383
+ ) . toBe ( true ) ;
384
+ expect (
385
+ requestQueryString . includes (
386
+ `${ AADServerParamKeys . NONCE } =${ encodeURIComponent (
387
+ TEST_CONFIG . NONCE
388
+ ) } `
389
+ )
390
+ ) . toBe ( true ) ;
391
+ expect (
392
+ requestQueryString . includes (
393
+ `${ AADServerParamKeys . CODE_CHALLENGE } =${ encodeURIComponent (
394
+ TEST_CONFIG . TEST_CHALLENGE
395
+ ) } `
396
+ )
397
+ ) . toBe ( true ) ;
398
+ expect (
399
+ requestQueryString . includes (
400
+ `${
401
+ AADServerParamKeys . CODE_CHALLENGE_METHOD
402
+ } =${ encodeURIComponent ( TEST_CONFIG . CODE_CHALLENGE_METHOD ) } `
403
+ )
404
+ ) . toBe ( true ) ;
405
+ expect (
406
+ requestQueryString . includes (
407
+ `${ AADServerParamKeys . CODE } =${ encodeURIComponent (
408
+ TEST_TOKENS . AUTHORIZATION_CODE
409
+ ) } `
410
+ )
411
+ ) . toBe ( true ) ;
412
+ expect (
413
+ requestQueryString . includes (
414
+ `${ AADServerParamKeys . DEVICE_CODE } =${ encodeURIComponent (
415
+ DEVICE_CODE_RESPONSE . deviceCode
416
+ ) } `
417
+ )
418
+ ) . toBe ( true ) ;
419
+ expect (
420
+ requestQueryString . includes (
421
+ `${ AADServerParamKeys . CODE_VERIFIER } =${ encodeURIComponent (
422
+ TEST_CONFIG . TEST_VERIFIER
423
+ ) } `
424
+ )
425
+ ) . toBe ( true ) ;
426
+ expect (
427
+ requestQueryString . includes (
428
+ `${ AADServerParamKeys . SID } =${ encodeURIComponent (
429
+ TEST_CONFIG . SID
430
+ ) } `
431
+ )
432
+ ) . toBe ( true ) ;
433
+ expect (
434
+ requestQueryString . includes (
435
+ `${ AADServerParamKeys . LOGOUT_HINT } =${ encodeURIComponent (
436
+ TEST_CONFIG . LOGIN_HINT
437
+ ) } `
438
+ )
439
+ ) . toBe ( true ) ;
440
+ expect ( requestQueryString . includes ( `extra_params=param1,param2` ) ) . toBe (
441
+ true
442
+ ) ;
443
+ } ) ;
444
+
233
445
it ( "Adds token type and req_cnf correctly for proof-of-possession tokens" , ( ) => {
234
446
const parameters = new Map < string , string > ( ) ;
235
447
RequestParameterBuilder . addPopToken (
0 commit comments