-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[common][server] Bug fixes and clean of ACL handlers for GRPC (#982)
- Consolidate boiler plate code in ACL handlers for access validations - Fix code path that throws exception in GRPC and close the calls with the appropriate error messages - Fix the flow that invokes onMessage twice in GRPC call intercept to prevent exceptions - Rename GrpcSSLUtils to GrpcUtils to accommodate general utility methods - Add reflection service to GRPC server to interact with Grpcurl - Reuse the header for skipping ACLs from router since the store ACL handling is performed at the router for non FC clients - [code readability] Move public methods together followed by overridable and protected methods followed by package private and private methods Co-authored-by: Bharath Kumarasubramanian <[email protected]>
- Loading branch information
1 parent
0a64bf4
commit 2720a83
Showing
11 changed files
with
344 additions
and
356 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
372 changes: 168 additions & 204 deletions
372
internal/venice-common/src/main/java/com/linkedin/venice/acl/handler/StoreAclHandler.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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
This file contains 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
37 changes: 0 additions & 37 deletions
37
internal/venice-common/src/test/java/com/linkedin/venice/grpc/GrpcSslUtilsTest.java
This file was deleted.
Oops, something went wrong.
74 changes: 74 additions & 0 deletions
74
internal/venice-common/src/test/java/com/linkedin/venice/grpc/GrpcUtilsTest.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package com.linkedin.venice.grpc; | ||
|
||
import static org.mockito.Mockito.*; | ||
import static org.testng.Assert.*; | ||
|
||
import com.linkedin.venice.security.SSLFactory; | ||
import com.linkedin.venice.utils.SslUtils; | ||
import io.grpc.Status; | ||
import io.netty.handler.codec.http.HttpResponseStatus; | ||
import javax.net.ssl.KeyManager; | ||
import javax.net.ssl.TrustManager; | ||
import org.testng.annotations.BeforeTest; | ||
import org.testng.annotations.Test; | ||
|
||
|
||
public class GrpcUtilsTest { | ||
private static SSLFactory sslFactory; | ||
|
||
@BeforeTest | ||
public static void setup() { | ||
sslFactory = SslUtils.getVeniceLocalSslFactory(); | ||
} | ||
|
||
@Test | ||
public void testGetTrustManagers() throws Exception { | ||
TrustManager[] trustManagers = GrpcUtils.getTrustManagers(sslFactory); | ||
|
||
assertNotNull(trustManagers); | ||
assertTrue(trustManagers.length > 0); | ||
} | ||
|
||
@Test | ||
public void testGetKeyManagers() throws Exception { | ||
KeyManager[] keyManagers = GrpcUtils.getKeyManagers(sslFactory); | ||
|
||
assertNotNull(keyManagers); | ||
assertTrue(keyManagers.length > 0); | ||
} | ||
|
||
@Test | ||
public void testHttpResponseStatusToGrpcStatus() { | ||
final String permissionDeniedErrorMessage = "permission denied error message"; | ||
Status grpcStatus = | ||
GrpcUtils.httpResponseStatusToGrpcStatus(HttpResponseStatus.FORBIDDEN, permissionDeniedErrorMessage); | ||
|
||
assertEquals( | ||
grpcStatus.getCode(), | ||
Status.PERMISSION_DENIED.getCode(), | ||
"Mismatch in GRPC status for the http response status permission denied"); | ||
assertEquals( | ||
permissionDeniedErrorMessage, | ||
grpcStatus.getDescription(), | ||
"Mismatch in error description for the mapped grpc status"); | ||
|
||
final String unauthorizedErrorMessage = "unauthorized error message"; | ||
grpcStatus = GrpcUtils.httpResponseStatusToGrpcStatus(HttpResponseStatus.UNAUTHORIZED, unauthorizedErrorMessage); | ||
assertEquals( | ||
grpcStatus.getCode(), | ||
Status.PERMISSION_DENIED.getCode(), | ||
"Mismatch in GRPC status for the http response status unauthorized"); | ||
assertEquals( | ||
unauthorizedErrorMessage, | ||
grpcStatus.getDescription(), | ||
"Mismatch in error description for the mapped grpc status"); | ||
|
||
final String badRequestErrorMessage = "bad request error message"; | ||
grpcStatus = GrpcUtils.httpResponseStatusToGrpcStatus(HttpResponseStatus.BAD_REQUEST, badRequestErrorMessage); | ||
assertEquals(grpcStatus.getCode(), Status.UNKNOWN.getCode(), "Expected unknown status for everything else"); | ||
assertEquals( | ||
badRequestErrorMessage, | ||
grpcStatus.getDescription(), | ||
"Mismatch in error description for the mapped grpc status"); | ||
} | ||
} |
This file contains 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
Oops, something went wrong.