use of alluxio.security.user.UserState 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.security.user.UserState 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();
}
}
use of alluxio.security.user.UserState in project alluxio by Alluxio.
the class GrpcConnectionPoolTest method createServer.
private CloseableTestServer createServer() throws Exception {
InetSocketAddress bindAddress = new InetSocketAddress("0.0.0.0", 0);
UserState us = UserState.Factory.create(sConf);
GrpcServer grpcServer = GrpcServerBuilder.forAddress(GrpcServerAddress.create("localhost", bindAddress), sConf, us).build().start();
return new CloseableTestServer(grpcServer);
}
use of alluxio.security.user.UserState in project alluxio by Alluxio.
the class FileSystemMasterSyncMetadataTest method before.
@Before
public void before() throws Exception {
UserState s = UserState.Factory.create(ServerConfiguration.global());
AuthenticatedClientUser.set(s.getUser().getName());
TemporaryFolder tmpFolder = new TemporaryFolder();
tmpFolder.create();
File ufsRoot = tmpFolder.newFolder();
ServerConfiguration.set(PropertyKey.MASTER_JOURNAL_TYPE, JournalType.UFS);
ServerConfiguration.set(PropertyKey.MASTER_MOUNT_TABLE_ROOT_UFS, ufsRoot.getAbsolutePath());
ServerConfiguration.set(PropertyKey.MASTER_PERSISTENCE_INITIAL_INTERVAL_MS, 0);
ServerConfiguration.set(PropertyKey.MASTER_PERSISTENCE_MAX_INTERVAL_MS, 1000);
ServerConfiguration.set(PropertyKey.MASTER_PERSISTENCE_MAX_TOTAL_WAIT_TIME_MS, 1000);
mJournalFolder = tmpFolder.newFolder();
startServices();
}
use of alluxio.security.user.UserState in project alluxio by Alluxio.
the class MasterClientAuthenticationIntegrationTest method authenticationOperationTest.
/**
* Tests Alluxio client connects or disconnects to the Master. When the client connects
* successfully to the Master, it can successfully create file or not.
*
* @param filename the name of the file
*/
private void authenticationOperationTest(String filename) throws Exception {
UserState s = new TestUserState(SUPERUSER, ServerConfiguration.global());
FileSystemMasterClient masterClient = FileSystemMasterClient.Factory.create(MasterClientContext.newBuilder(ClientContext.create(s.getSubject(), ServerConfiguration.global())).build());
Assert.assertFalse(masterClient.isConnected());
masterClient.connect();
Assert.assertTrue(masterClient.isConnected());
masterClient.createFile(new AlluxioURI(filename), FileSystemOptions.createFileDefaults(ServerConfiguration.global()));
Assert.assertNotNull(masterClient.getStatus(new AlluxioURI(filename), FileSystemOptions.getStatusDefaults(ServerConfiguration.global())));
masterClient.disconnect();
masterClient.close();
}
Aggregations