Merge branch 'main' into fix-rose-babel-core-unmet-dependency
This commit is contained in:
8 files changed
+65
-7
No files matched your search
@@ -0,0 +1,15 @@
|
||||
import ModelAbility from './model';
|
||||
|
||||
/**
|
||||
* Provides abilities for accounts.
|
||||
*/
|
||||
export default class AccountAbility extends ModelAbility {
|
||||
// =permissions
|
||||
|
||||
/**
|
||||
* @type {boolean}
|
||||
*/
|
||||
get canSetPassword() {
|
||||
return this.hasAuthorizedAction('set-password');
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import ModelAbility from './model';
|
||||
|
||||
/**
|
||||
* Provides a `connect` ability for targets.
|
||||
* Provides abilities for targets.
|
||||
*/
|
||||
export default class TargetAbility extends ModelAbility {
|
||||
// =permissions
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
export { default } from 'api/abilities/account';
|
||||
@@ -9,6 +9,7 @@ export default factory.extend({
|
||||
'read',
|
||||
'update',
|
||||
'delete',
|
||||
'set-password',
|
||||
],
|
||||
attributes() {
|
||||
switch (this.type) {
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
|
||||
module('Unit | Abilities | Account', function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test('it reflects when a given account may set password based on authorized_actions', function (assert) {
|
||||
assert.expect(2);
|
||||
const service = this.owner.lookup('service:can');
|
||||
const model = {
|
||||
authorized_actions: ['set-password'],
|
||||
};
|
||||
assert.ok(service.can('setPassword target', model));
|
||||
model.authorized_actions = [];
|
||||
assert.notOk(service.can('setPassword target', model));
|
||||
});
|
||||
});
|
||||
@@ -6,6 +6,7 @@
|
||||
<title>Admin</title>
|
||||
<meta name="description" content="Simple and secure remote access with HashiCorp Boundary.">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="theme-color" content="#f24c53">
|
||||
|
||||
{{content-for "head"}}
|
||||
|
||||
|
||||
+7
-5
@@ -5,10 +5,12 @@
|
||||
{{t 'titles.details'}}
|
||||
</nav.link>
|
||||
{{#if @model.isPassword}}
|
||||
<nav.link
|
||||
@route='scopes.scope.auth-methods.auth-method.accounts.account.set-password'
|
||||
>
|
||||
{{t 'actions.set-password'}}
|
||||
</nav.link>
|
||||
{{#if (can 'setPassword account' @model)}}
|
||||
<nav.link
|
||||
@route='scopes.scope.auth-methods.auth-method.accounts.account.set-password'
|
||||
>
|
||||
{{t 'actions.set-password'}}
|
||||
</nav.link>
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
</Rose::Nav::Tabs>
|
||||
@@ -49,7 +49,8 @@ module('Acceptance | accounts | set password', function (hooks) {
|
||||
urls.authMethods = `${urls.orgScope}/auth-methods`;
|
||||
urls.authMethod = `${urls.authMethods}/${instances.authMethod.id}`;
|
||||
urls.accounts = `${urls.authMethod}/accounts`;
|
||||
urls.setPassword = `${urls.accounts}/${instances.account.id}/set-password`;
|
||||
urls.account = `${urls.accounts}/${instances.account.id}`;
|
||||
urls.setPassword = `${urls.account}/set-password`;
|
||||
});
|
||||
|
||||
test('visiting account set password', async function (assert) {
|
||||
@@ -59,6 +60,26 @@ module('Acceptance | accounts | set password', function (hooks) {
|
||||
assert.equal(currentURL(), urls.setPassword);
|
||||
});
|
||||
|
||||
test('can navigate to route with proper authorization', async function (assert) {
|
||||
assert.expect(1);
|
||||
await visit(urls.account);
|
||||
assert.ok(
|
||||
find(`.rose-layout-page-navigation [href="${urls.setPassword}"]`)
|
||||
);
|
||||
});
|
||||
|
||||
test('cannot navigate to route without proper authorization', async function (assert) {
|
||||
assert.expect(1);
|
||||
const authorized_actions = instances.account.authorized_actions.filter(
|
||||
(item) => item !== 'set-password'
|
||||
);
|
||||
instances.account.update({ authorized_actions });
|
||||
await visit(urls.account);
|
||||
assert.notOk(
|
||||
find(`.rose-layout-page-navigation [href="${urls.setPassword}"]`)
|
||||
);
|
||||
});
|
||||
|
||||
test('can set a new password for account', async function (assert) {
|
||||
assert.expect(1);
|
||||
this.server.post(
|
||||
|
||||
Reference in new issue
Block a user