@@ -1397,6 +1397,43 @@ describe('UrlService Tests', () => {
13971397 ) ;
13981398 } ) ;
13991399 } ) ) ;
1400+
1401+ it ( 'omits code_challenge and code_challenge_method when disablePkce is true' , waitForAsync ( ( ) => {
1402+ const config = {
1403+ clientId : 'testClientId' ,
1404+ responseType : 'testResponseType' ,
1405+ scope : 'testScope' ,
1406+ hdParam : undefined ,
1407+ customParamsAuthRequest : undefined ,
1408+ redirectUrl : 'testRedirectUrl' ,
1409+ disablePkce : true ,
1410+ } ;
1411+
1412+ spyOn (
1413+ flowsDataService ,
1414+ 'getExistingOrCreateAuthStateControl'
1415+ ) . and . returnValue ( 'testState' ) ;
1416+ spyOn ( flowsDataService , 'createNonce' ) . and . returnValue ( 'testNonce' ) ;
1417+ const createCodeVerifierSpy = spyOn (
1418+ flowsDataService ,
1419+ 'createCodeVerifier'
1420+ ) . and . returnValue ( 'testCodeVerifier' ) ;
1421+ const generateCodeChallengeSpy = spyOn (
1422+ jwtWindowCryptoService ,
1423+ 'generateCodeChallenge'
1424+ ) . and . returnValue ( of ( 'testCodeChallenge' ) ) ;
1425+ const resultObs$ = service . createBodyForParCodeFlowRequest ( config ) ;
1426+
1427+ resultObs$ . subscribe ( ( result ) => {
1428+ expect ( result ) . toBe (
1429+ `client_id=testClientId&redirect_uri=testRedirectUrl&response_type=testResponseType&scope=testScope&nonce=testNonce&state=testState`
1430+ ) ;
1431+ expect ( result ) . not . toContain ( 'code_challenge' ) ;
1432+ expect ( result ) . not . toContain ( 'code_challenge_method' ) ;
1433+ expect ( createCodeVerifierSpy ) . not . toHaveBeenCalled ( ) ;
1434+ expect ( generateCodeChallengeSpy ) . not . toHaveBeenCalled ( ) ;
1435+ } ) ;
1436+ } ) ) ;
14001437 } ) ;
14011438
14021439 describe ( 'createUrlImplicitFlowWithSilentRenew' , ( ) => {
0 commit comments