mirror of
https://github.com/hashicorp/vault-action.git
synced 2025-11-08 23:56:55 +00:00
chore(test): fix integration tests
This commit is contained in:
parent
3d4cea598b
commit
42a9c06aa7
4 changed files with 64 additions and 61 deletions
|
|
@ -57,7 +57,8 @@ async function exportSecrets() {
|
||||||
const requestOptions = {
|
const requestOptions = {
|
||||||
headers: {
|
headers: {
|
||||||
'X-Vault-Token': vaultToken
|
'X-Vault-Token': vaultToken
|
||||||
}};
|
},
|
||||||
|
};
|
||||||
|
|
||||||
if (vaultNamespace != null) {
|
if (vaultNamespace != null) {
|
||||||
requestOptions.headers["X-Vault-Namespace"] = vaultNamespace;
|
requestOptions.headers["X-Vault-Namespace"] = vaultNamespace;
|
||||||
|
|
|
||||||
5
dist/index.js
vendored
5
dist/index.js
vendored
|
|
@ -4120,10 +4120,11 @@ async function exportSecrets() {
|
||||||
const requestOptions = {
|
const requestOptions = {
|
||||||
headers: {
|
headers: {
|
||||||
'X-Vault-Token': vaultToken
|
'X-Vault-Token': vaultToken
|
||||||
}};
|
},
|
||||||
|
};
|
||||||
|
|
||||||
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);
|
||||||
|
|
|
||||||
|
|
@ -23,12 +23,11 @@ describe('integration', () => {
|
||||||
headers: {
|
headers: {
|
||||||
'X-Vault-Token': 'testtoken',
|
'X-Vault-Token': 'testtoken',
|
||||||
},
|
},
|
||||||
body: {
|
json: {
|
||||||
data: {
|
data: {
|
||||||
secret: 'SUPERSECRET',
|
secret: 'SUPERSECRET',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
json: true,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
await got(`${vaultUrl}/v1/secret/data/nested/test`, {
|
await got(`${vaultUrl}/v1/secret/data/nested/test`, {
|
||||||
|
|
@ -36,12 +35,11 @@ describe('integration', () => {
|
||||||
headers: {
|
headers: {
|
||||||
'X-Vault-Token': 'testtoken',
|
'X-Vault-Token': 'testtoken',
|
||||||
},
|
},
|
||||||
body: {
|
json: {
|
||||||
data: {
|
data: {
|
||||||
otherSecret: 'OTHERSUPERSECRET',
|
otherSecret: 'OTHERSUPERSECRET',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
json: true,
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ const vaultUrl = `http://${process.env.VAULT_HOST || 'localhost'}:${process.env.
|
||||||
|
|
||||||
describe('integration', () => {
|
describe('integration', () => {
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
|
try {
|
||||||
// Verify Connection
|
// Verify Connection
|
||||||
await got(`${vaultUrl}/v1/secret/config`, {
|
await got(`${vaultUrl}/v1/secret/config`, {
|
||||||
headers: {
|
headers: {
|
||||||
|
|
@ -23,8 +24,7 @@ describe('integration', () => {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'X-Vault-Token': 'testtoken',
|
'X-Vault-Token': 'testtoken',
|
||||||
},
|
}
|
||||||
json: true,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Enable secret engine
|
// Enable secret engine
|
||||||
|
|
@ -62,6 +62,10 @@ describe('integration', () => {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
} catch (e) {
|
||||||
|
console.error('Failed to setup test', e);
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
|
@ -144,7 +148,6 @@ describe('authenticate with approle', () => {
|
||||||
headers: {
|
headers: {
|
||||||
'X-Vault-Token': 'testtoken',
|
'X-Vault-Token': 'testtoken',
|
||||||
},
|
},
|
||||||
json: true,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Enable secret engine
|
// Enable secret engine
|
||||||
|
|
@ -214,7 +217,7 @@ describe('authenticate with approle', () => {
|
||||||
'X-Vault-Token': 'testtoken',
|
'X-Vault-Token': 'testtoken',
|
||||||
'X-Vault-Namespace': 'ns2',
|
'X-Vault-Namespace': 'ns2',
|
||||||
},
|
},
|
||||||
json: true,
|
responseType: 'json',
|
||||||
});
|
});
|
||||||
roleId = roldIdResponse.body.data.role_id;
|
roleId = roldIdResponse.body.data.role_id;
|
||||||
|
|
||||||
|
|
@ -225,12 +228,12 @@ describe('authenticate with approle', () => {
|
||||||
'X-Vault-Token': 'testtoken',
|
'X-Vault-Token': 'testtoken',
|
||||||
'X-Vault-Namespace': 'ns2',
|
'X-Vault-Namespace': 'ns2',
|
||||||
},
|
},
|
||||||
json: true,
|
responseType: 'json',
|
||||||
});
|
});
|
||||||
secretId = secretIdResponse.body.data.secret_id;
|
secretId = secretIdResponse.body.data.secret_id;
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
console.warn('Create approle', err);
|
console.warn('Create approle', err);
|
||||||
throw err
|
throw err;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue