Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 🐛 dynamic storage bucket showing as static #1933

Merged
merged 3 commits into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion addons/api/addon/models/storage-bucket.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
12 changes: 11 additions & 1 deletion addons/api/tests/unit/models/storage-bucket-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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) {
Expand Down