Class GRPCTestHelper
java.lang.Object
org.summerboot.jexpress.nio.grpc.GRPCTestHelper
For testing gRPC with two-way TLS.
(usage and example see https://github.com/SummerBootFramework/jExpressDemo-HelloSummer/blob/main/HelloSummer-demo02/src/test/java/test/integration/grpc/GrpcTest.java)
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected GRPCTestHelper.GRPCSimpleClient[]static io.grpc.netty.shaded.io.grpc.netty.NettyChannelBuilderbuildGRPCClient(String tlsProtocal, String host, int port, String loadBalancingPolicy, String loadBalancingTargetScheme, KeyManagerFactory kmfClient, TrustManagerFactory tmfClient, String overrideAuthority) static io.grpc.netty.shaded.io.grpc.netty.NettyChannelBuilderbuildGRPCClient(String tlsProtocal, String host, int port, KeyManagerFactory kmfClient, TrustManagerFactory tmfClient, String overrideAuthority) static io.grpc.netty.shaded.io.grpc.netty.NettyChannelBuilderstatic GRPCServerbuildGRPCServer(String host, int port, KeyManagerFactory kmfServer, TrustManagerFactory tmfServer, io.grpc.BindableService... serviceImps) static GRPCServerbuildGRPCServer(GRPCTestHelper.GRPCSimpleClient config, io.grpc.BindableService... serviceImps) protected abstract io.grpc.BindableService[]protected abstract voidrunClient(io.grpc.netty.shaded.io.grpc.netty.NettyChannelBuilder channelBuilder) voidvoidtest2WayTLS(String host, int port, KeyManagerFactory kmfServer, TrustManagerFactory tmfServer, io.grpc.BindableService[] serviceImpls, String loadBalancingTargetScheme, String tlsProtocalClient, KeyManagerFactory kmfClient, TrustManagerFactory tmfClient, String overrideAuthority) Run a gRPC server and client with two-way TLS.void
-
Constructor Details
-
GRPCTestHelper
public GRPCTestHelper()
-
-
Method Details
-
buildGRPCServer
public static GRPCServer buildGRPCServer(GRPCTestHelper.GRPCSimpleClient config, io.grpc.BindableService... serviceImps) throws GeneralSecurityException, IOException - Throws:
GeneralSecurityExceptionIOException
-
buildGRPCServer
public static GRPCServer buildGRPCServer(String host, int port, KeyManagerFactory kmfServer, TrustManagerFactory tmfServer, io.grpc.BindableService... serviceImps) throws IOException - Throws:
IOException
-
buildGRPCClient
public static io.grpc.netty.shaded.io.grpc.netty.NettyChannelBuilder buildGRPCClient(GRPCTestHelper.GRPCSimpleClient config) throws IOException, GeneralSecurityException - Throws:
IOExceptionGeneralSecurityException
-
buildGRPCClient
public static io.grpc.netty.shaded.io.grpc.netty.NettyChannelBuilder buildGRPCClient(String tlsProtocal, String host, int port, KeyManagerFactory kmfClient, TrustManagerFactory tmfClient, String overrideAuthority) throws SSLException - Throws:
SSLException
-
buildGRPCClient
public static io.grpc.netty.shaded.io.grpc.netty.NettyChannelBuilder buildGRPCClient(String tlsProtocal, String host, int port, String loadBalancingPolicy, String loadBalancingTargetScheme, KeyManagerFactory kmfClient, TrustManagerFactory tmfClient, String overrideAuthority) throws SSLException - Throws:
SSLException
-
test2WayTLS
- Throws:
GeneralSecurityExceptionIOException
-
buildDefaultTestConfigs
protected GRPCTestHelper.GRPCSimpleClient[] buildDefaultTestConfigs() throws GeneralSecurityException, IOException- Throws:
GeneralSecurityExceptionIOException
-
getServerImpls
protected abstract io.grpc.BindableService[] getServerImpls() -
test2WayTLS
- Throws:
IOException
-
test2WayTLS
public void test2WayTLS(String host, int port, KeyManagerFactory kmfServer, TrustManagerFactory tmfServer, io.grpc.BindableService[] serviceImpls, String loadBalancingTargetScheme, String tlsProtocalClient, KeyManagerFactory kmfClient, TrustManagerFactory tmfClient, String overrideAuthority) throws IOException Run a gRPC server and client with two-way TLS.- Parameters:
host- the host for the server and clientport- the port for the server and clientkmfServer- KeyManagerFactory for the servertmfServer- TrustManagerFactory for the serverserviceImpls- array of BindableService implementations for the serverloadBalancingTargetScheme- scheme for load balancing targetkmfClient- KeyManagerFactory for the clienttmfClient- TrustManagerFactory for the clientoverrideAuthority- override authority for the client- Throws:
IOException- if an I/O error occurs
-
runClient
protected abstract void runClient(io.grpc.netty.shaded.io.grpc.netty.NettyChannelBuilder channelBuilder)
-