Icu 10926 add dynamic credential fields in sb model (#1891)
* feat: 🎸 add support for dynamic credentials in storage bucket
This commit is contained in:
1 parent
f4c153a132
commit
29e57935f6
2 files changed
+88
-4
No files matched your search
@@ -79,6 +79,13 @@ export default class GeneratedStorageBucketModel extends BaseModel {
|
||||
})
|
||||
secrets_hmac;
|
||||
|
||||
@attr('boolean', {
|
||||
isNestedAttribute: true,
|
||||
description: 'If set to `true`, credential rotation is not performed.',
|
||||
})
|
||||
disable_credential_rotation;
|
||||
|
||||
// =attributes (static credentials)
|
||||
@attr('string', {
|
||||
isNestedSecret: true,
|
||||
description: 'The AWS access key ID to use.',
|
||||
@@ -91,9 +98,29 @@ export default class GeneratedStorageBucketModel extends BaseModel {
|
||||
})
|
||||
secret_access_key;
|
||||
|
||||
@attr('boolean', {
|
||||
// =attributes (dynamic credentials)
|
||||
@attr('string', {
|
||||
isNestedAttribute: true,
|
||||
description: '',
|
||||
description: 'The role ARN to use.',
|
||||
})
|
||||
disable_credential_rotation;
|
||||
role_arn;
|
||||
|
||||
@attr('string', {
|
||||
isNestedAttribute: true,
|
||||
description: 'The role external ID to use.',
|
||||
})
|
||||
role_external_id;
|
||||
|
||||
@attr('string', {
|
||||
isNestedAttribute: true,
|
||||
description: 'The role session to use.',
|
||||
})
|
||||
role_session_name;
|
||||
|
||||
@attr('object-as-array', {
|
||||
isNestedAttribute: true,
|
||||
description: 'The role tags to use.',
|
||||
useLabels: true,
|
||||
})
|
||||
role_tags;
|
||||
}
|
||||
@@ -22,7 +22,7 @@ module('Unit | Serializer | storage bucket', function (hooks) {
|
||||
assert.ok(serializedRecord);
|
||||
});
|
||||
|
||||
test('it serializes a new aws plugin as expected', async function (assert) {
|
||||
test('it serializes a new static aws plugin as expected', async function (assert) {
|
||||
assert.expect(1);
|
||||
const store = this.owner.lookup('service:store');
|
||||
const record = store.createRecord('storage-bucket', {
|
||||
@@ -37,6 +37,10 @@ module('Unit | Serializer | storage bucket', function (hooks) {
|
||||
secret_access_key: 'testing',
|
||||
secrets_hmac: 'hmac',
|
||||
disable_credential_rotation: true,
|
||||
role_arn: null,
|
||||
role_external_id: null,
|
||||
role_session_name: null,
|
||||
role_tags: null,
|
||||
});
|
||||
const expectedResult = {
|
||||
name: 'AWS',
|
||||
@@ -48,6 +52,10 @@ module('Unit | Serializer | storage bucket', function (hooks) {
|
||||
attributes: {
|
||||
region: 'eu-west-1',
|
||||
disable_credential_rotation: true,
|
||||
role_arn: null,
|
||||
role_external_id: null,
|
||||
role_session_name: null,
|
||||
role_tags: null,
|
||||
},
|
||||
secrets: {
|
||||
access_key_id: 'foobars',
|
||||
@@ -57,6 +65,47 @@ module('Unit | Serializer | storage bucket', function (hooks) {
|
||||
assert.deepEqual(record.serialize(), expectedResult);
|
||||
});
|
||||
|
||||
test('it serializes a new dynamic aws plugin as expected', async function (assert) {
|
||||
assert.expect(1);
|
||||
const store = this.owner.lookup('service:store');
|
||||
const record = store.createRecord('storage-bucket', {
|
||||
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',
|
||||
access_key_id: '',
|
||||
secret_access_key: '',
|
||||
secrets_hmac: 'hmac',
|
||||
disable_credential_rotation: true,
|
||||
role_arn: 'arn',
|
||||
role_external_id: 'Example987',
|
||||
role_session_name: 'my-session',
|
||||
role_tags: [
|
||||
{ key: 'Project', value: 'Automation' },
|
||||
{ key: 'foo', value: 'bar' },
|
||||
],
|
||||
});
|
||||
const expectedResult = {
|
||||
name: 'AWS',
|
||||
description: 'this has an aws plugin',
|
||||
type: TYPE_STORAGE_BUCKET_PLUGIN,
|
||||
bucket_name: 'bucketname',
|
||||
bucket_prefix: 'bucketprefix',
|
||||
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' },
|
||||
},
|
||||
};
|
||||
assert.deepEqual(record.serialize(), expectedResult);
|
||||
});
|
||||
test('it serializes when updating correctly', async function (assert) {
|
||||
assert.expect(1);
|
||||
const store = this.owner.lookup('service:store');
|
||||
@@ -79,6 +128,10 @@ module('Unit | Serializer | storage bucket', function (hooks) {
|
||||
secrets_hmac: 'hmac',
|
||||
disable_credential_rotation: true,
|
||||
version: 1,
|
||||
role_arn: null,
|
||||
role_external_id: null,
|
||||
role_session_name: null,
|
||||
role_tags: [],
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -94,6 +147,10 @@ module('Unit | Serializer | storage bucket', function (hooks) {
|
||||
attributes: {
|
||||
region: 'eu-west-1',
|
||||
disable_credential_rotation: true,
|
||||
role_arn: null,
|
||||
role_external_id: null,
|
||||
role_session_name: null,
|
||||
role_tags: null,
|
||||
},
|
||||
secrets: {
|
||||
access_key_id: 'foobars',
|
||||
|
||||
Reference in new issue
Block a user