Merge branch 'main' into feature-role-grant-scope
This commit is contained in:
10 files changed
+54
-54
No files matched your search
@@ -12,12 +12,12 @@ module('Unit | Model | role', function (hooks) {
|
||||
assert.ok(model);
|
||||
});
|
||||
|
||||
test('it has a `saveGrants` method that targets a specific POST API endpoint and serialization', async function (assert) {
|
||||
test('it has a `saveGrantStrings` method that targets a specific POST API endpoint and serialization', async function (assert) {
|
||||
assert.expect(1);
|
||||
this.server.post('/v1/roles/123abc:set-grants', (schema, request) => {
|
||||
const body = JSON.parse(request.requestBody);
|
||||
assert.deepEqual(body, {
|
||||
grant_strings: ['grant1', 'grant2'],
|
||||
grant_strings: ['foo', 'bar'],
|
||||
version: 1,
|
||||
});
|
||||
return { id: '123abc' };
|
||||
@@ -30,7 +30,7 @@ module('Unit | Model | role', function (hooks) {
|
||||
attributes: {
|
||||
name: 'Role',
|
||||
description: 'Description',
|
||||
grants: [{ value: 'grant1' }, { value: 'grant2' }],
|
||||
grant_strings: ['grant1', 'grant2'],
|
||||
version: 1,
|
||||
scope: {
|
||||
scope_id: 'o_1',
|
||||
@@ -40,7 +40,7 @@ module('Unit | Model | role', function (hooks) {
|
||||
},
|
||||
});
|
||||
const model = store.peekRecord('role', '123abc');
|
||||
await model.saveGrants();
|
||||
await model.saveGrantStrings(['foo', 'bar']);
|
||||
});
|
||||
|
||||
test('it has an `addPrincipals` method that targets a specific POST API endpoint and serialization', async function (assert) {
|
||||
|
||||
@@ -11,7 +11,7 @@ module('Unit | Serializer | role', function (hooks) {
|
||||
const record = store.createRecord('role', {
|
||||
name: 'User',
|
||||
description: 'Description',
|
||||
grants: [{ value: 'foo' }, { value: 'bar' }],
|
||||
grant_strings: ['foo', 'bar'],
|
||||
version: 1,
|
||||
});
|
||||
const snapshot = record._createSnapshot();
|
||||
@@ -25,19 +25,19 @@ module('Unit | Serializer | role', function (hooks) {
|
||||
});
|
||||
});
|
||||
|
||||
test('it serializes only grants when `adapterOptions.serializeGrants` is true', function (assert) {
|
||||
test('it serializes only grant strings when `adapterOptions.grantStrings` is set', function (assert) {
|
||||
assert.expect(1);
|
||||
const store = this.owner.lookup('service:store');
|
||||
const serializer = store.serializerFor('role');
|
||||
const record = store.createRecord('role', {
|
||||
name: 'User',
|
||||
description: 'Description',
|
||||
grants: [{ value: 'foo' }, { value: 'bar' }],
|
||||
grant_strings: ['grant1', 'grant2'],
|
||||
version: 1,
|
||||
});
|
||||
const snapshot = record._createSnapshot();
|
||||
snapshot.adapterOptions = {
|
||||
serializeGrants: true,
|
||||
grantStrings: ['foo', 'bar'],
|
||||
};
|
||||
const serializedRecord = serializer.serialize(snapshot);
|
||||
assert.deepEqual(serializedRecord, {
|
||||
@@ -68,7 +68,7 @@ module('Unit | Serializer | role', function (hooks) {
|
||||
type: 'role',
|
||||
attributes: {
|
||||
name: 'Role 1',
|
||||
grants: [{ value: '*' }, { value: '*' }],
|
||||
grant_strings: ['*', '*'],
|
||||
principals: [],
|
||||
},
|
||||
relationships: {},
|
||||
|
||||
Reference in new issue
Block a user