adutra opened a new pull request, #3824:
URL: https://github.com/apache/polaris/pull/3824

   As promised, after #3780, this change further refactors the "authz" tests 
extending `PolarisAuthzTestBase` to introduce a fluent test builder.
   
   **No function change.**
   
   As an example, these two method calls:
   
   ```java
       return doTestSufficientPrivilegeSets(
           "attachPolicyToNamespace",
           List.of(
               Set.of(PolarisPrivilege.POLICY_ATTACH, 
PolarisPrivilege.NAMESPACE_ATTACH_POLICY),
               Set.of(PolarisPrivilege.CATALOG_MANAGE_METADATA),
               Set.of(PolarisPrivilege.CATALOG_MANAGE_CONTENT)),
           () -> newWrapper(Set.of(PRINCIPAL_ROLE1)).attachPolicy(POLICY_NS1_1, 
attachPolicyRequest),
           () -> newWrapper(Set.of(PRINCIPAL_ROLE2)).detachPolicy(POLICY_NS1_1, 
detachPolicyRequest));
   
       return doTestInsufficientPrivilegeSets(
           "attachPolicyToNamespace",
           List.of(
               Set.of(PolarisPrivilege.POLICY_ATTACH, 
PolarisPrivilege.CATALOG_ATTACH_POLICY),
               Set.of(PolarisPrivilege.POLICY_ATTACH, 
PolarisPrivilege.TABLE_ATTACH_POLICY),
               Set.of(PolarisPrivilege.POLICY_ATTACH),
               Set.of(PolarisPrivilege.NAMESPACE_ATTACH_POLICY)),
           () -> newWrapper(Set.of(PRINCIPAL_ROLE1)).attachPolicy(POLICY_NS1_1, 
attachPolicyRequest));
   ```
   
   Can now be replaced with:
   
   ```java
       return authzTestsBuilder("attachPolicyToNamespace")
           .action(
               () ->
                   
newHandler(Set.of(PRINCIPAL_ROLE1)).attachPolicy(POLICY_NS1_1, 
attachPolicyRequest))
           .cleanupAction(
               () ->
                   
newHandler(Set.of(PRINCIPAL_ROLE2)).detachPolicy(POLICY_NS1_1, 
detachPolicyRequest))
           .shouldPassWith(PolarisPrivilege.POLICY_ATTACH, 
PolarisPrivilege.NAMESPACE_ATTACH_POLICY)
           .shouldPassWith(PolarisPrivilege.CATALOG_MANAGE_METADATA)
           .shouldPassWith(PolarisPrivilege.CATALOG_MANAGE_CONTENT)
           .shouldFailWith(PolarisPrivilege.POLICY_ATTACH, 
PolarisPrivilege.CATALOG_ATTACH_POLICY)
           .shouldFailWith(PolarisPrivilege.POLICY_ATTACH, 
PolarisPrivilege.TABLE_ATTACH_POLICY)
           .shouldFailWith(PolarisPrivilege.POLICY_ATTACH)
           .shouldFailWith(PolarisPrivilege.NAMESPACE_ATTACH_POLICY)
           .createTests();
   ```
   
   <!--
   ๐Ÿ“ Describe what changes you're proposing, especially breaking or user-facing 
changes. 
   ๐Ÿ“– See https://github.com/apache/polaris/blob/main/CONTRIBUTING.md for more.
   -->
   
   ## Checklist
   - [ ] ๐Ÿ›ก๏ธ Don't disclose security issues! (contact [email protected])
   - [ ] ๐Ÿ”— Clearly explained why the changes are needed, or linked related 
issues: Fixes #
   - [ ] ๐Ÿงช Added/updated tests with good coverage, or manually tested (and 
explained how)
   - [ ] ๐Ÿ’ก Added comments for complex logic
   - [ ] ๐Ÿงพ Updated `CHANGELOG.md` (if needed)
   - [ ] ๐Ÿ“š Updated documentation in `site/content/in-dev/unreleased` (if needed)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to