fix: 🐛 permissions (#2269)

* fix: 🐛 permissions
This commit is contained in:
Dharini Jeeva authored and GitHub committed 2024-04-24 11:04:11 -07:00
1 parent bd394d9517
commit bedcdee048
7 files changed
+54 -84

No files matched your search

@@ -17,13 +17,12 @@ module('Acceptance | targets | manage-alias', function (hooks) {
let aliasResourceTwo, aliasResourceOne, getAliasCount;
const ALIASES_SIDEBAR = '.target-sidebar-aliases';
const ALIASES_SIDEBAR_LIST = '.link-list-item';
const DROPDOWN_BUTTON_SELECTOR = '.hds-dropdown-toggle-icon';
const DROPDOWN_ITEM_SELECTOR = '.hds-dropdown-list-item a';
const DROPDOWN_ACTION = '.hds-dropdown-toggle-button__text';
const CLEAR_BTN_SELECTOR = '.hds-dropdown-list-item--color-action button';
const DELETE_BTN_SELECTOR = '.hds-dropdown-list-item--color-critical button';
const LINK_TO_NEW_ALIAS = '.target-sidebar-aliases .hds-button';
const DEST_FIELD_SELECTOR = '[name="destination_id"]';
const ITEM_SELECTOR = '.link-list-item a';
const instances = {
scopes: {
@@ -33,6 +32,7 @@ module('Acceptance | targets | manage-alias', function (hooks) {
},
sshTarget: null,
tcpTarget: null,
alias: null,
};
const urls = {
globalScope: null,
@@ -97,13 +97,8 @@ module('Acceptance | targets | manage-alias', function (hooks) {
await visit(urls.tcpTarget);
assert.dom(ALIASES_SIDEBAR).exists();
assert.dom(ALIASES_SIDEBAR_LIST).exists();
await click(ITEM_SELECTOR);
await click(DROPDOWN_BUTTON_SELECTOR);
assert.dom(DROPDOWN_ITEM_SELECTOR).exists();
assert.dom(DROPDOWN_ITEM_SELECTOR).hasText('Manage');
await click(DROPDOWN_ITEM_SELECTOR);
assert.strictEqual(currentURL(), urls.tcpAlias);
await a11yAudit();
});
@@ -115,12 +110,9 @@ module('Acceptance | targets | manage-alias', function (hooks) {
await visit(urls.tcpTarget);
assert.dom(ALIASES_SIDEBAR).exists();
assert.dom(ALIASES_SIDEBAR_LIST).exists();
await click(DROPDOWN_BUTTON_SELECTOR);
assert.dom(DROPDOWN_ITEM_SELECTOR).exists();
assert.dom(DROPDOWN_ITEM_SELECTOR).hasText('Manage');
await click(ITEM_SELECTOR);
await click(DROPDOWN_ITEM_SELECTOR);
assert.strictEqual(currentURL(), urls.tcpAlias);
await click(DROPDOWN_ACTION);
@@ -144,12 +136,9 @@ module('Acceptance | targets | manage-alias', function (hooks) {
await visit(urls.tcpTarget);
assert.dom(ALIASES_SIDEBAR).exists();
assert.dom(ALIASES_SIDEBAR_LIST).exists();
await click(DROPDOWN_BUTTON_SELECTOR);
assert.dom(DROPDOWN_ITEM_SELECTOR).exists();
assert.dom(DROPDOWN_ITEM_SELECTOR).hasText('Manage');
await click(ITEM_SELECTOR);
await click(DROPDOWN_ITEM_SELECTOR);
assert.dom(DEST_FIELD_SELECTOR).doesNotHaveAttribute('readOnly');
assert.strictEqual(currentURL(), urls.tcpAlias);
+16 -18
View File
@@ -29,8 +29,6 @@ module('Acceptance | targets | read', function (hooks) {
const LINK_TO_NEW_ALIAS = '.target-sidebar-aliases .hds-button';
const VIEW_MORE_BTN = '[data-test-view-more]';
const FLYOUT_COMPONENT = '[data-test-flyout]';
const DROPDOWN_BUTTON_SELECTOR = '.hds-dropdown-toggle-icon';
const DROPDOWN_ITEM_SELECTOR = '.hds-dropdown-list-item a';
const instances = {
scopes: {
@@ -40,6 +38,7 @@ module('Acceptance | targets | read', function (hooks) {
},
sshTarget: null,
tcpTarget: null,
alias: null,
};
const urls = {
globalScope: null,
@@ -75,6 +74,7 @@ module('Acceptance | targets | read', function (hooks) {
instances.alias = this.server.createList('alias', 1, {
scope: instances.scopes.global,
value: 'alias 1',
});
aliasResource = instances.alias[0];
@@ -213,7 +213,7 @@ module('Acceptance | targets | read', function (hooks) {
test('can view aliases on the right sidebar', async function (assert) {
instances.tcpTarget.update({
aliases: [{ id: aliasResource.id, value: 'alias 1' }],
aliases: [{ id: aliasResource.id, value: aliasResource.value }],
});
await visit(urls.tcpTarget);
assert.dom(ALIASES_SIDEBAR).exists();
@@ -225,12 +225,25 @@ module('Acceptance | targets | read', function (hooks) {
});
test('cannot view aliases list on the right sidebar if there is no alias associated with the target', async function (assert) {
aliasResource.authorized_collection_actions = ['create'];
await visit(urls.tcpTarget);
assert.dom(ALIASES_SIDEBAR).exists();
assert.dom(LINK_TO_NEW_ALIAS).hasText('Add an alias');
assert.dom(ALIASES_SIDEBAR_LIST).doesNotExist();
});
test('user should not see add a new alias button without proper auth ', async function (assert) {
instances.scopes.global.authorized_collection_actions['aliases'] =
instances.scopes.global.authorized_collection_actions['aliases'].filter(
(item) => item !== 'create',
);
await visit(urls.tcpTarget);
assert.dom(ALIASES_SIDEBAR).doesNotExist();
assert.dom(LINK_TO_NEW_ALIAS).doesNotExist();
assert.dom(ALIASES_SIDEBAR_LIST).doesNotExist();
});
test('can click `view more aliases` to see the remaining associated aliases if there are more than 3', async function (assert) {
instances.tcpTarget.update({
aliases: [
@@ -247,19 +260,4 @@ module('Acceptance | targets | read', function (hooks) {
await click(VIEW_MORE_BTN);
assert.dom(FLYOUT_COMPONENT).exists();
});
test('users can click on associated alias card on the right sidebar', async function (assert) {
instances.tcpTarget.update({
aliases: [{ id: aliasResource.id, value: aliasResource.value }],
});
await visit(urls.tcpTarget);
assert.dom(ALIASES_SIDEBAR_LIST).exists();
await click(DROPDOWN_BUTTON_SELECTOR);
assert.dom(DROPDOWN_ITEM_SELECTOR).exists();
assert.dom(DROPDOWN_ITEM_SELECTOR).hasText('Manage');
await click(DROPDOWN_ITEM_SELECTOR);
assert.strictEqual(currentURL(), urls.alias);
});
});