test: 💍 Add acceptance tests for reading an spk credential (#1275)
Acceptance tests for spk type credentials added to read-test.js ✅ Closes: ICU-5653 Co-authored-by: Zhihe Li <zhihe.li@hashicorp.com>
This commit is contained in:
1 parent
a3517e53a8
commit
0dff900795
1 file changed
+45
-12
@@ -14,6 +14,9 @@ module('Acceptance | credential-stores | credentials | read', function (hooks) {
|
||||
org: null,
|
||||
project: null,
|
||||
},
|
||||
staticCredentialStore: null,
|
||||
usernamePasswordCredential: null,
|
||||
usernameKeyPairCredential: null,
|
||||
};
|
||||
|
||||
const urls = {
|
||||
@@ -21,7 +24,8 @@ module('Acceptance | credential-stores | credentials | read', function (hooks) {
|
||||
credentialStores: null,
|
||||
staticCredentialStore: null,
|
||||
credentials: null,
|
||||
credential: null,
|
||||
usernamePasswordCredential: null,
|
||||
usernameKeyPairCredential: null,
|
||||
unknownCredential: null,
|
||||
};
|
||||
|
||||
@@ -39,38 +43,67 @@ module('Acceptance | credential-stores | credentials | read', function (hooks) {
|
||||
scope: instances.scopes.project,
|
||||
type: 'static',
|
||||
});
|
||||
instances.credential = this.server.create('credential', {
|
||||
instances.usernamePasswordCredential = this.server.create('credential', {
|
||||
scope: instances.scopes.project,
|
||||
credentialStore: instances.staticCredentialStore,
|
||||
type: 'username_password',
|
||||
});
|
||||
instances.usernameKeyPairCredential = this.server.create('credential', {
|
||||
scope: instances.scopes.project,
|
||||
credentialStore: instances.staticCredentialStore,
|
||||
type: 'ssh_private_key',
|
||||
});
|
||||
// Generate route URLs for resources
|
||||
urls.projectScope = `/scopes/${instances.scopes.project.id}`;
|
||||
urls.credentialStores = `${urls.projectScope}/credential-stores`;
|
||||
urls.staticCredentialStore = `${urls.credentialStores}/${instances.staticCredentialStore.id}`;
|
||||
urls.credentials = `${urls.staticCredentialStore}/credentials`;
|
||||
urls.credential = `${urls.credentials}/${instances.credential.id}`;
|
||||
urls.usernamePasswordCredential = `${urls.credentials}/${instances.usernamePasswordCredential.id}`;
|
||||
urls.usernameKeyPairCredential = `${urls.credentials}/${instances.usernameKeyPairCredential.id}`;
|
||||
urls.unknownCredential = `${urls.credentials}/foo`;
|
||||
authenticateSession({});
|
||||
});
|
||||
|
||||
test('visiting /credentials', async function (assert) {
|
||||
test('visiting username & password credential', async function (assert) {
|
||||
assert.expect(2);
|
||||
await visit(urls.staticCredentialStore);
|
||||
await click(`[href="${urls.credentials}"]`);
|
||||
await a11yAudit();
|
||||
assert.strictEqual(currentURL(), urls.credentials);
|
||||
await click(`[href="${urls.credential}"]`);
|
||||
await click(`[href="${urls.usernamePasswordCredential}"]`);
|
||||
await a11yAudit();
|
||||
assert.strictEqual(currentURL(), urls.credential);
|
||||
assert.strictEqual(currentURL(), urls.usernamePasswordCredential);
|
||||
});
|
||||
|
||||
test('cannot navigate to a credential form without proper authorization', async function (assert) {
|
||||
test('visiting username & key pair credential', async function (assert) {
|
||||
assert.expect(2);
|
||||
await visit(urls.staticCredentialStore);
|
||||
await click(`[href="${urls.credentials}"]`);
|
||||
await a11yAudit();
|
||||
assert.strictEqual(currentURL(), urls.credentials);
|
||||
await click(`[href="${urls.usernameKeyPairCredential}"]`);
|
||||
await a11yAudit();
|
||||
assert.strictEqual(currentURL(), urls.usernameKeyPairCredential);
|
||||
});
|
||||
|
||||
test('cannot navigate to a username & password credential form without proper authorization', async function (assert) {
|
||||
assert.expect(1);
|
||||
instances.credential.authorized_actions =
|
||||
instances.credential.authorized_actions.filter((item) => item != 'read');
|
||||
instances.usernamePasswordCredential.authorized_actions =
|
||||
instances.usernamePasswordCredential.authorized_actions.filter(
|
||||
(item) => item != 'read'
|
||||
);
|
||||
await visit(urls.credentials);
|
||||
assert.notOk(find(`[href="${urls.credential}"]`));
|
||||
assert.dom(`[href="${urls.usernamePasswordCredential}"]`).doesNotExist();
|
||||
});
|
||||
|
||||
test('cannot navigate to a username & key pair credential form without proper authorization', async function (assert) {
|
||||
assert.expect(1);
|
||||
instances.usernameKeyPairCredential.authorized_actions =
|
||||
instances.usernameKeyPairCredential.authorized_actions.filter(
|
||||
(item) => item != 'read'
|
||||
);
|
||||
await visit(urls.credentials);
|
||||
assert.dom(`[href="${urls.usernameKeyPairCredential}"]`).doesNotExist();
|
||||
});
|
||||
|
||||
test('visiting an unknown credential displays 404 message', async function (assert) {
|
||||
@@ -80,9 +113,9 @@ module('Acceptance | credential-stores | credentials | read', function (hooks) {
|
||||
assert.ok(find('.rose-message-subtitle').textContent.trim(), 'Error 404');
|
||||
});
|
||||
|
||||
test('Users can link to docs page for credential store', async function (assert) {
|
||||
test('Users can link to docs page for credential', async function (assert) {
|
||||
assert.expect(1);
|
||||
await visit(urls.credential);
|
||||
await visit(urls.usernamePasswordCredential);
|
||||
assert.ok(
|
||||
find(`[href="https://boundaryproject.io/help/admin-ui/credentials"]`)
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user