@@ -4,9 +4,12 @@ import { dirname, join } from 'path';
44
55import { expect } from 'chai' ;
66import mockfs = require( 'mock-fs' ) ;
7- import * as requestlib from 'request' ;
87import * as path from 'path' ;
8+ import * as requestlib from 'request' ;
99
10+ import * as filesystem from 'fs' ;
11+ import { fs } from 'mock-fs' ;
12+ import * as os from 'os' ;
1013import { CoreV1Api } from './api' ;
1114import { bufferFromFileOrString , findHomeDir , findObject , KubeConfig , makeAbsolutePath } from './config' ;
1215import { Cluster , newClusters , newContexts , newUsers , User } from './config_types' ;
@@ -788,6 +791,31 @@ describe('KubeConfig', () => {
788791 expect ( opts . headers . Authorization ) . to . equal ( `Bearer ${ token } ` ) ;
789792 }
790793 } ) ;
794+ it ( 'should exec succesfully with spaces in cmd' , async ( ) => {
795+ const config = new KubeConfig ( ) ;
796+ const token = 'token' ;
797+ const responseStr = `{"token":{"accessToken":"${ token } "}}` ;
798+ config . loadFromClusterAndUser (
799+ { skipTLSVerify : false } as Cluster ,
800+ {
801+ authProvider : {
802+ name : 'azure' , // applies to gcp too as they are both handled by CloudAuth class
803+ config : {
804+ 'cmd-path' : path . join ( __dirname , '..' , 'test' , 'echo space.js' ) ,
805+ 'cmd-args' : `'${ responseStr } '` ,
806+ 'token-key' : '{.token.accessToken}' ,
807+ 'expiry-key' : '{.token.token_expiry}' ,
808+ } ,
809+ } ,
810+ } as User ,
811+ ) ;
812+ const opts = { } as requestlib . Options ;
813+ await config . applyToRequest ( opts ) ;
814+ expect ( opts . headers ) . to . not . be . undefined ;
815+ if ( opts . headers ) {
816+ expect ( opts . headers . Authorization ) . to . equal ( `Bearer ${ token } ` ) ;
817+ }
818+ } ) ;
791819 it ( 'should exec with exec auth and env vars' , async ( ) => {
792820 const config = new KubeConfig ( ) ;
793821 const token = 'token' ;
0 commit comments