@@ -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,39 @@ 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
+ /**
796
+ *
797
+ * to test this, symlink echo to dir that has spaces:
798
+ * mkdir -p /tmp/foo\ bar/
799
+ * ln -s /bin/echo /tmp/foo\ bar/echo
800
+ *
801
+ * FIXME: Figure out a "portable" way to dynamically do this sort of symlink as part of the test case
802
+ */
803
+ const config = new KubeConfig ( ) ;
804
+ const token = 'token' ;
805
+ const responseStr = `{"token":{"accessToken":"${ token } "}}` ;
806
+ config . loadFromClusterAndUser (
807
+ { skipTLSVerify : false } as Cluster ,
808
+ {
809
+ authProvider : {
810
+ name : 'azure' , // aplias to gcp too as they are both handled by CloudAuth class
811
+ config : {
812
+ 'cmd-path' : '/tmp/foo bar/echo' ,
813
+ 'cmd-args' : `'${ responseStr } '` ,
814
+ 'token-key' : '{.token.accessToken}' ,
815
+ 'expiry-key' : '{.token.token_expiry}' ,
816
+ } ,
817
+ } ,
818
+ } as User ,
819
+ ) ;
820
+ const opts = { } as requestlib . Options ;
821
+ await config . applyToRequest ( opts ) ;
822
+ expect ( opts . headers ) . to . not . be . undefined ;
823
+ if ( opts . headers ) {
824
+ expect ( opts . headers . Authorization ) . to . equal ( `Bearer ${ token } ` ) ;
825
+ }
826
+ } ) ;
791
827
it ( 'should exec with exec auth and env vars' , async ( ) => {
792
828
const config = new KubeConfig ( ) ;
793
829
const token = 'token' ;
0 commit comments