-
Notifications
You must be signed in to change notification settings - Fork 492
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix env variables to include existing environment variables, then ove…
…rride.
- Loading branch information
1 parent
e5ec945
commit 3fe1b53
Showing
4 changed files
with
70 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,4 +10,5 @@ coverage/* | |
examples/package-lock.json | ||
.nyc_output | ||
kubernetes-client-node-*.tgz | ||
**/*.swp | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { expect } from 'chai'; | ||
import { ExecAuth } from './exec_auth'; | ||
import * as shell from 'shelljs'; | ||
|
||
describe('ExecAuth', () => { | ||
it('should correctly exec', async () => { | ||
const auth = new ExecAuth(); | ||
(auth as any).execFn = (command: string, opts: shell.ExecOpts): shell.ShellReturnValue => { | ||
return { | ||
code: 0, | ||
stdout: JSON.stringify({ status: { token: 'foo' } }) | ||
} as shell.ShellReturnValue; | ||
}; | ||
|
||
const token = auth.getToken({ | ||
name: 'user', | ||
authProvider: { | ||
config: { | ||
exec: { | ||
command: 'echo' | ||
} | ||
} | ||
} | ||
}); | ||
expect(token).to.equal('Bearer foo'); | ||
}); | ||
|
||
it('should exec with env vars', async () => { | ||
const auth = new ExecAuth(); | ||
var optsOut: shell.ExecOpts = {}; | ||
(auth as any).execFn = (command: string, opts: shell.ExecOpts): shell.ShellReturnValue => { | ||
optsOut = opts | ||
return { | ||
code: 0, | ||
stdout: JSON.stringify({ status: { token: 'foo' } }) | ||
} as shell.ShellReturnValue; | ||
}; | ||
process.env.BLABBLE = 'flubble'; | ||
const token = auth.getToken({ | ||
name: 'user', | ||
authProvider: { | ||
config: { | ||
exec: { | ||
command: 'echo', | ||
env: [{ | ||
name: 'foo', | ||
value: 'bar' | ||
}] | ||
} | ||
} | ||
} | ||
}); | ||
expect(optsOut.env.foo).to.equal('bar'); | ||
expect(optsOut.env.PATH).to.equal(process.env.PATH); | ||
expect(optsOut.env.BLABBLE).to.equal(process.env.BLABBLE); | ||
}); | ||
}); |