From 39c0835a99910259d49dbd191f03b4b079c22890 Mon Sep 17 00:00:00 2001 From: Cameron Perera Date: Fri, 12 Aug 2022 15:56:19 -0500 Subject: [PATCH] =?UTF-8?q?feat:=20=F0=9F=8E=B8=20Update=20credential=20mo?= =?UTF-8?q?del=20with=20ssh=20private=20key=20attributes=20(#1254)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ✅ Closes: ICU-5645 --- .../api/addon/generated/models/credential.js | 22 ++++++++++++++++--- addons/api/addon/serializers/credential.js | 4 ++++ .../api/tests/unit/models/credential-test.js | 5 ++--- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/addons/api/addon/generated/models/credential.js b/addons/api/addon/generated/models/credential.js index e596d15bd..898beb83d 100644 --- a/addons/api/addon/generated/models/credential.js +++ b/addons/api/addon/generated/models/credential.js @@ -46,6 +46,14 @@ export default class GeneratedCredentialModel extends BaseModel { }) version; + // =attributes (username_password, ssh_private_key) + @attr('string', { + for: ['username_password', 'ssh_private_key'], + isNestedAttribute: true, + description: 'The username for credential.', + }) + username; + // =attributes (username_password) @attr('string', { for: 'username_password', @@ -54,10 +62,18 @@ export default class GeneratedCredentialModel extends BaseModel { }) password; + // =attributes (ssh_private_key) @attr('string', { - for: 'username_password', + for: 'ssh_private_key', isNestedAttribute: true, - description: 'The username for credential.', + description: 'The private key for credential.', }) - username; + private_key; + + @attr('string', { + for: 'ssh_private_key', + isNestedAttribute: true, + description: 'The passphrase for credential.', + }) + passphrase; } diff --git a/addons/api/addon/serializers/credential.js b/addons/api/addon/serializers/credential.js index 7aa3f19e2..8b6ddb419 100644 --- a/addons/api/addon/serializers/credential.js +++ b/addons/api/addon/serializers/credential.js @@ -5,6 +5,10 @@ export default class CredentialSerializer extends ApplicationSerializer { serialize() { const serialized = super.serialize(...arguments); delete serialized['attributes']['password_hmac']; + if (serialized.type === 'username_password') { + delete serialized['attributes']['private_key']; + delete serialized['attributes']['passphrase']; + } return serialized; } diff --git a/addons/api/tests/unit/models/credential-test.js b/addons/api/tests/unit/models/credential-test.js index c7f3b8863..7cf89e154 100644 --- a/addons/api/tests/unit/models/credential-test.js +++ b/addons/api/tests/unit/models/credential-test.js @@ -4,10 +4,9 @@ import { setupTest } from 'ember-qunit'; module('Unit | Model | credential', function (hooks) { setupTest(hooks); - // Replace this with your real tests. test('it exists', function (assert) { - let store = this.owner.lookup('service:store'); - let model = store.createRecord('credential', {}); + const store = this.owner.lookup('service:store'); + const model = store.createRecord('credential', {}); assert.ok(model); }); });