use of alluxio.grpc.GrpcServer in project alluxio by Alluxio.
the class GrpcSecurityTest method testAuthenticationRevoked.
@Test
public void testAuthenticationRevoked() throws Exception {
mConfiguration.set(PropertyKey.SECURITY_AUTHENTICATION_TYPE, AuthType.SIMPLE.getAuthName());
mConfiguration.set(PropertyKey.AUTHENTICATION_INACTIVE_CHANNEL_REAUTHENTICATE_PERIOD, "250ms");
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();
Assert.assertTrue(channel.isHealthy());
/*
* Sleeping will ensure that authentication sessions for the channel will expire on the
* server. This should have propagated back to the client and its health status should reflect
* that.
*
* Sleep more than authentication revocation timeout.
*/
Thread.sleep(500);
Assert.assertFalse(channel.isHealthy());
} finally {
server.shutdown();
}
}
use of alluxio.grpc.GrpcServer in project alluxio by Alluxio.
the class GrpcSecurityTest method testSimpleAuthentication.
@Test
public void testSimpleAuthentication() throws Exception {
GrpcServer server = createServer(AuthType.SIMPLE);
try {
server.start();
UserState us = UserState.Factory.create(mConfiguration);
GrpcChannelBuilder channelBuilder = GrpcChannelBuilder.newBuilder(getServerConnectAddress(server), mConfiguration).setSubject(us.getSubject());
channelBuilder.build();
} finally {
server.shutdown();
}
}
use of alluxio.grpc.GrpcServer in project alluxio by Alluxio.
the class GrpcSecurityTest method testDisabledAuthentication.
@Test
public void testDisabledAuthentication() throws Exception {
GrpcServer server = createServer(AuthType.SIMPLE);
try {
server.start();
GrpcChannelBuilder channelBuilder = GrpcChannelBuilder.newBuilder(getServerConnectAddress(server), mConfiguration);
channelBuilder.disableAuthentication().build();
} finally {
server.shutdown();
}
}
use of alluxio.grpc.GrpcServer in project alluxio by Alluxio.
the class GrpcSecurityTest method testCustomAuthentication.
@Test
public void testCustomAuthentication() 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);
channelBuilder.setSubject(createSubject(ExactlyMatchAuthenticationProvider.USERNAME, ExactlyMatchAuthenticationProvider.PASSWORD)).build();
} finally {
server.shutdown();
}
}
use of alluxio.grpc.GrpcServer 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