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();
}
}
Aggregations