2018-09-25 16:28:26 +00:00
|
|
|
import { currentRouteName } from '@ember/test-helpers';
|
|
|
|
import { module, test } from 'qunit';
|
|
|
|
import { setupApplicationTest } from 'ember-qunit';
|
2018-04-03 14:16:57 +00:00
|
|
|
import editPage from 'vault/tests/pages/secrets/backend/pki/edit-role';
|
|
|
|
import showPage from 'vault/tests/pages/secrets/backend/pki/show';
|
|
|
|
import listPage from 'vault/tests/pages/secrets/backend/list';
|
2018-09-25 16:28:26 +00:00
|
|
|
import enablePage from 'vault/tests/pages/settings/mount-secret-backend';
|
|
|
|
import authPage from 'vault/tests/pages/auth';
|
2018-04-03 14:16:57 +00:00
|
|
|
|
2018-09-25 16:28:26 +00:00
|
|
|
module('Acceptance | secrets/pki/create', function(hooks) {
|
|
|
|
setupApplicationTest(hooks);
|
|
|
|
|
|
|
|
hooks.beforeEach(function() {
|
|
|
|
return authPage.login();
|
|
|
|
});
|
2018-04-03 14:16:57 +00:00
|
|
|
|
2018-09-25 16:28:26 +00:00
|
|
|
const mountAndNav = async () => {
|
|
|
|
const path = `pki-${new Date().getTime()}`;
|
|
|
|
await enablePage.enable('pki', path);
|
|
|
|
await editPage.visitRoot({ backend: path });
|
|
|
|
return path;
|
|
|
|
};
|
2018-04-03 14:16:57 +00:00
|
|
|
|
2018-09-25 16:28:26 +00:00
|
|
|
test('it creates a role and redirects', async function(assert) {
|
|
|
|
const path = await mountAndNav(assert);
|
|
|
|
await editPage.createRole('role', 'example.com');
|
2018-04-03 14:16:57 +00:00
|
|
|
assert.equal(currentRouteName(), 'vault.cluster.secrets.backend.show', 'redirects to the show page');
|
|
|
|
assert.ok(showPage.editIsPresent, 'shows the edit button');
|
|
|
|
assert.ok(showPage.generateCertIsPresent, 'shows the generate button');
|
|
|
|
assert.ok(showPage.signCertIsPresent, 'shows the sign button');
|
|
|
|
|
2018-09-25 16:28:26 +00:00
|
|
|
await showPage.visit({ backend: path, id: 'role' });
|
|
|
|
await showPage.generateCert();
|
2018-04-03 14:16:57 +00:00
|
|
|
assert.equal(
|
|
|
|
currentRouteName(),
|
|
|
|
'vault.cluster.secrets.backend.credentials',
|
|
|
|
'navs to the credentials page'
|
|
|
|
);
|
|
|
|
|
2018-09-25 16:28:26 +00:00
|
|
|
await showPage.visit({ backend: path, id: 'role' });
|
|
|
|
await showPage.signCert();
|
2018-04-03 14:16:57 +00:00
|
|
|
assert.equal(
|
|
|
|
currentRouteName(),
|
|
|
|
'vault.cluster.secrets.backend.credentials',
|
|
|
|
'navs to the credentials page'
|
|
|
|
);
|
|
|
|
|
2018-09-25 16:28:26 +00:00
|
|
|
await listPage.visitRoot({ backend: path });
|
2018-06-14 04:06:19 +00:00
|
|
|
assert.equal(listPage.secrets.length, 1, 'shows role in the list');
|
2018-11-19 21:48:24 +00:00
|
|
|
let secret = listPage.secrets.objectAt(0);
|
|
|
|
await secret.menuToggle();
|
|
|
|
assert.ok(listPage.menuItems.length > 0, 'shows links in the menu');
|
2018-04-03 14:16:57 +00:00
|
|
|
});
|
|
|
|
|
2018-09-25 16:28:26 +00:00
|
|
|
test('it deletes a role', async function(assert) {
|
2019-05-17 17:29:21 +00:00
|
|
|
const path = await mountAndNav(assert);
|
2018-09-25 16:28:26 +00:00
|
|
|
await editPage.createRole('role', 'example.com');
|
2019-05-17 17:29:21 +00:00
|
|
|
await showPage.visit({ backend: path, id: 'role' });
|
|
|
|
await showPage.deleteRole();
|
2018-04-03 14:16:57 +00:00
|
|
|
assert.equal(currentRouteName(), 'vault.cluster.secrets.backend.list-root', 'redirects to list page');
|
|
|
|
assert.ok(listPage.backendIsEmpty, 'no roles listed');
|
|
|
|
});
|
|
|
|
});
|