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

Fix the db prefix not being removed from request parameters in method refresh_privileges #312

Merged
merged 2 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1342,7 +1342,7 @@ public GrantRevokePrivilegeResponse refresh_privileges(HiveObjectRef hiveObjectR
GrantRevokePrivilegeRequest grantRevokePrivilegeRequest) throws MetaException, TException {
DatabaseMapping databaseMapping = checkWritePermissions(hiveObjectRef.getDbName());
return databaseMapping.getClient().refresh_privileges(databaseMapping.transformInboundHiveObjectRef(hiveObjectRef),
authorizer, grantRevokePrivilegeRequest);
authorizer, databaseMapping.transformInboundGrantRevokePrivilegesRequest(grantRevokePrivilegeRequest));
}

private DatabaseMapping checkWritePermissionsForPrivileges(PrivilegeBag privileges) throws NoSuchObjectException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@
import org.apache.hadoop.hive.metastore.api.HeartbeatTxnRangeResponse;
import org.apache.hadoop.hive.metastore.api.HiveObjectPrivilege;
import org.apache.hadoop.hive.metastore.api.HiveObjectRef;
import org.apache.hadoop.hive.metastore.api.HiveObjectType;
import org.apache.hadoop.hive.metastore.api.ISchema;
import org.apache.hadoop.hive.metastore.api.ISchemaName;
import org.apache.hadoop.hive.metastore.api.LockComponent;
Expand Down Expand Up @@ -1990,9 +1991,21 @@ public void refresh_privileges() throws TException {
GrantRevokePrivilegeRequest grantRevokePrivilegeRequest = new GrantRevokePrivilegeRequest();
HiveObjectRef hiveObjectRef = new HiveObjectRef();
hiveObjectRef.setDbName(DB_P);
PrivilegeBag privileges = new PrivilegeBag();
List<HiveObjectPrivilege> privilegesList = new ArrayList<>();
HiveObjectPrivilege hiveObjectPrivilege = new HiveObjectPrivilege();
HiveObjectRef hor = new HiveObjectRef();
hor.setDbName(DB_P);
hor.setObjectType(HiveObjectType.DATABASE);
hor.setObjectName(DB_P);
hiveObjectPrivilege.setHiveObject(hor);
privilegesList.add(hiveObjectPrivilege);
privileges.setPrivileges(privilegesList);
grantRevokePrivilegeRequest.setPrivileges(privileges);
GrantRevokePrivilegeResponse grantRevokePrivilegeResponse = new GrantRevokePrivilegeResponse();

when(primaryMapping.transformInboundHiveObjectRef(hiveObjectRef)).thenReturn(hiveObjectRef);
when(primaryMapping.transformInboundGrantRevokePrivilegesRequest(grantRevokePrivilegeRequest)).thenReturn(grantRevokePrivilegeRequest);
when(primaryClient.refresh_privileges(hiveObjectRef, "dummy", grantRevokePrivilegeRequest)).thenReturn(grantRevokePrivilegeResponse);
GrantRevokePrivilegeResponse result = handler.refresh_privileges(hiveObjectRef, "dummy", grantRevokePrivilegeRequest);
assertThat(result, is(grantRevokePrivilegeResponse));
Expand Down
Loading