Search in sources :

Example 41 with RpcException

use of org.apache.drill.exec.rpc.RpcException in project drill by axbaretto.

the class TestCustomUserAuthenticator method negativeAuthHelper.

private static void negativeAuthHelper(final String user, final String password) throws Exception {
    RpcException negativeAuthEx = null;
    try {
        runTest(user, password);
    } catch (RpcException e) {
        negativeAuthEx = e;
    }
    assertNotNull("Expected RpcException.", negativeAuthEx);
    final String exMsg = negativeAuthEx.getMessage();
    assertThat(exMsg, containsString("Authentication failed"));
    assertThat(exMsg, containsString("Incorrect credentials"));
}
Also used : RpcException(org.apache.drill.exec.rpc.RpcException) StringContains.containsString(org.hamcrest.core.StringContains.containsString)

Example 42 with RpcException

use of org.apache.drill.exec.rpc.RpcException in project drill by axbaretto.

the class TestUserBitKerberosEncryption method failureOldClientEncryptionEnabled.

/**
 * Test to validate that older clients are not allowed to connect to secure cluster
 * with encryption enabled.
 */
@Test
public void failureOldClientEncryptionEnabled() {
    try {
        final Properties connectionProps = new Properties();
        connectionProps.setProperty(DrillProperties.SERVICE_PRINCIPAL, krbHelper.SERVER_PRINCIPAL);
        connectionProps.setProperty(DrillProperties.USER, krbHelper.CLIENT_PRINCIPAL);
        connectionProps.setProperty(DrillProperties.KEYTAB, krbHelper.clientKeytab.getAbsolutePath());
        connectionProps.setProperty(DrillProperties.TEST_SASL_LEVEL, "1");
        newConfig = new DrillConfig(DrillConfig.create(cloneDefaultTestConfigProperties()).withValue(ExecConstants.USER_AUTHENTICATION_ENABLED, ConfigValueFactory.fromAnyRef(true)).withValue(ExecConstants.USER_AUTHENTICATOR_IMPL, ConfigValueFactory.fromAnyRef(UserAuthenticatorTestImpl.TYPE)).withValue(ExecConstants.SERVICE_PRINCIPAL, ConfigValueFactory.fromAnyRef(krbHelper.SERVER_PRINCIPAL)).withValue(ExecConstants.SERVICE_KEYTAB_LOCATION, ConfigValueFactory.fromAnyRef(krbHelper.serverKeytab.toString())).withValue(ExecConstants.AUTHENTICATION_MECHANISMS, ConfigValueFactory.fromIterable(Lists.newArrayList("plain", "kerberos"))).withValue(ExecConstants.USER_ENCRYPTION_SASL_ENABLED, ConfigValueFactory.fromAnyRef(true)));
        updateTestCluster(1, newConfig, connectionProps);
        fail();
    } catch (Exception ex) {
        assert (ex.getCause() instanceof RpcException);
        System.out.println("Caught exception: " + ex.getMessage());
        logger.info("Caught exception: " + ex.getMessage());
    }
}
Also used : DrillConfig(org.apache.drill.common.config.DrillConfig) RpcException(org.apache.drill.exec.rpc.RpcException) NonTransientRpcException(org.apache.drill.exec.rpc.NonTransientRpcException) DrillProperties(org.apache.drill.common.config.DrillProperties) Properties(java.util.Properties) RpcException(org.apache.drill.exec.rpc.RpcException) NonTransientRpcException(org.apache.drill.exec.rpc.NonTransientRpcException) SecurityTest(org.apache.drill.categories.SecurityTest) Test(org.junit.Test)

Example 43 with RpcException

use of org.apache.drill.exec.rpc.RpcException in project drill by apache.

the class JdbcConnectTriesTestEmbeddedBits method testDirectConnectionConnectTriesGreaterThanDrillbitCount.

