463a3ebea9
* add popups * add ability to disable entity and banner when entity is disabled * re-add alias-popup template * add accpetance tests for creating entities * add more entity creation acceptance tests * add delete to edit-form * add more identity tests and associated selectors * add onSuccess hook and use UnloadModel route mixins * add ability to toggle entity disabling from the popover * fix store list cache because unloadAll isn't synchronous * fill out tests for identity items and aliases * add ability to enable entity from the detail page * toArray on the peekAll * fix other tests/behavior that relied on a RecordArray * adjust layout for disabled entity and label for disabling an entity on the edit form * add item-details integration tests * move disable field on the entity form * use ghost buttons for delete in identity and policy edit forms * adding computed macros for lazy capability fetching and using them in the identity models
90 lines
3.1 KiB
JavaScript
90 lines
3.1 KiB
JavaScript
import Ember from 'ember';
|
|
import { test } from 'qunit';
|
|
import moduleForAcceptance from 'vault/tests/helpers/module-for-acceptance';
|
|
import page from 'vault/tests/pages/policies/index';
|
|
|
|
let adapterException;
|
|
let loggerError;
|
|
moduleForAcceptance('Acceptance | policies (old)', {
|
|
beforeEach() {
|
|
loggerError = Ember.Logger.error;
|
|
adapterException = Ember.Test.adapter.exception;
|
|
Ember.Test.adapter.exception = () => {};
|
|
Ember.Logger.error = () => {};
|
|
return authLogin();
|
|
},
|
|
afterEach() {
|
|
Ember.Test.adapter.exception = adapterException;
|
|
Ember.Logger.error = loggerError;
|
|
},
|
|
});
|
|
|
|
test('policies', function(assert) {
|
|
const now = new Date().getTime();
|
|
const policyString = 'path "*" { capabilities = ["update"]}';
|
|
const policyName = `Policy test ${now}`;
|
|
const policyLower = policyName.toLowerCase();
|
|
|
|
page.visit({ type: 'acl' });
|
|
// new policy creation
|
|
click('[data-test-policy-create-link]');
|
|
fillIn('[data-test-policy-input="name"]', policyName);
|
|
click('[data-test-policy-save]');
|
|
andThen(function() {
|
|
assert.dom('[data-test-error]').exists({ count: 1 }, 'renders error messages on save');
|
|
find('.CodeMirror').get(0).CodeMirror.setValue(policyString);
|
|
});
|
|
click('[data-test-policy-save]');
|
|
andThen(function() {
|
|
assert.equal(
|
|
currentURL(),
|
|
`/vault/policy/acl/${encodeURIComponent(policyLower)}`,
|
|
'navigates to policy show on successful save'
|
|
);
|
|
assert.dom('[data-test-policy-name]').hasText(policyLower, 'displays the policy name on the show page');
|
|
assert.dom('[data-test-flash-message].is-info').doesNotExist('no flash message is displayed on save');
|
|
});
|
|
click('[data-test-policy-list-link]');
|
|
andThen(function() {
|
|
assert
|
|
.dom(`[data-test-policy-link="${policyLower}"]`)
|
|
.exists({ count: 1 }, 'new policy shown in the list');
|
|
});
|
|
|
|
// policy deletion
|
|
click(`[data-test-policy-link="${policyLower}"]`);
|
|
click('[data-test-policy-edit-toggle]');
|
|
click('[data-test-policy-delete] button');
|
|
click('[data-test-confirm-button]');
|
|
andThen(function() {
|
|
assert.equal(currentURL(), `/vault/policies/acl`, 'navigates to policy list on successful deletion');
|
|
assert
|
|
.dom(`[data-test-policy-item="${policyLower}"]`)
|
|
.doesNotExist('deleted policy is not shown in the list');
|
|
});
|
|
});
|
|
|
|
// https://github.com/hashicorp/vault/issues/4395
|
|
test('it properly fetches policies when the name ends in a ,', function(assert) {
|
|
const now = new Date().getTime();
|
|
const policyString = 'path "*" { capabilities = ["update"]}';
|
|
const policyName = `${now}-symbol,.`;
|
|
|
|
page.visit({ type: 'acl' });
|
|
// new policy creation
|
|
click('[data-test-policy-create-link]');
|
|
fillIn('[data-test-policy-input="name"]', policyName);
|
|
andThen(function() {
|
|
find('.CodeMirror').get(0).CodeMirror.setValue(policyString);
|
|
});
|
|
click('[data-test-policy-save]');
|
|
andThen(function() {
|
|
assert.equal(
|
|
currentURL(),
|
|
`/vault/policy/acl/${policyName}`,
|
|
'navigates to policy show on successful save'
|
|
);
|
|
assert.dom('[data-test-policy-edit-toggle]').exists({ count: 1 }, 'shows the edit toggle');
|
|
});
|
|
});
|