@@ -59,7 +59,11 @@ describe('CONVERT FUNCTION TESTS ', function() {
59
59
invalidNullInfo = path . join ( __dirname , INVALID_OPENAPI_PATH , '/invalid-null-info.json' ) ,
60
60
invalidNullInfoTitle = path . join ( __dirname , INVALID_OPENAPI_PATH , '/invalid-info-null-title.json' ) ,
61
61
invalidNullInfoVersion = path . join ( __dirname , INVALID_OPENAPI_PATH , '/invalid-info-null-version.json' ) ,
62
- specWithAuth = path . join ( __dirname , VALID_OPENAPI_PATH + '/specWithAuth.yaml' ) ;
62
+ specWithAuthBearer = path . join ( __dirname , VALID_OPENAPI_PATH + '/specWithAuthBearer.yaml' ) ,
63
+ specWithAuthApiKey = path . join ( __dirname , VALID_OPENAPI_PATH + '/specWithAuthApiKey.yaml' ) ,
64
+ specWithAuthDigest = path . join ( __dirname , VALID_OPENAPI_PATH + '/specWithAuthDigest.yaml' ) ,
65
+ specWithAuthOauth1 = path . join ( __dirname , VALID_OPENAPI_PATH + '/specWithAuthOauth1.yaml' ) ,
66
+ specWithAuthBasic = path . join ( __dirname , VALID_OPENAPI_PATH + '/specWithAuthBasic.yaml' ) ;
63
67
64
68
65
69
it ( 'Should add collection level auth with type as `bearer`' +
@@ -1294,9 +1298,10 @@ describe('CONVERT FUNCTION TESTS ', function() {
1294
1298
} ) ;
1295
1299
1296
1300
describe ( '[Github #643] - Generated value for corresponding' +
1297
- ' authorization should be as environment variable format' , function ( done ) {
1298
- it ( 'Should convert a collection and set auth placeholder as variable' , function ( ) {
1299
- var openapi = fs . readFileSync ( specWithAuth , 'utf8' ) ;
1301
+ ' authorization should be as environment variable format' , function ( ) {
1302
+
1303
+ it ( 'Should convert a collection and set bearer auth placeholder as variable' , function ( done ) {
1304
+ var openapi = fs . readFileSync ( specWithAuthBearer , 'utf8' ) ;
1300
1305
Converter . convert ( { type : 'string' , data : openapi } , { schemaFaker : true } , ( err , conversionResult ) => {
1301
1306
expect ( err ) . to . be . null ;
1302
1307
expect ( conversionResult . result ) . to . equal ( true ) ;
@@ -1309,6 +1314,71 @@ describe('CONVERT FUNCTION TESTS ', function() {
1309
1314
done ( ) ;
1310
1315
} ) ;
1311
1316
} ) ;
1317
+
1318
+ it ( 'Should convert a collection and set basic auth placeholder as variable' , function ( done ) {
1319
+ var openapi = fs . readFileSync ( specWithAuthBasic , 'utf8' ) ;
1320
+ Converter . convert ( { type : 'string' , data : openapi } , { schemaFaker : true } , ( err , conversionResult ) => {
1321
+ expect ( err ) . to . be . null ;
1322
+ expect ( conversionResult . result ) . to . equal ( true ) ;
1323
+ expect ( conversionResult . output . length ) . to . equal ( 1 ) ;
1324
+ expect ( conversionResult . output [ 0 ] . type ) . to . equal ( 'collection' ) ;
1325
+ expect ( conversionResult . output [ 0 ] . data ) . to . have . property ( 'info' ) ;
1326
+ expect ( conversionResult . output [ 0 ] . data ) . to . have . property ( 'item' ) ;
1327
+ expect ( conversionResult . output [ 0 ] . data . item . length ) . to . equal ( 1 ) ;
1328
+ expect ( conversionResult . output [ 0 ] . data . auth . basic [ 0 ] . value ) . to . equal ( '{{basic_auth_username}}' ) ;
1329
+ expect ( conversionResult . output [ 0 ] . data . auth . basic [ 1 ] . value ) . to . equal ( '{{basic_auth_password}}' ) ;
1330
+ done ( ) ;
1331
+ } ) ;
1332
+ } ) ;
1333
+
1334
+ it ( 'Should convert a collection and set digest auth placeholder as variable' , function ( done ) {
1335
+ var openapi = fs . readFileSync ( specWithAuthDigest , 'utf8' ) ;
1336
+ Converter . convert ( { type : 'string' , data : openapi } , { schemaFaker : true } , ( err , conversionResult ) => {
1337
+ expect ( err ) . to . be . null ;
1338
+ expect ( conversionResult . result ) . to . equal ( true ) ;
1339
+ expect ( conversionResult . output . length ) . to . equal ( 1 ) ;
1340
+ expect ( conversionResult . output [ 0 ] . type ) . to . equal ( 'collection' ) ;
1341
+ expect ( conversionResult . output [ 0 ] . data ) . to . have . property ( 'info' ) ;
1342
+ expect ( conversionResult . output [ 0 ] . data ) . to . have . property ( 'item' ) ;
1343
+ expect ( conversionResult . output [ 0 ] . data . item . length ) . to . equal ( 1 ) ;
1344
+ expect ( conversionResult . output [ 0 ] . data . auth . digest [ 0 ] . value ) . to . equal ( '{{digest_auth_username}}' ) ;
1345
+ expect ( conversionResult . output [ 0 ] . data . auth . digest [ 1 ] . value ) . to . equal ( '{{digest_auth_password}}' ) ;
1346
+ expect ( conversionResult . output [ 0 ] . data . auth . digest [ 2 ] . value ) . to . equal ( '{{realm}}' ) ;
1347
+ done ( ) ;
1348
+ } ) ;
1349
+ } ) ;
1350
+
1351
+ it ( 'Should convert a collection and set oauth1 auth placeholder as variable' , function ( done ) {
1352
+ var openapi = fs . readFileSync ( specWithAuthOauth1 , 'utf8' ) ;
1353
+ Converter . convert ( { type : 'string' , data : openapi } , { schemaFaker : true } , ( err , conversionResult ) => {
1354
+ expect ( err ) . to . be . null ;
1355
+ expect ( conversionResult . result ) . to . equal ( true ) ;
1356
+ expect ( conversionResult . output . length ) . to . equal ( 1 ) ;
1357
+ expect ( conversionResult . output [ 0 ] . type ) . to . equal ( 'collection' ) ;
1358
+ expect ( conversionResult . output [ 0 ] . data ) . to . have . property ( 'info' ) ;
1359
+ expect ( conversionResult . output [ 0 ] . data ) . to . have . property ( 'item' ) ;
1360
+ expect ( conversionResult . output [ 0 ] . data . item . length ) . to . equal ( 1 ) ;
1361
+ expect ( conversionResult . output [ 0 ] . data . auth . oauth1 [ 0 ] . value ) . to . equal ( '{{oauth_10_consumer_key}}' ) ;
1362
+ expect ( conversionResult . output [ 0 ] . data . auth . oauth1 [ 1 ] . value ) . to . equal ( '{{oauth_10_consumer_secret}}' ) ;
1363
+ done ( ) ;
1364
+ } ) ;
1365
+ } ) ;
1366
+
1367
+ it ( 'Should convert a collection and set apiKey auth placeholder as variable' , function ( done ) {
1368
+ var openapi = fs . readFileSync ( specWithAuthApiKey , 'utf8' ) ;
1369
+ Converter . convert ( { type : 'string' , data : openapi } , { schemaFaker : true } , ( err , conversionResult ) => {
1370
+ expect ( err ) . to . be . null ;
1371
+ expect ( conversionResult . result ) . to . equal ( true ) ;
1372
+ expect ( conversionResult . output . length ) . to . equal ( 1 ) ;
1373
+ expect ( conversionResult . output [ 0 ] . type ) . to . equal ( 'collection' ) ;
1374
+ expect ( conversionResult . output [ 0 ] . data ) . to . have . property ( 'info' ) ;
1375
+ expect ( conversionResult . output [ 0 ] . data ) . to . have . property ( 'item' ) ;
1376
+ expect ( conversionResult . output [ 0 ] . data . item . length ) . to . equal ( 1 ) ;
1377
+ expect ( conversionResult . output [ 0 ] . data . auth . apiKey [ 0 ] . value ) . to . equal ( '{{api_key_name}}' ) ;
1378
+ expect ( conversionResult . output [ 0 ] . data . auth . apiKey [ 1 ] . value ) . to . equal ( '{{api_key}}' ) ;
1379
+ done ( ) ;
1380
+ } ) ;
1381
+ } ) ;
1312
1382
} ) ;
1313
1383
} ) ;
1314
1384
0 commit comments