test: 💍 Refactor test selectors for targets credential sources (#2890)
* test: 💍 Refactor test selectors for targets credential sources ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-16432
This commit is contained in:
1 parent
c1f7fe2ddd
commit
10c98c66e7
5 files changed
+343
-235
No files matched your search
@@ -26,7 +26,7 @@
|
||||
>
|
||||
<:body as |B|>
|
||||
<B.Tr>
|
||||
<B.Td>
|
||||
<B.Td data-test-credential-source={{B.data.type}}>
|
||||
<Hds::Form::Checkbox::Field
|
||||
{{on 'change' (fn this.toggleCredentialSource B.data.id)}}
|
||||
as |F|
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@
|
||||
>
|
||||
<:body as |B|>
|
||||
<B.Tr>
|
||||
<B.Td>
|
||||
<B.Td data-test-credential-source={{B.data.type}}>
|
||||
<Hds::Form::Checkbox::Field
|
||||
{{on 'change' (fn this.toggleCredentialSource B.data.id)}}
|
||||
as |F|
|
||||
|
||||
@@ -4,13 +4,16 @@
|
||||
*/
|
||||
|
||||
import { module, test } from 'qunit';
|
||||
import { visit, findAll, click, currentURL } from '@ember/test-helpers';
|
||||
import { visit, click, currentURL } from '@ember/test-helpers';
|
||||
import { setupApplicationTest } from 'admin/tests/helpers';
|
||||
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
|
||||
import { Response } from 'miragejs';
|
||||
import a11yAudit from 'ember-a11y-testing/test-support/audit';
|
||||
import { authenticateSession } from 'ember-simple-auth/test-support';
|
||||
import * as commonSelectors from 'admin/tests/helpers/selectors';
|
||||
import * as selectors from './selectors';
|
||||
import { TYPE_CREDENTIAL_USERNAME_PASSWORD } from 'api/models/credential';
|
||||
import { TYPE_CREDENTIAL_LIBRARY_VAULT_GENERIC } from 'api/models/credential-library';
|
||||
|
||||
module('Acceptance | targets | brokered credential sources', function (hooks) {
|
||||
setupApplicationTest(hooks);
|
||||
@@ -124,14 +127,19 @@ module('Acceptance | targets | brokered credential sources', function (hooks) {
|
||||
test('visiting target brokered credential sources', async function (assert) {
|
||||
await visit(urls.brokeredCredentialSources);
|
||||
await a11yAudit();
|
||||
|
||||
assert.strictEqual(currentURL(), urls.brokeredCredentialSources);
|
||||
assert.strictEqual(findAll('tbody tr').length, credentialSourceCount);
|
||||
assert
|
||||
.dom(commonSelectors.TABLE_ROWS)
|
||||
.isVisible({ count: credentialSourceCount });
|
||||
});
|
||||
|
||||
test('can navigate to a vault type credential library', async function (assert) {
|
||||
await visit(urls.brokeredCredentialSources);
|
||||
await click('main tbody tr .hds-table__td:nth-child(1) a');
|
||||
|
||||
await click(commonSelectors.TABLE_RESOURCE_LINK(urls.credentialLibrary));
|
||||
await a11yAudit();
|
||||
|
||||
assert.strictEqual(currentURL(), urls.credentialLibrary);
|
||||
});
|
||||
|
||||
@@ -140,8 +148,10 @@ module('Acceptance | targets | brokered credential sources', function (hooks) {
|
||||
brokeredCredentialSourceIds: [...randomlySelectedCredentials],
|
||||
});
|
||||
await visit(urls.brokeredCredentialSources);
|
||||
await click('main tbody tr .hds-table__td:nth-child(1) a');
|
||||
|
||||
await click(commonSelectors.TABLE_RESOURCE_LINK(urls.credential));
|
||||
await a11yAudit();
|
||||
|
||||
assert.strictEqual(currentURL(), urls.credential);
|
||||
});
|
||||
|
||||
@@ -151,14 +161,16 @@ module('Acceptance | targets | brokered credential sources', function (hooks) {
|
||||
brokeredCredentialSourceIds: [...randomlySelectedCredentials],
|
||||
});
|
||||
await visit(urls.brokeredCredentialSources);
|
||||
|
||||
assert.false(featuresService.isEnabled('json-credentials'));
|
||||
assert.dom('.hds-table__tr:nth-child(3)').includesText(jsonCredential.name);
|
||||
assert.dom(`[href="${urls.jsonCredential}"]`).doesNotExist();
|
||||
assert.dom(commonSelectors.TABLE_ROW(3)).includesText(jsonCredential.name);
|
||||
assert.dom(commonSelectors.HREF(urls.jsonCredential)).doesNotExist();
|
||||
});
|
||||
|
||||
test('visiting add brokered credential sources', async function (assert) {
|
||||
await visit(urls.addBrokeredCredentialSources);
|
||||
await a11yAudit();
|
||||
|
||||
assert.strictEqual(currentURL(), urls.addBrokeredCredentialSources);
|
||||
});
|
||||
|
||||
@@ -167,8 +179,11 @@ module('Acceptance | targets | brokered credential sources', function (hooks) {
|
||||
brokeredCredentialSourceIds: [],
|
||||
});
|
||||
await visit(urls.addBrokeredCredentialSources);
|
||||
assert.strictEqual(findAll('tbody tr').length, credentialSourceCount);
|
||||
assert.dom('.hds-application-state__title').doesNotExist();
|
||||
|
||||
assert
|
||||
.dom(commonSelectors.TABLE_ROWS)
|
||||
.isVisible({ count: credentialSourceCount });
|
||||
assert.dom(commonSelectors.PAGE_MESSAGE_HEADER).doesNotExist();
|
||||
});
|
||||
|
||||
test('displays list of brokered credential sources with only credential libraries available', async function (assert) {
|
||||
@@ -176,14 +191,18 @@ module('Acceptance | targets | brokered credential sources', function (hooks) {
|
||||
brokeredCredentialSourceIds: [...randomlySelectedCredentials],
|
||||
});
|
||||
await visit(urls.addBrokeredCredentialSources);
|
||||
assert.strictEqual(findAll('tbody tr').length, getCredentialLibraryCount());
|
||||
assert.dom('.hds-application-state__title').doesNotExist();
|
||||
|
||||
assert
|
||||
.dom(commonSelectors.TABLE_ROWS)
|
||||
.isVisible({ count: getCredentialLibraryCount() });
|
||||
assert.dom(commonSelectors.PAGE_MESSAGE_HEADER).doesNotExist();
|
||||
});
|
||||
|
||||
test('displays no brokered credential sources message when none available', async function (assert) {
|
||||
await visit(urls.addBrokeredCredentialSources);
|
||||
|
||||
assert
|
||||
.dom('.hds-application-state__title')
|
||||
.dom(commonSelectors.PAGE_MESSAGE_HEADER)
|
||||
.hasText('No Brokered Credential Sources Available');
|
||||
});
|
||||
|
||||
@@ -192,53 +211,80 @@ module('Acceptance | targets | brokered credential sources', function (hooks) {
|
||||
brokeredCredentialSourceIds: [],
|
||||
});
|
||||
await visit(urls.brokeredCredentialSources);
|
||||
|
||||
// Click on the rose message link
|
||||
await click('.hds-application-state__footer .hds-link-standalone');
|
||||
await click(commonSelectors.PAGE_MESSAGE_LINK);
|
||||
|
||||
assert.strictEqual(currentURL(), urls.addBrokeredCredentialSources);
|
||||
});
|
||||
|
||||
test('can select and save a vault type credential library to add', async function (assert) {
|
||||
instances.target.update({
|
||||
brokeredCredentialSourceIds: [],
|
||||
});
|
||||
await visit(urls.brokeredCredentialSources);
|
||||
assert.strictEqual(findAll('tbody tr').length, 0);
|
||||
await visit(urls.addBrokeredCredentialSources);
|
||||
assert.strictEqual(findAll('tbody tr').length, credentialSourceCount);
|
||||
await click('tbody tr:first-child label');
|
||||
await click('form [type="submit"]');
|
||||
assert.strictEqual(currentURL(), urls.brokeredCredentialSources);
|
||||
assert.strictEqual(findAll('tbody tr').length, 1);
|
||||
});
|
||||
test.each(
|
||||
'can select credential sources',
|
||||
{
|
||||
'save vault generic credential-library': {
|
||||
credentialSources: [TYPE_CREDENTIAL_LIBRARY_VAULT_GENERIC],
|
||||
action: commonSelectors.SAVE_BTN,
|
||||
expectedCount: 1,
|
||||
},
|
||||
'save username and password credential': {
|
||||
credentialSources: [TYPE_CREDENTIAL_USERNAME_PASSWORD],
|
||||
action: commonSelectors.SAVE_BTN,
|
||||
expectedCount: 1,
|
||||
},
|
||||
'save credentials and credential-libraries': {
|
||||
credentialSources: [
|
||||
TYPE_CREDENTIAL_USERNAME_PASSWORD,
|
||||
TYPE_CREDENTIAL_LIBRARY_VAULT_GENERIC,
|
||||
],
|
||||
action: commonSelectors.SAVE_BTN,
|
||||
expectedCount: 2,
|
||||
},
|
||||
'cancel vault generic credential-library': {
|
||||
credentialSources: [TYPE_CREDENTIAL_LIBRARY_VAULT_GENERIC],
|
||||
action: commonSelectors.CANCEL_BTN,
|
||||
expectedCount: 0,
|
||||
},
|
||||
'cancel username and password credential': {
|
||||
credentialSources: [TYPE_CREDENTIAL_USERNAME_PASSWORD],
|
||||
action: commonSelectors.CANCEL_BTN,
|
||||
expectedCount: 0,
|
||||
},
|
||||
'cancel credentials and credential-libraries': {
|
||||
credentialSources: [
|
||||
TYPE_CREDENTIAL_USERNAME_PASSWORD,
|
||||
TYPE_CREDENTIAL_LIBRARY_VAULT_GENERIC,
|
||||
],
|
||||
action: commonSelectors.CANCEL_BTN,
|
||||
expectedCount: 0,
|
||||
},
|
||||
},
|
||||
async function (assert, input) {
|
||||
instances.target.update({
|
||||
brokeredCredentialSourceIds: [],
|
||||
});
|
||||
await visit(urls.brokeredCredentialSources);
|
||||
|
||||
test('can select and save a username & password type credential to add', async function (assert) {
|
||||
instances.target.update({
|
||||
brokeredCredentialSourceIds: [],
|
||||
});
|
||||
await visit(urls.brokeredCredentialSources);
|
||||
assert.strictEqual(findAll('tbody tr').length, 0);
|
||||
await visit(urls.addBrokeredCredentialSources);
|
||||
assert.strictEqual(findAll('tbody tr').length, credentialSourceCount);
|
||||
await click('tbody tr:last-child label');
|
||||
await click('form [type="submit"]');
|
||||
assert.strictEqual(currentURL(), urls.brokeredCredentialSources);
|
||||
assert.strictEqual(findAll('tbody tr').length, 1);
|
||||
});
|
||||
assert.dom(commonSelectors.TABLE_ROWS).isVisible({ count: 0 });
|
||||
|
||||
test('can select and save both a credential-library and a credential to add', async function (assert) {
|
||||
instances.target.update({
|
||||
brokeredCredentialSourceIds: [],
|
||||
});
|
||||
await visit(urls.brokeredCredentialSources);
|
||||
assert.strictEqual(findAll('tbody tr').length, 0);
|
||||
await visit(urls.addBrokeredCredentialSources);
|
||||
assert.strictEqual(findAll('tbody tr').length, credentialSourceCount);
|
||||
await click('tbody tr:last-child label');
|
||||
await click('tbody tr:first-child label');
|
||||
await click('form [type="submit"]');
|
||||
assert.strictEqual(currentURL(), urls.brokeredCredentialSources);
|
||||
assert.strictEqual(findAll('tbody tr').length, 2);
|
||||
});
|
||||
await click(selectors.MANAGE_DROPDOWN);
|
||||
await click(selectors.MANGE_DROPDOWN_ADD_BROKERED_CREDENTIALS);
|
||||
|
||||
assert.strictEqual(currentURL(), urls.addBrokeredCredentialSources);
|
||||
assert
|
||||
.dom(commonSelectors.TABLE_ROWS)
|
||||
.isVisible({ count: credentialSourceCount });
|
||||
|
||||
for (const type of input.credentialSources) {
|
||||
await click(selectors.TABLE_CREDENTIAL_SOURCE_CHECKBOX(type));
|
||||
}
|
||||
await click(input.action);
|
||||
|
||||
assert.strictEqual(currentURL(), urls.brokeredCredentialSources);
|
||||
assert
|
||||
.dom(commonSelectors.TABLE_ROWS)
|
||||
.isVisible({ count: input.expectedCount });
|
||||
},
|
||||
);
|
||||
|
||||
test('cannot add credential sources without proper authorization', async function (assert) {
|
||||
instances.target.authorized_actions =
|
||||
@@ -246,36 +292,12 @@ module('Acceptance | targets | brokered credential sources', function (hooks) {
|
||||
(item) => item !== 'add-credential-sources',
|
||||
);
|
||||
await visit(urls.brokeredCredentialSources);
|
||||
assert.dom('[data-test-add-brokered-cred-sources-action]').doesNotExist();
|
||||
});
|
||||
|
||||
test('can select and cancel credential sources to add', async function (assert) {
|
||||
instances.target.update({
|
||||
brokeredCredentialSourceIds: [],
|
||||
});
|
||||
await visit(urls.brokeredCredentialSources);
|
||||
assert.strictEqual(findAll('tbody tr').length, 0);
|
||||
await visit(urls.addBrokeredCredentialSources);
|
||||
assert.strictEqual(findAll('tbody tr').length, credentialSourceCount);
|
||||
await click('tbody label');
|
||||
await click('form [type="button"]');
|
||||
assert.strictEqual(currentURL(), urls.brokeredCredentialSources);
|
||||
assert.strictEqual(findAll('tbody tr').length, 0);
|
||||
});
|
||||
await click(selectors.MANAGE_DROPDOWN);
|
||||
|
||||
test('can select multiple brokered credential sources to add and cancel', async function (assert) {
|
||||
instances.target.update({
|
||||
brokeredCredentialSourceIds: [],
|
||||
});
|
||||
await visit(urls.brokeredCredentialSources);
|
||||
assert.strictEqual(findAll('tbody tr').length, 0);
|
||||
await visit(urls.addBrokeredCredentialSources);
|
||||
assert.strictEqual(findAll('tbody tr').length, credentialSourceCount);
|
||||
await click('tbody tr:last-child label');
|
||||
await click('tbody tr:first-child label');
|
||||
await click('form [type="button"]');
|
||||
assert.strictEqual(currentURL(), urls.brokeredCredentialSources);
|
||||
assert.strictEqual(findAll('tbody tr').length, 0);
|
||||
assert
|
||||
.dom(selectors.MANGE_DROPDOWN_ADD_BROKERED_CREDENTIALS)
|
||||
.doesNotExist();
|
||||
});
|
||||
|
||||
test('adding credential sources which errors displays error message', async function (assert) {
|
||||
@@ -295,9 +317,19 @@ module('Acceptance | targets | brokered credential sources', function (hooks) {
|
||||
brokeredCredentialSourceIds: [],
|
||||
});
|
||||
await visit(urls.addBrokeredCredentialSources);
|
||||
await click('tbody tr:last-child label');
|
||||
await click('tbody tr:first-child label');
|
||||
await click('form [type="submit"]');
|
||||
|
||||
await click(
|
||||
selectors.TABLE_CREDENTIAL_SOURCE_CHECKBOX(
|
||||
TYPE_CREDENTIAL_LIBRARY_VAULT_GENERIC,
|
||||
),
|
||||
);
|
||||
await click(
|
||||
selectors.TABLE_CREDENTIAL_SOURCE_CHECKBOX(
|
||||
TYPE_CREDENTIAL_USERNAME_PASSWORD,
|
||||
),
|
||||
);
|
||||
await click(commonSelectors.SAVE_BTN);
|
||||
|
||||
assert.dom(commonSelectors.ALERT_TOAST_BODY).isVisible();
|
||||
});
|
||||
|
||||
@@ -308,15 +340,24 @@ module('Acceptance | targets | brokered credential sources', function (hooks) {
|
||||
const credentialLibraryCount = getCredentialLibraryCount();
|
||||
const availableCredentialsCount = getCredentialCount();
|
||||
await visit(urls.brokeredCredentialSources);
|
||||
assert.strictEqual(findAll('tbody tr').length, credentialLibraryCount);
|
||||
await click('tbody tr td:last-child .hds-dropdown-toggle-icon');
|
||||
await click('tbody tr .hds-dropdown-list-item button');
|
||||
assert.strictEqual(findAll('tbody tr').length, credentialLibraryCount - 1);
|
||||
await visit(urls.addBrokeredCredentialSources);
|
||||
assert.strictEqual(
|
||||
findAll('tbody tr').length,
|
||||
availableCredentialsCount + 1,
|
||||
);
|
||||
|
||||
assert
|
||||
.dom(commonSelectors.TABLE_ROWS)
|
||||
.isVisible({ count: credentialLibraryCount });
|
||||
|
||||
await click(commonSelectors.TABLE_FIRST_ROW_ACTION_DROPDOWN);
|
||||
await click(commonSelectors.TABLE_FIRST_ROW_ACTION_DROPDOWN_ITEM_BTN);
|
||||
|
||||
assert
|
||||
.dom(commonSelectors.TABLE_ROWS)
|
||||
.isVisible({ count: credentialLibraryCount - 1 });
|
||||
|
||||
await click(selectors.MANAGE_DROPDOWN);
|
||||
await click(selectors.MANGE_DROPDOWN_ADD_BROKERED_CREDENTIALS);
|
||||
|
||||
assert
|
||||
.dom(commonSelectors.TABLE_ROWS)
|
||||
.isVisible({ count: availableCredentialsCount + 1 });
|
||||
});
|
||||
|
||||
test('can remove a username & password type credential', async function (assert) {
|
||||
@@ -326,15 +367,24 @@ module('Acceptance | targets | brokered credential sources', function (hooks) {
|
||||
const credentialCount = getCredentialCount();
|
||||
const availableCredentialsCount = getCredentialLibraryCount();
|
||||
await visit(urls.brokeredCredentialSources);
|
||||
assert.strictEqual(findAll('tbody tr').length, credentialCount);
|
||||
await click('tbody tr td:last-child .hds-dropdown-toggle-icon');
|
||||
await click('tbody tr .hds-dropdown-list-item button');
|
||||
assert.strictEqual(findAll('tbody tr').length, credentialCount - 1);
|
||||
await visit(urls.addBrokeredCredentialSources);
|
||||
assert.strictEqual(
|
||||
findAll('tbody tr').length,
|
||||
availableCredentialsCount + 1,
|
||||
);
|
||||
|
||||
assert
|
||||
.dom(commonSelectors.TABLE_ROWS)
|
||||
.isVisible({ count: credentialCount });
|
||||
|
||||
await click(commonSelectors.TABLE_FIRST_ROW_ACTION_DROPDOWN);
|
||||
await click(commonSelectors.TABLE_FIRST_ROW_ACTION_DROPDOWN_ITEM_BTN);
|
||||
|
||||
assert
|
||||
.dom(commonSelectors.TABLE_ROWS)
|
||||
.isVisible({ count: credentialCount - 1 });
|
||||
|
||||
await click(selectors.MANAGE_DROPDOWN);
|
||||
await click(selectors.MANGE_DROPDOWN_ADD_BROKERED_CREDENTIALS);
|
||||
|
||||
assert
|
||||
.dom(commonSelectors.TABLE_ROWS)
|
||||
.isVisible({ count: availableCredentialsCount + 1 });
|
||||
});
|
||||
|
||||
test('cannot remove credential libraries without proper authorization', async function (assert) {
|
||||
@@ -343,7 +393,8 @@ module('Acceptance | targets | brokered credential sources', function (hooks) {
|
||||
(item) => item !== 'remove-credential-sources',
|
||||
);
|
||||
await visit(urls.brokeredCredentialSources);
|
||||
assert.dom('tbody tr .hds-dropdown-list-item button').doesNotExist();
|
||||
|
||||
assert.dom(commonSelectors.TABLE_FIRST_ROW_ACTION_DROPDOWN).doesNotExist();
|
||||
});
|
||||
|
||||
test('removing a target credential library which errors displays error messages', async function (assert) {
|
||||
@@ -364,9 +415,12 @@ module('Acceptance | targets | brokered credential sources', function (hooks) {
|
||||
});
|
||||
const count = getCredentialLibraryCount();
|
||||
await visit(urls.brokeredCredentialSources);
|
||||
assert.strictEqual(findAll('tbody tr').length, count);
|
||||
await click('tbody tr td:last-child .hds-dropdown-toggle-icon');
|
||||
await click('tbody tr .hds-dropdown-list-item button');
|
||||
|
||||
assert.dom(commonSelectors.TABLE_ROWS).isVisible({ count });
|
||||
|
||||
await click(commonSelectors.TABLE_FIRST_ROW_ACTION_DROPDOWN);
|
||||
await click(commonSelectors.TABLE_FIRST_ROW_ACTION_DROPDOWN_ITEM_BTN);
|
||||
|
||||
assert.dom(commonSelectors.ALERT_TOAST_BODY).isVisible();
|
||||
});
|
||||
|
||||
@@ -388,9 +442,12 @@ module('Acceptance | targets | brokered credential sources', function (hooks) {
|
||||
});
|
||||
const count = getCredentialCount();
|
||||
await visit(urls.brokeredCredentialSources);
|
||||
assert.strictEqual(findAll('tbody tr').length, count);
|
||||
await click('tbody tr td:last-child .hds-dropdown-toggle-icon');
|
||||
await click('tbody tr .hds-dropdown-list-item button');
|
||||
|
||||
assert.dom(commonSelectors.TABLE_ROWS).isVisible({ count });
|
||||
|
||||
await click(commonSelectors.TABLE_FIRST_ROW_ACTION_DROPDOWN);
|
||||
await click(commonSelectors.TABLE_FIRST_ROW_ACTION_DROPDOWN_ITEM_BTN);
|
||||
|
||||
assert.dom(commonSelectors.ALERT_TOAST_BODY).isVisible();
|
||||
});
|
||||
});
|
||||
+170
-125
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
import { module, test } from 'qunit';
|
||||
import { visit, findAll, click, currentURL } from '@ember/test-helpers';
|
||||
import { visit, click, currentURL } from '@ember/test-helpers';
|
||||
import { setupApplicationTest } from 'admin/tests/helpers';
|
||||
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
|
||||
import { Response } from 'miragejs';
|
||||
@@ -12,6 +12,9 @@ import a11yAudit from 'ember-a11y-testing/test-support/audit';
|
||||
import { authenticateSession } from 'ember-simple-auth/test-support';
|
||||
import { TYPE_TARGET_SSH } from 'api/models/target';
|
||||
import * as commonSelectors from 'admin/tests/helpers/selectors';
|
||||
import * as selectors from './selectors';
|
||||
import { TYPE_CREDENTIAL_USERNAME_PASSWORD } from 'api/models/credential';
|
||||
import { TYPE_CREDENTIAL_LIBRARY_VAULT_GENERIC } from 'api/models/credential-library';
|
||||
|
||||
module(
|
||||
'Acceptance | targets | injected application credential sources',
|
||||
@@ -123,17 +126,22 @@ module(
|
||||
test('visiting target injected application credential sources', async function (assert) {
|
||||
await visit(urls.injectedApplicationCredentialSources);
|
||||
await a11yAudit();
|
||||
|
||||
assert.strictEqual(
|
||||
currentURL(),
|
||||
urls.injectedApplicationCredentialSources,
|
||||
);
|
||||
assert.strictEqual(findAll('tbody tr').length, credentialSourceCount);
|
||||
assert
|
||||
.dom(commonSelectors.TABLE_ROWS)
|
||||
.isVisible({ count: credentialSourceCount });
|
||||
});
|
||||
|
||||
test('can navigate to a vault type credential library', async function (assert) {
|
||||
await visit(urls.injectedApplicationCredentialSources);
|
||||
await click('main tbody tr .hds-table__td:nth-child(1) a');
|
||||
|
||||
await click(commonSelectors.TABLE_RESOURCE_LINK(urls.credentialLibrary));
|
||||
await a11yAudit();
|
||||
|
||||
assert.strictEqual(currentURL(), urls.credentialLibrary);
|
||||
});
|
||||
|
||||
@@ -144,14 +152,17 @@ module(
|
||||
],
|
||||
});
|
||||
await visit(urls.injectedApplicationCredentialSources);
|
||||
await click('main tbody tr .hds-table__td:nth-child(1) a');
|
||||
|
||||
await click(commonSelectors.TABLE_RESOURCE_LINK(urls.credential));
|
||||
await a11yAudit();
|
||||
|
||||
assert.strictEqual(currentURL(), urls.credential);
|
||||
});
|
||||
|
||||
test('visiting add injected application credential sources', async function (assert) {
|
||||
await visit(urls.addInjectedApplicationCredentialSources);
|
||||
await a11yAudit();
|
||||
|
||||
assert.strictEqual(
|
||||
currentURL(),
|
||||
urls.addInjectedApplicationCredentialSources,
|
||||
@@ -163,8 +174,11 @@ module(
|
||||
injectedApplicationCredentialSourceIds: [],
|
||||
});
|
||||
await visit(urls.addInjectedApplicationCredentialSources);
|
||||
assert.strictEqual(findAll('tbody tr').length, credentialSourceCount);
|
||||
assert.dom('.hds-application-state__title').doesNotExist();
|
||||
|
||||
assert
|
||||
.dom(commonSelectors.TABLE_ROWS)
|
||||
.isVisible({ count: credentialSourceCount });
|
||||
assert.dom(commonSelectors.PAGE_MESSAGE_HEADER).doesNotExist();
|
||||
});
|
||||
|
||||
test('displays list of injected application credential sources with only credential libraries available', async function (assert) {
|
||||
@@ -174,17 +188,18 @@ module(
|
||||
],
|
||||
});
|
||||
await visit(urls.addInjectedApplicationCredentialSources);
|
||||
assert.strictEqual(
|
||||
findAll('tbody tr').length,
|
||||
getCredentialLibraryCount(),
|
||||
);
|
||||
assert.dom('.hds-application-state__title').doesNotExist();
|
||||
|
||||
assert
|
||||
.dom(commonSelectors.TABLE_ROWS)
|
||||
.isVisible({ count: getCredentialLibraryCount() });
|
||||
assert.dom(commonSelectors.PAGE_MESSAGE_HEADER).doesNotExist();
|
||||
});
|
||||
|
||||
test('displays no injected application credential sources message when none available', async function (assert) {
|
||||
await visit(urls.addInjectedApplicationCredentialSources);
|
||||
|
||||
assert
|
||||
.dom('.hds-application-state__title')
|
||||
.dom(commonSelectors.PAGE_MESSAGE_HEADER)
|
||||
.hasText('No Injected Application Credential Sources Available');
|
||||
});
|
||||
|
||||
@@ -193,65 +208,89 @@ module(
|
||||
injectedApplicationCredentialSourceIds: [],
|
||||
});
|
||||
await visit(urls.injectedApplicationCredentialSources);
|
||||
|
||||
// Click on the rose message link
|
||||
await click('.hds-application-state__footer .hds-link-standalone');
|
||||
await click(commonSelectors.PAGE_MESSAGE_LINK);
|
||||
|
||||
assert.strictEqual(
|
||||
currentURL(),
|
||||
urls.addInjectedApplicationCredentialSources,
|
||||
);
|
||||
});
|
||||
|
||||
test('can select and save a vault type credential library to add', async function (assert) {
|
||||
instances.target.update({
|
||||
injectedApplicationCredentialSourceIds: [],
|
||||
});
|
||||
await visit(urls.injectedApplicationCredentialSources);
|
||||
assert.strictEqual(findAll('tbody tr').length, 0);
|
||||
await visit(urls.addInjectedApplicationCredentialSources);
|
||||
assert.strictEqual(findAll('tbody tr').length, credentialSourceCount);
|
||||
await click('tbody tr:first-child label');
|
||||
await click('form [type="submit"]');
|
||||
assert.strictEqual(
|
||||
currentURL(),
|
||||
urls.injectedApplicationCredentialSources,
|
||||
);
|
||||
assert.strictEqual(findAll('tbody tr').length, 1);
|
||||
});
|
||||
test.each(
|
||||
'can select credential sources',
|
||||
{
|
||||
'save vault generic credential-library': {
|
||||
credentialSources: [TYPE_CREDENTIAL_LIBRARY_VAULT_GENERIC],
|
||||
action: commonSelectors.SAVE_BTN,
|
||||
expectedCount: 1,
|
||||
},
|
||||
'save username and password credential': {
|
||||
credentialSources: [TYPE_CREDENTIAL_USERNAME_PASSWORD],
|
||||
action: commonSelectors.SAVE_BTN,
|
||||
expectedCount: 1,
|
||||
},
|
||||
'save credentials and credential-libraries': {
|
||||
credentialSources: [
|
||||
TYPE_CREDENTIAL_USERNAME_PASSWORD,
|
||||
TYPE_CREDENTIAL_LIBRARY_VAULT_GENERIC,
|
||||
],
|
||||
action: commonSelectors.SAVE_BTN,
|
||||
expectedCount: 2,
|
||||
},
|
||||
'cancel vault generic credential-library': {
|
||||
credentialSources: [TYPE_CREDENTIAL_LIBRARY_VAULT_GENERIC],
|
||||
action: commonSelectors.CANCEL_BTN,
|
||||
expectedCount: 0,
|
||||
},
|
||||
'cancel username and password credential': {
|
||||
credentialSources: [TYPE_CREDENTIAL_USERNAME_PASSWORD],
|
||||
action: commonSelectors.CANCEL_BTN,
|
||||
expectedCount: 0,
|
||||
},
|
||||
'cancel credentials and credential-libraries': {
|
||||
credentialSources: [
|
||||
TYPE_CREDENTIAL_USERNAME_PASSWORD,
|
||||
TYPE_CREDENTIAL_LIBRARY_VAULT_GENERIC,
|
||||
],
|
||||
action: commonSelectors.CANCEL_BTN,
|
||||
expectedCount: 0,
|
||||
},
|
||||
},
|
||||
async function (assert, input) {
|
||||
instances.target.update({
|
||||
injectedApplicationCredentialSourceIds: [],
|
||||
});
|
||||
await visit(urls.injectedApplicationCredentialSources);
|
||||
|
||||
test('can select and save a username & password type credential to add', async function (assert) {
|
||||
instances.target.update({
|
||||
injectedApplicationCredentialSourceIds: [],
|
||||
});
|
||||
await visit(urls.injectedApplicationCredentialSources);
|
||||
assert.strictEqual(findAll('tbody tr').length, 0);
|
||||
await visit(urls.addInjectedApplicationCredentialSources);
|
||||
assert.strictEqual(findAll('tbody tr').length, credentialSourceCount);
|
||||
await click('tbody tr:last-child label');
|
||||
await click('form [type="submit"]');
|
||||
assert.strictEqual(
|
||||
currentURL(),
|
||||
urls.injectedApplicationCredentialSources,
|
||||
);
|
||||
assert.strictEqual(findAll('tbody tr').length, 1);
|
||||
});
|
||||
assert.dom(commonSelectors.TABLE_ROWS).isVisible({ count: 0 });
|
||||
|
||||
test('can select and save both a credential-library and a credential to add', async function (assert) {
|
||||
instances.target.update({
|
||||
injectedApplicationCredentialSourceIds: [],
|
||||
});
|
||||
await visit(urls.injectedApplicationCredentialSources);
|
||||
assert.strictEqual(findAll('tbody tr').length, 0);
|
||||
await visit(urls.addInjectedApplicationCredentialSources);
|
||||
assert.strictEqual(findAll('tbody tr').length, credentialSourceCount);
|
||||
await click('tbody tr:last-child label');
|
||||
await click('tbody tr:first-child label');
|
||||
await click('form [type="submit"]');
|
||||
assert.strictEqual(
|
||||
currentURL(),
|
||||
urls.injectedApplicationCredentialSources,
|
||||
);
|
||||
assert.strictEqual(findAll('tbody tr').length, 2);
|
||||
});
|
||||
await click(selectors.MANAGE_DROPDOWN);
|
||||
await click(selectors.MANGE_DROPDOWN_ADD_INJECTED_CREDENTIALS);
|
||||
|
||||
assert.strictEqual(
|
||||
currentURL(),
|
||||
urls.addInjectedApplicationCredentialSources,
|
||||
);
|
||||
assert
|
||||
.dom(commonSelectors.TABLE_ROWS)
|
||||
.isVisible({ count: credentialSourceCount });
|
||||
|
||||
for (const type of input.credentialSources) {
|
||||
await click(selectors.TABLE_CREDENTIAL_SOURCE_CHECKBOX(type));
|
||||
}
|
||||
await click(input.action);
|
||||
|
||||
assert.strictEqual(
|
||||
currentURL(),
|
||||
urls.injectedApplicationCredentialSources,
|
||||
);
|
||||
assert
|
||||
.dom(commonSelectors.TABLE_ROWS)
|
||||
.isVisible({ count: input.expectedCount });
|
||||
},
|
||||
);
|
||||
|
||||
test('cannot add credential sources without proper authorization', async function (assert) {
|
||||
assert.expect(1);
|
||||
@@ -261,42 +300,11 @@ module(
|
||||
);
|
||||
await visit(urls.injectedApplicationCredentialSources);
|
||||
|
||||
assert.dom('[data-test-add-injected-cred-sources-action]').doesNotExist();
|
||||
});
|
||||
await click(selectors.MANAGE_DROPDOWN);
|
||||
|
||||
test('can select and cancel credential sources to add', async function (assert) {
|
||||
instances.target.update({
|
||||
injectedApplicationCredentialSourceIds: [],
|
||||
});
|
||||
await visit(urls.injectedApplicationCredentialSources);
|
||||
assert.strictEqual(findAll('tbody tr').length, 0);
|
||||
await visit(urls.addInjectedApplicationCredentialSources);
|
||||
assert.strictEqual(findAll('tbody tr').length, credentialSourceCount);
|
||||
await click('tbody label');
|
||||
await click('form [type="button"]');
|
||||
assert.strictEqual(
|
||||
currentURL(),
|
||||
urls.injectedApplicationCredentialSources,
|
||||
);
|
||||
assert.strictEqual(findAll('tbody tr').length, 0);
|
||||
});
|
||||
|
||||
test('can select multiple injected application credential sources to add and cancel', async function (assert) {
|
||||
instances.target.update({
|
||||
injectedApplicationCredentialSourceIds: [],
|
||||
});
|
||||
await visit(urls.injectedApplicationCredentialSources);
|
||||
assert.strictEqual(findAll('tbody tr').length, 0);
|
||||
await visit(urls.addInjectedApplicationCredentialSources);
|
||||
assert.strictEqual(findAll('tbody tr').length, credentialSourceCount);
|
||||
await click('tbody tr:last-child label');
|
||||
await click('tbody tr:first-child label');
|
||||
await click('form [type="button"]');
|
||||
assert.strictEqual(
|
||||
currentURL(),
|
||||
urls.injectedApplicationCredentialSources,
|
||||
);
|
||||
assert.strictEqual(findAll('tbody tr').length, 0);
|
||||
assert
|
||||
.dom(selectors.MANGE_DROPDOWN_ADD_INJECTED_CREDENTIALS)
|
||||
.doesNotExist();
|
||||
});
|
||||
|
||||
test('adding credential sources which errors displays error message', async function (assert) {
|
||||
@@ -316,9 +324,19 @@ module(
|
||||
injectedApplicationCredentialSourceIds: [],
|
||||
});
|
||||
await visit(urls.addInjectedApplicationCredentialSources);
|
||||
await click('tbody tr:last-child label');
|
||||
await click('tbody tr:first-child label');
|
||||
await click('form [type="submit"]');
|
||||
|
||||
await click(
|
||||
selectors.TABLE_CREDENTIAL_SOURCE_CHECKBOX(
|
||||
TYPE_CREDENTIAL_LIBRARY_VAULT_GENERIC,
|
||||
),
|
||||
);
|
||||
await click(
|
||||
selectors.TABLE_CREDENTIAL_SOURCE_CHECKBOX(
|
||||
TYPE_CREDENTIAL_USERNAME_PASSWORD,
|
||||
),
|
||||
);
|
||||
await click(commonSelectors.SAVE_BTN);
|
||||
|
||||
assert.dom(commonSelectors.ALERT_TOAST_BODY).isVisible();
|
||||
});
|
||||
|
||||
@@ -330,18 +348,24 @@ module(
|
||||
});
|
||||
const credentialLibraryCount = getCredentialLibraryCount();
|
||||
await visit(urls.injectedApplicationCredentialSources);
|
||||
assert.strictEqual(findAll('tbody tr').length, credentialLibraryCount);
|
||||
await click('tbody tr td:last-child .hds-dropdown-toggle-icon');
|
||||
await click('tbody tr .hds-dropdown-list-item button');
|
||||
assert.strictEqual(
|
||||
findAll('tbody tr').length,
|
||||
credentialLibraryCount - 1,
|
||||
);
|
||||
await visit(urls.addInjectedApplicationCredentialSources);
|
||||
assert.strictEqual(
|
||||
findAll('tbody tr').length,
|
||||
credentialLibraryCount + 1,
|
||||
);
|
||||
|
||||
assert
|
||||
.dom(commonSelectors.TABLE_ROWS)
|
||||
.isVisible({ count: credentialLibraryCount });
|
||||
|
||||
await click(commonSelectors.TABLE_FIRST_ROW_ACTION_DROPDOWN);
|
||||
await click(commonSelectors.TABLE_FIRST_ROW_ACTION_DROPDOWN_ITEM_BTN);
|
||||
|
||||
assert
|
||||
.dom(commonSelectors.TABLE_ROWS)
|
||||
.isVisible({ count: credentialLibraryCount - 1 });
|
||||
|
||||
await click(selectors.MANAGE_DROPDOWN);
|
||||
await click(selectors.MANGE_DROPDOWN_ADD_INJECTED_CREDENTIALS);
|
||||
|
||||
assert
|
||||
.dom(commonSelectors.TABLE_ROWS)
|
||||
.isVisible({ count: credentialLibraryCount + 1 });
|
||||
});
|
||||
|
||||
test('can remove a username & password type credential', async function (assert) {
|
||||
@@ -352,12 +376,24 @@ module(
|
||||
});
|
||||
const credentialCount = getCredentialCount();
|
||||
await visit(urls.injectedApplicationCredentialSources);
|
||||
assert.strictEqual(findAll('tbody tr').length, credentialCount);
|
||||
await click('tbody tr td:last-child .hds-dropdown-toggle-icon');
|
||||
await click('tbody tr .hds-dropdown-list-item button');
|
||||
assert.strictEqual(findAll('tbody tr').length, credentialCount - 1);
|
||||
await visit(urls.addInjectedApplicationCredentialSources);
|
||||
assert.strictEqual(findAll('tbody tr').length, credentialCount + 1);
|
||||
|
||||
assert
|
||||
.dom(commonSelectors.TABLE_ROWS)
|
||||
.isVisible({ count: credentialCount });
|
||||
|
||||
await click(commonSelectors.TABLE_FIRST_ROW_ACTION_DROPDOWN);
|
||||
await click(commonSelectors.TABLE_FIRST_ROW_ACTION_DROPDOWN_ITEM_BTN);
|
||||
|
||||
assert
|
||||
.dom(commonSelectors.TABLE_ROWS)
|
||||
.isVisible({ count: credentialCount - 1 });
|
||||
|
||||
await click(selectors.MANAGE_DROPDOWN);
|
||||
await click(selectors.MANGE_DROPDOWN_ADD_INJECTED_CREDENTIALS);
|
||||
|
||||
assert
|
||||
.dom(commonSelectors.TABLE_ROWS)
|
||||
.isVisible({ count: credentialCount + 1 });
|
||||
});
|
||||
|
||||
test('cannot remove credential libraries without proper authorization', async function (assert) {
|
||||
@@ -366,7 +402,10 @@ module(
|
||||
(item) => item !== 'remove-credential-sources',
|
||||
);
|
||||
await visit(urls.injectedApplicationCredentialSources);
|
||||
assert.dom(`tbody tr ${commonSelectors.DELETE_BTN}`).doesNotExist();
|
||||
|
||||
assert
|
||||
.dom(commonSelectors.TABLE_FIRST_ROW_ACTION_DROPDOWN)
|
||||
.doesNotExist();
|
||||
});
|
||||
|
||||
test('removing a target credential library which errors displays error messages', async function (assert) {
|
||||
@@ -389,9 +428,12 @@ module(
|
||||
});
|
||||
const count = getCredentialLibraryCount();
|
||||
await visit(urls.injectedApplicationCredentialSources);
|
||||
assert.strictEqual(findAll('tbody tr').length, count);
|
||||
await click('tbody tr td:last-child .hds-dropdown-toggle-icon');
|
||||
await click('tbody tr .hds-dropdown-list-item button');
|
||||
|
||||
assert.dom(commonSelectors.TABLE_ROWS).isVisible({ count });
|
||||
|
||||
await click(commonSelectors.TABLE_FIRST_ROW_ACTION_DROPDOWN);
|
||||
await click(commonSelectors.TABLE_FIRST_ROW_ACTION_DROPDOWN_ITEM_BTN);
|
||||
|
||||
assert.dom(commonSelectors.ALERT_TOAST_BODY).isVisible();
|
||||
});
|
||||
|
||||
@@ -415,9 +457,12 @@ module(
|
||||
});
|
||||
const count = getCredentialCount();
|
||||
await visit(urls.injectedApplicationCredentialSources);
|
||||
assert.strictEqual(findAll('tbody tr').length, count);
|
||||
await click('tbody tr td:last-child .hds-dropdown-toggle-icon');
|
||||
await click('tbody tr .hds-dropdown-list-item button');
|
||||
|
||||
assert.dom(commonSelectors.TABLE_ROWS).isVisible({ count });
|
||||
|
||||
await click(commonSelectors.TABLE_FIRST_ROW_ACTION_DROPDOWN);
|
||||
await click(commonSelectors.TABLE_FIRST_ROW_ACTION_DROPDOWN_ITEM_BTN);
|
||||
|
||||
assert.dom(commonSelectors.ALERT_TOAST_BODY).isVisible();
|
||||
});
|
||||
},
|
||||
|
||||
@@ -22,6 +22,10 @@ export const NEW_TARGET_BTN = '[data-test-new-target-button]';
|
||||
export const MANAGE_DROPDOWN = '[data-test-manage-targets-dropdown] button';
|
||||
export const MANAGE_DROPDOWN_DELETE =
|
||||
'[data-test-manage-targets-dropdown] ul li:last-child button';
|
||||
export const MANGE_DROPDOWN_ADD_BROKERED_CREDENTIALS =
|
||||
'[data-test-manage-targets-dropdown] [data-test-add-brokered-cred-sources-action]';
|
||||
export const MANGE_DROPDOWN_ADD_INJECTED_CREDENTIALS =
|
||||
'[data-test-manage-targets-dropdown] [data-test-add-injected-cred-sources-action]';
|
||||
|
||||
export const ALIASES_SIDEBAR = '.target-sidebar-aliases';
|
||||
export const ALIASES_SIDEBAR_LIST = '.target-sidebar-aliases .link-list-item';
|
||||
@@ -35,3 +39,5 @@ export const TABLE_ACTIVE_SESSIONS = (id) =>
|
||||
`tbody [data-test-targets-table-row="${id}"] .hds-table__td:nth-child(3) a`;
|
||||
export const TABLE_SESSIONS_ID = (id) =>
|
||||
`tbody [data-test-sessions-table-row="${id}"] .hds-table__td:first-child`;
|
||||
export const TABLE_CREDENTIAL_SOURCE_CHECKBOX = (type) =>
|
||||
`tbody [data-test-credential-source="${type}"] input[type="checkbox"]`;
|
||||
Reference in new issue
Block a user