Search in sources :

Example 6 with GrpcChannelBuilder

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();
    }
}
Also used : GrpcServer(alluxio.grpc.GrpcServer) GrpcChannelBuilder(alluxio.grpc.GrpcChannelBuilder) Test(org.junit.Test)

Example 7 with GrpcChannelBuilder

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();
    }
}
Also used : GrpcServer(alluxio.grpc.GrpcServer) GrpcChannelBuilder(alluxio.grpc.GrpcChannelBuilder) Test(org.junit.Test)

Example 8 with GrpcChannelBuilder

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();
    }
}
Also used : GrpcServer(alluxio.grpc.GrpcServer) GrpcChannelBuilder(alluxio.grpc.GrpcChannelBuilder) Test(org.junit.Test)

Example 9 with GrpcChannelBuilder

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();
    }
}
Also used : CountingRetry(alluxio.retry.CountingRetry) ManagerAgentServiceGrpc(alluxio.hub.proto.ManagerAgentServiceGrpc) GrpcChannelBuilder(alluxio.grpc.GrpcChannelBuilder) Test(org.junit.Test) BaseHubTest(alluxio.hub.test.BaseHubTest)

Aggregations

GrpcChannelBuilder (alluxio.grpc.GrpcChannelBuilder)9 Test (org.junit.Test)8 GrpcServer (alluxio.grpc.GrpcServer)6 BaseHubTest (alluxio.hub.test.BaseHubTest)2 TestLoggerRule (alluxio.TestLoggerRule)1 InstancedConfiguration (alluxio.conf.InstancedConfiguration)1 GrpcChannel (alluxio.grpc.GrpcChannel)1 HubTestUtils.generateNodeAddress (alluxio.hub.manager.util.HubTestUtils.generateNodeAddress)1 HubTestUtils.hubStatusToAlluxioStatus (alluxio.hub.manager.util.HubTestUtils.hubStatusToAlluxioStatus)1 AlluxioNodeStatus (alluxio.hub.proto.AlluxioNodeStatus)1 AlluxioNodeType (alluxio.hub.proto.AlluxioNodeType)1 HubNodeAddress (alluxio.hub.proto.HubNodeAddress)1 HubNodeState (alluxio.hub.proto.HubNodeState)1 ManagerAgentServiceGrpc (alluxio.hub.proto.ManagerAgentServiceGrpc)1 CountingRetry (alluxio.retry.CountingRetry)1 UserState (alluxio.security.user.UserState)1 MoreExecutors (com.google.common.util.concurrent.MoreExecutors)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1