File tree Expand file tree Collapse file tree 1 file changed +69
-0
lines changed Expand file tree Collapse file tree 1 file changed +69
-0
lines changed Original file line number Diff line number Diff line change @@ -2957,3 +2957,72 @@ describe('findCommonSubpath method', function () {
2957
2957
} ) ;
2958
2958
2959
2959
} ) ;
2960
+
2961
+ describe ( 'getAuthHelper method - OAuth2 Flows' , function ( ) {
2962
+ it ( 'Should parse OAuth2 configuration to collection' , function ( ) {
2963
+ const openAPISpec = {
2964
+ 'components' : {
2965
+ 'responses' : { } ,
2966
+ 'schemas' : { } ,
2967
+ 'securitySchemes' : {
2968
+ 'oauth2' : {
2969
+ 'flows' : {
2970
+ 'clientCredentials' : {
2971
+ 'scopes' : { } ,
2972
+ 'tokenUrl' : 'https://example.com/oauth2/token'
2973
+ }
2974
+ } ,
2975
+ 'type' : 'oauth2'
2976
+ }
2977
+ }
2978
+ } ,
2979
+ 'info' : {
2980
+ 'title' : 'API' ,
2981
+ 'version' : '0.2'
2982
+ } ,
2983
+ 'openapi' : '3.0.0' ,
2984
+ 'paths' : { } ,
2985
+ 'security' : [
2986
+ {
2987
+ 'oauth2' : [ ]
2988
+ }
2989
+ ] ,
2990
+ 'servers' : [
2991
+ {
2992
+ 'url' : 'https://example.com' ,
2993
+ 'variables' : { }
2994
+ }
2995
+ ] ,
2996
+ 'tags' : [ ] ,
2997
+ 'securityDefs' : {
2998
+ 'oauth2' : {
2999
+ 'flows' : {
3000
+ 'clientCredentials' : {
3001
+ 'scopes' : { } ,
3002
+ 'tokenUrl' : 'https://example.com/oauth2/token'
3003
+ }
3004
+ } ,
3005
+ 'type' : 'oauth2'
3006
+ }
3007
+ } ,
3008
+ 'baseUrl' : 'https://example.com' ,
3009
+ 'baseUrlVariables' : { }
3010
+ } ,
3011
+ securitySet = [ { oauth2 : [ ] } ] ,
3012
+ helperData = SchemaUtils . getAuthHelper ( openAPISpec , securitySet ) ;
3013
+
3014
+ expect ( helperData . type ) . to . be . equal ( 'oauth2' ) ;
3015
+ expect ( helperData ) . to . have . property ( 'oauth2' ) . with . lengthOf ( 2 ) ;
3016
+ expect ( helperData . oauth2 [ 0 ] ) . to . be . an ( 'object' ) ;
3017
+ expect ( helperData ) . to . deep . equal ( {
3018
+ type : 'oauth2' ,
3019
+ oauth2 : [
3020
+ {
3021
+ key : 'accessTokenUrl' ,
3022
+ value : 'https://example.com/oauth2/token'
3023
+ } ,
3024
+ { key : 'grant_type' , value : 'client_credentials' }
3025
+ ]
3026
+ } ) ;
3027
+ } ) ;
3028
+ } ) ;
You can’t perform that action at this time.
0 commit comments