Icu 5651 create spk type (#1266)

Add functionality for creating a ssh private key credential and add
corresponding acceptance tests.

✅ Closes: ICU-5651

Co-authored-by: Cameron Perera <cameron.perera@hashicorp.com>
Co-authored-by: Randall Morey <randall@randallmorey.com>
Co-authored-by: Zhihe Li <zhihe.li@hashicorp.com>
This commit is contained in:
authored and GitHub committed 2022-08-24 15:50:48 -07:00
1 parent 1ee83dd1e6
commit fb981c02ea
9 files changed
+423 -129

No files matched your search

+10 -4
View File
@@ -26,15 +26,19 @@ export default class CredentialSerializer extends ApplicationSerializer {
serializeUsernamePassword() {
const serialized = super.serialize(...arguments);
// Remove non-username_password type attributes
delete serialized['attributes']['private_key'];
delete serialized['attributes']['passphrase'];
delete serialized.attributes.private_key;
delete serialized.attributes.passphrase;
return serialized;
}
serializeSSHPrivateKey() {
const serialized = super.serialize(...arguments);
// Remove non-ssh_private_key type attributes
delete serialized['attributes']['password'];
delete serialized.attributes.password;
if (!serialized?.attributes?.passphrase)
delete serialized.attributes.passphrase;
if (!serialized?.attributes?.private_key)
delete serialized.attributes.private_key;
return serialized;
}
@@ -42,7 +46,9 @@ export default class CredentialSerializer extends ApplicationSerializer {
const normalizedHash = copy(hash, true);
const normalized = super.normalize(typeClass, normalizedHash, ...rest);
// Remove passphrase as we don't track it after being created/updated
delete normalized['data']['attributes']['passphrase'];
normalized.data.attributes.passphrase = '';
normalized.data.attributes.password = '';
normalized.data.attributes.private_key = '';
return normalized;
}
}