RANGER-5551: TestRangerOzoneAuthorizer should use builder for RequestContext#913
Open
spacemonkd wants to merge 3 commits intoapache:masterfrom
Open
RANGER-5551: TestRangerOzoneAuthorizer should use builder for RequestContext#913spacemonkd wants to merge 3 commits intoapache:masterfrom
spacemonkd wants to merge 3 commits intoapache:masterfrom
Conversation
adoroszlai
reviewed
Apr 10, 2026
Contributor
adoroszlai
left a comment
There was a problem hiding this comment.
Thanks @spacemonkd for the patch.
Comment on lines
+111
to
+150
| RequestContext ctxListWithoutSessionPolicy = RequestContext.newBuilder() | ||
| .setHost(hostname) | ||
| .setIp(ipAddress) | ||
| .setClientUgi(user1) | ||
| .setServiceId(OZONE_SERVICE_ID) | ||
| .setAclType(IAccessAuthorizer.ACLIdentityType.ANONYMOUS) | ||
| .setAclRights(IAccessAuthorizer.ACLType.LIST) | ||
| .setOwnerName(OWNER_NAME) | ||
| .build(); | ||
| RequestContext ctxReadWithoutSessionPolicy = RequestContext.newBuilder() | ||
| .setHost(hostname) | ||
| .setIp(ipAddress) | ||
| .setClientUgi(user1) | ||
| .setServiceId(OZONE_SERVICE_ID) | ||
| .setAclType(IAccessAuthorizer.ACLIdentityType.ANONYMOUS) | ||
| .setAclRights(IAccessAuthorizer.ACLType.READ) | ||
| .setOwnerName(OWNER_NAME) | ||
| .build(); | ||
| RequestContext ctxListWithSessionPolicy = RequestContext.newBuilder() | ||
| .setHost(hostname) | ||
| .setIp(ipAddress) | ||
| .setClientUgi(user1) | ||
| .setServiceId(OZONE_SERVICE_ID) | ||
| .setAclType(IAccessAuthorizer.ACLIdentityType.ANONYMOUS) | ||
| .setAclRights(IAccessAuthorizer.ACLType.LIST) | ||
| .setOwnerName(OWNER_NAME) | ||
| .setRecursiveAccessCheck(false) | ||
| .setSessionPolicy(sessionPolicy) | ||
| .build(); | ||
| RequestContext ctxReadWithSessionPolicy = RequestContext.newBuilder() | ||
| .setHost(hostname) | ||
| .setIp(ipAddress) | ||
| .setClientUgi(user1) | ||
| .setServiceId(OZONE_SERVICE_ID) | ||
| .setAclType(IAccessAuthorizer.ACLIdentityType.ANONYMOUS) | ||
| .setAclRights(IAccessAuthorizer.ACLType.READ) | ||
| .setOwnerName(OWNER_NAME) | ||
| .setRecursiveAccessCheck(false) | ||
| .setSessionPolicy(sessionPolicy) | ||
| .build(); |
Contributor
There was a problem hiding this comment.
- Indentation looks very odd.
- To reduce code duplication, we can create a base builder with the common properties, and build different
RequestContextinstances with tweaks.
Something like:
RequestContext.Builder builder = RequestContext.newBuilder()
.setHost(hostname)
.setIp(ipAddress)
.setClientUgi(user1)
.setServiceId(OZONE_SERVICE_ID)
.setAclType(IAccessAuthorizer.ACLIdentityType.ANONYMOUS);
RequestContext ctxListWithoutSessionPolicy = builder
.setAclRights(IAccessAuthorizer.ACLType.LIST)
.build();
RequestContext ctxReadWithoutSessionPolicy = builder
.setAclRights(IAccessAuthorizer.ACLType.READ)
.build();
RequestContext ctxListWithSessionPolicy = builder
.setAclRights(IAccessAuthorizer.ACLType.LIST)
.setRecursiveAccessCheck(false)
.setSessionPolicy(sessionPolicy)
.build();
RequestContext ctxReadWithoutSessionPolicy = builder
.setAclRights(IAccessAuthorizer.ACLType.READ)
.setRecursiveAccessCheck(false)
.setSessionPolicy(sessionPolicy)
.build();
Author
There was a problem hiding this comment.
Thanks for the inputs, I realized that as soon as you pointed it out.
Went for a quick fix and missed out on the basics.
adoroszlai
reviewed
Apr 10, 2026
...rc/test/java/org/apache/ranger/authorization/ozone/authorizer/TestRangerOzoneAuthorizer.java
Outdated
Show resolved
Hide resolved
Co-authored-by: Doroszlai, Attila <6454655+adoroszlai@users.noreply.github.com>
Author
|
Tests have passed: @pradeepagrawal8184 @mneethiraj could you help with reviewing this PR as well? |
adoroszlai
approved these changes
Apr 11, 2026
Contributor
adoroszlai
left a comment
There was a problem hiding this comment.
Thanks @spacemonkd for the patch.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
Currently TestRangerOzoneAuthorizer passes the arguments directly to the Ozone RequestContext construcutor.
Example here
However on Ozone as part of PR #9493 we have updated the constructor to accept a Builder instance.
These tests need to be updated to pass this builder instead of direct arguments
How was this patch tested?
Patch was tested by running this test