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:
9 files changed
+423
-129
No files matched your search
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -86,6 +86,9 @@ module('Unit | Serializer | credential', function (hooks) {
|
||||
type: 'username_password',
|
||||
username: 'username',
|
||||
version: 1,
|
||||
passphrase: '',
|
||||
private_key: '',
|
||||
password: '',
|
||||
},
|
||||
type: 'credential',
|
||||
id: 'credup_123',
|
||||
@@ -117,6 +120,9 @@ module('Unit | Serializer | credential', function (hooks) {
|
||||
type: 'ssh_private_key',
|
||||
username: 'username',
|
||||
version: 1,
|
||||
passphrase: '',
|
||||
private_key: '',
|
||||
password: '',
|
||||
},
|
||||
type: 'credential',
|
||||
id: 'credspk_123',
|
||||
|
||||
@@ -396,6 +396,20 @@ credential:
|
||||
ssh_private_key: Username & Key Pair
|
||||
help:
|
||||
username_password: This host requires a username and password to connect.
|
||||
ssh_private_key: This host requires a username, public key, and private key to connect.
|
||||
form:
|
||||
username:
|
||||
label: Username
|
||||
help: The username to use when connecting with this credential store.
|
||||
password:
|
||||
label: Password
|
||||
help: The password to use when signing in with this credential store.
|
||||
private_key:
|
||||
label: SSH Private Key
|
||||
help: The private key to use when connecting with this credential store.
|
||||
passphrase:
|
||||
label: Pass phrase
|
||||
help: Optional.
|
||||
scope:
|
||||
title: Scope
|
||||
title_plural: Scopes
|
||||
|
||||
Reference in new issue
Block a user