mirror of
https://github.com/hashicorp/vault.git
synced 2026-06-11 09:51:16 -04:00
Bug fix - ui context menu (#6018)
* add dot-to-dash helper * fix context menu on policy page and add test for deletion * use dot-to-dash where we use confirm component * fix acceptance test
This commit is contained in:
parent
04fa50cc0a
commit
96f103535e
17 changed files with 92 additions and 36 deletions
7
ui/app/helpers/dot-to-dash.js
Normal file
7
ui/app/helpers/dot-to-dash.js
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
import { helper as buildHelper } from '@ember/component/helper';
|
||||
|
||||
export function dotToDash([string]) {
|
||||
return string.replace(/\./gi, '-');
|
||||
}
|
||||
|
||||
export default buildHelper(dotToDash);
|
||||
|
|
@ -29,8 +29,8 @@
|
|||
buttonClasses="link is-destroy"
|
||||
onConfirmAction=(action "performTransaction" item)
|
||||
confirmMessage=(concat "Are you sure you want to delete " item.id "?")
|
||||
showConfirm=(get this (concat "shouldDelete-" item.id))
|
||||
class=(if (get this (concat "shouldDelete-" item.id)) "message is-block is-warning is-outline")
|
||||
showConfirm=(get this (concat "shouldDelete-" (dot-to-dash item.id)))
|
||||
class=(if (get this (concat "shouldDelete-" (dot-to-dash item.id))) "message is-block is-warning is-outline")
|
||||
containerClasses="message-body is-block"
|
||||
messageClasses="is-block"
|
||||
}}
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@
|
|||
buttonClasses="link is-destroy"
|
||||
onConfirmAction=(action "performTransaction" model groupArray memberId)
|
||||
confirmMessage=(concat "Are you sure you want to remove " memberId "?")
|
||||
showConfirm=(get this (concat "shouldDelete-" memberId))
|
||||
class=(if (get this (concat "shouldDelete-" memberId)) "message is-block is-warning is-outline")
|
||||
showConfirm=(get this (concat "shouldDelete-" (dot-to-dash memberId)))
|
||||
class=(if (get this (concat "shouldDelete-" (dot-to-dash memberId))) "message is-block is-warning is-outline")
|
||||
containerClasses="message-body is-block"
|
||||
messageClasses="is-block"
|
||||
}}
|
||||
|
|
|
|||
|
|
@ -18,8 +18,8 @@
|
|||
buttonClasses="link is-destroy"
|
||||
onConfirmAction=(action "performTransaction" model policyName)
|
||||
confirmMessage=(concat "Are you sure you want to remove " policyName "?")
|
||||
showConfirm=(get this (concat "shouldDelete-" policyName))
|
||||
class=(if (get this (concat "shouldDelete-" policyName)) "message is-block is-warning is-outline")
|
||||
showConfirm=(get this (concat "shouldDelete-" (dot-to-dash policyName)))
|
||||
class=(if (get this (concat "shouldDelete-" (dot-to-dash policyName))) "message is-block is-warning is-outline")
|
||||
containerClasses="message-body is-block"
|
||||
messageClasses="is-block"
|
||||
}}
|
||||
|
|
|
|||
|
|
@ -13,8 +13,8 @@
|
|||
buttonClasses="link is-destroy"
|
||||
onConfirmAction=(action "delete" item)
|
||||
confirmMessage=(concat "Are you sure you want to revoke " item.id "?")
|
||||
showConfirm=(get this (concat "shouldDelete-" item.id))
|
||||
class=(if (get this (concat "shouldDelete-" item.id)) "message is-block is-warning is-outline")
|
||||
showConfirm=(get this (concat "shouldDelete-" (dot-to-dash item.id)))
|
||||
class=(if (get this (concat "shouldDelete-" (dot-to-dash item.id))) "message is-block is-warning is-outline")
|
||||
containerClasses="message-body is-block"
|
||||
messageClasses="is-block"
|
||||
confirmButtonText="Revoke"
|
||||
|
|
|
|||
|
|
@ -47,8 +47,8 @@
|
|||
buttonClasses="link is-destroy"
|
||||
onConfirmAction=(action "delete" item)
|
||||
confirmMessage=(concat "Are you sure you want to delete " item.id "?")
|
||||
showConfirm=(get this (concat "shouldDelete-" item.id))
|
||||
class=(if (get this (concat "shouldDelete-" item.id)) "message is-block is-warning is-outline")
|
||||
showConfirm=(get this (concat "shouldDelete-" (dot-to-dash item.id)))
|
||||
class=(if (get this (concat "shouldDelete-" (dot-to-dash item.id))) "message is-block is-warning is-outline")
|
||||
containerClasses="message-body is-block"
|
||||
messageClasses="is-block"
|
||||
data-test-aws-role-delete=item.id
|
||||
|
|
|
|||
|
|
@ -60,8 +60,8 @@
|
|||
buttonClasses="link is-destroy"
|
||||
onConfirmAction=(action "delete" item)
|
||||
confirmMessage=(concat "Are you sure you want to delete " item.id "?")
|
||||
showConfirm=(get this (concat "shouldDelete-" item.id))
|
||||
class=(if (get this (concat "shouldDelete-" item.id)) "message is-block is-warning is-outline")
|
||||
showConfirm=(get this (concat "shouldDelete-" (dot-to-dash item.id)))
|
||||
class=(if (get this (concat "shouldDelete-" (dot-to-dash item.id))) "message is-block is-warning is-outline")
|
||||
containerClasses="message-body is-block"
|
||||
messageClasses="is-block"
|
||||
data-test-aws-role-delete=item.id
|
||||
|
|
|
|||
|
|
@ -63,8 +63,8 @@
|
|||
buttonClasses="link is-destroy"
|
||||
onConfirmAction=(action "delete" item)
|
||||
confirmMessage=(concat "Are you sure you want to delete " item.id "?")
|
||||
showConfirm=(get this (concat "shouldDelete-" item.id))
|
||||
class=(if (get this (concat "shouldDelete-" item.id)) "message is-block is-warning is-outline")
|
||||
showConfirm=(get this (concat "shouldDelete-" (dot-to-dash item.id)))
|
||||
class=(if (get this (concat "shouldDelete-" (dot-to-dash item.id))) "message is-block is-warning is-outline")
|
||||
containerClasses="message-body is-block"
|
||||
messageClasses="is-block"
|
||||
data-test-ssh-role-delete=item.id
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
@mode={{if item.isFolder "list" "show" }}
|
||||
@secret={{item.id}}
|
||||
@class="has-text-black has-text-weight-semibold"
|
||||
>
|
||||
>
|
||||
<ICon
|
||||
@glyph={{if item.isFolder 'folder' 'file' }}
|
||||
@size="14"
|
||||
|
|
@ -31,7 +31,7 @@
|
|||
@mode="list"
|
||||
@secret={{item.id}}
|
||||
@class="has-text-black has-text-weight-semibold"
|
||||
>
|
||||
>
|
||||
Contents
|
||||
</SecretLink>
|
||||
{{else}}
|
||||
|
|
@ -48,7 +48,7 @@
|
|||
@mode="show"
|
||||
@secret={{item.id}}
|
||||
@class="has-text-black has-text-weight-semibold"
|
||||
>
|
||||
>
|
||||
Details
|
||||
</SecretLink>
|
||||
</li>
|
||||
|
|
@ -58,7 +58,7 @@
|
|||
@mode="versions"
|
||||
@secret={{item.id}}
|
||||
@class="has-text-black has-text-weight-semibold"
|
||||
>
|
||||
>
|
||||
View version history
|
||||
</SecretLink>
|
||||
</li>
|
||||
|
|
@ -70,7 +70,7 @@
|
|||
@mode="edit"
|
||||
@secret={{item.id}}
|
||||
@class="has-text-black has-text-weight-semibold"
|
||||
>
|
||||
>
|
||||
{{if backendModel.isV2KV
|
||||
"Create New Version"
|
||||
"Edit"
|
||||
|
|
@ -85,8 +85,8 @@
|
|||
buttonClasses="link is-destroy"
|
||||
onConfirmAction=(action "delete" item "secret")
|
||||
confirmMessage=(concat "Are you sure you want to permanently delete " item.id " and all its versions?")
|
||||
showConfirm=(get this (concat "shouldDelete-" item.id))
|
||||
class=(if (get this (concat "shouldDelete-" item.id)) "message is-block is-warning is-outline")
|
||||
showConfirm=(get this (concat "shouldDelete-" (dot-to-dash item.id)))
|
||||
class=(if (get this (concat "shouldDelete-" (dot-to-dash item.id))) "message is-block is-warning is-outline")
|
||||
containerClasses="message-body is-block"
|
||||
messageClasses="is-block"
|
||||
data-test-v2-kv-delete=item.id
|
||||
|
|
|
|||
|
|
@ -64,8 +64,8 @@
|
|||
buttonClasses="link"
|
||||
onConfirmAction=(action "toggleDisabled" item)
|
||||
confirmMessage=(concat "Are you sure you want to disable " item.id "?")
|
||||
showConfirm=(get this (concat "shouldDisable-" item.id))
|
||||
class=(if (get this (concat "shouldDisable-" item.id)) "message is-block is-warning is-outline")
|
||||
showConfirm=(get this (concat "shouldDisable-" (dot-to-dash item.id)))
|
||||
class=(if (get this (concat "shouldDisable-" (dot-to-dash item.id))) "message is-block is-warning is-outline")
|
||||
containerClasses="message-body is-block"
|
||||
messageClasses="is-block"
|
||||
}}
|
||||
|
|
@ -89,8 +89,8 @@
|
|||
buttonClasses="link"
|
||||
onConfirmAction=(action "delete" item)
|
||||
confirmMessage=(concat "Are you sure you want to delete " item.id "?")
|
||||
showConfirm=(get this (concat "shouldDelete-" item.id))
|
||||
class=(if (get this (concat "shouldDelete-" item.id)) "message is-block is-warning is-outline")
|
||||
showConfirm=(get this (concat "shouldDelete-" (dot-to-dash item.id)))
|
||||
class=(if (get this (concat "shouldDelete-" (dot-to-dash item.id))) "message is-block is-warning is-outline")
|
||||
containerClasses="message-body is-block"
|
||||
messageClasses="is-block"
|
||||
}}
|
||||
|
|
|
|||
|
|
@ -64,8 +64,8 @@
|
|||
buttonClasses="link is-destroy"
|
||||
onConfirmAction=(perform disableMethod method)
|
||||
confirmMessage=(concat "Are you sure you want to disable the " method.id " auth method at " method.path "?")
|
||||
showConfirm=(get this (concat "shouldDelete-" method.id))
|
||||
class=(if (get this (concat "shouldDelete-" method.id)) "message is-block is-warning is-outline")
|
||||
showConfirm=(get this (concat "shouldDelete-" (dot-to-dash method.id)))
|
||||
class=(if (get this (concat "shouldDelete-" (dot-to-dash method.id))) "message is-block is-warning is-outline")
|
||||
containerClasses="message-body is-block"
|
||||
messageClasses="is-block"
|
||||
confirmButtonText="Disable"
|
||||
|
|
|
|||
|
|
@ -43,8 +43,8 @@
|
|||
)
|
||||
}}
|
||||
@confirmMessage={{concat "Are you sure you want to delete " list.item.id "?"}}
|
||||
@showConfirm={{get this (concat "shouldDelete-" list.item.id)}}
|
||||
@class={{if (get this (concat "shouldDelete-" list.item.id)) "message is-block is-warning is-outline"}}
|
||||
@showConfirm={{get this (concat "shouldDelete-" (dot-to-dash list.item.id))}}
|
||||
@class={{if (get this (concat "shouldDelete-" (dot-to-dash list.item.id))) "message is-block is-warning is-outline"}}
|
||||
@containerClasses="message-body is-block"
|
||||
@messageClasses="is-block"
|
||||
>
|
||||
|
|
|
|||
|
|
@ -121,8 +121,8 @@
|
|||
buttonClasses="link is-destroy"
|
||||
onConfirmAction=(action "deletePolicy" item)
|
||||
confirmMessage=(concat "Are you sure you want to delete " item.id "?")
|
||||
showConfirm=(get this (concat "shouldDelete-" item.id))
|
||||
class=(if (get this (concat "shouldDelete-" item.id)) "message is-block is-warning is-outline")
|
||||
showConfirm=(get this (concat "shouldDelete-" (dot-to-dash item.id)))
|
||||
class=(if (get this (concat "shouldDelete-" (dot-to-dash item.id))) "message is-block is-warning is-outline")
|
||||
containerClasses="message-body is-block"
|
||||
messageClasses="is-block"
|
||||
data-test-policy-delete=item.id
|
||||
|
|
|
|||
|
|
@ -66,8 +66,8 @@
|
|||
@buttonClasses="link is-destroy"
|
||||
@onConfirmAction={{perform disableEngine backend}}
|
||||
@confirmMessage={{concat "Are you sure you want to disable the " backend.engineType " secrets engine at " backend.path "?"}}
|
||||
@showConfirm={{get this (concat "shouldDelete-" backend.id)}}
|
||||
@class={{if (get this (concat "shouldDelete-" backend.id)) "message is-block is-warning is-outline"}}
|
||||
@showConfirm={{get this (concat "shouldDelete-" (dot-to-dash backend.id))}}
|
||||
@class={{if (get this (concat "shouldDelete-" (dot-to-dash backend.id))) "message is-block is-warning is-outline"}}
|
||||
@containerClasses="message-body is-block"
|
||||
@messageClasses="is-block"
|
||||
@confirmButtonText="Disable"
|
||||
|
|
@ -128,8 +128,8 @@
|
|||
@buttonClasses="link is-destroy"
|
||||
@onConfirmAction={{perform disableEngine backend}}
|
||||
@confirmMessage={{concat "Are you sure you want to disable the " backend.engineType " secrets engine at " backend.path "?"}}
|
||||
@showConfirm={{get this (concat "shouldDelete-" backend.id)}}
|
||||
@class={{if (get this (concat "shouldDelete-" backend.id)) "message is-block is-warning is-outline"}}
|
||||
@showConfirm={{get this (concat "shouldDelete-" (dot-to-dash backend.id))}}
|
||||
@class={{if (get this (concat "shouldDelete-" (dot-to-dash backend.id))) "message is-block is-warning is-outline"}}
|
||||
@containerClasses="message-body is-block"
|
||||
@messageClasses="is-block"
|
||||
@confirmButtonText="Disable"
|
||||
|
|
|
|||
|
|
@ -1,8 +1,13 @@
|
|||
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);
|
||||
|
|
@ -24,4 +29,16 @@ module('Acceptance | policies/acl', function(hooks) {
|
|||
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='${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');
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,10 +1,20 @@
|
|||
import { text, create, collection, visitable } from 'ember-cli-page-object';
|
||||
import { text, create, collection, clickable, visitable } from 'ember-cli-page-object';
|
||||
export default create({
|
||||
visit: visitable('/vault/policies/:type'),
|
||||
policies: collection('[data-test-policy-item]', {
|
||||
name: text('[data-test-policy-name]'),
|
||||
}),
|
||||
row: collection('[data-test-policy-link]', {
|
||||
name: text(),
|
||||
menu: clickable('[data-test-popup-menu-trigger]'),
|
||||
}),
|
||||
findPolicyByName(name) {
|
||||
return this.policies.filterBy('name', name)[0];
|
||||
},
|
||||
delete: clickable('[data-test-confirm-action-trigger]', {
|
||||
testContainer: '#ember-testing',
|
||||
}),
|
||||
confirmDelete: clickable('[data-test-confirm-button]', {
|
||||
testContainer: '#ember-testing',
|
||||
}),
|
||||
});
|
||||
|
|
|
|||
22
ui/tests/unit/helpers/dot-to-dash-test.js
Normal file
22
ui/tests/unit/helpers/dot-to-dash-test.js
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
import { dotToDash } from 'vault/helpers/dot-to-dash';
|
||||
import { module, test } from 'qunit';
|
||||
|
||||
module('Unit | Helpers | dot-to-dash', function() {
|
||||
test('it returns a string unchanged if there are not .s', function(assert) {
|
||||
let string = 'foo';
|
||||
let result = dotToDash([string]);
|
||||
assert.equal(string, result);
|
||||
});
|
||||
|
||||
test('it replaces a single . with -', function(assert) {
|
||||
let string = 'foo.bar';
|
||||
let result = dotToDash([string]);
|
||||
assert.equal(result, 'foo-bar');
|
||||
});
|
||||
|
||||
test('it replaces multiple . with -', function(assert) {
|
||||
let string = 'foo.bar.baz';
|
||||
let result = dotToDash([string]);
|
||||
assert.equal(result, 'foo-bar-baz');
|
||||
});
|
||||
});
|
||||
Loading…
Reference in a new issue