b32da5daad
* add ember-concurrency-test-waiter * use withTestWaiter modifier in various parts of the application * more withTestWaiter * await instead of return for a few helpers * update ember-cli-flash * run ember generate ember-cli-flash * remove withFlash helper * fix typo and replication tests
121 lines
5.4 KiB
JavaScript
121 lines
5.4 KiB
JavaScript
import { currentRouteName, settled } from '@ember/test-helpers';
|
|
import { module, test } from 'qunit';
|
|
import { setupApplicationTest } from 'ember-qunit';
|
|
import page from 'vault/tests/pages/settings/configure-secret-backends/pki/section-cert';
|
|
import authPage from 'vault/tests/pages/auth';
|
|
import enablePage from 'vault/tests/pages/settings/mount-secret-backend';
|
|
|
|
module('Acceptance | settings/configure/secrets/pki/cert', function(hooks) {
|
|
setupApplicationTest(hooks);
|
|
|
|
hooks.beforeEach(function() {
|
|
return authPage.login();
|
|
});
|
|
|
|
//prettier-ignore
|
|
const PEM_BUNDLE = `-----BEGIN CERTIFICATE-----
|
|
MIIDGjCCAgKgAwIBAgIUFvnhb2nQ8+KNS3SzjlfYDMHGIRgwDQYJKoZIhvcNAQEL
|
|
BQAwDTELMAkGA1UEAxMCZmEwHhcNMTgwMTEwMTg1NDI5WhcNMTgwMjExMTg1NDU5
|
|
WjANMQswCQYDVQQDEwJmYTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB
|
|
AN2VtBn6EMlA4aYre/xoKHxlgNDxJnfSQWfs6yF/K201qPnt4QF9AXChatbmcKVn
|
|
OaURq+XEJrGVgF/u2lSos3NRZdhWVe8o3/sOetsGxcrd0gXAieOSmkqJjp27bYdl
|
|
uY3WsxhyiPvdfS6xz39OehsK/YCB6qCzwB4eEfSKqbkvfDL9sLlAiOlaoHC9pczf
|
|
6/FANKp35UDwInSwmq5vxGbnWk9zMkh5Jq6hjOWHZnVc2J8J49PYvkIM8uiHDgOE
|
|
w71T2xM5plz6crmZnxPCOcTKIdF7NTEP2lUfiqc9lONV9X1Pi4UclLPHJf5bwTmn
|
|
JaWgbKeY+IlF61/mgxzhC7cCAwEAAaNyMHAwD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3m
|
|
3YXRAoGAE7MBnVJWiIN5s63gGz9f9V6k1dPLfcPE1I0KMM/SDOIV0oLMsYQecTTB
|
|
ZzkXwRCdcJARkaKulTfjby7+oGpQydP8iZr+CNKFxwf838UbhhsXHnN6rc62qzYD
|
|
BXUV2Uwtxf+QCphnlht9muX2fsLIzDJea0JipWj1uf2H8OZsjE8=
|
|
-----END RSA PRIVATE KEY-----`;
|
|
|
|
const mountAndNav = async (assert, prefix) => {
|
|
const path = `${prefix}pki-${new Date().getTime()}`;
|
|
await enablePage.enable('pki', path);
|
|
await page.visit({ backend: path });
|
|
return path;
|
|
};
|
|
|
|
test('cert config: generate', async function(assert) {
|
|
await mountAndNav(assert);
|
|
assert.equal(currentRouteName(), 'vault.cluster.settings.configure-secret-backend.section');
|
|
|
|
await page.form.generateCA();
|
|
assert.ok(page.form.rows.length > 0, 'shows all of the rows');
|
|
assert.ok(page.form.certificateIsPresent, 'the certificate is included');
|
|
|
|
await page.form.back();
|
|
await page.form.generateCA();
|
|
assert.ok(
|
|
page.flash.latestMessage.includes('You tried to generate a new root CA'),
|
|
'shows warning message'
|
|
);
|
|
});
|
|
|
|
test('cert config: upload', async function(assert) {
|
|
await mountAndNav(assert);
|
|
assert.equal(page.form.downloadLinks.length, 0, 'there are no download links');
|
|
|
|
await page.form.uploadCA(PEM_BUNDLE);
|
|
assert.ok(
|
|
page.flash.latestMessage.startsWith('The certificate for this backend has been updated'),
|
|
'flash message displays properly'
|
|
);
|
|
});
|
|
|
|
test('cert config: sign intermediate and set signed intermediate', async function(assert) {
|
|
let csrVal, intermediateCert;
|
|
const rootPath = await mountAndNav(assert, 'root-');
|
|
await page.form.generateCA();
|
|
|
|
const intermediatePath = await mountAndNav(assert, 'intermediate-');
|
|
await page.form.generateCA('Intermediate CA', 'intermediate');
|
|
// cache csr
|
|
csrVal = page.form.csr;
|
|
await page.form.back();
|
|
|
|
await page.visit({ backend: rootPath });
|
|
await page.form.signIntermediate('Intermediate CA');
|
|
await page.form.csrField(csrVal).submit();
|
|
intermediateCert = page.form.certificate;
|
|
await page.form.back();
|
|
await page.visit({ backend: intermediatePath });
|
|
await page.form.setSignedIntermediateBtn().signedIntermediate(intermediateCert);
|
|
|
|
await page.form.submit();
|
|
await settled();
|
|
assert.equal(page.form.downloadLinks.length, 3, 'includes the caChain download link');
|
|
});
|
|
});
|