chore: 🤖 JSON credential data modeling (#1485)
* chore: 🤖 JSON credential data modeling Added json type to credential model, created `json_object` attribute for `json` type, updated credential serializer to handle `json_object` attribute data being sent to backend and updated normalizer to handlle secret untracked 'json_object'. ✅ Closes: ICU-6653, ICU-6684, ICU-6685, ICU-6802, ICU-6803 * Update en-us.yaml fixed spelling * Update addons/api/addon/models/credential.js Co-authored-by: Cameron Perera <cameron.perera@hashicorp.com> * refactor: 💡 refactor credential serializer and .yaml Refactored credential serializer to check for `json_object` existence before serializing and changed help variable in `.yaml` file for credentials. * refactor: 💡 refactor for credential serializer Refactor credential serializer removed redundant code, Co-authored-by: Cameron Perera <cameron.perera@hashicorp.com>
This commit is contained in:
1 parent
6b166401a1
commit
e3d44eb813
5 files changed
+90
-3
No files matched your search
@@ -79,4 +79,12 @@ export default class GeneratedCredentialModel extends BaseModel {
|
||||
description: 'The private key passphrase for credential.',
|
||||
})
|
||||
private_key_passphrase;
|
||||
|
||||
@attr('string', {
|
||||
for: 'json',
|
||||
isNestedAttribute: true,
|
||||
isSecret: true,
|
||||
description: 'The secret associated with credential.',
|
||||
})
|
||||
json_object;
|
||||
}
|
||||
@@ -13,6 +13,20 @@ export default class CredentialSerializer extends ApplicationSerializer {
|
||||
*/
|
||||
serializeScopeID = false;
|
||||
|
||||
serialize() {
|
||||
const serialized = super.serialize(...arguments);
|
||||
|
||||
if (serialized.type === 'json') {
|
||||
delete serialized.attributes.username;
|
||||
|
||||
if (serialized?.attributes?.json_object) {
|
||||
serialized.attributes.object = JSON.parse(serialized.attributes.json_object);
|
||||
delete serialized.attributes.json_object;
|
||||
}
|
||||
}
|
||||
|
||||
return serialized;
|
||||
}
|
||||
|
||||
normalize(typeClass, hash, ...rest) {
|
||||
const normalizedHash = copy(hash, true);
|
||||
@@ -21,6 +35,7 @@ export default class CredentialSerializer extends ApplicationSerializer {
|
||||
normalized.data.attributes.password = '';
|
||||
normalized.data.attributes.private_key = '';
|
||||
normalized.data.attributes.private_key_passphrase = '';
|
||||
normalized.data.attributes.json_object = '';
|
||||
return normalized;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user