Icu 11022 update dynamic credentials in sb form (#1901)

This commit is contained in:
Dharini Jeeva authored and GitHub committed 2023-09-18 14:23:30 -07:00
1 parent 4910070c95
commit 78d1e09a0d
8 files changed
+112 -33

No files matched your search

@@ -35,7 +35,6 @@ module('Unit | Serializer | storage bucket', function (hooks) {
region: 'eu-west-1',
access_key_id: 'foobars',
secret_access_key: 'testing',
secrets_hmac: 'hmac',
disable_credential_rotation: true,
role_arn: null,
role_external_id: null,
@@ -78,7 +77,6 @@ module('Unit | Serializer | storage bucket', function (hooks) {
region: 'eu-west-1',
access_key_id: '',
secret_access_key: '',
secrets_hmac: 'hmac',
disable_credential_rotation: true,
role_arn: 'arn',
role_external_id: 'Example987',
@@ -106,7 +104,7 @@ module('Unit | Serializer | storage bucket', function (hooks) {
};
assert.deepEqual(record.serialize(), expectedResult);
});
test('it serializes when updating correctly', async function (assert) {
test('it serializes when updating a storage bucket with static credential correctly', async function (assert) {
assert.expect(1);
const store = this.owner.lookup('service:store');
const serializer = store.serializerFor('storage-bucket');
@@ -125,13 +123,8 @@ module('Unit | Serializer | storage bucket', function (hooks) {
region: 'eu-west-1',
access_key_id: 'foobars',
secret_access_key: 'testing',
secrets_hmac: 'hmac',
disable_credential_rotation: true,
version: 1,
role_arn: null,
role_external_id: null,
role_session_name: null,
role_tags: [],
},
},
});
@@ -161,6 +154,57 @@ module('Unit | Serializer | storage bucket', function (hooks) {
assert.deepEqual(serializedRecord, expectedResult);
});
test('it serializes when updating a storage bucket with dynamic credential correctly', async function (assert) {
assert.expect(1);
const store = this.owner.lookup('service:store');
const serializer = store.serializerFor('storage-bucket');
store.push({
data: {
id: '1',
type: 'storage-bucket',
attributes: {
type: TYPE_STORAGE_BUCKET_PLUGIN,
compositeType: TYPE_STORAGE_BUCKET_PLUGIN_AWS_S3,
name: 'AWS',
description: 'this has an aws plugin',
bucket_name: 'bucketname',
bucket_prefix: 'bucketprefix',
worker_filter: 'workerfilter',
region: 'eu-west-1',
disable_credential_rotation: true,
version: 1,
role_arn: 'arn',
role_external_id: 'Example987',
role_session_name: 'my-session',
role_tags: [
{ key: 'Project', value: 'Automation' },
{ key: 'foo', value: 'bar' },
],
},
},
});
const record = store.peekRecord('storage-bucket', '1');
const snapshot = record._createSnapshot();
const serializedRecord = serializer.serialize(snapshot);
const expectedResult = {
name: 'AWS',
description: 'this has an aws plugin',
type: TYPE_STORAGE_BUCKET_PLUGIN,
worker_filter: 'workerfilter',
attributes: {
region: 'eu-west-1',
disable_credential_rotation: true,
role_arn: 'arn',
role_external_id: 'Example987',
role_session_name: 'my-session',
role_tags: { Project: 'Automation', foo: 'bar' },
},
version: 1,
};
assert.deepEqual(serializedRecord, expectedResult);
});
test('it normalizes correctly', function (assert) {
assert.expect(1);
const store = this.owner.lookup('service:store');
@@ -179,7 +223,6 @@ module('Unit | Serializer | storage bucket', function (hooks) {
region: 'eu-west-1',
disable_credential_rotation: true,
},
secrets_hmac: 'this is secret',
};
const normalized = serializer.normalizeSingleResponse(
store,
@@ -200,7 +243,6 @@ module('Unit | Serializer | storage bucket', function (hooks) {
bucket_name: 'bucketname',
bucket_prefix: 'bucketprefix',
worker_filter: 'workerfilter',
secrets_hmac: 'this is secret',
region: 'eu-west-1',
disable_credential_rotation: true,
access_key_id: null,