feat: 🎸 add grant_scope_ids to role model (#2308)

* feat: 🎸 add grant_scope_ids to role model

✅ Closes: https://hashicorp.atlassian.net/browse/ICU-12709

* refactor: 💡 remove removeGrantScopes method

✅ Closes: https://hashicorp.atlassian.net/browse/ICU-12709

* style: 💄 add braces around if statement

✅ Closes: https://hashicorp.atlassian.net/browse/ICU-12709
This commit is contained in:
Cameron Perera authored and Lisbet Alvarez committed 2024-07-15 17:23:00 -07:00
1 parent c0cecda312
commit f9e85aa9aa
5 files changed
+123 -6

No files matched your search

+31
View File
@@ -17,6 +17,37 @@ module('Unit | Model | role', function (hooks) {
assert.ok(model);
});
test('it has a `setGrantScopes` method that targets a specific POST API endpoint and serialization', async function (assert) {
assert.expect(1);
this.server.post('/roles/r_123:set-grant-scopes', (schema, request) => {
const body = JSON.parse(request.requestBody);
assert.deepEqual(body, {
grant_scope_ids: ['this', 'children'],
version: 1,
});
return { id: 'r_123' };
});
const store = this.owner.lookup('service:store');
store.push({
data: {
id: 'r_123',
type: 'role',
attributes: {
name: 'Role',
description: 'Description',
grant_scope_ids: ['this'],
version: 1,
scope: {
scope_id: 'o_1',
type: 'scope',
},
},
},
});
const model = store.peekRecord('role', 'r_123');
await model.setGrantScopes(['this', 'children']);
});
test('it has a `saveGrantStrings` method that targets a specific POST API endpoint and serialization', async function (assert) {
assert.expect(1);
this.server.post('/roles/123abc:set-grants', (schema, request) => {