mirror of
https://github.com/expo/node-vault.git
synced 2026-11-27 16:45:28 -10:00
40 lines
1.0 KiB
JavaScript
40 lines
1.0 KiB
JavaScript
const chai = require('chai');
|
|
const dirtyChai = require('dirty-chai');
|
|
const should = chai.Should;
|
|
|
|
should();
|
|
chai.use(dirtyChai);
|
|
|
|
const vault = require('./../src/index.js')();
|
|
// use json schema in commands.js validate response
|
|
const commands = require('./../src/commands.js');
|
|
const tv4 = require('tv4');
|
|
const assert = require('assert');
|
|
|
|
const validResult = (commandName, result) => {
|
|
const schema = commands[commandName].schema.res;
|
|
return tv4.validate(result, schema);
|
|
};
|
|
|
|
describe('integration', () => {
|
|
describe('node-vault', () => {
|
|
it('should initialize a vault server', (done) => {
|
|
vault.init({ secret_shares: 1, secret_threshold: 1 })
|
|
.then((result) => {
|
|
vault.token = result.root_token;
|
|
assert(validResult('init', result));
|
|
return done();
|
|
})
|
|
.catch(done);
|
|
});
|
|
it('should show the current status of the vault server', (done) => {
|
|
vault.status()
|
|
.then((result) => {
|
|
assert(validResult('status', result));
|
|
return done();
|
|
})
|
|
.catch(done);
|
|
});
|
|
});
|
|
});
|