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

Feature-1816: Metacat Admin MN Privileges (auth.administrators) #1819

Merged
merged 24 commits into from
Mar 13, 2024

Conversation

doulikecookiedough
Copy link
Contributor

Summary of Changes:

  • Added code to doAdminAuthorization method in D1Authhelper.java class to also check whether session subject is a Metacat admin user (part of the auth.administrators list) to determine MN Node access privileges.

Hi @taojing2002 - When you have a moment, can you please review my PR? @artntek If you have a moment, your feedback is welcome too.

… also check if session subject is a Metacat admin to determine MN node admin privileges
@artntek
Copy link
Contributor

artntek commented Mar 5, 2024

LGTM. With some mocking, I think it might be possible to add some test cases in the existign class? ?

@doulikecookiedough
Copy link
Contributor Author

doulikecookiedough commented Mar 5, 2024

After reviewing the D1AuthHelperTest test class, there exists a note regarding the doAdminAuthorization method that explains why it has not been implemented (requires client communication). Due to my lack of familiarity here and the likely associated time requirement to implement a working test - I am going to leave the test class as it is for now to move onto other tasks for the Metacat 3.0.0 release.

That being said - I have tested locally and my code change are working as expected with a valid token/auth.admin (manually adding my orcid as an auth.administrator to metacat.properties, retrieving the respective JWT token from the CN, and using it in a curl command) and non-matching subject from JWT token (subject does not match what is set in auth.admin).

@taojing2002
Copy link
Contributor

@doulikecookiedough I agree with @artntek. It is good time to add a test for this method. We can use Mock or even without Mock to archive testing. This testing shouldn't be very hard and it can be a chance to get familiar with the code space.

@doulikecookiedough
Copy link
Contributor Author

Understood @taojing2002! I will work on adding a test for this new change.

@taojing2002
Copy link
Contributor

taojing2002 commented Mar 5, 2024 via email

@doulikecookiedough
Copy link
Contributor Author

@taojing2002 I've added tests for the code change to the doAdminAuthorization method - can you please help review this PR again and let me know if you have any other feedback?

@artntek
Copy link
Contributor

artntek commented Mar 11, 2024

Network dependencies have been introduced in testDoAdminAuthorization_cnAdmin() and testDoAdminAuthorization_notAuthorized(). Can we mock these?

…ize new 'authDelMock' to eliminate network dependencies
…or authMN Node reference and add a new test & assert statements for 'isAuthoritativeMNodeAdmin' test method
…eAdmin' and new test for valid admin scenario
@doulikecookiedough
Copy link
Contributor Author

doulikecookiedough commented Mar 11, 2024

Thank you @artntek for reviewing my changes. I've added a Mock which I believe has eliminated the network dependencies. I've also cleaned up the existing tests & added javadocs, implemented some missing tests & removed redundant ones and added a few new tests. Please let me know if you have any other feedback (and @taojing2002 as well).

Notes: I have not implemented the test for expandRightsHolder() at this time so I can prioritize testing the config changes for d1_portal (certificates).

  • Update: There also exists a test in the test class D1NodeServiceTest which calls this method. I tested the relevant code locally and it appears to be working but it makes a network call to locate the CN, and then to get the subject list. I've attempted to re-work it with a mock but I'm unable to make progress at this time - so I've paused on it (and left a TODO statement).

@artntek
Copy link
Contributor

artntek commented Mar 12, 2024

This is one of the most beautiful tests I have ever seen. Thank you, and well done! 😄

a few linter errors for your consideration before merge:

Screenshot 2024-03-12 at 10 43 32 AM

@doulikecookiedough
Copy link
Contributor Author

doulikecookiedough commented Mar 13, 2024

Thank you @artntek (and for the nudge to resolve my IDE issues)!

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.

None yet

3 participants