diff --git a/addons/api/addon/models/fragment-host-set.js b/addons/api/addon/models/fragment-host-source.js similarity index 66% rename from addons/api/addon/models/fragment-host-set.js rename to addons/api/addon/models/fragment-host-source.js index e0f3a1e1c..5f39cb8f7 100644 --- a/addons/api/addon/models/fragment-host-set.js +++ b/addons/api/addon/models/fragment-host-source.js @@ -1,13 +1,13 @@ import Fragment from 'ember-data-model-fragments/fragment'; import { attr } from '@ember-data/model'; -export default class FragmentHostSetModel extends Fragment { +export default class FragmentHostSourceModel extends Fragment { // =attributes @attr('string', { - description: 'ID of the related host set', + description: 'ID of the related host source', }) - host_set_id; + host_source_id; @attr('string', { description: 'ID of the catalog to which the host set belongs', diff --git a/addons/api/addon/models/target.js b/addons/api/addon/models/target.js index d60596465..9b36a5749 100644 --- a/addons/api/addon/models/target.js +++ b/addons/api/addon/models/target.js @@ -12,23 +12,23 @@ export default class TargetModel extends GeneratedTargetModel { @fragment('fragment-target-attributes', { defaultValue: {} }) attributes; /** - * @type {[FragmentHostSetModel]} + * @type {[FragmentHostSourceModel]} */ - @fragmentArray('fragment-host-set', { + @fragmentArray('fragment-host-source', { readOnly: true, emptyArrayIfMissing: true, }) - host_sets; + host_sources; /** - * Credential library ids are read only and can be - * persisted via a dedicated call to `addCredentialLibraries()`. + * Credential source ids are read only and can be + * persisted via a dedicated call to `addCredentialSources()`. */ @fragmentArray('fragment-string', { readOnly: true, emptyArrayIfMissing: true, }) - application_credential_library_ids; + application_credential_source_ids; /** * An array of resolved host set and host catalog instances. Model instances @@ -36,11 +36,11 @@ export default class TargetModel extends GeneratedTargetModel { * instances). Unresolvable instances are excluded from the array. * @type {[{model: HostSetModel, hostCatalog: HostCatalogModel}]} */ - @computed('host_sets.[]', 'store') + @computed('host_sources.[]', 'store') get hostSets() { - return this.host_sets - .map(({ host_set_id, host_catalog_id }) => ({ - model: this.store.peekRecord('host-set', host_set_id), + return this.host_sources + .map(({ host_source_id, host_catalog_id }) => ({ + model: this.store.peekRecord('host-set', host_source_id), hostCatalog: this.store.peekRecord('host-catalog', host_catalog_id), })) .filter((hostSetRef) => hostSetRef.model !== null); @@ -52,14 +52,11 @@ export default class TargetModel extends GeneratedTargetModel { * instances). Unresolvable instances are excluded from the array. * @type {[CredentialLibraryModel]} */ - @computed('application_credential_library_ids.[]', 'store') + @computed('application_credential_source_ids.[]', 'store') get credentialLibraries() { - return this.application_credential_library_ids - .map((credential_library_fragment) => - this.store.peekRecord( - 'credential-library', - credential_library_fragment.value - ) + return this.application_credential_source_ids + .map((source) => + this.store.peekRecord('credential-library', source.value) ) .filter(Boolean); } @@ -96,16 +93,16 @@ export default class TargetModel extends GeneratedTargetModel { // =methods /** - * Adds host sets via the `add-host-sets` method. + * Adds host sets via the `add-host-sources` method. * See serializer and adapter for more information. * @param {[string]} hostSetIDs * @param {object} options * @param {object} options.adapterOptions * @return {Promise} */ - addHostSets(hostSetIDs, options = { adapterOptions: {} }) { + addHostSources(hostSetIDs, options = { adapterOptions: {} }) { const defaultAdapterOptions = { - method: 'add-host-sets', + method: 'add-host-sources', hostSetIDs, }; // There is no "deep merge" in ES. @@ -119,16 +116,16 @@ export default class TargetModel extends GeneratedTargetModel { } /** - * Delete host sets via the `remove-host-sets` method. + * Delete host sets via the `remove-host-sources` method. * See serializer and adapter for more information. * @param {[string]} hostSetIDs * @param {object} options * @param {object} options.adapterOptions * @return {Promise} */ - removeHostSets(hostSetIDs, options = { adapterOptions: {} }) { + removeHostSources(hostSetIDs, options = { adapterOptions: {} }) { const defaultAdapterOptions = { - method: 'remove-host-sets', + method: 'remove-host-sources', hostSetIDs, }; // There is no "deep merge" in ES. @@ -142,29 +139,26 @@ export default class TargetModel extends GeneratedTargetModel { } /** - * Delete a single host set via the `remove-host-sets` method. + * Delete a single host set via the `remove-host-sources` method. * @param {number} hostSetID * @param {object} options * @return {Promise} */ - removeHostSet(hostSetID, options) { - return this.removeHostSets([hostSetID], options); + removeHostSource(hostSetID, options) { + return this.removeHostSources([hostSetID], options); } /** - * Adds credential libraries via the `add-credential-libraries` method. + * Adds credential libraries via the `add-credential-sources` method. * See serializer and adapter for more information. * @param {[string]} credentialLibraryIDs * @param {object} options * @param {object} options.adapterOptions * @return {Promise} */ - addCredentialLibraries( - credentialLibraryIDs, - options = { adapterOptions: {} } - ) { + addCredentialSources(credentialLibraryIDs, options = { adapterOptions: {} }) { const defaultAdapterOptions = { - method: 'add-credential-libraries', + method: 'add-credential-sources', credentialLibraryIDs, }; // There is no "deep merge" in ES. @@ -178,19 +172,19 @@ export default class TargetModel extends GeneratedTargetModel { } /** - * Delete credential libraries via the `remove-credential-libraries` method. + * Delete credential libraries via the `remove-credential-sources` method. * See serializer and adapter for more information. * @param {[string]} credentialLibraryIDs * @param {object} options * @param {object} options.adapterOptions * @return {Promise} */ - removeCredentialLibraries( + removeCredentialSources( credentialLibraryIDs, options = { adapterOptions: {} } ) { const defaultAdapterOptions = { - method: 'remove-credential-libraries', + method: 'remove-credential-sources', credentialLibraryIDs, }; // There is no "deep merge" in ES. @@ -204,12 +198,12 @@ export default class TargetModel extends GeneratedTargetModel { } /** - * Delete a single credential library set via the `remove-credential-libraries` method. + * Delete a single credential library set via the `remove-credential-sources` method. * @param {number} credentialLibraryID * @param {object} options * @return {Promise} */ - removeCredentialLibrary(credentialLibraryID, options) { - return this.removeCredentialLibraries([credentialLibraryID], options); + removeCredentialSource(credentialLibraryID, options) { + return this.removeCredentialSources([credentialLibraryID], options); } } diff --git a/addons/api/addon/serializers/fragment-auth-method-attributes-account-claim-map.js b/addons/api/addon/serializers/fragment-auth-method-attributes-account-claim-map.js index 5c5b4789e..611f6aa13 100644 --- a/addons/api/addon/serializers/fragment-auth-method-attributes-account-claim-map.js +++ b/addons/api/addon/serializers/fragment-auth-method-attributes-account-claim-map.js @@ -1,6 +1,6 @@ import JSONSerializer from '@ember-data/serializer/json'; -export default class FragmentHostSetSerializer extends JSONSerializer { +export default class FragmentHostSourceSerializer extends JSONSerializer { // =methods /** diff --git a/addons/api/addon/serializers/fragment-host-set.js b/addons/api/addon/serializers/fragment-host-set.js deleted file mode 100644 index 564c7ec9b..000000000 --- a/addons/api/addon/serializers/fragment-host-set.js +++ /dev/null @@ -1,16 +0,0 @@ -import JSONSerializer from '@ember-data/serializer/json'; - -export default class FragmentHostSetSerializer extends JSONSerializer { - // =methods - - /** - * Renames `id` to `host_set_id` because fragments may not have IDs. - * Otherwise normalizes as normal. - * @param {ModelClass} typeClass - * @param {object} resourceHash - * @return {object} - */ - normalize(typeClass, { id: host_set_id, ...obj }) { - return super.normalize(typeClass, { host_set_id, ...obj }); - } -} diff --git a/addons/api/addon/serializers/fragment-host-source.js b/addons/api/addon/serializers/fragment-host-source.js new file mode 100644 index 000000000..f4467f151 --- /dev/null +++ b/addons/api/addon/serializers/fragment-host-source.js @@ -0,0 +1,16 @@ +import JSONSerializer from '@ember-data/serializer/json'; + +export default class FragmentHostSourceSerializer extends JSONSerializer { + // =methods + + /** + * Renames `id` to `host_source_id` because fragments may not have IDs. + * Otherwise normalizes as normal. + * @param {ModelClass} typeClass + * @param {object} resourceHash + * @return {object} + */ + normalize(typeClass, { id: host_source_id, ...obj }) { + return super.normalize(typeClass, { host_source_id, ...obj }); + } +} diff --git a/addons/api/addon/serializers/target.js b/addons/api/addon/serializers/target.js index c287aca46..8bf8b6882 100644 --- a/addons/api/addon/serializers/target.js +++ b/addons/api/addon/serializers/target.js @@ -17,43 +17,44 @@ export default class TargetSerializer extends ApplicationSerializer { */ serialize(snapshot) { let serialized = super.serialize(...arguments); - const hostSetIDs = snapshot?.adapterOptions?.hostSetIDs; - if (hostSetIDs) - serialized = this.serializeWithHostSets(snapshot, hostSetIDs); - const credentialLibraryIDs = snapshot?.adapterOptions?.credentialLibraryIDs; - if (credentialLibraryIDs) - serialized = this.serializeWithCredentialLibraries( + const hostSourceIDs = snapshot?.adapterOptions?.hostSetIDs; + if (hostSourceIDs) { + serialized = this.serializeWithHostSources(snapshot, hostSourceIDs); + } + const credentialSourceIDs = snapshot?.adapterOptions?.credentialLibraryIDs; + if (credentialSourceIDs) + serialized = this.serializeWithCredentialSources( snapshot, - credentialLibraryIDs + credentialSourceIDs ); return serialized; } /** - * Returns a payload containing only the host_set_ids array using IDs - * passed into the function (rather than existing host sets on the model). + * Returns a payload containing only version and an array of passed IDs, + * rather than existing instances on the model. * @param {Snapshot} snapshot * @param {[string]} hostSetIDs * @return {object} */ - serializeWithHostSets(snapshot, hostSetIDs) { + serializeWithHostSources(snapshot, hostSourceIDs) { return { version: snapshot.attr('version'), - host_set_ids: hostSetIDs, + host_source_ids: hostSourceIDs, }; } /** - * Returns a payload containing only the credential_library_ids array using IDs - * passed into the function (rather than existing credential libraries on the model). + * Returns a payload containing only version and an array of passed IDs, + * rather than existing instances on the model. * @param {Snapshot} snapshot - * @param {[string]} credentialLibraryIDs + * @param {[string]} credentialSourceIDs * @return {object} */ - serializeWithCredentialLibraries(snapshot, credentialLibraryIDs) { + serializeWithCredentialSources(snapshot, credentialSourceIDs) { return { version: snapshot.attr('version'), - application_credential_library_ids: credentialLibraryIDs, + application_credential_source_ids: credentialSourceIDs, }; } } diff --git a/addons/api/app/models/fragment-host-set.js b/addons/api/app/models/fragment-host-set.js deleted file mode 100644 index bd1726680..000000000 --- a/addons/api/app/models/fragment-host-set.js +++ /dev/null @@ -1 +0,0 @@ -export { default } from 'api/models/fragment-host-set'; diff --git a/addons/api/app/models/fragment-host-source.js b/addons/api/app/models/fragment-host-source.js new file mode 100644 index 000000000..20b7480cc --- /dev/null +++ b/addons/api/app/models/fragment-host-source.js @@ -0,0 +1 @@ +export { default } from 'api/models/fragment-host-source'; diff --git a/addons/api/app/serializers/fragment-host-set.js b/addons/api/app/serializers/fragment-host-set.js deleted file mode 100644 index 62d638912..000000000 --- a/addons/api/app/serializers/fragment-host-set.js +++ /dev/null @@ -1 +0,0 @@ -export { default } from 'api/serializers/fragment-host-set'; diff --git a/addons/api/app/serializers/fragment-host-source.js b/addons/api/app/serializers/fragment-host-source.js new file mode 100644 index 000000000..6e5a68c75 --- /dev/null +++ b/addons/api/app/serializers/fragment-host-source.js @@ -0,0 +1 @@ +export { default } from 'api/serializers/fragment-host-source'; diff --git a/addons/api/mirage/config.js b/addons/api/mirage/config.js index c1b535a41..68c7f6b94 100644 --- a/addons/api/mirage/config.js +++ b/addons/api/mirage/config.js @@ -367,37 +367,37 @@ export default function () { const updatedAttrs = { version: attrs.version, }; - // If adding host sets, push them into the array - if (method === 'add-host-sets') { + // If adding host sources, push them into the array + if (method === 'add-host-sources') { updatedAttrs.hostSetIds = target.hostSetIds; - attrs.hostSetIds.forEach((id) => { + attrs.hostSourceIds.forEach((id) => { if (!updatedAttrs.hostSetIds.includes(id)) { updatedAttrs.hostSetIds.push(id); } }); } - // If deleting host sets, filter them out of the array - if (method === 'remove-host-sets') { + // If deleting host sources, filter them out of the array + if (method === 'remove-host-sources') { updatedAttrs.hostSetIds = target.hostSetIds; updatedAttrs.hostSetIds = updatedAttrs.hostSetIds.filter((id) => { - return !attrs.hostSetIds.includes(id); + return !attrs.hostSourceIds.includes(id); }); } - // If adding credential libraries, push them into the array - if (method === 'add-credential-libraries') { + // If adding credential sources, push them into the array + if (method === 'add-credential-sources') { updatedAttrs.credentialLibraryIds = target.credentialLibraryIds; - attrs.applicationCredentialLibraryIds.forEach((id) => { + attrs.applicationCredentialSourceIds.forEach((id) => { if (!updatedAttrs.credentialLibraryIds.includes(id)) { updatedAttrs.credentialLibraryIds.push(id); } }); } - // If deleting credential libraries, filter them out of the array - if (method === 'remove-credential-libraries') { + // If deleting credential sources, filter them out of the array + if (method === 'remove-credential-sources') { updatedAttrs.credentialLibraryIds = target.credentialLibraryIds; updatedAttrs.credentialLibraryIds = updatedAttrs.credentialLibraryIds.filter((id) => { - return !attrs.applicationCredentialLibraryIds.includes(id); + return !attrs.applicationCredentialSourceIds.includes(id); }); } return target.update(updatedAttrs); diff --git a/addons/api/mirage/serializers/target.js b/addons/api/mirage/serializers/target.js index b970f4853..00249f164 100644 --- a/addons/api/mirage/serializers/target.js +++ b/addons/api/mirage/serializers/target.js @@ -17,14 +17,14 @@ export default ApplicationSerializer.extend({ ); const { hostSets } = this.schema; if (model.hostSetIds?.length) { - json.host_sets = model.hostSetIds.map((host_set_id) => { + json.host_sources = model.hostSetIds.map((host_set_id) => { const hostSet = hostSets.find(host_set_id); const host_catalog_id = hostSet?.hostCatalog?.id; return { id: host_set_id, host_catalog_id }; }); } if (model.credentialLibraryIds?.length) { - json.application_credential_library_ids = model.credentialLibraryIds; + json.application_credential_source_ids = model.credentialLibraryIds; } return json; }, diff --git a/addons/api/tests/unit/models/fragment-host-set-test.js b/addons/api/tests/unit/models/fragment-host-source-test.js similarity index 63% rename from addons/api/tests/unit/models/fragment-host-set-test.js rename to addons/api/tests/unit/models/fragment-host-source-test.js index 3031c94f5..69cde9319 100644 --- a/addons/api/tests/unit/models/fragment-host-set-test.js +++ b/addons/api/tests/unit/models/fragment-host-source-test.js @@ -1,12 +1,12 @@ import { module, test } from 'qunit'; import { setupTest } from 'ember-qunit'; -module('Unit | Model | fragment host set', function (hooks) { +module('Unit | Model | fragment host source', function (hooks) { setupTest(hooks); test('it exists', function (assert) { let store = this.owner.lookup('service:store'); - let model = store.createRecord('fragment-host-set', {}); + let model = store.createRecord('fragment-host-source', {}); assert.ok(model); }); }); diff --git a/addons/api/tests/unit/models/host-set-test.js b/addons/api/tests/unit/models/host-set-test.js index d3738fe5b..f1cf1c110 100644 --- a/addons/api/tests/unit/models/host-set-test.js +++ b/addons/api/tests/unit/models/host-set-test.js @@ -68,7 +68,7 @@ module('Unit | Model | host set', function (hooks) { await model.addHost('foobar'); }); - test('it has a `removeHostSets` method that targets a specific POST API endpoint and serialization', async function (assert) { + test('it has a `removeHosts` method that targets a specific POST API endpoint and serialization', async function (assert) { assert.expect(1); this.server.post('/v1/host-sets/123abc:remove-hosts', (schema, request) => { const body = JSON.parse(request.requestBody); diff --git a/addons/api/tests/unit/models/target-test.js b/addons/api/tests/unit/models/target-test.js index 1c6fa2b22..e182ccf9f 100644 --- a/addons/api/tests/unit/models/target-test.js +++ b/addons/api/tests/unit/models/target-test.js @@ -14,18 +14,18 @@ module('Unit | Model | target', function (hooks) { id: '123abc', type: 'target', attributes: { - host_sets: [ - { host_set_id: '1', host_catalog_id: '2' }, - { host_set_id: '3', host_catalog_id: '2' }, + host_sources: [ + { host_source_id: '1', host_catalog_id: '2' }, + { host_source_id: '3', host_catalog_id: '2' }, ], }, }, }); const target = store.peekRecord('target', '123abc'); assert.equal( - target.host_sets.length, + target.host_sources.length, 2, - 'Target has two entires in host_sets' + 'Target has two entires in host_sources' ); assert.equal( target.hostSets.length, @@ -46,14 +46,14 @@ module('Unit | Model | target', function (hooks) { attributes: {}, }, }); - // Since `hostSets` is computed on `host_sets`, not the store itself, + // Since `hostSets` is computed on `host_sources`, not the store itself, // it's necessary to do this assignment to kick-off the computed update. // eslint-disable-next-line no-self-assign - target.host_sets = target.host_sets; + target.host_sources = target.host_sources; assert.equal( - target.host_sets.length, + target.host_sources.length, 2, - 'Target has two entires in host_sets' + 'Target has two entires in host_sources' ); assert.equal(target.hostSets.length, 2, 'Target has two resolved hostSets'); assert.notOk( @@ -68,52 +68,18 @@ module('Unit | Model | target', function (hooks) { }, }); // eslint-disable-next-line no-self-assign - target.host_sets = target.host_sets; + target.host_sources = target.host_sources; assert.ok(target.hostSets[0].hostCatalog, 'Host catalog is resolved'); }); - test('it has an `addHostSets` method that targets a specific POST API endpoint and serialization', async function (assert) { - assert.expect(1); - this.server.post('/v1/targets/123abc:add-host-sets', (schema, request) => { - const body = JSON.parse(request.requestBody); - assert.deepEqual(body, { - host_set_ids: ['123_abc', 'foobar'], - version: 1, - }); - return { id: '123abc' }; - }); - const store = this.owner.lookup('service:store'); - store.push({ - data: { - id: '123abc', - type: 'target', - attributes: { - name: 'Target', - description: 'Description', - host_sets: [ - { host_set_id: '1', host_catalog_id: '2' }, - { host_set_id: '3', host_catalog_id: '4' }, - ], - version: 1, - scope: { - scope_id: 'o_1', - type: 'scope', - }, - }, - }, - }); - const model = store.peekRecord('target', '123abc'); - await model.addHostSets(['123_abc', 'foobar']); - }); - - test('it has a `removeHostSets` method that targets a specific POST API endpoint and serialization', async function (assert) { + test('it has an `addHostSources` method that targets a specific POST API endpoint and serialization', async function (assert) { assert.expect(1); this.server.post( - '/v1/targets/123abc:remove-host-sets', + '/v1/targets/123abc:add-host-sources', (schema, request) => { const body = JSON.parse(request.requestBody); assert.deepEqual(body, { - host_set_ids: ['1', '3'], + host_source_ids: ['123_abc', 'foobar'], version: 1, }); return { id: '123abc' }; @@ -127,9 +93,9 @@ module('Unit | Model | target', function (hooks) { attributes: { name: 'Target', description: 'Description', - host_sets: [ - { host_set_id: '1', host_catalog_id: '2' }, - { host_set_id: '3', host_catalog_id: '4' }, + host_sources: [ + { host_source_id: '1', host_catalog_id: '2' }, + { host_source_id: '3', host_catalog_id: '4' }, ], version: 1, scope: { @@ -140,17 +106,17 @@ module('Unit | Model | target', function (hooks) { }, }); const model = store.peekRecord('target', '123abc'); - await model.removeHostSets(['1', '3']); + await model.addHostSources(['123_abc', 'foobar']); }); - test('it has a `removeHostSet` method that deletes a single host set using `removeHostSets` method', async function (assert) { + test('it has a `removeHostSources` method that targets a specific POST API endpoint and serialization', async function (assert) { assert.expect(1); this.server.post( - '/v1/targets/123abc:remove-host-sets', + '/v1/targets/123abc:remove-host-sources', (schema, request) => { const body = JSON.parse(request.requestBody); assert.deepEqual(body, { - host_set_ids: ['3'], + host_source_ids: ['1', '3'], version: 1, }); return { id: '123abc' }; @@ -164,9 +130,9 @@ module('Unit | Model | target', function (hooks) { attributes: { name: 'Target', description: 'Description', - host_sets: [ - { host_set_id: '1', host_catalog_id: '2' }, - { host_set_id: '3', host_catalog_id: '4' }, + host_sources: [ + { host_source_id: '1', host_catalog_id: '2' }, + { host_source_id: '3', host_catalog_id: '4' }, ], version: 1, scope: { @@ -177,7 +143,44 @@ module('Unit | Model | target', function (hooks) { }, }); const model = store.peekRecord('target', '123abc'); - await model.removeHostSet('3'); + await model.removeHostSources(['1', '3']); + }); + + test('it has a `removeHostSource` method that deletes a single host set using `removeHostSources` method', async function (assert) { + assert.expect(1); + this.server.post( + '/v1/targets/123abc:remove-host-sources', + (schema, request) => { + const body = JSON.parse(request.requestBody); + assert.deepEqual(body, { + host_source_ids: ['3'], + version: 1, + }); + return { id: '123abc' }; + } + ); + const store = this.owner.lookup('service:store'); + store.push({ + data: { + id: '123abc', + type: 'target', + attributes: { + name: 'Target', + description: 'Description', + host_sources: [ + { host_source_id: '1', host_catalog_id: '2' }, + { host_source_id: '3', host_catalog_id: '4' }, + ], + version: 1, + scope: { + scope_id: 'o_1', + type: 'scope', + }, + }, + }, + }); + const model = store.peekRecord('target', '123abc'); + await model.removeHostSource('3'); }); test('it has a `sessions` array of session instances associated with the target (if those instances are already in the store)', function (assert) { @@ -232,15 +235,15 @@ module('Unit | Model | target', function (hooks) { id: '123abc', type: 'target', attributes: { - application_credential_library_ids: [{ value: '1' }, { value: '2' }], + application_credential_source_ids: [{ value: '1' }, { value: '2' }], }, }, }); const target = store.peekRecord('target', '123abc'); assert.equal( - target.application_credential_library_ids.length, + target.application_credential_source_ids.length, 2, - 'Target has two entires in application_credential_library_ids' + 'Target has two entires in application_credential_source_ids' ); assert.equal( target.credentialLibraries.length, @@ -261,17 +264,17 @@ module('Unit | Model | target', function (hooks) { attributes: {}, }, }); - // Since `credentialLibraries` is computed on `application_credential_library_ids`, + // Since `credentialLibraries` is computed on `application_credential_source_ids`, // not the store itself, it's necessary to do this assignment to kick-off the // computed update. /* eslint-disable no-self-assign */ - target.application_credential_library_ids = - target.application_credential_library_ids; + target.application_credential_source_ids = + target.application_credential_source_ids; /* eslint-enable no-self-assign */ assert.equal( - target.application_credential_library_ids.length, + target.application_credential_source_ids.length, 2, - 'Target has two entires in application_credential_library_ids' + 'Target has two entires in application_credential_source_ids' ); assert.equal( target.credentialLibraries.length, @@ -280,14 +283,14 @@ module('Unit | Model | target', function (hooks) { ); }); - test('it has an `addCredentialLibraries` method that targets a specific POST API endpoint and serialization', async function (assert) { + test('it has an `addCredentialSources` method that targets a specific POST API endpoint and serialization', async function (assert) { assert.expect(1); this.server.post( - '/v1/targets/123abc:add-credential-libraries', + '/v1/targets/123abc:add-credential-sources', (schema, request) => { const body = JSON.parse(request.requestBody); assert.deepEqual(body, { - application_credential_library_ids: ['123_abc', 'foobar'], + application_credential_source_ids: ['123_abc', 'foobar'], version: 1, }); return { id: '123abc' }; @@ -301,7 +304,7 @@ module('Unit | Model | target', function (hooks) { attributes: { name: 'Target', description: 'Description', - application_credential_library_ids: [{ value: '1' }, { value: '2' }], + application_credential_source_ids: [{ value: '1' }, { value: '2' }], version: 1, scope: { scope_id: 'o_1', @@ -311,17 +314,17 @@ module('Unit | Model | target', function (hooks) { }, }); const model = store.peekRecord('target', '123abc'); - await model.addCredentialLibraries(['123_abc', 'foobar']); + await model.addCredentialSources(['123_abc', 'foobar']); }); - test('it has a `removeCredentialLibraries` method that targets a specific POST API endpoint and serialization', async function (assert) { + test('it has a `removeCredentialSources` method that targets a specific POST API endpoint and serialization', async function (assert) { assert.expect(1); this.server.post( - '/v1/targets/123abc:remove-credential-libraries', + '/v1/targets/123abc:remove-credential-sources', (schema, request) => { const body = JSON.parse(request.requestBody); assert.deepEqual(body, { - application_credential_library_ids: ['1', '2'], + application_credential_source_ids: ['1', '2'], version: 1, }); return { id: '123abc' }; @@ -335,7 +338,7 @@ module('Unit | Model | target', function (hooks) { attributes: { name: 'Target', description: 'Description', - application_credential_library_ids: [{ value: '1' }, { value: '2' }], + application_credential_source_ids: [{ value: '1' }, { value: '2' }], version: 1, scope: { scope_id: 'o_1', @@ -345,17 +348,17 @@ module('Unit | Model | target', function (hooks) { }, }); const model = store.peekRecord('target', '123abc'); - await model.removeCredentialLibraries(['1', '2']); + await model.removeCredentialSources(['1', '2']); }); - test('it has a `removeCredentialLibrary` method that deletes a single credential library using `removeCredentialLibraries` method', async function (assert) { + test('it has a `removeCredentialSource` method that deletes a single credential library using `removeCredentialSources` method', async function (assert) { assert.expect(1); this.server.post( - '/v1/targets/123abc:remove-credential-libraries', + '/v1/targets/123abc:remove-credential-sources', (schema, request) => { const body = JSON.parse(request.requestBody); assert.deepEqual(body, { - application_credential_library_ids: ['2'], + application_credential_source_ids: ['2'], version: 1, }); return { id: '123abc' }; @@ -369,7 +372,7 @@ module('Unit | Model | target', function (hooks) { attributes: { name: 'Target', description: 'Description', - application_credential_library_ids: [{ value: '1' }, { value: '2' }], + application_credential_source_ids: [{ value: '1' }, { value: '2' }], version: 1, scope: { scope_id: 'o_1', @@ -379,6 +382,6 @@ module('Unit | Model | target', function (hooks) { }, }); const model = store.peekRecord('target', '123abc'); - await model.removeCredentialLibrary('2'); + await model.removeCredentialSource('2'); }); }); diff --git a/addons/api/tests/unit/serializers/application-test.js b/addons/api/tests/unit/serializers/application-test.js index 242b269c1..e1488127f 100644 --- a/addons/api/tests/unit/serializers/application-test.js +++ b/addons/api/tests/unit/serializers/application-test.js @@ -204,8 +204,8 @@ module('Unit | Serializer | application', function (hooks) { authorized_actions: [], name: 'Target 1', scope: { scope_id: 'o_123' }, - host_sets: [], - application_credential_library_ids: [], + host_sources: [], + application_credential_source_ids: [], }, relationships: {}, }, diff --git a/addons/api/tests/unit/serializers/fragment-host-set-test.js b/addons/api/tests/unit/serializers/fragment-host-source-test.js similarity index 50% rename from addons/api/tests/unit/serializers/fragment-host-set-test.js rename to addons/api/tests/unit/serializers/fragment-host-source-test.js index 61285678d..5dee0ecb7 100644 --- a/addons/api/tests/unit/serializers/fragment-host-set-test.js +++ b/addons/api/tests/unit/serializers/fragment-host-source-test.js @@ -1,27 +1,27 @@ import { module, test } from 'qunit'; import { setupTest } from 'ember-qunit'; -import FragmentHostSet from 'api/models/fragment-host-set'; +import FragmentHostSource from 'api/models/fragment-host-source'; -module('Unit | Serializer | fragment host set', function (hooks) { +module('Unit | Serializer | fragment host source', function (hooks) { setupTest(hooks); - test('it normalizes `id` into `host_set_id`', function (assert) { + test('it normalizes `id` into `host_source_id`', function (assert) { assert.expect(1); const store = this.owner.lookup('service:store'); - const serializer = store.serializerFor('fragment-host-set'); - const normalized = serializer.normalize(FragmentHostSet, { + const serializer = store.serializerFor('fragment-host-source'); + const normalized = serializer.normalize(FragmentHostSource, { id: '2', host_catalog_id: '1', }); assert.deepEqual(normalized, { data: { attributes: { - host_set_id: '2', + host_source_id: '2', host_catalog_id: '1', }, id: null, relationships: {}, - type: 'fragment-host-set', + type: 'fragment-host-source', }, }); }); diff --git a/addons/api/tests/unit/serializers/target-test.js b/addons/api/tests/unit/serializers/target-test.js index d7103cc0e..0c1bd089c 100644 --- a/addons/api/tests/unit/serializers/target-test.js +++ b/addons/api/tests/unit/serializers/target-test.js @@ -11,11 +11,11 @@ module('Unit | Serializer | target', function (hooks) { const record = store.createRecord('target', { name: 'User', description: 'Description', - host_sets: [ - { host_set_id: '1', host_catalog_id: '2' }, - { host_set_id: '3', host_catalog_id: '4' }, + host_sources: [ + { host_source_id: '1', host_catalog_id: '2' }, + { host_source_id: '3', host_catalog_id: '4' }, ], - application_credential_library_ids: [{ value: '1' }, { value: '2' }], + application_credential_source_ids: [{ value: '1' }, { value: '2' }], scope: { scope_id: 'org_1', type: 'org', @@ -40,16 +40,16 @@ module('Unit | Serializer | target', function (hooks) { }); }); - test('it serializes only host sets and version when an `adapterOptions.hostSetIDs` array is passed', function (assert) { + test('it serializes only host sources and version when an `adapterOptions.hostSetIDs` array is passed', function (assert) { assert.expect(1); const store = this.owner.lookup('service:store'); const serializer = store.serializerFor('target'); const record = store.createRecord('target', { name: 'User', description: 'Description', - host_sets: [ - { host_set_id: '1', host_catalog_id: '2' }, - { host_set_id: '3', host_catalog_id: '4' }, + host_sources: [ + { host_source_id: '1', host_catalog_id: '2' }, + { host_source_id: '3', host_catalog_id: '4' }, ], version: 1, }); @@ -59,19 +59,19 @@ module('Unit | Serializer | target', function (hooks) { }; const serializedRecord = serializer.serialize(snapshot); assert.deepEqual(serializedRecord, { - host_set_ids: ['4', '5'], + host_source_ids: ['4', '5'], version: 1, }); }); - test('it serializes only credential libraries and version when an `adapterOptions.credentialLibraryIDs` array is passed', function (assert) { + test('it serializes only credential sources and version when an `adapterOptions.credentialLibraryIDs` array is passed', function (assert) { assert.expect(1); const store = this.owner.lookup('service:store'); const serializer = store.serializerFor('target'); const record = store.createRecord('target', { name: 'User', description: 'Description', - application_credential_library_ids: [{ value: '1' }, { value: '2' }], + application_credential_source_ids: [{ value: '1' }, { value: '2' }], version: 1, }); const snapshot = record._createSnapshot(); @@ -80,7 +80,7 @@ module('Unit | Serializer | target', function (hooks) { }; const serializedRecord = serializer.serialize(snapshot); assert.deepEqual(serializedRecord, { - application_credential_library_ids: ['4', '5'], + application_credential_source_ids: ['4', '5'], version: 1, }); }); @@ -93,11 +93,11 @@ module('Unit | Serializer | target', function (hooks) { const payload = { id: '1', name: 'Target 1', - host_sets: [ - { host_set_id: '1', host_catalog_id: '2' }, - { host_set_id: '3', host_catalog_id: '4' }, + host_sources: [ + { host_source_id: '1', host_catalog_id: '2' }, + { host_source_id: '3', host_catalog_id: '4' }, ], - application_credential_library_ids: ['1'], + application_credential_source_ids: ['1'], }; const normalized = serializer.normalizeSingleResponse( store, @@ -112,18 +112,18 @@ module('Unit | Serializer | target', function (hooks) { attributes: { authorized_actions: [], name: 'Target 1', - host_sets: [ - { host_set_id: '1', host_catalog_id: '2' }, - { host_set_id: '3', host_catalog_id: '4' }, + host_sources: [ + { host_source_id: '1', host_catalog_id: '2' }, + { host_source_id: '3', host_catalog_id: '4' }, ], - application_credential_library_ids: [{ value: '1' }], + application_credential_source_ids: [{ value: '1' }], }, relationships: {}, }, }); }); - test('it normalizes missing host_sets and credential libraries to empty array', function (assert) { + test('it normalizes missing host_sources and application_credential_source_ids to empty array', function (assert) { assert.expect(1); const store = this.owner.lookup('service:store'); const serializer = store.serializerFor('target'); @@ -147,8 +147,8 @@ module('Unit | Serializer | target', function (hooks) { authorized_actions: [], name: 'Target 1', scope: { scope_id: 'o_123' }, - host_sets: [], - application_credential_library_ids: [], + host_sources: [], + application_credential_source_ids: [], }, relationships: {}, }, diff --git a/addons/core/translations/actions/en-us.yaml b/addons/core/translations/actions/en-us.yaml index 9b7a8561d..144ced636 100644 --- a/addons/core/translations/actions/en-us.yaml +++ b/addons/core/translations/actions/en-us.yaml @@ -23,7 +23,6 @@ choose-org: Choose Scope choose-different-org: Choose a different scope add-host-set: Create Host Set add-host: Create Host -add-host-sets: Add Host Sets add-principals: Add Principals add-members: Add Members add-hosts: Add Hosts diff --git a/addons/core/translations/resources/en-us.yaml b/addons/core/translations/resources/en-us.yaml index 4d373e26d..91ed16ac1 100644 --- a/addons/core/translations/resources/en-us.yaml +++ b/addons/core/translations/resources/en-us.yaml @@ -253,11 +253,11 @@ target: actions: create: New Target delete: Delete Target - add-host-sets: Add Host Sources - add-credential-libraries: Add Credential Sources + add-host-sources: Add Host Sources + add-credential-sources: Add Credential Sources types: tcp: TCP - host-set: + host-source: title: Host Source title_plural: Host Sources messages: @@ -270,7 +270,7 @@ target: add: title: Add Host Sources description: Select host sources to assign to this target. - credential-library: + credential-source: title: Credential Source title_plural: Credential Sources messages: diff --git a/ui/admin/app/components/form/target/add-credential-libraries/index.hbs b/ui/admin/app/components/form/target/add-credential-libraries/index.hbs index 693179213..d07c27884 100644 --- a/ui/admin/app/components/form/target/add-credential-libraries/index.hbs +++ b/ui/admin/app/components/form/target/add-credential-libraries/index.hbs @@ -8,7 +8,7 @@ as |form| >
{{t 'resources.target.credential-library.messages.add.description'}}
\ No newline at end of file diff --git a/ui/admin/app/templates/scopes/scope/targets/target/add-credential-libraries.hbs b/ui/admin/app/templates/scopes/scope/targets/target/add-credential-sources.hbs similarity index 73% rename from ui/admin/app/templates/scopes/scope/targets/target/add-credential-libraries.hbs rename to ui/admin/app/templates/scopes/scope/targets/target/add-credential-sources.hbs index 4ddfd983d..cc0992c50 100644 --- a/ui/admin/app/templates/scopes/scope/targets/target/add-credential-libraries.hbs +++ b/ui/admin/app/templates/scopes/scope/targets/target/add-credential-sources.hbs @@ -1,4 +1,4 @@ -{{page-title (t 'resources.target.actions.add-credential-libraries')}} +{{page-title (t 'resources.target.actions.add-credential-sources')}} {{#if @model.credentialLibraries}}{{t 'resources.target.credential-source.messages.add.description'}}
\ No newline at end of file diff --git a/ui/admin/app/templates/scopes/scope/targets/target/add-host-sets/-header.hbs b/ui/admin/app/templates/scopes/scope/targets/target/add-host-sets/-header.hbs deleted file mode 100644 index 5f127e68c..000000000 --- a/ui/admin/app/templates/scopes/scope/targets/target/add-host-sets/-header.hbs +++ /dev/null @@ -1,5 +0,0 @@ -{{t 'resources.target.host-set.messages.add.description'}}
\ No newline at end of file diff --git a/ui/admin/app/templates/scopes/scope/targets/target/add-host-sets.hbs b/ui/admin/app/templates/scopes/scope/targets/target/add-host-sources.hbs similarity index 68% rename from ui/admin/app/templates/scopes/scope/targets/target/add-host-sets.hbs rename to ui/admin/app/templates/scopes/scope/targets/target/add-host-sources.hbs index eb0d9bc71..f846930c6 100644 --- a/ui/admin/app/templates/scopes/scope/targets/target/add-host-sets.hbs +++ b/ui/admin/app/templates/scopes/scope/targets/target/add-host-sources.hbs @@ -1,4 +1,4 @@ -{{page-title (t 'resources.target.actions.add-host-sets')}} +{{page-title (t 'resources.target.actions.add-host-sources')}} {{#if @model.hostSets}}{{t 'resources.target.host-source.messages.add.description'}}
\ No newline at end of file diff --git a/ui/admin/app/templates/scopes/scope/targets/target/credential-libraries.hbs b/ui/admin/app/templates/scopes/scope/targets/target/credential-sources.hbs similarity index 84% rename from ui/admin/app/templates/scopes/scope/targets/target/credential-libraries.hbs rename to ui/admin/app/templates/scopes/scope/targets/target/credential-sources.hbs index 7dd80919c..1c297bd1e 100644 --- a/ui/admin/app/templates/scopes/scope/targets/target/credential-libraries.hbs +++ b/ui/admin/app/templates/scopes/scope/targets/target/credential-sources.hbs @@ -1,4 +1,4 @@ -{{page-title (t 'resources.target.credential-library.title_plural')}} +{{page-title (t 'resources.target.credential-source.title_plural')}} {{#if @model.credentialLibraries}} @@ -56,7 +56,7 @@ {{on 'click' (route-action - 'removeCredentialLibrary' @model credentialLibrary + 'removeCredentialSource' @model credentialLibrary ) }} > @@ -73,17 +73,15 @@