Search in sources :

Example 6 with UserState

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

Example 7 with UserState

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

Example 8 with UserState

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);
}
Also used : UserState(alluxio.security.user.UserState) InetSocketAddress(java.net.InetSocketAddress)

Example 9 with UserState

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();
}
Also used : UserState(alluxio.security.user.UserState) TemporaryFolder(org.junit.rules.TemporaryFolder) File(java.io.File) Before(org.junit.Before)

Example 10 with UserState

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();
}
Also used : UserState(alluxio.security.user.UserState) TestUserState(alluxio.security.user.TestUserState) FileSystemMasterClient(alluxio.client.file.FileSystemMasterClient) TestUserState(alluxio.security.user.TestUserState) AlluxioURI(alluxio.AlluxioURI)

Aggregations

UserState (alluxio.security.user.UserState)11 Test (org.junit.Test)5 GrpcServer (alluxio.grpc.GrpcServer)3 Before (org.junit.Before)3 AlluxioURI (alluxio.AlluxioURI)2 FileSystemMasterClient (alluxio.client.file.FileSystemMasterClient)2 GrpcChannel (alluxio.grpc.GrpcChannel)2 TestUserState (alluxio.security.user.TestUserState)2 File (java.io.File)2 InetSocketAddress (java.net.InetSocketAddress)2 TemporaryFolder (org.junit.rules.TemporaryFolder)2 UnauthenticatedException (alluxio.exception.status.UnauthenticatedException)1 GrpcChannelBuilder (alluxio.grpc.GrpcChannelBuilder)1 GrpcConnection (alluxio.grpc.GrpcConnection)1 GrpcServerBuilder (alluxio.grpc.GrpcServerBuilder)1 JobConfig (alluxio.job.JobConfig)1 JobInfo (alluxio.job.wire.JobInfo)1 DefaultSafeModeManager (alluxio.master.DefaultSafeModeManager)1 BaseIntegrationTest (alluxio.testutils.BaseIntegrationTest)1 UnderFileSystem (alluxio.underfs.UnderFileSystem)1