Search in sources :

Example 1 with GrpcConnection

use of alluxio.grpc.GrpcConnection in project alluxio by Alluxio.

the class GrpcSecurityTest method testAuthenticationClosed.

@Test
public void testAuthenticationClosed() throws Exception {
    mConfiguration.set(PropertyKey.SECURITY_AUTHENTICATION_TYPE, AuthType.SIMPLE.getAuthName());
    GrpcServer server = createServer(AuthType.SIMPLE);
    try {
        server.start();
        UserState us = UserState.Factory.create(mConfiguration);
        GrpcChannel channel = GrpcChannelBuilder.newBuilder(getServerConnectAddress(server), mConfiguration).setSubject(us.getSubject()).build();
        // Grab internal channel-Id.
        GrpcConnection connection = Whitebox.getInternalState(channel, "mConnection");
        UUID channelId = connection.getChannelKey().getChannelId();
        // Assert that authentication server has a login info for the channel.
        Assert.assertNotNull(server.getAuthenticationServer().getUserInfoForChannel(channelId));
        // Shutdown channel.
        channel.shutdown();
        // Assert that authentication server doesn't contain login info for the channel anymore.
        // Wait in a loop. Because closing the authentication will propagate asynchronously.
        CommonUtils.waitFor("login state removed", () -> {
            try {
                server.getAuthenticationServer().getUserInfoForChannel(channelId);
                return false;
            } catch (UnauthenticatedException exc) {
                return true;
            }
        }, WaitForOptions.defaults().setTimeoutMs(S_AUTHENTICATION_PROPOGATE_TIMEOUT));
    } finally {
        server.shutdown();
    }
}
Also used : UserState(alluxio.security.user.UserState) UnauthenticatedException(alluxio.exception.status.UnauthenticatedException) GrpcConnection(alluxio.grpc.GrpcConnection) GrpcServer(alluxio.grpc.GrpcServer) UUID(java.util.UUID) GrpcChannel(alluxio.grpc.GrpcChannel) Test(org.junit.Test)

Aggregations

UnauthenticatedException (alluxio.exception.status.UnauthenticatedException)1 GrpcChannel (alluxio.grpc.GrpcChannel)1 GrpcConnection (alluxio.grpc.GrpcConnection)1 GrpcServer (alluxio.grpc.GrpcServer)1 UserState (alluxio.security.user.UserState)1 UUID (java.util.UUID)1 Test (org.junit.Test)1