From 406e45f039485ad086074414e1f3222a2536913f Mon Sep 17 00:00:00 2001 From: Cameron Perera Date: Thu, 28 Sep 2023 12:10:35 -0500 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20dynamic=20storage=20bucke?= =?UTF-8?q?t=20showing=20as=20static=20(#1933)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- addons/api/addon/models/storage-bucket.js | 8 +++++++- addons/api/tests/unit/models/storage-bucket-test.js | 12 +++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/addons/api/addon/models/storage-bucket.js b/addons/api/addon/models/storage-bucket.js index 6f7d1b28ef..8a1a4f1f7c 100644 --- a/addons/api/addon/models/storage-bucket.js +++ b/addons/api/addon/models/storage-bucket.js @@ -38,7 +38,13 @@ export default class StorageBucketModel extends GeneratedStorageBucketModel { * @type {string} */ get credentialType() { - if (!this.#credentialType) return 'static'; + if (!this.#credentialType) { + if (this.role_arn) { + this.#credentialType = TYPE_CREDENTIAL_DYNAMIC; + } else { + this.#credentialType = TYPE_CREDENTIAL_STATIC; + } + } return this.#credentialType; } diff --git a/addons/api/tests/unit/models/storage-bucket-test.js b/addons/api/tests/unit/models/storage-bucket-test.js index 81ffa60e3f..e88417da5c 100644 --- a/addons/api/tests/unit/models/storage-bucket-test.js +++ b/addons/api/tests/unit/models/storage-bucket-test.js @@ -46,7 +46,7 @@ module('Unit | Model | storage bucket', function (hooks) { }); test('it has credentialType property and returns the expected values', async function (assert) { - assert.expect(2); + assert.expect(4); const store = this.owner.lookup('service:store'); const modelA = store.createRecord('storage-bucket', { role_arn: 'test-role-arn', @@ -58,8 +58,18 @@ module('Unit | Model | storage bucket', function (hooks) { access_key_id: 'test-access-key-id', credentialType: TYPE_CREDENTIAL_STATIC, }); + const modelC = store.createRecord('storage-bucket', { + role_arn: null, + access_key_id: 'test-access-key-id', + }); + const modelD = store.createRecord('storage-bucket', { + role_arn: 'test-role-arn', + access_key_id: null, + }); assert.strictEqual(modelA.credentialType, TYPE_CREDENTIAL_DYNAMIC); assert.strictEqual(modelB.credentialType, TYPE_CREDENTIAL_STATIC); + assert.strictEqual(modelC.credentialType, TYPE_CREDENTIAL_STATIC); + assert.strictEqual(modelD.credentialType, TYPE_CREDENTIAL_DYNAMIC); }); test('it has isAWS property and returns the expected values', async function (assert) {