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) - Resolve Broken Tests #1824

Merged
merged 13 commits into from
Mar 18, 2024

Conversation

doulikecookiedough
Copy link
Contributor

Hi @taojing2002, I have amended doAdminAuthorization in D1AuthHelper to throw NotAuthorized exceptions when session is null, and when session is not null but subject is empty or null. Can you please let me know if you are experiencing any other errors?

…' method when session is null and adminUser is null or empty, and add new junit tests to 'D1AuthhelperTest'
@doulikecookiedough
Copy link
Contributor Author

Thank you for reviewing this PR and meeting with me @taojing2002! I believe I have addressed the issues raised here. Additionally, I have refactored doAdminAuthorization so that we are checking for a valid session (and subject value) before attempting to check for LocalNode, CN or Metacat admin privileges; and added additional comments/updated javadocs. Please let me know if there are any other issues.

@taojing2002
Copy link
Contributor

All tests passed! Great! Overall it looks good. But I added some comments.

throw new NotAuthorized("0000", "Session is null.");
}
// If there is no subject or if subject is empty, session is not authorized.
String sessionSubject = session.getSubject().getValue();
Copy link
Contributor

Choose a reason for hiding this comment

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

If session.getSubject is null, the method will get null exception.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have wrapped the relevant block in a try statement to catch this NullPointerException and throw a new NotAuthorized exception with the message "Session subject is not set."

…min in the auth.administrators's list, and new junit test for 'doAuthUpdate' with mismatched auth mnode
@doulikecookiedough
Copy link
Contributor Author

Hi @taojing2002, I have addressed your feedback. Can you please let me know if I misunderstood the second point:

Do we have a test for a subject which is in that list can get the admin privilege? I only see the ones which fail.

I am assuming that you mean a check to ensure that if the auth.administrator's list has more than one admin, that anyone in this list can get admin authorization. Please let me know if you have any other comments.

… 'NotAuthorized' exception to the last if statement when checking auth for metacat admins
…id session and respective subject value into new method 'checkSessionAndGetSubjectValue'
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