Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[To Main] Add metadata management role #2506

Merged
merged 3 commits into from
May 14, 2024

Conversation

VineetBala-AOT
Copy link
Collaborator

Issue #: https://apps.itsm.gov.bc.ca/jira/browse/DESENG-603

Description of changes:

  • Implemented a new role named "manage_metadata" within the Admin group to restrci access for metadata management
  • Updated the frontend to restrict access to the "metadata management" link in the menu for users without the newly added role
  • Backend changes to incorporate the new role for access control purposes, ensuring only authorized users can perform metadata management actions

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of the met-public license (Apache 2.0).

@codecov-commenter
Copy link

codecov-commenter commented May 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 75.82%. Comparing base (1b990ba) to head (f904382).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2506      +/-   ##
==========================================
+ Coverage   75.78%   75.82%   +0.04%     
==========================================
  Files         597      597              
  Lines       21334    21333       -1     
  Branches     1568     1568              
==========================================
+ Hits        16167    16175       +8     
+ Misses       4913     4904       -9     
  Partials      254      254              
Flag Coverage Δ
metapi 87.97% <100.00%> (+0.08%) ⬆️
metweb 63.81% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
...t-api/src/met_api/resources/engagement_metadata.py 91.22% <100.00%> (+7.89%) ⬆️
met-api/src/met_api/resources/metadata_taxon.py 88.28% <100.00%> (-0.19%) ⬇️
met-api/src/met_api/utils/roles.py 100.00% <100.00%> (ø)
.../src/components/layout/SideNav/SideNavElements.tsx 100.00% <ø> (ø)
met-web/src/services/userService/constants.ts 100.00% <ø> (ø)

@VineetBala-AOT VineetBala-AOT marked this pull request as ready for review May 13, 2024 20:14
Copy link
Collaborator

@Baelx Baelx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't completed review of the tests yet but could you please update the changes to allow users who could edit engagement metadata to be able to perform CRUD operations on them? We want to make sure that many users can still access/modify metadata on individual engagements. Taxons should be restricted to metadata managers.

Please see the ticket or speak with Nat for more information!

def get(engagement_id):
"""Fetch engagement metadata entries by engagement id."""
authorization.check_auth(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Levels of abstraction are tricky here, but the ticket still calls for engagement metadata to allow CRUD operations for users who can edit engagements.

I believe it's the metadata_taxon file that will restrict its operations to the MANAGE_METADATA role.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, changed it back to use edit engagement. The only change here being allowing team members assigned to the engagement to edit as well.

Copy link

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@@ -131,11 +146,16 @@ class EngagementMetadataById(Resource):

@staticmethod
@cross_origin(origins=allowedorigins())
@require_role(VIEW_ENGAGEMENT_ROLES)
@_jwt.requires_auth
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we sure about requiring authorization for this route? What if we're pulling engagement metadata on the frontend for public users?

Copy link
Collaborator

@Baelx Baelx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I chatted with Vineet about my questions:

  • We don't need to allow public access to metadata for engagements yet. Tickets are coming for how we handle metadata on the frontend
  • Tests look for user groups which include the new metadata manager role, so we're covered in terms of testing it

@@ -75,9 +73,16 @@ class EngagementMetadata(Resource):
@cross_origin(origins=allowedorigins())
@API.doc(security='apikey')
@API.marshal_list_with(metadata_return_model)
@require_role(VIEW_ENGAGEMENT_ROLES)
@_jwt.requires_auth
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will public users still be able to get engagement metadata?

@@ -182,3 +189,25 @@ def test_delete_engagement_metadata(client, jwt, session):
content_type=ContentType.JSON.value)
assert response.status_code == HTTPStatus.NO_CONTENT, (f'Wrong response code; '
f'HTTP {response.status_code} -> {response.text}')


def test_get_engagement_metadata_by_id(client, jwt, session):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have a way to test requests based on roles? It would be nice to have some tests directly related to the work for this ticket. Although I appreciate that you added a couple more general metadata tests

@VineetBala-AOT VineetBala-AOT merged commit a94a65a into main May 14, 2024
15 checks passed
@VineetBala-AOT VineetBala-AOT deleted the feature/deseng-603-metadata-management branch May 16, 2024 06:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants