[ICU-15403] Trim whitespace on storage buckets and host sets json attrs serializers (#2636)
* trim whitespace on json attrs in storage bucket serializer * add test for storage bucket serializer * move trimWhitespace check to application level * add trimWhitespace to preferred_endpoints attr * add conditional for string arr * trim whitespace on str arr * add check for null val * refactor, move logic * relocate comment * add unit test for application serializer
This commit is contained in:
1 parent
b287683a61
commit
e8cc22879f
7 files changed
+46
-5
No files matched your search
@@ -381,4 +381,29 @@ module('Unit | Serializer | application', function (hooks) {
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
// JSON values will only be trimmed if the model attr
|
||||
// includes the trimWhitespace property set to true
|
||||
// See preferred_endpoints attr on host-set model
|
||||
test('it trims whitespace on json values', function (assert) {
|
||||
const store = this.owner.lookup('service:store');
|
||||
const record = store.createRecord('host-set', {
|
||||
name: 'Host Set 1',
|
||||
compositeType: 'azure',
|
||||
description: 'Description',
|
||||
host_catalog_id: '123',
|
||||
version: 1,
|
||||
preferred_endpoints: [{ value: ' option 1' }, { value: 'option 2 ' }],
|
||||
sync_interval_seconds: 1,
|
||||
});
|
||||
assert.deepEqual(record.serialize(), {
|
||||
name: 'Host Set 1',
|
||||
description: 'Description',
|
||||
host_catalog_id: '123',
|
||||
version: 1,
|
||||
preferred_endpoints: ['option 1', 'option 2'],
|
||||
sync_interval_seconds: 1,
|
||||
attributes: {},
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -54,7 +54,7 @@ module('Unit | Serializer | host set', function (hooks) {
|
||||
description: 'Description',
|
||||
host_catalog_id: '123',
|
||||
version: 1,
|
||||
preferred_endpoints: [{ value: 'option 1' }, { value: 'option 2' }],
|
||||
preferred_endpoints: [{ value: ' option 1' }, { value: 'option 2 ' }],
|
||||
sync_interval_seconds: 1,
|
||||
filters: [{ value: 'filter 1' }, { value: 'filter 2' }],
|
||||
});
|
||||
|
||||
@@ -26,7 +26,7 @@ module('Unit | Serializer | storage bucket', function (hooks) {
|
||||
bucket_name: 'bucketname',
|
||||
bucket_prefix: 'bucketprefix',
|
||||
worker_filter: 'workerfilter',
|
||||
region: 'eu-west-1',
|
||||
region: 'eu-west-1 ',
|
||||
access_key_id: 'foobars',
|
||||
secret_access_key: 'testing',
|
||||
disable_credential_rotation: true,
|
||||
@@ -117,7 +117,7 @@ module('Unit | Serializer | storage bucket', function (hooks) {
|
||||
access_key_id: '',
|
||||
secret_access_key: '',
|
||||
disable_credential_rotation: true,
|
||||
role_arn: 'arn',
|
||||
role_arn: 'arn ',
|
||||
role_external_id: 'Example987',
|
||||
role_session_name: 'my-session',
|
||||
role_tags: [
|
||||
@@ -160,12 +160,12 @@ module('Unit | Serializer | storage bucket', function (hooks) {
|
||||
bucket_prefix: 'bucketprefix',
|
||||
worker_filter: 'workerfilter',
|
||||
plugin: { name: 'aws' },
|
||||
region: 'eu-west-1',
|
||||
region: ' eu-west-1 ',
|
||||
access_key_id: 'foobars',
|
||||
secret_access_key: 'testing',
|
||||
disable_credential_rotation: true,
|
||||
version: 1,
|
||||
role_arn: 'role_arn_test',
|
||||
role_arn: ' role_arn_test ',
|
||||
role_external_id: 'role_external_id_test',
|
||||
role_session_name: 'role_session_test',
|
||||
role_tags: [
|
||||
|
||||
Reference in new issue
Block a user