open-vault/ui/tests/acceptance/policies/index-test.js
Matthew Irish 23946d75a7
web-cli quote parsing (#6755)
* upgrade yargs-parser for better quote handling

* remove encoding pre&post parse, and remove wrapping quotes when pushing to data array

* add test for spaces and strings

* base64 encode policy strings in tests where we're using them with string interpolation

* improve regex to only remove wrapping single and double quotes

* don't support quotes in paths in the web cli
2019-05-22 16:07:42 -05:00

45 lines
1.8 KiB
JavaScript

import { currentURL, currentRouteName } from '@ember/test-helpers';
import { module, test } from 'qunit';
import { setupApplicationTest } from 'ember-qunit';
import { create } from 'ember-cli-page-object';
import page from 'vault/tests/pages/policies/index';
import authPage from 'vault/tests/pages/auth';
import consoleClass from 'vault/tests/pages/components/console/ui-panel';
const consoleComponent = create(consoleClass);
module('Acceptance | policies/acl', function(hooks) {
setupApplicationTest(hooks);
hooks.beforeEach(function() {
return authPage.login();
});
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');
});
test('it navigates to show when clicking on the link', async function(assert) {
await page.visit({ type: 'acl' });
await page.findPolicyByName('default').click();
assert.equal(currentRouteName(), 'vault.cluster.policy.show');
assert.equal(currentURL(), '/vault/policy/acl/default');
});
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=${btoa(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');
});
});