chore: 🤖 rename application_credentials_sources_ids to brokered (#1255)
This commit is contained in:
1 parent
39c0835a99
commit
e3324ad64a
9 files changed
+37
-36
No files matched your search
@@ -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);
|
||||
|
||||
@@ -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,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
@@ -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,
|
||||
];
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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: {},
|
||||
},
|
||||
|
||||
@@ -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: {},
|
||||
|
||||
Reference in new issue
Block a user