2018-09-25 16:28:26 +00:00
|
|
|
import { currentURL, currentRouteName } from '@ember/test-helpers';
|
|
|
|
import { module, test } from 'qunit';
|
|
|
|
import { setupApplicationTest } from 'ember-qunit';
|
2019-01-09 18:30:19 +00:00
|
|
|
import { create } from 'ember-cli-page-object';
|
|
|
|
|
2018-04-03 14:16:57 +00:00
|
|
|
import page from 'vault/tests/pages/policies/index';
|
2018-09-25 16:28:26 +00:00
|
|
|
import authPage from 'vault/tests/pages/auth';
|
2019-01-09 18:30:19 +00:00
|
|
|
import consoleClass from 'vault/tests/pages/components/console/ui-panel';
|
|
|
|
|
|
|
|
const consoleComponent = create(consoleClass);
|
2018-04-03 14:16:57 +00:00
|
|
|
|
2018-09-25 16:28:26 +00:00
|
|
|
module('Acceptance | policies/acl', function(hooks) {
|
|
|
|
setupApplicationTest(hooks);
|
2018-04-03 14:16:57 +00:00
|
|
|
|
2018-09-25 16:28:26 +00:00
|
|
|
hooks.beforeEach(function() {
|
|
|
|
return authPage.login();
|
2018-04-03 14:16:57 +00:00
|
|
|
});
|
|
|
|
|
2018-09-25 16:28:26 +00:00
|
|
|
test('it lists default and root acls', async function(assert) {
|
|
|
|
await page.visit({ type: 'acl' });
|
|
|
|
assert.equal(currentURL(), '/vault/policies/acl');
|
|
|
|
assert.ok(page.findPolicyByName('root'), 'root policy shown in the list');
|
|
|
|
assert.ok(page.findPolicyByName('default'), 'default policy shown in the list');
|
2018-04-03 14:16:57 +00:00
|
|
|
});
|
|
|
|
|
2018-09-25 16:28:26 +00:00
|
|
|
test('it navigates to show when clicking on the link', async function(assert) {
|
|
|
|
await page.visit({ type: 'acl' });
|
|
|
|
await page.findPolicyByName('default').click();
|
2018-04-03 14:16:57 +00:00
|
|
|
assert.equal(currentRouteName(), 'vault.cluster.policy.show');
|
|
|
|
assert.equal(currentURL(), '/vault/policy/acl/default');
|
|
|
|
});
|
2019-01-09 18:30:19 +00:00
|
|
|
|
|
|
|
test('it allows deletion of policies with dots in names', async function(assert) {
|
|
|
|
const POLICY = 'path "*" { capabilities = ["list"]}';
|
|
|
|
let policyName = 'list.policy';
|
|
|
|
await consoleComponent.runCommands([`write sys/policies/acl/${policyName} policy='${POLICY}'`]);
|
|
|
|
await page.visit({ type: 'acl' });
|
|
|
|
let policy = page.row.filterBy('name', policyName)[0];
|
|
|
|
assert.ok(policy, 'policy is shown in the list');
|
|
|
|
await policy.menu();
|
|
|
|
await page.delete().confirmDelete();
|
|
|
|
assert.notOk(page.findPolicyByName(policyName), 'policy is deleted successfully');
|
|
|
|
});
|
2018-04-03 14:16:57 +00:00
|
|
|
});
|