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:
lisbet-alvarezandCameron Perera authored and GitHub committed 2022-12-12 18:37:01 -06:00
1 parent e18b30a54e
commit e418017bc2
17 files changed
+420 -86

No files matched your search

@@ -0,0 +1,90 @@
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
module('Unit | Abilities | credential', function (hooks) {
setupTest(hooks);
test('canRead', function (assert) {
assert.expect(3);
const service = this.owner.lookup('service:can');
const credential = {
authorized_actions: ['read'],
type: 'json'
};
assert.ok(
service.can('read credential', credential)
);
credential.type = 'username_password'
assert.ok(
service.can('read credential', credential)
);
credential.type = 'ssh_private_key'
assert.ok(
service.can('read credential', credential)
);
});
test('cannot read without proper authorized actions', function (assert) {
assert.expect(3);
const service = this.owner.lookup('service:can');
const credential = {
authorized_actions: [],
type: 'json'
};
assert.notOk(
service.can('read credential', credential)
);
credential.type = 'username_password'
assert.notOk(
service.can('read credential', credential)
);
credential.type = 'ssh_private_key'
assert.notOk(
service.can('read credential', credential)
);
});
test('cannot read without proper authorized actions and json-credentials disabled', function (assert) {
assert.expect(3);
const service = this.owner.lookup('service:can');
const featuresService = this.owner.lookup('service:features');
featuresService.disable('json-credentials');
const credential = {
authorized_actions: [],
type: 'json'
};
assert.notOk(
service.can('read credential', credential)
);
credential.type = 'username_password'
assert.notOk(
service.can('read credential', credential)
);
credential.type = 'ssh_private_key'
assert.notOk(
service.can('read credential', credential)
);
});
test('cannot read when json-credentials is disabled', function (assert) {
assert.expect(3);
const service = this.owner.lookup('service:can');
const featuresService = this.owner.lookup('service:features');
featuresService.disable('json-credentials');
const credential = {
authorized_actions: ['read'],
type: 'json'
};
assert.notOk(
service.can('read credential', credential)
);
credential.type = 'username_password'
assert.ok(
service.can('read credential', credential)
);
credential.type = 'ssh_private_key'
assert.ok(
service.can('read credential', credential)
);
});
});