@Test
public void testDirectConnectionConnectTriesGreaterThanDrillbitCount() throws SQLException {
    Connection connection = null;
    try {
        connection = testDrillDriver.connect("jdbc:drill:drillbit=127.0.0.1:5000,127.0.0.1:5001;tries=5", getDefaultProperties());
        fail();
    } catch (SQLException ex) {
        assertNull(connection);
        assertTrue(ex.getCause() instanceof RpcException);
        assertTrue(ex.getCause().getCause() instanceof ExecutionException);
    }
}
Also used : SQLException(java.sql.SQLException) RpcException(org.apache.drill.exec.rpc.RpcException) Connection(java.sql.Connection) ExecutionException(java.util.concurrent.ExecutionException) Test(org.junit.Test) JdbcTest(org.apache.drill.categories.JdbcTest)

Example 44 with RpcException

use of org.apache.drill.exec.rpc.RpcException in project drill by apache.

the class JdbcConnectTriesTestEmbeddedBits method testDirectConnectionNegativeConnectTries.

@Test
public void testDirectConnectionNegativeConnectTries() throws SQLException {
    Connection connection = null;
    try {
        connection = testDrillDriver.connect("jdbc:drill:drillbit=127.0.0.1:5000,127.0.0.1:5001;tries=-5", getDefaultProperties());
        fail();
    } catch (SQLException ex) {
        assertNull(connection);
        assertTrue(ex.getCause() instanceof RpcException);
        assertTrue(ex.getCause().getCause() instanceof ExecutionException);
    }
}
Also used : SQLException(java.sql.SQLException) RpcException(org.apache.drill.exec.rpc.RpcException) Connection(java.sql.Connection) ExecutionException(java.util.concurrent.ExecutionException) Test(org.junit.Test) JdbcTest(org.apache.drill.categories.JdbcTest)

Example 45 with RpcException

use of org.apache.drill.exec.rpc.RpcException in project drill by apache.

the class JdbcConnectTriesTestEmbeddedBits method testDirectConnectionZeroConnectTries.

@Test
public void testDirectConnectionZeroConnectTries() throws SQLException {
    Connection connection = null;
    try {
        connection = testDrillDriver.connect("jdbc:drill:drillbit=127.0.0.1:5000,127.0.0.1:5001;tries=0", getDefaultProperties());
        fail();
    } catch (SQLException ex) {
        assertNull(connection);
        assertTrue(ex.getCause() instanceof RpcException);
        assertTrue(ex.getCause().getCause() instanceof ExecutionException);
    }
}
Also used : SQLException(java.sql.SQLException) RpcException(org.apache.drill.exec.rpc.RpcException) Connection(java.sql.Connection) ExecutionException(java.util.concurrent.ExecutionException) Test(org.junit.Test) JdbcTest(org.apache.drill.categories.JdbcTest)

Aggregations

RpcException (org.apache.drill.exec.rpc.RpcException)56 Test (org.junit.Test)22 ExecutionException (java.util.concurrent.ExecutionException)18 IOException (java.io.IOException)15 NonTransientRpcException (org.apache.drill.exec.rpc.NonTransientRpcException)12 Connection (java.sql.Connection)10 SQLException (java.sql.SQLException)10 JdbcTest (org.apache.drill.categories.JdbcTest)10 Response (org.apache.drill.exec.rpc.Response)9 Properties (java.util.Properties)8 SaslException (javax.security.sasl.SaslException)8 QueryId (org.apache.drill.exec.proto.UserBitShared.QueryId)8 UserException (org.apache.drill.common.exceptions.UserException)6 DrillBuf (io.netty.buffer.DrillBuf)5 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)4 ByteString (com.google.protobuf.ByteString)4 InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)4 ByteBufInputStream (io.netty.buffer.ByteBufInputStream)4 DrillException (org.apache.drill.common.exceptions.DrillException)4 UserRemoteException (org.apache.drill.common.exceptions.UserRemoteException)4