loopbackio / loopbackio/loopback-next

lb3app boot scrip defined role not run when running tests

Open
#7,098 1 comment 0 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.