hashi-vault-js
Version:
A node.js module to interact with the Hashicorp Vault API.
39 lines (34 loc) • 1.14 kB
JavaScript
//Simple smoke test
// TLS-Cert auth method
// This test will login to the TLS-Cert auth method using a certificate.
// source process.env
// node TLS-Cert-smoke-test.js
import Vault from '../src/Vault.js';
const CACert = process.env.CA_CERT;
const VaultUrl = process.env.VAULT_URL;
const RootToken = process.env.VAULT_ROOT_TOKEN;
const TLSCertName = process.env.TLS_CERT_NAME;
const TLSCertCertificate = process.env.TLS_CERT_CERTIFICATE;
const TLSCertPrivKey = process.env.TLS_CERT_PRIV_KEY;
const vault = new Vault( {
https: true,
cert: TLSCertCertificate,
key: TLSCertPrivKey,
cacert: CACert,
baseUrl: VaultUrl,
rootPath: 'auth/cert',
timeout: 20000,
proxy: false
});
vault.healthCheck().then(function(data) {
console.log('> healthCheck output: \n',data);
if (!data.sealed) {
vault.loginWithCert(TLSCertName, null).then(function(data){
console.log('>> loginWithCert output: \n',data);
}).catch(function(setError){
console.error('>>> loginWithCert error: \n',setError);
});
}
}).catch(function(healthError){
console.error('> healthCheck error: \n',healthError);
});