Assign roles to a user record for requisitions

Description

As an administrator, I would like to assign roles to users to provide/restrict system permissions at a user level so that users can complete their business workflows (approve requisitions) to order the right stock. Initially we will focus on the Requisition service.

Roles are defined in OLMIS-545.
Review the RBAC and Entity Relationship Diagram - OLMIS-865: ERD - focus on entities required for Role-based authenticationDone
See User_Role assignment PDF attached for 2.0 UI.

Section for role based access:
For now start with the following two sections (the pdf has more)

  • Home Facility - supports the requisition process and apply specifically to the facility designated in the users profile as their home facility

  • Supervisory Roles - supports the requisition process and apply to facilities under a given supervisory node (or facilities under nodes that are children of a given supervisory node)

Within the above sections, an admin can assign a "role" by program. That role will only apply to that program with the section's scope. Home facility and Supervisory apply to requisitions.

Acceptance Criteria
Verify that:

  • an admin can assign a "home" facility to a user

    • home facility must be from a list of defined facilities (from reference data)

    • an error message is delivered if admin attempts to add a new facility

  • an admin can can associate programs to the home facility

    • programs must be from reference data, no new program can be defined

  • admin can designate one or more roles by program

  • admin can remove roles

  • Under Supervisory an admin can add a role by program and supervisory node

    • an admin must select a program and supervisory node for role assignment, if not a role cannot be added

  • if a user is given role permissions within a program and specific facility - the access to those rights within that program and facility should be enforced

  • If a user doesn't have access to certain rights, user access should be limited accordingly

  • admin user can save changes

  • only admin users can assign roles

Attachments

5

QAlity Plus - Test Management

Checklists

Activity

Show:
Lucyna Laska
October 4, 2016 at 12:50 PM

Hi , thank you for the explanation. Now, everything is clear.

My test process:
1. Create user without roles.
2. Create right with ORDER_FULFILLMENT right type.
3. Create right with SUPERVISION right type.
4. Create right with GENERAL_ADMIN right type.
5. Create right with REPORTS right type.
6. Create role with ORDER_FULFILLMENT right type.
7. Create role with SUPERVISION right type.
8. Create role with GENERAL_ADMIN right type.
9. Create role with REPORTS right type.
10. Create program, facility and supervisoryNode.
11. Assign home facility to User.
12. Assign invalid home facility to User.
13. Assign program to User.
14. Assign invalid program to User.
15. Get the programs at a user's home facility or programs that the user supervises.
16. Assign role by program and supervisoryNode
17. As a User, try to assign the role to another Users.
18. As an Admin, try to delete the role.

I noticed that User can also delete the role.

For more details, see test case:
https://openlmis.atlassian.net/wiki/x/S4A7BQ

Chongsun Ahn
September 30, 2016 at 11:29 PM

Hey , I think there is some confusion about programs associated with a home facility. You do not associate programs to a home facility using a homeFacilityPrograms attribute. Programs are associated with a user's home facility through the user's assigned roles. If the user has a role assignment with a specified program (and not a supervisory node), then that role is automatically associated with a home facility, and the program that goes with it is a "home facility program". You can see the home facility programs associated with a user by going to /api/users/{userId}/programs.

Please let me know if this does not make sense, and we can try to Skype about it.

Lucyna Laska
September 30, 2016 at 12:41 PM

Hi . Sorry for not testing this ticket earlier, but I was some problem with user creation. Problem has been eliminated, now everything works.

I tested some AC so far and I have some doubts about this one:

  • an admin can can associate programs to the home facility
    programs must be from reference data, no new program can be defined

I assumed that homeFacilityPrograms attribute should be set to cover this AC.
When I try to do that, my user is updated properly, but in response I don’t see my homeFacilityPrograms. When I list all users, I don’t see this too. I can enter not existed ID for HomeFacilityPrograms and despite that, user will be created

Could you take a look of that?

  • my URL: http://172.23.0.1/referencedata/api/users?access_token=bd7aa178-2c96-48c4-985b-28027152dc36

  • body:
    {
    "id": "8c589aed-da97-46c9-b9f4-94ac68562d30",
    "username" : "admin123",
    "firstName" : "Admin2",
    "lastName" : "User2",
    "email" : "testowysoldevelo@gmail.com",
    "verified" : false,
    "active" : false,
    "loginRestricted": true,
    "homeFacility": {
    "id": "8a2a0a6b-7614-41c8-b4d1-e887959956f7"
    },
    "homeFacilityPrograms": {
    "id": "7ffb2b3c-4f9f-4121-b7a9-5d66558c729a"
    },
    "roleAssignments": [
    {
    "roleId": "00000000-0000-0000-0000-000000000004",
    "programCode": "program02",
    "supervisoryNodeCode": "supervisorycode"
    },
    {
    "roleId": "00000000-0000-0000-0000-000000000001",
    "warehouseCode": "hospital"
    }]
    }

Screen with my json:

The server response:

Paweł Gesek
September 28, 2016 at 10:08 AM
Paweł Gesek
September 28, 2016 at 10:08 AM

please update the .env file with email properties - they have been externalized there

Done
Pinned fields
Click on the next to a field label to start pinning.

Details

Assignee

Reporter

Original estimate

Time tracking

4d 5h logged

Sprint

None

Fix versions

Priority

Time Assistant

Created July 27, 2016 at 11:35 PM
Updated October 10, 2016 at 4:46 PM
Resolved October 4, 2016 at 12:50 PM