diff --git a/addons/api/addon/models/target.js b/addons/api/addon/models/target.js index 0e3f61f7a..9011613b4 100644 --- a/addons/api/addon/models/target.js +++ b/addons/api/addon/models/target.js @@ -29,7 +29,7 @@ export default class TargetModel extends GeneratedTargetModel { readOnly: true, emptyArrayIfMissing: true, }) - application_credential_source_ids; + brokered_credential_source_ids; /** * An array of resolved host set and host catalog instances. Model instances @@ -53,9 +53,9 @@ export default class TargetModel extends GeneratedTargetModel { * instances). Unresolvable instances are excluded from the array. * @type {[CredentialLibraryModel, CredentialModel]} */ - @computed('application_credential_source_ids.[]', 'store') + @computed('brokered_credential_source_ids.[]', 'store') get credentialSources() { - return this.application_credential_source_ids + return this.brokered_credential_source_ids .map((source) => { if (source.value.startsWith('cred')) { return this.store.peekRecord('credential', source.value); diff --git a/addons/api/addon/serializers/target.js b/addons/api/addon/serializers/target.js index df277ed34..074ad33e0 100644 --- a/addons/api/addon/serializers/target.js +++ b/addons/api/addon/serializers/target.js @@ -54,7 +54,7 @@ export default class TargetSerializer extends ApplicationSerializer { serializeWithCredentialSources(snapshot, credentialSourceIDs) { return { version: snapshot.attr('version'), - application_credential_source_ids: credentialSourceIDs, + brokered_credential_source_ids: credentialSourceIDs, }; } } diff --git a/addons/api/mirage/config.js b/addons/api/mirage/config.js index 1dabfcd90..6c3b7d5aa 100644 --- a/addons/api/mirage/config.js +++ b/addons/api/mirage/config.js @@ -465,7 +465,7 @@ export default function () { if (method === 'add-credential-sources') { updatedAttrs.credentialLibraryIds = target.credentialLibraryIds; updatedAttrs.credentialIds = target.credentialIds; - attrs.applicationCredentialSourceIds.forEach((id) => { + attrs.brokeredCredentialSourceIds.forEach((id) => { if ( !updatedAttrs.credentialLibraryIds.includes(id) || !updatedAttrs.credentialIds.includes(id) @@ -484,10 +484,10 @@ export default function () { updatedAttrs.credentialIds = target.credentialIds; updatedAttrs.credentialLibraryIds = updatedAttrs.credentialLibraryIds.filter((id) => { - return !attrs.applicationCredentialSourceIds.includes(id); + return !attrs.brokeredCredentialSourceIds.includes(id); }); updatedAttrs.credentialIds = updatedAttrs.credentialIds.filter((id) => { - return !attrs.applicationCredentialSourceIds.includes(id); + return !attrs.brokeredCredentialSourceIds.includes(id); }); } return target.update(updatedAttrs); diff --git a/addons/api/mirage/serializers/target.js b/addons/api/mirage/serializers/target.js index 3ed7be347..9f01d5287 100644 --- a/addons/api/mirage/serializers/target.js +++ b/addons/api/mirage/serializers/target.js @@ -24,7 +24,7 @@ export default ApplicationSerializer.extend({ }); } if (model.credentialLibraryIds?.length || model.credentialIds?.length) { - json.application_credential_source_ids = [ + json.brokered_credential_source_ids = [ ...model.credentialLibraryIds, ...model.credentialIds, ]; diff --git a/addons/api/tests/unit/models/target-test.js b/addons/api/tests/unit/models/target-test.js index cee097ca6..3cdb9b35c 100644 --- a/addons/api/tests/unit/models/target-test.js +++ b/addons/api/tests/unit/models/target-test.js @@ -239,15 +239,15 @@ module('Unit | Model | target', function (hooks) { id: '123abc', type: 'target', attributes: { - application_credential_source_ids: [{ value: '1' }, { value: '2' }], + brokered_credential_source_ids: [{ value: '1' }, { value: '2' }], }, }, }); const target = store.peekRecord('target', '123abc'); assert.strictEqual( - target.application_credential_source_ids.length, + target.brokered_credential_source_ids.length, 2, - 'Target has two entires in application_credential_source_ids' + 'Target has two entires in brokered_credential_source_ids' ); assert.strictEqual( target.credentialSources.length, @@ -268,17 +268,17 @@ module('Unit | Model | target', function (hooks) { attributes: {}, }, }); - // Since `credentialSources` is computed on `application_credential_source_ids`, + // Since `credentialSources` is computed on `brokered_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_source_ids = - target.application_credential_source_ids; + target.brokered_credential_source_ids = + target.brokered_credential_source_ids; /* eslint-enable no-self-assign */ assert.strictEqual( - target.application_credential_source_ids.length, + target.brokered_credential_source_ids.length, 2, - 'Target has two entires in application_credential_source_ids' + 'Target has two entires in brokered_credential_source_ids' ); assert.strictEqual( target.credentialSources.length, @@ -294,7 +294,7 @@ module('Unit | Model | target', function (hooks) { (schema, request) => { const body = JSON.parse(request.requestBody); assert.deepEqual(body, { - application_credential_source_ids: ['123_abc', 'foobar'], + brokered_credential_source_ids: ['123_abc', 'foobar'], version: 1, }); return { id: '123abc' }; @@ -308,7 +308,7 @@ module('Unit | Model | target', function (hooks) { attributes: { name: 'Target', description: 'Description', - application_credential_source_ids: [{ value: '1' }, { value: '2' }], + brokered_credential_source_ids: [{ value: '1' }, { value: '2' }], version: 1, scope: { scope_id: 'o_1', @@ -328,7 +328,7 @@ module('Unit | Model | target', function (hooks) { (schema, request) => { const body = JSON.parse(request.requestBody); assert.deepEqual(body, { - application_credential_source_ids: ['1', '2'], + brokered_credential_source_ids: ['1', '2'], version: 1, }); return { id: '123abc' }; @@ -342,7 +342,7 @@ module('Unit | Model | target', function (hooks) { attributes: { name: 'Target', description: 'Description', - application_credential_source_ids: [{ value: '1' }, { value: '2' }], + brokered_credential_source_ids: [{ value: '1' }, { value: '2' }], version: 1, scope: { scope_id: 'o_1', @@ -362,7 +362,7 @@ module('Unit | Model | target', function (hooks) { (schema, request) => { const body = JSON.parse(request.requestBody); assert.deepEqual(body, { - application_credential_source_ids: ['2'], + brokered_credential_source_ids: ['2'], version: 1, }); return { id: '123abc' }; @@ -376,7 +376,7 @@ module('Unit | Model | target', function (hooks) { attributes: { name: 'Target', description: 'Description', - application_credential_source_ids: [{ value: '1' }, { value: '2' }], + brokered_credential_source_ids: [{ value: '1' }, { value: '2' }], version: 1, scope: { scope_id: 'o_1', diff --git a/addons/api/tests/unit/serializers/application-test.js b/addons/api/tests/unit/serializers/application-test.js index 6993fb5da..ff50169d6 100644 --- a/addons/api/tests/unit/serializers/application-test.js +++ b/addons/api/tests/unit/serializers/application-test.js @@ -214,7 +214,7 @@ module('Unit | Serializer | application', function (hooks) { name: 'Target 1', scope: { id: 'o_123', scope_id: 'o_123' }, host_sources: [], - application_credential_source_ids: [], + brokered_credential_source_ids: [], }, relationships: {}, }, diff --git a/addons/api/tests/unit/serializers/target-test.js b/addons/api/tests/unit/serializers/target-test.js index 28dad5d55..6ec23edf9 100644 --- a/addons/api/tests/unit/serializers/target-test.js +++ b/addons/api/tests/unit/serializers/target-test.js @@ -15,7 +15,7 @@ module('Unit | Serializer | target', function (hooks) { { host_source_id: '1', host_catalog_id: '2' }, { host_source_id: '3', host_catalog_id: '4' }, ], - application_credential_source_ids: [{ value: '1' }, { value: '2' }], + brokered_credential_source_ids: [{ value: '1' }, { value: '2' }], scope: { scope_id: 'org_1', type: 'org', @@ -73,7 +73,7 @@ module('Unit | Serializer | target', function (hooks) { const record = store.createRecord('target', { name: 'User', description: 'Description', - application_credential_source_ids: [{ value: '1' }, { value: '2' }], + brokered_credential_source_ids: [{ value: '1' }, { value: '2' }], version: 1, }); const snapshot = record._createSnapshot(); @@ -82,7 +82,7 @@ module('Unit | Serializer | target', function (hooks) { }; const serializedRecord = serializer.serialize(snapshot); assert.deepEqual(serializedRecord, { - application_credential_source_ids: ['4', '5'], + brokered_credential_source_ids: ['4', '5'], version: 1, }); }); @@ -131,7 +131,7 @@ module('Unit | Serializer | target', function (hooks) { { host_source_id: '1', host_catalog_id: '2' }, { host_source_id: '3', host_catalog_id: '4' }, ], - application_credential_source_ids: ['1'], + brokered_credential_source_ids: ['1'], }; const normalized = serializer.normalizeSingleResponse( store, @@ -150,7 +150,7 @@ module('Unit | Serializer | target', function (hooks) { { host_source_id: '1', host_catalog_id: '2' }, { host_source_id: '3', host_catalog_id: '4' }, ], - application_credential_source_ids: [{ value: '1' }], + brokered_credential_source_ids: [{ value: '1' }], }, relationships: {}, }, @@ -180,7 +180,7 @@ module('Unit | Serializer | target', function (hooks) { id: '1', type: 'target', attributes: { - application_credential_source_ids: [], + brokered_credential_source_ids: [], authorized_actions: [], host_sources: [], name: 'Target 1', @@ -191,7 +191,7 @@ module('Unit | Serializer | target', function (hooks) { }); }); - test('it normalizes missing host_sources and application_credential_source_ids to empty array', function (assert) { + test('it normalizes missing host_sources and brokered_credential_source_ids to empty array', function (assert) { assert.expect(1); const store = this.owner.lookup('service:store'); const serializer = store.serializerFor('target'); @@ -216,7 +216,7 @@ module('Unit | Serializer | target', function (hooks) { name: 'Target 1', scope: { id: 'o_123', scope_id: 'o_123' }, host_sources: [], - application_credential_source_ids: [], + brokered_credential_source_ids: [], }, relationships: {}, }, @@ -247,7 +247,7 @@ module('Unit | Serializer | target', function (hooks) { authorized_actions: [], name: 'Target 1', host_sources: [], - application_credential_source_ids: [], + brokered_credential_source_ids: [], worker_filter: 'worker', }, relationships: {}, diff --git a/ui/admin/app/controllers/scopes/scope/targets/target/add-credential-sources.js b/ui/admin/app/controllers/scopes/scope/targets/target/add-credential-sources.js index b022058d2..104f2be0e 100644 --- a/ui/admin/app/controllers/scopes/scope/targets/target/add-credential-sources.js +++ b/ui/admin/app/controllers/scopes/scope/targets/target/add-credential-sources.js @@ -22,12 +22,12 @@ export default class ScopesScopeTargetsTargetAddCredentialSourcesController exte * @type {[CredentialLibraryModel, CredentialModel]} */ @computed( - 'model.{target.application_credential_source_ids.[],credentialLibraries.[],credentials.[]}' + 'model.{target.brokered_credential_source_ids.[],credentialLibraries.[],credentials.[]}' ) get filteredCredentialSources() { // Get IDs for credential sources already added to the current target const currentCredentialSourceIDs = - this.model.target.application_credential_source_ids.map( + this.model.target.brokered_credential_source_ids.map( (source) => source.value ); const notAddedCredentialLibraries = this.model.credentialLibraries.filter( diff --git a/ui/admin/app/routes/scopes/scope/targets/target/credential-sources.js b/ui/admin/app/routes/scopes/scope/targets/target/credential-sources.js index b196734b1..deeae8e91 100644 --- a/ui/admin/app/routes/scopes/scope/targets/target/credential-sources.js +++ b/ui/admin/app/routes/scopes/scope/targets/target/credential-sources.js @@ -13,8 +13,9 @@ export default class ScopesScopeTargetsTargetCredentialSourcesRoute extends Rout * @return {Promise{[CredentialLibraryModel, CredentialModel]}} */ beforeModel() { - const { application_credential_source_ids: sourceIDFragments } = - this.modelFor('scopes.scope.targets.target'); + const { brokered_credential_source_ids: sourceIDFragments } = this.modelFor( + 'scopes.scope.targets.target' + ); return all( sourceIDFragments.map(({ value }) => { const isStatic = value.includes('cred');