From a470236d666c276c35db6d39e2292448ffcbd04d Mon Sep 17 00:00:00 2001 From: cecemei Date: Wed, 18 Dec 2024 09:57:02 -0800 Subject: [PATCH] fix style and bug --- .../main/java/org/apache/druid/grpc/server/QueryDriver.java | 2 +- .../druid/metadata/SQLMetadataStorageActionHandler.java | 3 +-- .../main/java/org/apache/druid/server/security/Access.java | 4 ++-- .../java/org/apache/druid/server/QueryLifecycleTest.java | 5 +++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/extensions-contrib/grpc-query/src/main/java/org/apache/druid/grpc/server/QueryDriver.java b/extensions-contrib/grpc-query/src/main/java/org/apache/druid/grpc/server/QueryDriver.java index 10559026af54..50c426a70b52 100644 --- a/extensions-contrib/grpc-query/src/main/java/org/apache/druid/grpc/server/QueryDriver.java +++ b/extensions-contrib/grpc-query/src/main/java/org/apache/druid/grpc/server/QueryDriver.java @@ -148,7 +148,7 @@ private QueryResponse runNativeQuery(QueryRequest request, AuthenticationResult try { queryLifecycle.initialize(query); AuthorizationResult authorizationResult = queryLifecycle.authorize(authResult); - if (!authorizationResult.getPermissionErrorMessage(true).isPresent()) { + if (authorizationResult.getPermissionErrorMessage(true).isPresent()) { throw new ForbiddenException(Access.DEFAULT_ERROR_MESSAGE); } queryResponse = queryLifecycle.execute(); diff --git a/server/src/main/java/org/apache/druid/metadata/SQLMetadataStorageActionHandler.java b/server/src/main/java/org/apache/druid/metadata/SQLMetadataStorageActionHandler.java index eaf2efc82aaf..622191138e9f 100644 --- a/server/src/main/java/org/apache/druid/metadata/SQLMetadataStorageActionHandler.java +++ b/server/src/main/java/org/apache/druid/metadata/SQLMetadataStorageActionHandler.java @@ -119,8 +119,7 @@ public SQLMetadataStorageActionHandler( this.connector = connector; //fully qualified references required below due to identical package names across project modules. //noinspection UnnecessaryFullyQualifiedName - this.jsonMapper = jsonMapper.copy().addMixIn(org.apache.druid.metadata.PasswordProvider.class, - org.apache.druid.metadata.PasswordProviderRedactionMixIn.class); + this.jsonMapper = jsonMapper.copy().addMixIn(PasswordProvider.class,PasswordProviderRedactionMixIn.class); this.entryType = types.getEntryType(); this.statusType = types.getStatusType(); this.lockType = types.getLockType(); diff --git a/server/src/main/java/org/apache/druid/server/security/Access.java b/server/src/main/java/org/apache/druid/server/security/Access.java index 0dff2d3d64ef..5cd4ddd298da 100644 --- a/server/src/main/java/org/apache/druid/server/security/Access.java +++ b/server/src/main/java/org/apache/druid/server/security/Access.java @@ -32,8 +32,8 @@ public class Access public static final String DEFAULT_ERROR_MESSAGE = "Unauthorized"; public static final String DEFAULT_AUTHORIZED_MESSAGE = "Authorized"; - public static final Access OK = Access.allow(); - public static final Access DENIED = Access.deny(""); + public static final Access OK = allow(); + public static final Access DENIED = deny(""); private final boolean allowed; private final String message; diff --git a/server/src/test/java/org/apache/druid/server/QueryLifecycleTest.java b/server/src/test/java/org/apache/druid/server/QueryLifecycleTest.java index a816345fed7b..92c57ce82fe6 100644 --- a/server/src/test/java/org/apache/druid/server/QueryLifecycleTest.java +++ b/server/src/test/java/org/apache/druid/server/QueryLifecycleTest.java @@ -22,6 +22,7 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; +import org.apache.druid.error.DruidException; import org.apache.druid.java.util.common.ISE; import org.apache.druid.java.util.common.Intervals; import org.apache.druid.java.util.common.guava.Sequences; @@ -173,8 +174,8 @@ public void testRunSimplePreauthorized() @Test public void testRunSimpleUnauthorized() { - expectedException.expect(ISE.class); - expectedException.expectMessage(Access.DEFAULT_ERROR_MESSAGE); + expectedException.expect(DruidException.class); + expectedException.expectMessage("Unexpected state [UNAUTHORIZED], expecting [AUTHORIZED]"); EasyMock.expect(queryConfig.getContext()).andReturn(ImmutableMap.of()).anyTimes(); EasyMock.expect(authenticationResult.getIdentity()).andReturn(IDENTITY).anyTimes();