chore(test): organize tests a bit better (#7)

* chore(test): organize tests a bit better

* add caching
This commit is contained in:
Richard Simpson 2019-11-24 16:00:31 -06:00 committed by GitHub
parent 3747195c5f
commit 38c189f087
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 101 additions and 73 deletions

View file

@ -0,0 +1,4 @@
# e2e tests
This test suite runs `vault-action` as a GitHub Action in the context of a live build, and then verifies that the appropriate environmental variables are set.
These tests are intended to mostly be very simple smoke tests to verify that the action is being compiled and run correctly in context.

View file

@ -0,0 +1,7 @@
describe('e2e', () => {
it('verify', () => {
expect(process.env.SECRET).toBe("SUPERSECRET");
expect(process.env.NAMED_SECRET).toBe("SUPERSECRET");
expect(process.env.OTHERSECRET).toBe("OTHERSUPERSECRET");
});
});

View file

@ -0,0 +1,3 @@
module.exports = {
verbose: true
};

View file

@ -0,0 +1,41 @@
const got = require('got');
(async () => {
try {
// Verify Connection
await got(`http://${process.env.VAULT_HOST}:${process.env.VAULT_PORT}/v1/secret/config`, {
headers: {
'X-Vault-Token': 'testtoken',
},
});
await got(`http://${process.env.VAULT_HOST}:${process.env.VAULT_PORT}/v1/secret/data/test`, {
method: 'POST',
headers: {
'X-Vault-Token': 'testtoken',
},
body: {
data: {
secret: 'SUPERSECRET',
},
},
json: true,
});
await got(`http://${process.env.VAULT_HOST}:${process.env.VAULT_PORT}/v1/secret/data/nested/test`, {
method: 'POST',
headers: {
'X-Vault-Token': 'testtoken',
},
body: {
data: {
otherSecret: 'OTHERSUPERSECRET',
},
},
json: true,
});
} catch (error) {
console.log(error);
process.exit(1);
}
})();