feat: 🎸 create form for json credentials (#1498)
* feat: 🎸 create form for json credentials ✅ Closes: ICU-6682 * refactor: 💡 add new info field * refactor: 💡 add feature flag * refactor: 💡 add hds radio cards to json cred * Update ui/admin/tests/acceptance/credential-store/credentials/create-test.js * test: 💍 add test for json cred * chore: 🤖 Remove ember-data-model-fragments package * fix: 🐛 Update how json is added as a known credential type * refactor: 💡 update credentialTypes if statement to ternary * chore: 🤖 add ember-data back to addon/api project * chore: 🤖 remove ember-feature-flag from addon/api * refactor: 💡 remove if statement in cred form * refactor: 💡 update selectors for json cred. tests * refactor: 💡 Update Credential Form to use form.disabled * test: 💍 Fix test selectors for radio card credential tests * refactor: 💡 update credential types declaration to const * style: 💄 Fix style issue with SecretEditor in edit mode * refactor: 💡 remove disabled and readonly attributes in form * refactor: 💡 Create credential ability canRead override * test: 💍 add credential ability override tests * test: 💍 Fix brokered credential test with json support added * refactor: 💡 add attributes comment back to credential model Co-authored-by: Cameron Perera <cameron.perera@hashicorp.com>
This commit is contained in:
1 parent
e18b30a54e
commit
e418017bc2
17 files changed
+420
-86
No files matched your search
@@ -15,6 +15,7 @@ module('Acceptance | targets | brokered credential sources', function (hooks) {
|
||||
let credentialSourceCount;
|
||||
let randomlySelectedCredentialLibraries;
|
||||
let randomlySelectedCredentials;
|
||||
let featuresService;
|
||||
|
||||
const instances = {
|
||||
scopes: {
|
||||
@@ -37,11 +38,14 @@ module('Acceptance | targets | brokered credential sources', function (hooks) {
|
||||
target: null,
|
||||
credentialLibraries: null,
|
||||
credentialLibrary: null,
|
||||
credential: null,
|
||||
jsonCredential: null,
|
||||
addBrokeredCredentialSources: null,
|
||||
brokeredCredentialSources: null,
|
||||
};
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
featuresService = this.owner.lookup('service:features');
|
||||
// Generate resources
|
||||
instances.scopes.global = this.server.create('scope', { id: 'global' });
|
||||
instances.scopes.org = this.server.create('scope', {
|
||||
@@ -60,7 +64,7 @@ module('Acceptance | targets | brokered credential sources', function (hooks) {
|
||||
type: 'static',
|
||||
scope: instances.scopes.project,
|
||||
});
|
||||
instances.credentials = this.server.createList('credential', 2, {
|
||||
instances.credentials = this.server.createList('credential', 3, {
|
||||
scope: instances.scopes.project,
|
||||
credentialStore: instances.staticCredentialStore,
|
||||
});
|
||||
@@ -100,6 +104,7 @@ module('Acceptance | targets | brokered credential sources', function (hooks) {
|
||||
urls.brokeredCredentialSources = `${urls.target}/brokered-credential-sources`;
|
||||
urls.credentialLibrary = `${urls.projectScope}/credential-stores/${instances.credentialLibrary.credentialStoreId}/credential-libraries/${instances.credentialLibrary.id}`;
|
||||
urls.credential = `${urls.projectScope}/credential-stores/${instances.credential.credentialStoreId}/credentials/${instances.credential.id}`;
|
||||
urls.jsonCredential = `${urls.projectScope}/credential-stores/${instances.credentials[2].credentialStoreId}/credentials/${instances.credentials[2].id}`;
|
||||
urls.addBrokeredCredentialSources = `${urls.target}/add-brokered-credential-sources`;
|
||||
getCredentialLibraryCount = () =>
|
||||
this.server.schema.credentialLibraries.all().models.length;
|
||||
@@ -137,6 +142,19 @@ module('Acceptance | targets | brokered credential sources', function (hooks) {
|
||||
assert.strictEqual(currentURL(), urls.credential);
|
||||
});
|
||||
|
||||
test('cannot navigate to a json type credential when feature is disabled', async function (assert) {
|
||||
featuresService.disable('json-credentials');
|
||||
assert.expect(2);
|
||||
const jsonCredential = instances.credentials[2];
|
||||
instances.target.update({
|
||||
brokeredCredentialSourceIds: [...randomlySelectedCredentials],
|
||||
});
|
||||
await visit(urls.brokeredCredentialSources);
|
||||
|
||||
assert.dom('.rose-table-row:nth-child(3)').includesText(jsonCredential.name);
|
||||
assert.dom(`[href="${urls.jsonCredential}"]`).doesNotExist();
|
||||
});
|
||||
|
||||
test('visiting add brokered credential sources', async function (assert) {
|
||||
assert.expect(1);
|
||||
await visit(urls.addBrokeredCredentialSources);
|
||||
@@ -157,7 +175,7 @@ module('Acceptance | targets | brokered credential sources', function (hooks) {
|
||||
test('displays list of brokered credential sources with only credential libraries available', async function (assert) {
|
||||
assert.expect(2);
|
||||
instances.target.update({
|
||||
brokeredCredentialSourceIds: [...randomlySelectedCredentialLibraries],
|
||||
brokeredCredentialSourceIds: [...randomlySelectedCredentials],
|
||||
});
|
||||
await visit(urls.addBrokeredCredentialSources);
|
||||
assert.strictEqual(findAll('tbody tr').length, getCredentialLibraryCount());
|
||||
@@ -300,12 +318,13 @@ module('Acceptance | targets | brokered credential sources', function (hooks) {
|
||||
brokeredCredentialSourceIds: [...randomlySelectedCredentialLibraries],
|
||||
});
|
||||
const credentialLibraryCount = getCredentialLibraryCount();
|
||||
const availableCredentialsCount = getCredentialCount();
|
||||
await visit(urls.brokeredCredentialSources);
|
||||
assert.strictEqual(findAll('tbody tr').length, credentialLibraryCount);
|
||||
await click('tbody tr .rose-dropdown-button-danger');
|
||||
assert.strictEqual(findAll('tbody tr').length, credentialLibraryCount - 1);
|
||||
await visit(urls.addBrokeredCredentialSources);
|
||||
assert.strictEqual(findAll('tbody tr').length, credentialLibraryCount + 1);
|
||||
assert.strictEqual(findAll('tbody tr').length, availableCredentialsCount + 1);
|
||||
});
|
||||
|
||||
test('can remove a username & password type credential', async function (assert) {
|
||||
@@ -314,12 +333,13 @@ module('Acceptance | targets | brokered credential sources', function (hooks) {
|
||||
brokeredCredentialSourceIds: [...randomlySelectedCredentials],
|
||||
});
|
||||
const credentialCount = getCredentialCount();
|
||||
const availableCredentialsCount = getCredentialLibraryCount();
|
||||
await visit(urls.brokeredCredentialSources);
|
||||
assert.strictEqual(findAll('tbody tr').length, credentialCount);
|
||||
await click('tbody tr .rose-dropdown-button-danger');
|
||||
assert.strictEqual(findAll('tbody tr').length, credentialCount - 1);
|
||||
await visit(urls.addBrokeredCredentialSources);
|
||||
assert.strictEqual(findAll('tbody tr').length, credentialCount + 1);
|
||||
assert.strictEqual(findAll('tbody tr').length, availableCredentialsCount + 1);
|
||||
});
|
||||
|
||||
test('cannot remove credential libraries without proper authorization', async function (assert) {
|
||||
|
||||
Reference in new issue
Block a user