Refactor key value comp (#2180)

* refactor: 💡 keyvalue comp
This commit is contained in:
Dharini Jeeva authored and GitHub committed 2024-06-03 13:38:42 -07:00
1 parent 9b403b3159
commit 6397cd80a6
22 files changed
+531 -405

No files matched your search

@@ -139,7 +139,7 @@ module('Unit | Serializer | application', function (hooks) {
type: TYPE_AUTH_METHOD_OIDC, //has both string and array `for` option
name: 'OIDC Auth Method',
state: 'foo',
account_claim_maps: [{ from: 'foo', to: 'bar' }],
account_claim_maps: [{ key: 'foo', value: 'bar' }],
claims_scopes: [{ value: 'profile' }, { value: 'email' }],
signing_algorithms: [{ value: 'RS256' }, { value: 'RS384' }],
allowed_audiences: [
@@ -45,7 +45,7 @@ module('Unit | Serializer | auth method', function (hooks) {
type: TYPE_AUTH_METHOD_OIDC,
name: 'OIDC Auth Method',
state: 'foo',
account_claim_maps: [{ from: 'foo', to: 'bar' }],
account_claim_maps: [{ key: 'foo', value: 'bar' }],
claims_scopes: [{ value: 'profile' }, { value: 'email' }],
signing_algorithms: [{ value: 'RS256' }, { value: 'RS384' }],
allowed_audiences: [
@@ -96,7 +96,7 @@ module('Unit | Serializer | auth method', function (hooks) {
type: TYPE_AUTH_METHOD_LDAP,
name: 'LDAP Auth Method',
state: 'baz',
account_attribute_maps: [{ from: 'foo', to: 'bar' }],
account_attribute_maps: [{ key: 'foo', value: 'bar' }],
urls: [{ value: 'ldap://ldap.example.com' }],
use_token_groups: false,
start_tls: true,
@@ -160,7 +160,7 @@ module('Unit | Serializer | auth method', function (hooks) {
type: TYPE_AUTH_METHOD_OIDC,
name: 'OIDC Auth Method',
state: 'foo',
account_claim_maps: [{ from: 'foo', to: 'bar' }],
account_claim_maps: [{ key: 'foo', value: 'bar' }],
claims_scopes: [{ value: 'profile' }, { value: 'email' }],
signing_algorithms: [{ value: 'RS256' }, { value: 'RS384' }],
allowed_audiences: [
@@ -210,7 +210,7 @@ module('Unit | Serializer | auth method', function (hooks) {
type: TYPE_AUTH_METHOD_LDAP,
name: 'LDAP Auth Method',
state: 'baz',
account_attribute_maps: [{ from: 'foo', to: 'bar' }],
account_attribute_maps: [{ key: 'foo', value: 'bar' }],
urls: [{ value: 'ldap://ldap.example.com' }],
use_token_groups: false,
start_tls: true,
@@ -410,8 +410,8 @@ module('Unit | Serializer | auth method', function (hooks) {
prompts,
} = record;
assert.deepEqual(account_claim_maps, [
{ from: 'from', to: 'to' },
{ from: 'foo', to: 'bar' },
{ key: 'from', value: 'to' },
{ key: 'foo', value: 'bar' },
]);
assert.deepEqual(claims_scopes, [{ value: 'profile' }, { value: 'email' }]);
assert.deepEqual(allowed_audiences, [
@@ -481,8 +481,8 @@ module('Unit | Serializer | auth method', function (hooks) {
certificates: recordCertificates,
} = record;
assert.deepEqual(account_attribute_maps, [
{ from: 'from', to: 'to' },
{ from: 'foo', to: 'bar' },
{ key: 'from', value: 'to' },
{ key: 'foo', value: 'bar' },
]);
assert.deepEqual(urls, [{ value: ldapUrl }]);
assert.deepEqual(recordCertificates, [
@@ -24,7 +24,9 @@ module('Unit | Serializer | credential library', function (hooks) {
http_method: 'GET',
version: 1,
credential_type: 'ssh_private_key',
credential_mapping_overrides: { username_attribute: 'user' },
credential_mapping_overrides: [
{ key: 'username_attribute', value: 'user' },
],
});
const snapshot = record._createSnapshot();
const serializedRecord = serializer.serialize(snapshot);
@@ -61,7 +63,9 @@ module('Unit | Serializer | credential library', function (hooks) {
http_method: 'GET',
version: 1,
credential_type: 'ssh_private_key',
credential_mapping_overrides: {},
credential_mapping_overrides: [
{ key: 'private_key_attribute', value: 'test' },
],
},
},
});
@@ -75,7 +79,7 @@ module('Unit | Serializer | credential library', function (hooks) {
description: 'Description',
credential_type: 'ssh_private_key',
credential_mapping_overrides: {
private_key_attribute: null,
private_key_attribute: 'test',
private_key_passphrase_attribute: null,
username_attribute: null,
},
@@ -116,7 +120,7 @@ module('Unit | Serializer | credential library', function (hooks) {
name: null,
type: TYPE_CREDENTIAL_LIBRARY_VAULT_GENERIC,
credential_type: null,
credential_mapping_overrides: {},
credential_mapping_overrides: null,
});
assert.deepEqual(serializedVaultSSHCertificateRecord, {
attributes: {
@@ -157,7 +161,7 @@ module('Unit | Serializer | credential library', function (hooks) {
name: null,
type: TYPE_CREDENTIAL_LIBRARY_VAULT_GENERIC,
credential_type: null,
credential_mapping_overrides: {},
credential_mapping_overrides: null,
},
'http_request_body attribute is not expected',
);
@@ -177,7 +181,7 @@ module('Unit | Serializer | credential library', function (hooks) {
name: null,
type: TYPE_CREDENTIAL_LIBRARY_VAULT_GENERIC,
credential_type: null,
credential_mapping_overrides: {},
credential_mapping_overrides: null,
},
'http_request_body attribute is expected',
);
@@ -13,16 +13,16 @@ module('Unit | Transform | account value map array', function (hooks) {
const transform = this.owner.lookup('transform:account-value-map-array');
const deserialized = transform.deserialize(['oid=sub', 'full_name=name']);
assert.deepEqual(deserialized, [
{ from: 'oid', to: 'sub' },
{ from: 'full_name', to: 'name' },
{ key: 'oid', value: 'sub' },
{ key: 'full_name', value: 'name' },
]);
});
test('it serializes an array of account claims', function (assert) {
const transform = this.owner.lookup('transform:account-value-map-array');
const serialized = transform.serialize([
{ from: 'oid', to: 'sub' },
{ from: 'full_name', to: 'name' },
{ key: 'oid', value: 'sub' },
{ key: 'full_name', value: 'name' },
]);
assert.deepEqual(serialized, ['oid=sub', 'full_name=name']);
});