use of alluxio.grpc.GrpcChannelBuilder in project alluxio by Alluxio.
the class GrpcSecurityTest method testCustomAuthenticationFails.
@Test
public void testCustomAuthenticationFails() throws Exception {
mConfiguration.set(PropertyKey.SECURITY_AUTHENTICATION_TYPE, AuthType.CUSTOM.getAuthName());
mConfiguration.set(PropertyKey.SECURITY_AUTHENTICATION_CUSTOM_PROVIDER_CLASS, ExactlyMatchAuthenticationProvider.class.getName());
GrpcServer server = createServer(AuthType.CUSTOM);
try {
server.start();
GrpcChannelBuilder channelBuilder = GrpcChannelBuilder.newBuilder(getServerConnectAddress(server), mConfiguration);
mThrown.expect(UnauthenticatedException.class);
channelBuilder.setSubject(createSubject("fail", "fail")).build();
} finally {
server.shutdown();
}
}
use of alluxio.grpc.GrpcChannelBuilder in project alluxio by Alluxio.
the class GrpcSecurityTest method testNoSaslAuthentication.
@Test
public void testNoSaslAuthentication() throws Exception {
GrpcServer server = createServer(AuthType.NOSASL);
try {
server.start();
GrpcChannelBuilder channelBuilder = GrpcChannelBuilder.newBuilder(getServerConnectAddress(server), mConfiguration);
channelBuilder.build();
} finally {
server.shutdown();
}
}
use of alluxio.grpc.GrpcChannelBuilder in project alluxio by Alluxio.
the class GrpcSecurityTest method testAuthMismatch.
@Test
public void testAuthMismatch() throws Exception {
GrpcServer server = createServer(AuthType.NOSASL);
try {
server.start();
mConfiguration.set(PropertyKey.SECURITY_AUTHENTICATION_TYPE, AuthType.SIMPLE);
GrpcChannelBuilder channelBuilder = GrpcChannelBuilder.newBuilder(getServerConnectAddress(server), mConfiguration);
mThrown.expect(UnauthenticatedException.class);
channelBuilder.build();
} finally {
server.shutdown();
}
}
use of alluxio.grpc.GrpcChannelBuilder in project alluxio by Alluxio.
the class RpcClientTest method testGrpcChannelBuilderThrowsException.
@Test
public void testGrpcChannelBuilderThrowsException() throws Exception {
try (MockedStatic<GrpcChannelBuilder> builderMock = Mockito.mockStatic(GrpcChannelBuilder.class)) {
builderMock.when(() -> GrpcChannelBuilder.newBuilder(any(), any())).thenReturn(mMockChannelBuilder);
doThrow(AlluxioStatusException.from(Status.UNAVAILABLE)).when(mMockChannelBuilder).build();
RpcClient<ManagerAgentServiceGrpc.ManagerAgentServiceBlockingStub> client = new RpcClient<>(mConf, mAddr, ManagerAgentServiceGrpc::newBlockingStub, () -> new CountingRetry(4));
assertThrows(AlluxioStatusException.class, client::get);
verify(mMockChannelBuilder, VerificationModeFactory.times(5)).build();
}
}
Aggregations