@@ -4,9 +4,12 @@ import { dirname, join } from 'path';
4
4
5
5
import { expect } from 'chai' ;
6
6
import mockfs = require( 'mock-fs' ) ;
7
- import * as requestlib from 'request' ;
8
7
import * as path from 'path' ;
8
+ import * as requestlib from 'request' ;
9
9
10
+ import * as filesystem from 'fs' ;
11
+ import { fs } from 'mock-fs' ;
12
+ import * as os from 'os' ;
10
13
import { CoreV1Api } from './api' ;
11
14
import { bufferFromFileOrString , findHomeDir , findObject , KubeConfig , makeAbsolutePath } from './config' ;
12
15
import { Cluster , newClusters , newContexts , newUsers , User } from './config_types' ;
@@ -788,6 +791,31 @@ describe('KubeConfig', () => {
788
791
expect ( opts . headers . Authorization ) . to . equal ( `Bearer ${ token } ` ) ;
789
792
}
790
793
} ) ;
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
+ } ) ;
791
819
it ( 'should exec with exec auth and env vars' , async ( ) => {
792
820
const config = new KubeConfig ( ) ;
793
821
const token = 'token' ;
0 commit comments