Quanlong Huang has posted comments on this change. ( 
http://gerrit.cloudera.org:8080/24785 )

Change subject: IMPALA-15323: Produce Ranger audit events for CREATE/DROP ROLE
......................................................................


Patch Set 5:

(1 comment)

http://gerrit.cloudera.org:8080/#/c/24785/5/fe/src/test/java/org/apache/impala/authorization/ranger/RangerCatalogdAuthorizationManagerTest.java
File 
fe/src/test/java/org/apache/impala/authorization/ranger/RangerCatalogdAuthorizationManagerTest.java:

http://gerrit.cloudera.org:8080/#/c/24785/5/fe/src/test/java/org/apache/impala/authorization/ranger/RangerCatalogdAuthorizationManagerTest.java@131
PS5, Line 131:     // at the beginning dropRole(), we create the test role 
'TEST_ROLE_2' as the user
> Thanks Quanlong!
Since these are tests on audit events, can we expect authzManager.createRole() 
and authzManager.dropRole() always work as expected? Then probably we can merge 
the tests, e.g. for RANGER_ADMIN:

    createRole(handlers -> {
      assertEquals(1, handlers.size());
      List<AuthzAuditEvent> events = handlers.get(0).getAuthzEvents();
      assertEventEquals(events.get(0), CREATE_ACTION, CREATE_ACCESS_TYPE,
          RANGER_ADMIN.getName(), /* expectSuccess */ true, /* policyId */ -1L,
          CLIENT_IP_ADDRESS, "CREATE ROLE test_role_2",
          /* resultReason */ null, /* resultPath */ null, /* resultType */ 
null);
    }, RANGER_ADMIN.getName(), TEST_ROLE_2, /* expectSuccess */ true);
    dropRole(handlers -> {
      assertEquals(2, handlers.size());
      List<AuthzAuditEvent> events = handlers.get(1).getAuthzEvents();
      assertEventEquals(events.get(0), DROP_ACTION, DROP_ACCESS_TYPE,
          RANGER_ADMIN.getName(), /* expectSuccess */ true, /* policyId */ -1L,
          CLIENT_IP_ADDRESS, "DROP ROLE test_role_2",
          /* resultReason */ null, /* resultPath */ null, /* resultType */ 
null);
    }, RANGER_ADMIN.getName(), TEST_ROLE_2, /* expectSuccess */ true);

for OWNER_USER, manually create the role in the middle:

    createRole(handlers -> {
      assertEquals(1, handlers.size());
      List<AuthzAuditEvent> events = handlers.get(0).getAuthzEvents();
      assertEventEquals(events.get(0), CREATE_ACTION, CREATE_ACCESS_TYPE,
          OWNER_USER.getName(), /* expectSuccess */ false, /* policyId */ -1L,
          CLIENT_IP_ADDRESS, "CREATE ROLE test_role_2",
          /* resultReason */ null, /* resultPath */ null, /* resultType */ 
null);
    }, OWNER_USER.getName(), TEST_ROLE_2, /* expectSuccess */ false);
    RangerRole role = new RangerRole();
    role.setName(TEST_ROLE_2);
    role.setCreatedByUser(RANGER_ADMIN.getName());
    rangerImpalaPlugin_.createRole(role, /* resultProcessor */ null);
    dropRole(handlers -> {
      assertEquals(2, handlers.size());
      List<AuthzAuditEvent> events = handlers.get(1).getAuthzEvents();
      assertEventEquals(events.get(0), DROP_ACTION, DROP_ACCESS_TYPE,
          OWNER_USER.getName(), /* expectSuccess */ false, /* policyId */ -1L,
          CLIENT_IP_ADDRESS, "DROP ROLE test_role_2",
          /* resultReason */ null, /* resultPath */ null, /* resultType */ 
null);
    }, OWNER_USER.getName(), TEST_ROLE_2, /* expectSuccess */ false);

and surround these with a finally-clause to drop the role. Is this feasible? I 
might miss something. Just want to simplify createRole() and dropRole() in this 
class.



--
To view, visit http://gerrit.cloudera.org:8080/24785
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I3fcfe0dcf54041aca57ed66ddef95b0ddd15b6fb
Gerrit-Change-Number: 24785
Gerrit-PatchSet: 5
Gerrit-Owner: Fang-Yu Rao <[email protected]>
Gerrit-Reviewer: Csaba Ringhofer <[email protected]>
Gerrit-Reviewer: Fang-Yu Rao <[email protected]>
Gerrit-Reviewer: Impala Public Jenkins <[email protected]>
Gerrit-Reviewer: Jason Fehr <[email protected]>
Gerrit-Reviewer: Michael Smith <[email protected]>
Gerrit-Reviewer: Quanlong Huang <[email protected]>
Gerrit-Comment-Date: Thu, 29 Oct 2026 02:22:53 +0000
Gerrit-HasComments: Yes

Reply via email to