fix(plugin-acl): roles.resources target key is the resource name

This commit is contained in:
chenos 2022-02-19 18:29:34 +08:00
parent 014bb7ab3f
commit 118abe1de5

View File

@ -165,23 +165,21 @@ describe('acl', () => {
// revoke action // revoke action
const response = await app const response = await app
.agent() .agent()
.resource('roles.resources') .resource('roles.resources', role.get('name'))
.list({ .list({
associatedIndex: role.get('name') as string,
appends: ['actions'], appends: ['actions'],
}); });
const actions = response.body.data[0].actions; const actions = response.body.data[0].actions;
const resourceId = response.body.data[0].id; const collectionName = response.body.data[0].name;
const viewActionId = actions.find((action) => action.name === 'view').id; const viewActionId = actions.find((action) => action.name === 'view').id;
await app await app
.agent() .agent()
.resource('roles.resources') .resource('roles.resources', role.get('name'))
.update({ .update({
associatedIndex: role.get('name') as string, filterByTk: collectionName,
resourceIndex: resourceId,
values: { values: {
name: 'c1', name: 'c1',
usingActionsConfig: true, usingActionsConfig: true,
@ -319,17 +317,16 @@ describe('acl', () => {
await app await app
.agent() .agent()
.resource('roles.resources') .resource('roles.resources', role.get('name'))
.update({ .update({
associatedIndex: role.get('name') as string, filterByTk: (
resourceIndex: (
await db.getRepository('rolesResources').findOne({ await db.getRepository('rolesResources').findOne({
filter: { filter: {
name: 'posts', name: 'posts',
roleName: 'admin', roleName: 'admin',
}, },
}) })
).get('id') as string, ).get('name') as string,
values: { values: {
usingActionsConfig: false, usingActionsConfig: false,
}, },
@ -345,17 +342,16 @@ describe('acl', () => {
await app await app
.agent() .agent()
.resource('roles.resources') .resource('roles.resources', role.get('name'))
.update({ .update({
associatedIndex: role.get('name') as string, filterByTk: (
resourceIndex: (
await db.getRepository('rolesResources').findOne({ await db.getRepository('rolesResources').findOne({
filter: { filter: {
name: 'posts', name: 'posts',
roleName: 'admin', roleName: 'admin',
}, },
}) })
).get('id') as string, ).get('name') as string,
values: { values: {
usingActionsConfig: true, usingActionsConfig: true,
}, },