test: 💍 credential store CRUDL tests (#1212)
Revised acceptance tests to reflect two types of credential stores ✅ Closes: ICU-5329 * test: 💍 credential store CRUDL tests * test: 💍 small addition to type of cred. store * test: 💍 Add missing vault cred. store type tests * fix: 🐛 rename variable in read-test.js
This commit is contained in:
1 parent
f51c56b4a1
commit
f00da3d8d7
4 files changed
+330
-91
No files matched your search
@@ -10,6 +10,8 @@ module('Acceptance | credential-stores | create', function (hooks) {
|
||||
setupMirage(hooks);
|
||||
|
||||
let getCredentialStoresCount;
|
||||
let getStaticCredentialStoresCount;
|
||||
let getVaultCredentialStoresCount;
|
||||
|
||||
const instances = {
|
||||
scopes: {
|
||||
@@ -23,7 +25,6 @@ module('Acceptance | credential-stores | create', function (hooks) {
|
||||
globalScope: null,
|
||||
projectScope: null,
|
||||
credentialStores: null,
|
||||
credentialStore: null,
|
||||
newCredentialStore: null,
|
||||
};
|
||||
|
||||
@@ -38,29 +39,43 @@ module('Acceptance | credential-stores | create', function (hooks) {
|
||||
type: 'project',
|
||||
scope: { id: instances.scopes.org.id, type: 'org' },
|
||||
});
|
||||
instances.credentialStore = this.server.create('credential-store', {
|
||||
scope: instances.scopes.project,
|
||||
});
|
||||
// Generate route URLs for resources
|
||||
urls.globalScope = `/scopes/global/scopes`;
|
||||
urls.projectScope = `/scopes/${instances.scopes.project.id}`;
|
||||
urls.credentialStores = `${urls.projectScope}/credential-stores`;
|
||||
urls.credentialStore = `${urls.credentialStores}/${instances.credentialStore.id}`;
|
||||
urls.newCredentialStore = `${urls.credentialStores}/new`;
|
||||
// Generate resource counter
|
||||
getCredentialStoresCount = () => {
|
||||
return this.server.schema.credentialStores.all().models.length;
|
||||
};
|
||||
getStaticCredentialStoresCount = () => {
|
||||
return this.server.schema.credentialStores.where({ type: 'static' })
|
||||
.models.length;
|
||||
};
|
||||
getVaultCredentialStoresCount = () => {
|
||||
return this.server.schema.credentialStores.where({ type: 'vault' }).models
|
||||
.length;
|
||||
};
|
||||
authenticateSession({});
|
||||
});
|
||||
|
||||
test('Users can create a new credential stores', async function (assert) {
|
||||
test('Users can create a new credential store of default type static', async function (assert) {
|
||||
assert.expect(1);
|
||||
const count = getCredentialStoresCount();
|
||||
const count = getStaticCredentialStoresCount();
|
||||
await visit(urls.newCredentialStore);
|
||||
await fillIn('[name="name"]', 'random string');
|
||||
await click('[type="submit"]');
|
||||
assert.strictEqual(getCredentialStoresCount(), count + 1);
|
||||
assert.strictEqual(getStaticCredentialStoresCount(), count + 1);
|
||||
});
|
||||
|
||||
test('Users can create a new credential store of type vault', async function (assert) {
|
||||
assert.expect(1);
|
||||
const count = getVaultCredentialStoresCount();
|
||||
await visit(urls.newCredentialStore);
|
||||
await fillIn('[name="name"]', 'random string');
|
||||
await click('[value="vault"]');
|
||||
await click('[type="submit"]');
|
||||
assert.strictEqual(getVaultCredentialStoresCount(), count + 1);
|
||||
});
|
||||
|
||||
test('Users can cancel create new credential stores', async function (assert) {
|
||||
|
||||
@@ -11,7 +11,8 @@ module('Acceptance | credential-stores | delete', function (hooks) {
|
||||
setupApplicationTest(hooks);
|
||||
setupMirage(hooks);
|
||||
|
||||
let getCredentialStoresCount;
|
||||
let getStaticCredentialStoresCount;
|
||||
let getVaultCredentialStoresCount;
|
||||
|
||||
const instances = {
|
||||
scopes: {
|
||||
@@ -26,9 +27,8 @@ module('Acceptance | credential-stores | delete', function (hooks) {
|
||||
orgScope: null,
|
||||
projectScope: null,
|
||||
credentialStores: null,
|
||||
credentialStore: null,
|
||||
unknownCredentialStore: null,
|
||||
newCredentialStore: null,
|
||||
staticCredentialStore: null,
|
||||
vaultCredentialStore: null,
|
||||
};
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
@@ -42,69 +42,122 @@ module('Acceptance | credential-stores | delete', function (hooks) {
|
||||
type: 'project',
|
||||
scope: { id: instances.scopes.org.id, type: 'org' },
|
||||
});
|
||||
instances.credentialStore = this.server.create('credential-store', {
|
||||
instances.staticCredentialStore = this.server.create('credential-store', {
|
||||
scope: instances.scopes.project,
|
||||
type: 'static',
|
||||
});
|
||||
instances.vaultCredentialStore = this.server.create('credential-store', {
|
||||
scope: instances.scopes.project,
|
||||
type: 'vault',
|
||||
});
|
||||
// Generate route URLs for resources
|
||||
urls.globalScope = `/scopes/global/scopes`;
|
||||
urls.orgScope = `/scopes/${instances.scopes.org.id}/scopes`;
|
||||
urls.projectScope = `/scopes/${instances.scopes.project.id}`;
|
||||
urls.credentialStores = `${urls.projectScope}/credential-stores`;
|
||||
urls.credentialStore = `${urls.credentialStores}/${instances.credentialStore.id}`;
|
||||
urls.unknownCredentialStore = `${urls.credentialStores}/foo`;
|
||||
urls.newCredentialStore = `${urls.credentialStores}/new`;
|
||||
urls.staticCredentialStore = `${urls.credentialStores}/${instances.staticCredentialStore.id}`;
|
||||
urls.vaultCredentialStore = `${urls.credentialStores}/${instances.vaultCredentialStore.id}`;
|
||||
// Generate resource counter
|
||||
getCredentialStoresCount = () => {
|
||||
return this.server.schema.credentialStores.all().models.length;
|
||||
getStaticCredentialStoresCount = () => {
|
||||
return this.server.schema.credentialStores.where({ type: 'static' })
|
||||
.models.length;
|
||||
};
|
||||
getVaultCredentialStoresCount = () => {
|
||||
return this.server.schema.credentialStores.where({ type: 'vault' }).models
|
||||
.length;
|
||||
};
|
||||
authenticateSession({});
|
||||
});
|
||||
|
||||
test('can delete credential store', async function (assert) {
|
||||
test('can delete credential store of type vault', async function (assert) {
|
||||
assert.expect(1);
|
||||
const count = getCredentialStoresCount();
|
||||
await visit(urls.credentialStore);
|
||||
const count = getVaultCredentialStoresCount();
|
||||
await visit(urls.vaultCredentialStore);
|
||||
await click('.rose-layout-page-actions .rose-dropdown-button-danger');
|
||||
assert.strictEqual(getCredentialStoresCount(), count - 1);
|
||||
assert.strictEqual(getVaultCredentialStoresCount(), count - 1);
|
||||
});
|
||||
|
||||
test('cannot delete a credential store without proper authorization', async function (assert) {
|
||||
test('can delete credential store of type static', async function (assert) {
|
||||
assert.expect(1);
|
||||
instances.credentialStore.authorized_actions =
|
||||
instances.credentialStore.authorized_actions.filter(
|
||||
const count = getStaticCredentialStoresCount();
|
||||
await visit(urls.staticCredentialStore);
|
||||
await click('.rose-layout-page-actions .rose-dropdown-button-danger');
|
||||
assert.strictEqual(getStaticCredentialStoresCount(), count - 1);
|
||||
});
|
||||
|
||||
test('cannot delete a vault credential store without proper authorization', async function (assert) {
|
||||
assert.expect(1);
|
||||
instances.vaultCredentialStore.authorized_actions =
|
||||
instances.vaultCredentialStore.authorized_actions.filter(
|
||||
(item) => item !== 'delete'
|
||||
);
|
||||
await visit(urls.credentialStores);
|
||||
await visit(urls.vaultCredentialStore);
|
||||
assert.notOk(
|
||||
find('.rose-layout-page-actions .rose-dropdown-button-danger')
|
||||
);
|
||||
});
|
||||
|
||||
test('can accept delete credential store via dialog', async function (assert) {
|
||||
test('cannot delete a static credential store without proper authorization', async function (assert) {
|
||||
assert.expect(1);
|
||||
instances.staticCredentialStore.authorized_actions =
|
||||
instances.staticCredentialStore.authorized_actions.filter(
|
||||
(item) => item !== 'delete'
|
||||
);
|
||||
await visit(urls.staticCredentialStore);
|
||||
assert.notOk(
|
||||
find('.rose-layout-page-actions .rose-dropdown-button-danger')
|
||||
);
|
||||
});
|
||||
|
||||
test('can accept delete static credential store via dialog', async function (assert) {
|
||||
assert.expect(2);
|
||||
const confirmService = this.owner.lookup('service:confirm');
|
||||
confirmService.enabled = true;
|
||||
confirmService.confirm = sinon.fake.returns(resolve());
|
||||
const count = getCredentialStoresCount();
|
||||
await visit(urls.credentialStore);
|
||||
const count = getStaticCredentialStoresCount();
|
||||
await visit(urls.staticCredentialStore);
|
||||
await click('.rose-layout-page-actions .rose-dropdown-button-danger');
|
||||
assert.strictEqual(getCredentialStoresCount(), count - 1);
|
||||
assert.strictEqual(getStaticCredentialStoresCount(), count - 1);
|
||||
assert.ok(confirmService.confirm.calledOnce);
|
||||
});
|
||||
|
||||
test('cannot cancel delete credential store via dialog', async function (assert) {
|
||||
test('can accept delete vault credential store via dialog', async function (assert) {
|
||||
assert.expect(2);
|
||||
const confirmService = this.owner.lookup('service:confirm');
|
||||
confirmService.enabled = true;
|
||||
confirmService.confirm = sinon.fake.returns(resolve());
|
||||
const count = getVaultCredentialStoresCount();
|
||||
await visit(urls.vaultCredentialStore);
|
||||
await click('.rose-layout-page-actions .rose-dropdown-button-danger');
|
||||
assert.strictEqual(getVaultCredentialStoresCount(), count - 1);
|
||||
assert.ok(confirmService.confirm.calledOnce);
|
||||
});
|
||||
|
||||
test('cannot cancel delete for static credential store via dialog', async function (assert) {
|
||||
assert.expect(2);
|
||||
const confirmService = this.owner.lookup('service:confirm');
|
||||
confirmService.enabled = true;
|
||||
confirmService.confirm = sinon.fake.returns(reject());
|
||||
const count = getCredentialStoresCount();
|
||||
await visit(urls.credentialStore);
|
||||
const count = getStaticCredentialStoresCount();
|
||||
await visit(urls.staticCredentialStore);
|
||||
await click('.rose-layout-page-actions .rose-dropdown-button-danger');
|
||||
assert.strictEqual(getCredentialStoresCount(), count);
|
||||
assert.strictEqual(getStaticCredentialStoresCount(), count);
|
||||
assert.ok(confirmService.confirm.calledOnce);
|
||||
});
|
||||
|
||||
test('deleting a credential store which errors displays error messages', async function (assert) {
|
||||
test('cannot cancel delete for vault credential store via dialog', async function (assert) {
|
||||
assert.expect(2);
|
||||
const confirmService = this.owner.lookup('service:confirm');
|
||||
confirmService.enabled = true;
|
||||
confirmService.confirm = sinon.fake.returns(reject());
|
||||
const count = getVaultCredentialStoresCount();
|
||||
await visit(urls.vaultCredentialStore);
|
||||
await click('.rose-layout-page-actions .rose-dropdown-button-danger');
|
||||
assert.strictEqual(getVaultCredentialStoresCount(), count);
|
||||
assert.ok(confirmService.confirm.calledOnce);
|
||||
});
|
||||
|
||||
test('deleting a static credential store which errors displays error messages', async function (assert) {
|
||||
assert.expect(1);
|
||||
this.server.del('/credential-stores/:id', () => {
|
||||
return new Response(
|
||||
@@ -117,7 +170,25 @@ module('Acceptance | credential-stores | delete', function (hooks) {
|
||||
}
|
||||
);
|
||||
});
|
||||
await visit(urls.credentialStore);
|
||||
await visit(urls.staticCredentialStore);
|
||||
await click('.rose-layout-page-actions .rose-dropdown-button-danger');
|
||||
assert.ok(find('[role="alert"]').textContent.trim(), 'Oops.');
|
||||
});
|
||||
|
||||
test('deleting a vault credential store which errors displays error messages', async function (assert) {
|
||||
assert.expect(1);
|
||||
this.server.del('/credential-stores/:id', () => {
|
||||
return new Response(
|
||||
490,
|
||||
{},
|
||||
{
|
||||
status: 490,
|
||||
code: 'error',
|
||||
message: 'Oops.',
|
||||
}
|
||||
);
|
||||
});
|
||||
await visit(urls.vaultCredentialStore);
|
||||
await click('.rose-layout-page-actions .rose-dropdown-button-danger');
|
||||
assert.ok(find('[role="alert"]').textContent.trim(), 'Oops.');
|
||||
});
|
||||
|
||||
@@ -22,9 +22,9 @@ module('Acceptance | credential-stores | read', function (hooks) {
|
||||
orgScope: null,
|
||||
projectScope: null,
|
||||
credentialStores: null,
|
||||
credentialStore: null,
|
||||
staticCredentialStore: null,
|
||||
vaultCredentialStore: null,
|
||||
unknownCredentialStore: null,
|
||||
newCredentialStore: null,
|
||||
};
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
@@ -38,37 +38,62 @@ module('Acceptance | credential-stores | read', function (hooks) {
|
||||
type: 'project',
|
||||
scope: { id: instances.scopes.org.id, type: 'org' },
|
||||
});
|
||||
instances.credentialStore = this.server.create('credential-store', {
|
||||
instances.staticCredentialStore = this.server.create('credential-store', {
|
||||
scope: instances.scopes.project,
|
||||
type: 'static',
|
||||
});
|
||||
instances.vaultCredentialStore = this.server.create('credential-store', {
|
||||
scope: instances.scopes.project,
|
||||
type: 'vault',
|
||||
});
|
||||
// Generate route URLs for resources
|
||||
urls.globalScope = `/scopes/global/scopes`;
|
||||
urls.orgScope = `/scopes/${instances.scopes.org.id}/scopes`;
|
||||
urls.projectScope = `/scopes/${instances.scopes.project.id}`;
|
||||
urls.credentialStores = `${urls.projectScope}/credential-stores`;
|
||||
urls.credentialStore = `${urls.credentialStores}/${instances.credentialStore.id}`;
|
||||
urls.staticCredentialStore = `${urls.credentialStores}/${instances.staticCredentialStore.id}`;
|
||||
urls.vaultCredentialStore = `${urls.credentialStores}/${instances.vaultCredentialStore.id}`;
|
||||
urls.unknownCredentialStore = `${urls.credentialStores}/foo`;
|
||||
urls.newCredentialStore = `${urls.credentialStores}/new`;
|
||||
authenticateSession({});
|
||||
});
|
||||
|
||||
test('visiting /credential-stores', async function (assert) {
|
||||
test('visiting static credential store in /credential-stores', async function (assert) {
|
||||
assert.expect(2);
|
||||
await visit(urls.credentialStores);
|
||||
await a11yAudit();
|
||||
assert.strictEqual(currentURL(), urls.credentialStores);
|
||||
await visit(urls.credentialStore);
|
||||
await visit(urls.staticCredentialStore);
|
||||
await a11yAudit();
|
||||
assert.strictEqual(currentURL(), urls.credentialStore);
|
||||
assert.strictEqual(currentURL(), urls.staticCredentialStore);
|
||||
});
|
||||
|
||||
test('cannot navigate to a credential store form without proper authorization', async function (assert) {
|
||||
test('visiting vault credential store in /credential-stores', async function (assert) {
|
||||
assert.expect(2);
|
||||
await visit(urls.credentialStores);
|
||||
await a11yAudit();
|
||||
assert.strictEqual(currentURL(), urls.credentialStores);
|
||||
await visit(urls.vaultCredentialStore);
|
||||
await a11yAudit();
|
||||
assert.strictEqual(currentURL(), urls.vaultCredentialStore);
|
||||
});
|
||||
|
||||
test('cannot navigate to a static credential store form without proper authorization', async function (assert) {
|
||||
assert.expect(1);
|
||||
instances.credentialStore.authorized_actions =
|
||||
instances.credentialStore.authorized_actions.filter(
|
||||
instances.staticCredentialStore.authorized_actions =
|
||||
instances.staticCredentialStore.authorized_actions.filter(
|
||||
(item) => item !== 'read'
|
||||
);
|
||||
await visit(urls.credentialStores);
|
||||
await visit(urls.staticCredentialStore);
|
||||
assert.notOk(find('main tbody .rose-table-header-cell:nth-child(1) a'));
|
||||
});
|
||||
|
||||
test('cannot navigate to a vault credential store form without proper authorization', async function (assert) {
|
||||
assert.expect(1);
|
||||
instances.vaultCredentialStore.authorized_actions =
|
||||
instances.vaultCredentialStore.authorized_actions.filter(
|
||||
(item) => item !== 'read'
|
||||
);
|
||||
await visit(urls.vaultCredentialStore);
|
||||
assert.notOk(find('main tbody .rose-table-header-cell:nth-child(1) a'));
|
||||
});
|
||||
|
||||
@@ -84,7 +109,7 @@ module('Acceptance | credential-stores | read', function (hooks) {
|
||||
|
||||
test('Users can link to docs page for credential store', async function (assert) {
|
||||
assert.expect(1);
|
||||
await visit(urls.credentialStore);
|
||||
await visit(urls.staticCredentialStore);
|
||||
assert.ok(
|
||||
find(
|
||||
`[href="https://boundaryproject.io/help/admin-ui/credential-stores"]`
|
||||
|
||||
@@ -22,9 +22,8 @@ module('Acceptance | credential-stores | update', function (hooks) {
|
||||
orgScope: null,
|
||||
projectScope: null,
|
||||
credentialStores: null,
|
||||
credentialStore: null,
|
||||
unknownCredentialStore: null,
|
||||
newCredentialStore: null,
|
||||
staticCredentialStore: null,
|
||||
vaultCredentialStore: null,
|
||||
};
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
@@ -38,58 +37,101 @@ module('Acceptance | credential-stores | update', function (hooks) {
|
||||
type: 'project',
|
||||
scope: { id: instances.scopes.org.id, type: 'org' },
|
||||
});
|
||||
instances.credentialStore = this.server.create('credential-store', {
|
||||
instances.staticCredentialStore = this.server.create('credential-store', {
|
||||
scope: instances.scopes.project,
|
||||
type: 'static',
|
||||
});
|
||||
instances.vaultCredentialStore = this.server.create('credential-store', {
|
||||
scope: instances.scopes.project,
|
||||
type: 'vault',
|
||||
});
|
||||
// Generate route URLs for resources
|
||||
urls.globalScope = `/scopes/global/scopes`;
|
||||
urls.orgScope = `/scopes/${instances.scopes.org.id}/scopes`;
|
||||
urls.projectScope = `/scopes/${instances.scopes.project.id}`;
|
||||
urls.credentialStores = `${urls.projectScope}/credential-stores`;
|
||||
urls.credentialStore = `${urls.credentialStores}/${instances.credentialStore.id}`;
|
||||
urls.unknownCredentialStore = `${urls.credentialStores}/foo`;
|
||||
urls.newCredentialStore = `${urls.credentialStores}/new`;
|
||||
urls.vaultCredentialStore = `${urls.credentialStores}/${instances.vaultCredentialStore.id}`;
|
||||
urls.staticCredentialStore = `${urls.credentialStores}/${instances.staticCredentialStore.id}`;
|
||||
authenticateSession({});
|
||||
});
|
||||
|
||||
test('can save changes to existing credential store', async function (assert) {
|
||||
test('can save changes to existing static credential store', async function (assert) {
|
||||
assert.expect(3);
|
||||
assert.notEqual(instances.credentialStore.name, 'random string');
|
||||
await visit(urls.credentialStore);
|
||||
assert.notEqual(instances.staticCredentialStore.name, 'random string');
|
||||
await visit(urls.staticCredentialStore);
|
||||
await click('form [type="button"]', 'Activate edit mode');
|
||||
await fillIn('[name="name"]', 'random string');
|
||||
await click('.rose-form-actions [type="submit"]');
|
||||
assert.strictEqual(currentURL(), urls.credentialStore);
|
||||
assert.strictEqual(currentURL(), urls.staticCredentialStore);
|
||||
assert.strictEqual(
|
||||
this.server.schema.credentialStores.all().models[0].name,
|
||||
this.server.schema.credentialStores.where({ type: 'static' }).models[0]
|
||||
.name,
|
||||
'random string'
|
||||
);
|
||||
});
|
||||
|
||||
test('cannot make changes to an existing credential store without proper authorization', async function (assert) {
|
||||
assert.expect(1);
|
||||
instances.credentialStore.authorized_actions =
|
||||
instances.credentialStore.authorized_actions.filter(
|
||||
(item) => item !== 'update'
|
||||
);
|
||||
await visit(urls.credentialStore);
|
||||
assert.notOk(find('.rose-layout-page-actions .rose-button-secondary'));
|
||||
});
|
||||
|
||||
test('can cancel changes to existing credential store', async function (assert) {
|
||||
assert.expect(2);
|
||||
await visit(urls.credentialStore);
|
||||
test('can save changes to existing vault credential store', async function (assert) {
|
||||
assert.expect(3);
|
||||
assert.notEqual(instances.vaultCredentialStore.name, 'random string');
|
||||
await visit(urls.vaultCredentialStore);
|
||||
await click('form [type="button"]', 'Activate edit mode');
|
||||
await fillIn('[name="name"]', 'random string');
|
||||
await click('.rose-form-actions [type="button"]');
|
||||
assert.notEqual(instances.credentialStore.name, 'random string');
|
||||
await click('.rose-form-actions [type="submit"]');
|
||||
assert.strictEqual(currentURL(), urls.vaultCredentialStore);
|
||||
assert.strictEqual(
|
||||
find('[name="name"]').value,
|
||||
instances.credentialStore.name
|
||||
this.server.schema.credentialStores.where({ type: 'vault' }).models[0]
|
||||
.name,
|
||||
'random string'
|
||||
);
|
||||
});
|
||||
|
||||
test('saving an existing credential store with invalid fields displays error messages', async function (assert) {
|
||||
test('cannot make changes to an existing static credential store without proper authorization', async function (assert) {
|
||||
assert.expect(1);
|
||||
instances.staticCredentialStore.authorized_actions =
|
||||
instances.staticCredentialStore.authorized_actions.filter(
|
||||
(item) => item !== 'update'
|
||||
);
|
||||
await visit(urls.staticCredentialStore);
|
||||
assert.notOk(find('.rose-layout-page-actions .rose-button-secondary'));
|
||||
});
|
||||
|
||||
test('cannot make changes to an existing vault credential store without proper authorization', async function (assert) {
|
||||
assert.expect(1);
|
||||
instances.vaultCredentialStore.authorized_actions =
|
||||
instances.vaultCredentialStore.authorized_actions.filter(
|
||||
(item) => item !== 'update'
|
||||
);
|
||||
await visit(urls.vaultCredentialStore);
|
||||
assert.notOk(find('.rose-layout-page-actions .rose-button-secondary'));
|
||||
});
|
||||
|
||||
test('can cancel changes to existing static credential store', async function (assert) {
|
||||
assert.expect(2);
|
||||
await visit(urls.staticCredentialStore);
|
||||
await click('form [type="button"]', 'Activate edit mode');
|
||||
await fillIn('[name="name"]', 'random string');
|
||||
await click('.rose-form-actions [type="button"]');
|
||||
assert.notEqual(instances.staticCredentialStore.name, 'random string');
|
||||
assert.strictEqual(
|
||||
find('[name="name"]').value,
|
||||
instances.staticCredentialStore.name
|
||||
);
|
||||
});
|
||||
|
||||
test('can cancel changes to existing vault credential store', async function (assert) {
|
||||
assert.expect(2);
|
||||
await visit(urls.vaultCredentialStore);
|
||||
await click('form [type="button"]', 'Activate edit mode');
|
||||
await fillIn('[name="name"]', 'random string');
|
||||
await click('.rose-form-actions [type="button"]');
|
||||
assert.notEqual(instances.vaultCredentialStore.name, 'random string');
|
||||
assert.strictEqual(
|
||||
find('[name="name"]').value,
|
||||
instances.vaultCredentialStore.name
|
||||
);
|
||||
});
|
||||
|
||||
test('saving an existing static credential store with invalid fields displays error messages', async function (assert) {
|
||||
assert.expect(2);
|
||||
this.server.patch('/credential-stores/:id', () => {
|
||||
return new Response(
|
||||
@@ -110,7 +152,7 @@ module('Acceptance | credential-stores | update', function (hooks) {
|
||||
}
|
||||
);
|
||||
});
|
||||
await visit(urls.credentialStore);
|
||||
await visit(urls.staticCredentialStore);
|
||||
await click('form [type="button"]', 'Activate edit mode');
|
||||
await fillIn('[name="name"]', 'random string');
|
||||
await click('[type="submit"]');
|
||||
@@ -124,16 +166,51 @@ module('Acceptance | credential-stores | update', function (hooks) {
|
||||
);
|
||||
});
|
||||
|
||||
test('can discard unsaved credential store changes via dialog', async function (assert) {
|
||||
test('saving an existing vault credential store with invalid fields displays error messages', async function (assert) {
|
||||
assert.expect(2);
|
||||
this.server.patch('/credential-stores/:id', () => {
|
||||
return new Response(
|
||||
400,
|
||||
{},
|
||||
{
|
||||
status: 400,
|
||||
code: 'invalid_argument',
|
||||
message: 'The request was invalid.',
|
||||
details: {
|
||||
request_fields: [
|
||||
{
|
||||
name: 'name',
|
||||
description: 'Name is required.',
|
||||
},
|
||||
],
|
||||
},
|
||||
}
|
||||
);
|
||||
});
|
||||
await visit(urls.vaultCredentialStore);
|
||||
await click('form [type="button"]', 'Activate edit mode');
|
||||
await fillIn('[name="name"]', 'random string');
|
||||
await click('[type="submit"]');
|
||||
assert.ok(
|
||||
find('[role="alert"]').textContent.trim(),
|
||||
'The request was invalid.'
|
||||
);
|
||||
assert.ok(
|
||||
find('.rose-form-error-message').textContent.trim(),
|
||||
'Name is required.'
|
||||
);
|
||||
});
|
||||
|
||||
test('can discard unsaved static credential store changes via dialog', async function (assert) {
|
||||
assert.expect(5);
|
||||
const confirmService = this.owner.lookup('service:confirm');
|
||||
confirmService.enabled = true;
|
||||
assert.notEqual(instances.credentialStore.name, 'random string');
|
||||
assert.notEqual(instances.staticCredentialStore.name, 'random string');
|
||||
|
||||
await visit(urls.credentialStore);
|
||||
await visit(urls.staticCredentialStore);
|
||||
await click('form [type="button"]', 'Activate edit mode');
|
||||
await fillIn('[name="name"]', 'random string');
|
||||
assert.strictEqual(currentURL(), urls.credentialStore);
|
||||
assert.strictEqual(currentURL(), urls.staticCredentialStore);
|
||||
|
||||
try {
|
||||
await visit(urls.credentialStores);
|
||||
@@ -142,30 +219,81 @@ module('Acceptance | credential-stores | update', function (hooks) {
|
||||
await click('.rose-dialog-footer button:first-child', 'Click Discard');
|
||||
assert.strictEqual(currentURL(), urls.credentialStores);
|
||||
assert.notEqual(
|
||||
this.server.schema.credentialStores.all().models[0].name,
|
||||
this.server.schema.credentialStores.where({ type: 'static' }).models[0]
|
||||
.name,
|
||||
'random string'
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
test('can cancel discard unsaved credential store via dialog', async function (assert) {
|
||||
test('can discard unsaved vault credential store changes via dialog', async function (assert) {
|
||||
assert.expect(5);
|
||||
const confirmService = this.owner.lookup('service:confirm');
|
||||
confirmService.enabled = true;
|
||||
assert.notEqual(instances.credentialStore.name, 'random string');
|
||||
await visit(urls.credentialStore);
|
||||
assert.notEqual(instances.vaultCredentialStore.name, 'random string');
|
||||
|
||||
await visit(urls.vaultCredentialStore);
|
||||
await click('form [type="button"]', 'Activate edit mode');
|
||||
await fillIn('[name="name"]', 'random string');
|
||||
assert.strictEqual(currentURL(), urls.credentialStore);
|
||||
assert.strictEqual(currentURL(), urls.vaultCredentialStore);
|
||||
|
||||
try {
|
||||
await visit(urls.credentialStores);
|
||||
} catch (e) {
|
||||
assert.ok(find('.rose-dialog'));
|
||||
await click('.rose-dialog-footer button:first-child', 'Click Discard');
|
||||
assert.strictEqual(currentURL(), urls.credentialStores);
|
||||
assert.notEqual(
|
||||
this.server.schema.credentialStores.where({ type: 'vault' }).models[0]
|
||||
.name,
|
||||
'random string'
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
test('can cancel discard unsaved static credential store via dialog', async function (assert) {
|
||||
assert.expect(5);
|
||||
const confirmService = this.owner.lookup('service:confirm');
|
||||
confirmService.enabled = true;
|
||||
assert.notEqual(instances.staticCredentialStore.name, 'random string');
|
||||
await visit(urls.staticCredentialStore);
|
||||
await click('form [type="button"]', 'Activate edit mode');
|
||||
await fillIn('[name="name"]', 'random string');
|
||||
assert.strictEqual(currentURL(), urls.staticCredentialStore);
|
||||
|
||||
try {
|
||||
await visit(urls.credentialStores);
|
||||
} catch (e) {
|
||||
assert.ok(find('.rose-dialog'));
|
||||
await click('.rose-dialog-footer button:last-child');
|
||||
assert.strictEqual(currentURL(), urls.credentialStore);
|
||||
assert.strictEqual(currentURL(), urls.staticCredentialStore);
|
||||
assert.notEqual(
|
||||
this.server.schema.credentialStores.all().models[0].name,
|
||||
this.server.schema.credentialStores.where({ type: 'static' }).models[0]
|
||||
.name,
|
||||
'random string'
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
test('can cancel discard unsaved vault credential store via dialog', async function (assert) {
|
||||
assert.expect(5);
|
||||
const confirmService = this.owner.lookup('service:confirm');
|
||||
confirmService.enabled = true;
|
||||
assert.notEqual(instances.vaultCredentialStore.name, 'random string');
|
||||
await visit(urls.vaultCredentialStore);
|
||||
await click('form [type="button"]', 'Activate edit mode');
|
||||
await fillIn('[name="name"]', 'random string');
|
||||
assert.strictEqual(currentURL(), urls.vaultCredentialStore);
|
||||
|
||||
try {
|
||||
await visit(urls.credentialStores);
|
||||
} catch (e) {
|
||||
assert.ok(find('.rose-dialog'));
|
||||
await click('.rose-dialog-footer button:last-child');
|
||||
assert.strictEqual(currentURL(), urls.vaultCredentialStore);
|
||||
assert.notEqual(
|
||||
this.server.schema.credentialStores.where({ type: 'vault' }).models[0]
|
||||
.name,
|
||||
'random string'
|
||||
);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user