From 3d4cea598b75f7d9dea1d7987b582bd65cfc1ba8 Mon Sep 17 00:00:00 2001 From: Richard Simpson Date: Tue, 14 Jan 2020 20:22:55 -0600 Subject: [PATCH] chore: update tests to use got correctly --- action.js | 4 ++-- dist/index.js | 4 ++-- integrationTests/e2e/setup.js | 6 ++--- .../enterprise/enterprise.test.js | 24 +++++++------------ 4 files changed, 14 insertions(+), 24 deletions(-) diff --git a/action.js b/action.js index 69ff084..56cc633 100644 --- a/action.js +++ b/action.js @@ -59,8 +59,8 @@ async function exportSecrets() { 'X-Vault-Token': vaultToken }}; - if (vaultNamespace != null){ - requestOptions.headers["X-Vault-Namespace"] = vaultNamespace + if (vaultNamespace != null) { + requestOptions.headers["X-Vault-Namespace"] = vaultNamespace; } const result = await got(`${vaultUrl}/v1/secret/data/${secretPath}`, requestOptions); diff --git a/dist/index.js b/dist/index.js index c46dc96..1883a47 100644 --- a/dist/index.js +++ b/dist/index.js @@ -4096,8 +4096,8 @@ async function exportSecrets() { responseType: 'json' }; - if (vaultNamespace != null){ - options.headers["X-Vault-Namespace"] = vaultNamespace + if (vaultNamespace != null) { + options.headers["X-Vault-Namespace"] = vaultNamespace; } const result = await got.post(`${vaultUrl}/v1/auth/approle/login`, options); diff --git a/integrationTests/e2e/setup.js b/integrationTests/e2e/setup.js index 8abe9a3..f81e412 100644 --- a/integrationTests/e2e/setup.js +++ b/integrationTests/e2e/setup.js @@ -14,12 +14,11 @@ const got = require('got'); headers: { 'X-Vault-Token': 'testtoken', }, - body: { + json: { data: { secret: 'SUPERSECRET', }, }, - json: true, }); await got(`http://${process.env.VAULT_HOST}:${process.env.VAULT_PORT}/v1/secret/data/nested/test`, { @@ -27,12 +26,11 @@ const got = require('got'); headers: { 'X-Vault-Token': 'testtoken', }, - body: { + json: { data: { otherSecret: 'OTHERSUPERSECRET', }, }, - json: true, }); } catch (error) { console.log(error); diff --git a/integrationTests/enterprise/enterprise.test.js b/integrationTests/enterprise/enterprise.test.js index 4761c54..cc0ae97 100644 --- a/integrationTests/enterprise/enterprise.test.js +++ b/integrationTests/enterprise/enterprise.test.js @@ -34,8 +34,7 @@ describe('integration', () => { 'X-Vault-Token': 'testtoken', 'X-Vault-Namespace': 'ns1', }, - body: { path: 'secret', type: 'kv', config: {}, options: { version: 2 }, generate_signing_key: true }, - json: true, + json: { path: 'secret', type: 'kv', config: {}, options: { version: 2 }, generate_signing_key: true }, }); await got(`${vaultUrl}/v1/secret/data/test`, { @@ -44,12 +43,11 @@ describe('integration', () => { 'X-Vault-Token': 'testtoken', 'X-Vault-Namespace': 'ns1', }, - body: { + json: { data: { secret: 'SUPERSECRET_IN_NAMESPACE', }, }, - json: true, }); await got(`${vaultUrl}/v1/secret/data/nested/test`, { @@ -58,12 +56,11 @@ describe('integration', () => { 'X-Vault-Token': 'testtoken', 'X-Vault-Namespace': 'ns1', }, - body: { + json: { data: { otherSecret: 'OTHERSUPERSECRET_IN_NAMESPACE', }, }, - json: true, }); }); @@ -157,8 +154,7 @@ describe('authenticate with approle', () => { 'X-Vault-Token': 'testtoken', 'X-Vault-Namespace': 'ns2', }, - body: { path: 'secret', type: 'kv', config: {}, options: { version: 2 }, generate_signing_key: true }, - json: true, + json: { path: 'secret', type: 'kv', config: {}, options: { version: 2 }, generate_signing_key: true }, }); // Add secret @@ -168,12 +164,11 @@ describe('authenticate with approle', () => { 'X-Vault-Token': 'testtoken', 'X-Vault-Namespace': 'ns2', }, - body: { + json: { data: { secret: 'SUPERSECRET_WITH_APPROLE', }, }, - json: true, }); // Enable approle @@ -183,10 +178,9 @@ describe('authenticate with approle', () => { 'X-Vault-Token': 'testtoken', 'X-Vault-Namespace': 'ns2', }, - body: { + json: { type: 'approle' }, - json: true, }); // Create policies @@ -196,11 +190,10 @@ describe('authenticate with approle', () => { 'X-Vault-Token': 'testtoken', 'X-Vault-Namespace': 'ns2', }, - body: { + json: { "name":"test", "policy":"path \"auth/approle/*\" {\n capabilities = [\"read\", \"list\"]\n}\npath \"auth/approle/role/my-role/role-id\"\n{\n capabilities = [\"create\", \"read\", \"update\", \"delete\", \"list\"]\n}\npath \"auth/approle/role/my-role/secret-id\"\n{\n capabilities = [\"create\", \"read\", \"update\", \"delete\", \"list\"]\n}\n\npath \"secret/data/*\" {\n capabilities = [\"list\"]\n}\npath \"secret/metadata/*\" {\n capabilities = [\"list\"]\n}\n\npath \"secret/data/test\" {\n capabilities = [\"read\", \"list\"]\n}\npath \"secret/metadata/test\" {\n capabilities = [\"read\", \"list\"]\n}\npath \"secret/data/test/*\" {\n capabilities = [\"read\", \"list\"]\n}\npath \"secret/metadata/test/*\" {\n capabilities = [\"read\", \"list\"]\n}\n" }, - json: true, }); // Create approle @@ -210,10 +203,9 @@ describe('authenticate with approle', () => { 'X-Vault-Token': 'testtoken', 'X-Vault-Namespace': 'ns2', }, - body: { + json: { policies: 'test' }, - json: true, }); // Get role-id