@@ -1321,4 +1321,44 @@ describe('AuthorizeHandler integration', function() {
13211321 response . get ( 'location' ) . should . equal ( 'http://example.com/cb?state=foobar' ) ;
13221322 } ) ;
13231323 } ) ;
1324+
1325+ describe ( 'getCodeChallengeMethod()' , function ( ) {
1326+ it ( 'should get code challenge method' , function ( ) {
1327+ const model = {
1328+ getAccessToken : function ( ) { } ,
1329+ getClient : function ( ) { } ,
1330+ saveAuthorizationCode : function ( ) { }
1331+ } ;
1332+ const handler = new AuthorizeHandler ( { authorizationCodeLifetime : 120 , model : model } ) ; const request = new Request ( { body : { code_challenge_method : 'S256' } , headers : { } , method : { } , query : { } } ) ;
1333+
1334+ const codeChallengeMethod = handler . getCodeChallengeMethod ( request ) ;
1335+ codeChallengeMethod . should . equal ( 'S256' ) ;
1336+ } ) ;
1337+
1338+ it ( 'should get default code challenge method plain if missing' , function ( ) {
1339+ const model = {
1340+ getAccessToken : function ( ) { } ,
1341+ getClient : function ( ) { } ,
1342+ saveAuthorizationCode : function ( ) { }
1343+ } ;
1344+ const handler = new AuthorizeHandler ( { authorizationCodeLifetime : 120 , model : model } ) ; const request = new Request ( { body : { } , headers : { } , method : { } , query : { } } ) ;
1345+
1346+ const codeChallengeMethod = handler . getCodeChallengeMethod ( request ) ;
1347+ codeChallengeMethod . should . equal ( 'plain' ) ;
1348+ } ) ;
1349+ } ) ;
1350+
1351+ describe ( 'getCodeChallenge()' , function ( ) {
1352+ it ( 'should get code challenge' , function ( ) {
1353+ const model = {
1354+ getAccessToken : function ( ) { } ,
1355+ getClient : function ( ) { } ,
1356+ saveAuthorizationCode : function ( ) { }
1357+ } ;
1358+ const handler = new AuthorizeHandler ( { authorizationCodeLifetime : 120 , model : model } ) ; const request = new Request ( { body : { code_challenge : 'challenge' } , headers : { } , method : { } , query : { } } ) ;
1359+
1360+ const codeChallengeMethod = handler . getCodeChallenge ( request ) ;
1361+ codeChallengeMethod . should . equal ( 'challenge' ) ;
1362+ } ) ;
1363+ } ) ;
13241364} ) ;
0 commit comments