From bd0189cf103b6fb37fc9aab9ac040f5a50d127b4 Mon Sep 17 00:00:00 2001 From: lisbet-alvarez <107949262+lisbet-alvarez@users.noreply.github.com> Date: Tue, 19 Jul 2022 13:02:04 -0700 Subject: [PATCH] Icu 5229 credential model (#1197) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: 🎸 Create Credential Model in API ✅ Closes: ICU-5229 Co-authored-by: Cameron Perera --- .../api/addon/generated/models/credential.js | 63 +++++++++++++++++++ addons/api/addon/models/credential.js | 3 + addons/api/app/models/credential.js | 1 + .../api/tests/unit/models/credential-test.js | 13 ++++ 4 files changed, 80 insertions(+) create mode 100644 addons/api/addon/generated/models/credential.js create mode 100644 addons/api/addon/models/credential.js create mode 100644 addons/api/app/models/credential.js create mode 100644 addons/api/tests/unit/models/credential-test.js diff --git a/addons/api/addon/generated/models/credential.js b/addons/api/addon/generated/models/credential.js new file mode 100644 index 000000000..302e4a6db --- /dev/null +++ b/addons/api/addon/generated/models/credential.js @@ -0,0 +1,63 @@ +import BaseModel from '../../models/base'; +import { attr } from '@ember-data/model'; + +/** + * A credential is a data structure containing one or more secrets that binds an + * identity to a set of permissions or capabilities on a host for a session. + */ +export default class GeneratedCredentialModel extends BaseModel { + // =attributes + + @attr('string', { + description: + 'The ID of the Credential Store of which this Credential is a part.', + }) + credential_store_id; + + @attr('string', { + description: 'The type of the resource, to help differentiate schemas', + }) + type; + + @attr('string', { + description: 'Optional name for identification purposes', + }) + name; + + @attr('string', { + description: 'Optional user-set description for identification purposes', + }) + description; + + @attr('date', { + description: 'The time this resource was created\nOutput only.', + readOnly: true, + }) + created_time; + + @attr('date', { + description: 'The time this resource was last updated\nOutput only.', + readOnly: true, + }) + updated_time; + + @attr('number', { + description: 'Current version number of this resource.', + }) + version; + + // =attributes (username_password) + @attr('string', { + for: 'username_password', + isNestedAttribute: true, + description: 'The password hmac for credential.', + }) + password_hmac; + + @attr('string', { + for: 'username_password', + isNestedAttribute: true, + description: 'The username for credential.', + }) + username; +} diff --git a/addons/api/addon/models/credential.js b/addons/api/addon/models/credential.js new file mode 100644 index 000000000..2908d772b --- /dev/null +++ b/addons/api/addon/models/credential.js @@ -0,0 +1,3 @@ +import GeneratedCredentialModel from '../generated/models/credential'; + +export default class CredentialModel extends GeneratedCredentialModel {} diff --git a/addons/api/app/models/credential.js b/addons/api/app/models/credential.js new file mode 100644 index 000000000..b29e404b9 --- /dev/null +++ b/addons/api/app/models/credential.js @@ -0,0 +1 @@ +export { default } from 'api/models/credential'; diff --git a/addons/api/tests/unit/models/credential-test.js b/addons/api/tests/unit/models/credential-test.js new file mode 100644 index 000000000..2d6018943 --- /dev/null +++ b/addons/api/tests/unit/models/credential-test.js @@ -0,0 +1,13 @@ +import { module, test } from 'qunit'; +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', {}); + assert.ok(model); + }); +});