@@ -6,9 +6,11 @@ import * as shell from 'shelljs';
66
77import execa = require( 'execa' ) ;
88import request = require( 'request' ) ;
9+ import https = require( 'https' ) ;
910
1011import { ExecAuth } from './exec_auth' ;
1112import { User } from './config_types' ;
13+ import { fail } from 'assert' ;
1214
1315describe ( 'ExecAuth' , ( ) => {
1416 it ( 'should claim correctly' , ( ) => {
@@ -246,4 +248,37 @@ describe('ExecAuth', () => {
246248 expect ( optsOut . env . PATH ) . to . equal ( process . env . PATH ) ;
247249 expect ( optsOut . env . BLABBLE ) . to . equal ( process . env . BLABBLE ) ;
248250 } ) ;
251+
252+ it ( 'should handle empty headers array correctly' , async ( ) => {
253+ const auth = new ExecAuth ( ) ;
254+ ( auth as any ) . execFn = (
255+ command : string ,
256+ args : string [ ] ,
257+ opts : execa . SyncOptions ,
258+ ) : execa . ExecaSyncReturnValue => {
259+ return {
260+ code : 0 ,
261+ stdout : JSON . stringify ( { status : { token : 'foo' } } ) ,
262+ } as execa . ExecaSyncReturnValue ;
263+ } ;
264+ const opts = { } as https . RequestOptions ;
265+ auth . applyAuthentication (
266+ {
267+ name : 'user' ,
268+ authProvider : {
269+ config : {
270+ exec : {
271+ command : 'echo' ,
272+ } ,
273+ } ,
274+ } ,
275+ } ,
276+ opts ,
277+ ) ;
278+ if ( ! opts . headers ) {
279+ fail ( 'unexpected null headers!' ) ;
280+ } else {
281+ expect ( opts . headers . Authorization ) . to . equal ( 'Bearer foo' ) ;
282+ }
283+ } ) ;
249284} ) ;
0 commit comments