loopbackio / loopbackio/loopback-next
lb3app boot scrip defined role not run when running tests
Open
Nobody has claimed this yet.
bug
- Dominant language
- TypeScript
- Stars
- 5.1k
- Forks
- 1.1k
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 27
Description
Steps to reproduce
- Create boot script: /lb3app/server/boot/role.js
module.exports = async function(app) {
var Role = app.models.Role;
Role.registerResolver('testrole', function(role, ctx, cb) {
console.log('testrole');
process.nextTick(function() {
cb(null, true);
});
});
};
Add it to a model json "acls" definition:
{
"accessType": "EXECUTE",
"principalType": "ROLE",
"principalId": "$unauthenticated",
"permission": "DENY",
"property": "create"
},
{
"accessType": "EXECUTE",
"principalType": "ROLE",
"principalId": "testrole",
"permission": "ALLOW",
"property": "create"
}
Current Behavior
Running a test to create a resource on the model returns 401 error.
Expected Behavior
Running a test to create a resource on the model should be successful with 200 status.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with /lb3app/server/boot/role.js, the model JSON ACL entries, and a test that creates the resource. Trace how boot scripts are loaded when tests start and verify that the testrole resolver is registered; done means the create request returns HTTP 200 instead of 401.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- authorization
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100