Icu 6800 api is secret data modeling (#1448)

* refactor: 💡 Add isSecret option for model attributes

Move secret attribute logic to application serializer that will remove
the key/value pair if the value is null or empty

✅ Closes: ICU-6800

* refactor: 💡 Add isSecret option to credential store token

* Update addons/api/addon/serializers/credential.js

Remove unneeded serialize method for credentials

Co-authored-by: Randall Morey <randall@randallmorey.com>

* refactor: 💡 add type check for serializing secret attributes

Co-authored-by: Randall Morey <randall@randallmorey.com>
This commit is contained in:
Cameron PereraandRandall Morey authored and GitHub committed 2022-11-14 14:45:53 -06:00
1 parent faec9aad73
commit 84077b5d8a
7 files changed
+36 -43

No files matched your search

@@ -107,6 +107,33 @@ module('Unit | Serializer | application', function (hooks) {
});
});
test('it serializes secret attributes correctly', function (assert) {
assert.expect(1);
const store = this.owner.lookup('service:store');
const record = store.createRecord('credential', {
private_key_passphrase: undefined,
private_key: null,
password: '',
username: 'user',
credential_store_id: 'csst_i7p1eu0Nw8',
type: 'username_password',
name: 'Name',
description: 'Description',
version: 1,
});
const serializedRecord = record.serialize();
assert.deepEqual(serializedRecord, {
attributes: {
username: 'user',
},
credential_store_id: 'csst_i7p1eu0Nw8',
type: 'username_password',
name: 'Name',
description: 'Description',
version: 1,
});
});
test('it normalizes array records from an `items` root key', function (assert) {
assert.expect(1);
const store = this.owner.lookup('service:store');
@@ -97,7 +97,7 @@ module('Unit | Serializer | credential', function (hooks) {
const store = this.owner.lookup('service:store');
const serializer = store.serializerFor('credential');
const record = store.createRecord('credential', {
private_key_passphrase: '',
private_key_passphrase: null,
private_key: '',
username: 'user',
credential_store_id: 'csst_i7p1eu0Nw8',