@@ -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,39 @@ describe('KubeConfig', () => {
788791 expect ( opts . headers . Authorization ) . to . equal ( `Bearer ${ token } ` ) ;
789792 }
790793 } ) ;
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+ } ) ;
791827 it ( 'should exec with exec auth and env vars' , async ( ) => {
792828 const config = new KubeConfig ( ) ;
793829 const token = 'token' ;
0 commit comments