vvauth 2.4.0 → 2.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -89,7 +89,7 @@ class vvauth {
89
89
  }
90
90
 
91
91
 
92
- if(!process.env.SSH_AUTH_SOCK)
92
+ if(!process.env.SSH_AUTH_SOCK && process.platform !== 'win32')
93
93
  this.rc.token_cache = false;
94
94
 
95
95
  this.VAULT_ADDR = this.rc.vault_addr || process.env.VAULT_ADDR; //might be null
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vvauth",
3
- "version": "2.4.0",
3
+ "version": "2.4.1",
4
4
  "description": "Vault Auth helper",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -792,3 +792,27 @@ for(const inherited of ['', 'inherited-token']) {
792
792
  assert.deepEqual(requests, []);
793
793
  });
794
794
  }
795
+
796
+ test('Windows keeps cache enabled and selects Pageant without SSH_AUTH_SOCK', async t => {
797
+ const {client, file} = await fixture(t);
798
+ const home = path.dirname(path.dirname(path.dirname(file)));
799
+ const rc = path.join(home, 'foundry.vauthrc');
800
+ fs.writeFileSync(rc, JSON.stringify({vault_addr : client().VAULT_ADDR, ssh_auth : {role : 'windows-role'}}));
801
+ const module_path = path.resolve(__dirname, '..', 'index.js');
802
+ const script = `const Vauth = require(${JSON.stringify(module_path)});
803
+ Object.defineProperty(process, 'platform', {value: 'win32'});
804
+ const instance = new Vauth();
805
+ const result = {cacheDisabled: instance.rc.token_cache === false, role: instance.rc.ssh_auth.role};
806
+ instance._read_token_cache = async () => undefined;
807
+ instance._save_cached_token = async () => {};
808
+ instance._login_vault_ssh = async (auth, agent) => {
809
+ result.agent = agent;
810
+ return {client_token: 'windows-test-token', lease_duration: 86400, renewable: true};
811
+ };
812
+ instance.connect().then(() => process.stdout.write(JSON.stringify(result))).catch(() => process.exit(1));`;
813
+ const output = await exec(process.execPath, ['-e', script], {
814
+ cwd : home,
815
+ env : {...process.env, VAUTHRC : rc, VAULT_TOKEN : '', SSH_AUTH_SOCK : ''},
816
+ });
817
+ assert.deepEqual(JSON.parse(output.stdout), {cacheDisabled : false, role : 'windows-role', agent : 'pageant'});
818
+ });