refactor: 💡 convert brokered cred IDs array to simple attribute (#1259)
* refactor: 💡 convert brokered cred IDs array to simple attribute * fix: 🐛 missing test assertion * fix: 🐛 simplify computed * refactor: 💡 convert host sources array to simple attribute (#1260) * refactor: 💡 convert host source IDs array to simple attribute * fix: 🐛 host source tests * Refactor role fragment arrays (#1262) * refactor: 💡 convert grant strings to regular attribute * refactor: 💡 convert principals array to simple attribute * Update ui/admin/app/routes/scopes/scope/roles/role.js Co-authored-by: Zhihe Li <zhihe.li@hashicorp.com> Co-authored-by: Zhihe Li <zhihe.li@hashicorp.com> Co-authored-by: Zhihe Li <zhihe.li@hashicorp.com> * fix: 🐛 remove unused import Co-authored-by: Zhihe Li <zhihe.li@hashicorp.com>
This commit is contained in:
1 parent
83c7b76f48
commit
cde6abd445
28 files changed
+147
-182
No files matched your search
@@ -1,12 +0,0 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
|
||||
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-source', {});
|
||||
assert.ok(model);
|
||||
});
|
||||
});
|
||||
@@ -1,12 +0,0 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
|
||||
module('Unit | Model | fragment principal', function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test('it exists', function (assert) {
|
||||
let store = this.owner.lookup('service:store');
|
||||
let model = store.createRecord('fragment-principal', {});
|
||||
assert.ok(model);
|
||||
});
|
||||
});
|
||||
@@ -46,10 +46,6 @@ module('Unit | Model | target', function (hooks) {
|
||||
attributes: {},
|
||||
},
|
||||
});
|
||||
// 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_sources = target.host_sources;
|
||||
assert.strictEqual(
|
||||
target.host_sources.length,
|
||||
2,
|
||||
@@ -252,7 +248,7 @@ module('Unit | Model | target', function (hooks) {
|
||||
assert.strictEqual(
|
||||
target.brokeredCredentialSources.length,
|
||||
0,
|
||||
'Target has no resolved credentialSources because they are not loaded yet'
|
||||
'Target has no resolved credentialSources, because they are not yet loaded'
|
||||
);
|
||||
store.push({
|
||||
data: {
|
||||
@@ -268,12 +264,6 @@ module('Unit | Model | target', function (hooks) {
|
||||
attributes: {},
|
||||
},
|
||||
});
|
||||
// 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.brokered_credential_source_ids =
|
||||
target.brokered_credential_source_ids;
|
||||
/* eslint-enable no-self-assign */
|
||||
assert.strictEqual(
|
||||
target.brokered_credential_source_ids.length,
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
import FragmentHostSource from 'api/models/fragment-host-source';
|
||||
|
||||
module('Unit | Serializer | fragment host source', function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
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-source');
|
||||
const normalized = serializer.normalize(FragmentHostSource, {
|
||||
id: '2',
|
||||
host_catalog_id: '1',
|
||||
});
|
||||
assert.deepEqual(normalized, {
|
||||
data: {
|
||||
attributes: {
|
||||
host_source_id: '2',
|
||||
host_catalog_id: '1',
|
||||
},
|
||||
id: null,
|
||||
relationships: {},
|
||||
type: 'fragment-host-source',
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,30 +0,0 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
import FragmentPrincipal from 'api/models/fragment-principal';
|
||||
|
||||
module('Unit | Serializer | fragment principal', function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test('it normalizes `id` into `principal_id`', function (assert) {
|
||||
assert.expect(1);
|
||||
const store = this.owner.lookup('service:store');
|
||||
const serializer = store.serializerFor('fragment-principal');
|
||||
const normalized = serializer.normalize(FragmentPrincipal, {
|
||||
scope_id: '1',
|
||||
principal_id: '2',
|
||||
type: 'user',
|
||||
});
|
||||
assert.deepEqual(normalized, {
|
||||
data: {
|
||||
attributes: {
|
||||
scope_id: '1',
|
||||
principal_id: '2',
|
||||
type: 'user',
|
||||
},
|
||||
id: null,
|
||||
relationships: {},
|
||||
type: 'fragment-principal',
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -98,6 +98,7 @@ module('Unit | Serializer | role', function (hooks) {
|
||||
name: 'Role 1',
|
||||
scope: { id: 'o_123', scope_id: 'o_123' },
|
||||
principals: [],
|
||||
grant_strings: [],
|
||||
},
|
||||
relationships: {},
|
||||
},
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
|
||||
module('Unit | Transform | host source id array', function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test('it deserializes an array of strings to an array of `{value}`', function (assert) {
|
||||
assert.expect(1);
|
||||
const transform = this.owner.lookup('transform:host-source-id-array');
|
||||
const deserialized = transform.deserialize([
|
||||
{ id: '123', host_catalog_id: '1' },
|
||||
]);
|
||||
assert.deepEqual(deserialized, [
|
||||
{ host_source_id: '123', host_catalog_id: '1' },
|
||||
]);
|
||||
});
|
||||
|
||||
test('it serializes an array of `{value}` to an array of strings', function (assert) {
|
||||
assert.expect(1);
|
||||
const transform = this.owner.lookup('transform:host-source-id-array');
|
||||
const serialized = transform.serialize([
|
||||
{ host_source_id: '123', host_catalog_id: '1' },
|
||||
]);
|
||||
assert.deepEqual(serialized, [{ id: '123', host_catalog_id: '1' }]);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,12 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
|
||||
module('Unit | Transform | principal array', function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
// Replace this with your real tests.
|
||||
test('it exists', function (assert) {
|
||||
let transform = this.owner.lookup('transform:principal-array');
|
||||
assert.ok(transform);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,28 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
|
||||
module('Unit | Transform | string array', function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test('it deserializes an array of strings to an array of `{value}`', function (assert) {
|
||||
assert.expect(1);
|
||||
const transform = this.owner.lookup('transform:string-array');
|
||||
const deserialized = transform.deserialize(['a', 'bee', 'Hello World']);
|
||||
assert.deepEqual(deserialized, [
|
||||
{ value: 'a' },
|
||||
{ value: 'bee' },
|
||||
{ value: 'Hello World' },
|
||||
]);
|
||||
});
|
||||
|
||||
test('it serializes an array of `{value}` to an array of strings', function (assert) {
|
||||
assert.expect(1);
|
||||
const transform = this.owner.lookup('transform:string-array');
|
||||
const serialized = transform.serialize([
|
||||
{ value: 'a' },
|
||||
{ value: 'bee' },
|
||||
{ value: 'Hello World' },
|
||||
]);
|
||||
assert.deepEqual(serialized, ['a', 'bee', 'Hello World']);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user