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
const response = await app
.agent()
.resource('roles.resources')
.resource('roles.resources', role.get('name'))
.list({
associatedIndex: role.get('name') as string,
appends: ['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;
await app
.agent()
.resource('roles.resources')
.resource('roles.resources', role.get('name'))
.update({
associatedIndex: role.get('name') as string,
resourceIndex: resourceId,
filterByTk: collectionName,
values: {
name: 'c1',
usingActionsConfig: true,
@ -319,17 +317,16 @@ describe('acl', () => {
await app
.agent()
.resource('roles.resources')
.resource('roles.resources', role.get('name'))
.update({
associatedIndex: role.get('name') as string,
resourceIndex: (
filterByTk: (
await db.getRepository('rolesResources').findOne({
filter: {
name: 'posts',
roleName: 'admin',
},
})
).get('id') as string,
).get('name') as string,
values: {
usingActionsConfig: false,
},
@ -345,17 +342,16 @@ describe('acl', () => {
await app
.agent()
.resource('roles.resources')
.resource('roles.resources', role.get('name'))
.update({
associatedIndex: role.get('name') as string,
resourceIndex: (
filterByTk: (
await db.getRepository('rolesResources').findOne({
filter: {
name: 'posts',
roleName: 'admin',
},
})
).get('id') as string,
).get('name') as string,
values: {
usingActionsConfig: true,
},