mirror of
https://github.com/hashicorp/vault-action.git
synced 2025-11-08 23:56:55 +00:00
chore: update tests to use got correctly
This commit is contained in:
parent
333e4389dc
commit
3d4cea598b
4 changed files with 14 additions and 24 deletions
|
|
@ -60,7 +60,7 @@ async function exportSecrets() {
|
||||||
}};
|
}};
|
||||||
|
|
||||||
if (vaultNamespace != null) {
|
if (vaultNamespace != null) {
|
||||||
requestOptions.headers["X-Vault-Namespace"] = vaultNamespace
|
requestOptions.headers["X-Vault-Namespace"] = vaultNamespace;
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = await got(`${vaultUrl}/v1/secret/data/${secretPath}`, requestOptions);
|
const result = await got(`${vaultUrl}/v1/secret/data/${secretPath}`, requestOptions);
|
||||||
|
|
|
||||||
2
dist/index.js
vendored
2
dist/index.js
vendored
|
|
@ -4097,7 +4097,7 @@ async function exportSecrets() {
|
||||||
};
|
};
|
||||||
|
|
||||||
if (vaultNamespace != null) {
|
if (vaultNamespace != null) {
|
||||||
options.headers["X-Vault-Namespace"] = vaultNamespace
|
options.headers["X-Vault-Namespace"] = vaultNamespace;
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = await got.post(`${vaultUrl}/v1/auth/approle/login`, options);
|
const result = await got.post(`${vaultUrl}/v1/auth/approle/login`, options);
|
||||||
|
|
|
||||||
|
|
@ -14,12 +14,11 @@ const got = require('got');
|
||||||
headers: {
|
headers: {
|
||||||
'X-Vault-Token': 'testtoken',
|
'X-Vault-Token': 'testtoken',
|
||||||
},
|
},
|
||||||
body: {
|
json: {
|
||||||
data: {
|
data: {
|
||||||
secret: 'SUPERSECRET',
|
secret: 'SUPERSECRET',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
json: true,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
await got(`http://${process.env.VAULT_HOST}:${process.env.VAULT_PORT}/v1/secret/data/nested/test`, {
|
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: {
|
headers: {
|
||||||
'X-Vault-Token': 'testtoken',
|
'X-Vault-Token': 'testtoken',
|
||||||
},
|
},
|
||||||
body: {
|
json: {
|
||||||
data: {
|
data: {
|
||||||
otherSecret: 'OTHERSUPERSECRET',
|
otherSecret: 'OTHERSUPERSECRET',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
json: true,
|
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
|
|
|
||||||
|
|
@ -34,8 +34,7 @@ describe('integration', () => {
|
||||||
'X-Vault-Token': 'testtoken',
|
'X-Vault-Token': 'testtoken',
|
||||||
'X-Vault-Namespace': 'ns1',
|
'X-Vault-Namespace': 'ns1',
|
||||||
},
|
},
|
||||||
body: { path: 'secret', type: 'kv', config: {}, options: { version: 2 }, generate_signing_key: true },
|
json: { path: 'secret', type: 'kv', config: {}, options: { version: 2 }, generate_signing_key: true },
|
||||||
json: true,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
await got(`${vaultUrl}/v1/secret/data/test`, {
|
await got(`${vaultUrl}/v1/secret/data/test`, {
|
||||||
|
|
@ -44,12 +43,11 @@ describe('integration', () => {
|
||||||
'X-Vault-Token': 'testtoken',
|
'X-Vault-Token': 'testtoken',
|
||||||
'X-Vault-Namespace': 'ns1',
|
'X-Vault-Namespace': 'ns1',
|
||||||
},
|
},
|
||||||
body: {
|
json: {
|
||||||
data: {
|
data: {
|
||||||
secret: 'SUPERSECRET_IN_NAMESPACE',
|
secret: 'SUPERSECRET_IN_NAMESPACE',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
json: true,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
await got(`${vaultUrl}/v1/secret/data/nested/test`, {
|
await got(`${vaultUrl}/v1/secret/data/nested/test`, {
|
||||||
|
|
@ -58,12 +56,11 @@ describe('integration', () => {
|
||||||
'X-Vault-Token': 'testtoken',
|
'X-Vault-Token': 'testtoken',
|
||||||
'X-Vault-Namespace': 'ns1',
|
'X-Vault-Namespace': 'ns1',
|
||||||
},
|
},
|
||||||
body: {
|
json: {
|
||||||
data: {
|
data: {
|
||||||
otherSecret: 'OTHERSUPERSECRET_IN_NAMESPACE',
|
otherSecret: 'OTHERSUPERSECRET_IN_NAMESPACE',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
json: true,
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -157,8 +154,7 @@ describe('authenticate with approle', () => {
|
||||||
'X-Vault-Token': 'testtoken',
|
'X-Vault-Token': 'testtoken',
|
||||||
'X-Vault-Namespace': 'ns2',
|
'X-Vault-Namespace': 'ns2',
|
||||||
},
|
},
|
||||||
body: { path: 'secret', type: 'kv', config: {}, options: { version: 2 }, generate_signing_key: true },
|
json: { path: 'secret', type: 'kv', config: {}, options: { version: 2 }, generate_signing_key: true },
|
||||||
json: true,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Add secret
|
// Add secret
|
||||||
|
|
@ -168,12 +164,11 @@ describe('authenticate with approle', () => {
|
||||||
'X-Vault-Token': 'testtoken',
|
'X-Vault-Token': 'testtoken',
|
||||||
'X-Vault-Namespace': 'ns2',
|
'X-Vault-Namespace': 'ns2',
|
||||||
},
|
},
|
||||||
body: {
|
json: {
|
||||||
data: {
|
data: {
|
||||||
secret: 'SUPERSECRET_WITH_APPROLE',
|
secret: 'SUPERSECRET_WITH_APPROLE',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
json: true,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Enable approle
|
// Enable approle
|
||||||
|
|
@ -183,10 +178,9 @@ describe('authenticate with approle', () => {
|
||||||
'X-Vault-Token': 'testtoken',
|
'X-Vault-Token': 'testtoken',
|
||||||
'X-Vault-Namespace': 'ns2',
|
'X-Vault-Namespace': 'ns2',
|
||||||
},
|
},
|
||||||
body: {
|
json: {
|
||||||
type: 'approle'
|
type: 'approle'
|
||||||
},
|
},
|
||||||
json: true,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Create policies
|
// Create policies
|
||||||
|
|
@ -196,11 +190,10 @@ describe('authenticate with approle', () => {
|
||||||
'X-Vault-Token': 'testtoken',
|
'X-Vault-Token': 'testtoken',
|
||||||
'X-Vault-Namespace': 'ns2',
|
'X-Vault-Namespace': 'ns2',
|
||||||
},
|
},
|
||||||
body: {
|
json: {
|
||||||
"name":"test",
|
"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"
|
"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
|
// Create approle
|
||||||
|
|
@ -210,10 +203,9 @@ describe('authenticate with approle', () => {
|
||||||
'X-Vault-Token': 'testtoken',
|
'X-Vault-Token': 'testtoken',
|
||||||
'X-Vault-Namespace': 'ns2',
|
'X-Vault-Namespace': 'ns2',
|
||||||
},
|
},
|
||||||
body: {
|
json: {
|
||||||
policies: 'test'
|
policies: 'test'
|
||||||
},
|
},
|
||||||
json: true,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Get role-id
|
// Get role-id
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue