Search in sources :

Example 6 with SpnegoConfig

use of org.apache.drill.exec.server.rest.auth.SpnegoConfig in project drill by axbaretto.

the class TestSpnegoConfig method testSpnegoConfigOnlyKeytab.

/**
 * Invalid configuration with keytab only and missing principal
 * @throws Exception
 */
@Test
public void testSpnegoConfigOnlyKeytab() throws Exception {
    try {
        final DrillConfig newConfig = new DrillConfig(DrillConfig.create().withValue(ExecConstants.USER_AUTHENTICATION_ENABLED, ConfigValueFactory.fromAnyRef(true)).withValue(ExecConstants.AUTHENTICATION_MECHANISMS, ConfigValueFactory.fromIterable(Lists.newArrayList("plain"))).withValue(ExecConstants.HTTP_SPNEGO_KEYTAB, ConfigValueFactory.fromAnyRef(spnegoHelper.serverKeytab.toString())).withValue(ExecConstants.USER_AUTHENTICATOR_IMPL, ConfigValueFactory.fromAnyRef(UserAuthenticatorTestImpl.TYPE)));
        final SpnegoConfig spnegoConfig = new SpnegoConfig(newConfig);
        spnegoConfig.validateSpnegoConfig();
        fail();
    } catch (Exception ex) {
        assertTrue(ex instanceof DrillException);
    }
}
Also used : DrillConfig(org.apache.drill.common.config.DrillConfig) SpnegoConfig(org.apache.drill.exec.server.rest.auth.SpnegoConfig) DrillException(org.apache.drill.common.exceptions.DrillException) DrillException(org.apache.drill.common.exceptions.DrillException) Test(org.junit.Test) SecurityTest(org.apache.drill.categories.SecurityTest)

Example 7 with SpnegoConfig

use of org.apache.drill.exec.server.rest.auth.SpnegoConfig in project drill by axbaretto.

the class TestSpnegoConfig method testSpnegoConfigOnlyPrincipal.

/**
 * Invalid configuration with principal only and missing keytab
 * @throws Exception
 */
@Test
public void testSpnegoConfigOnlyPrincipal() throws Exception {
    try {
        final DrillConfig newConfig = new DrillConfig(DrillConfig.create().withValue(ExecConstants.USER_AUTHENTICATION_ENABLED, ConfigValueFactory.fromAnyRef(true)).withValue(ExecConstants.AUTHENTICATION_MECHANISMS, ConfigValueFactory.fromIterable(Lists.newArrayList("plain"))).withValue(ExecConstants.HTTP_SPNEGO_PRINCIPAL, ConfigValueFactory.fromAnyRef(spnegoHelper.SERVER_PRINCIPAL)).withValue(ExecConstants.USER_AUTHENTICATOR_IMPL, ConfigValueFactory.fromAnyRef(UserAuthenticatorTestImpl.TYPE)));
        final SpnegoConfig spnegoConfig = new SpnegoConfig(newConfig);
        spnegoConfig.validateSpnegoConfig();
        fail();
    } catch (Exception ex) {
        assertTrue(ex instanceof DrillException);
    }
}
Also used : DrillConfig(org.apache.drill.common.config.DrillConfig) SpnegoConfig(org.apache.drill.exec.server.rest.auth.SpnegoConfig) DrillException(org.apache.drill.common.exceptions.DrillException) DrillException(org.apache.drill.common.exceptions.DrillException) Test(org.junit.Test) SecurityTest(org.apache.drill.categories.SecurityTest)

Example 8 with SpnegoConfig

use of org.apache.drill.exec.server.rest.auth.SpnegoConfig in project drill by apache.

the class TestSpnegoConfig method testInvalidSpnegoConfig.

/**
 * Test invalid {@link SpnegoConfig} with missing keytab and principal
 * @throws Exception
 */
@Test
public void testInvalidSpnegoConfig() throws Exception {
    // Invalid configuration for SPNEGO
    try {
        final DrillConfig newConfig = new DrillConfig(DrillConfig.create().withValue(ExecConstants.USER_AUTHENTICATION_ENABLED, ConfigValueFactory.fromAnyRef(true)).withValue(ExecConstants.AUTHENTICATION_MECHANISMS, ConfigValueFactory.fromIterable(Lists.newArrayList("plain"))).withValue(ExecConstants.USER_AUTHENTICATOR_IMPL, ConfigValueFactory.fromAnyRef(UserAuthenticatorTestImpl.TYPE)));
        final SpnegoConfig spnegoConfig = new SpnegoConfig(newConfig);
        spnegoConfig.validateSpnegoConfig();
        fail();
    } catch (Exception ex) {
        assertTrue(ex instanceof DrillException);
    }
}
Also used : DrillConfig(org.apache.drill.common.config.DrillConfig) SpnegoConfig(org.apache.drill.exec.server.rest.auth.SpnegoConfig) DrillException(org.apache.drill.common.exceptions.DrillException) DrillException(org.apache.drill.common.exceptions.DrillException) Test(org.junit.Test) BaseTest(org.apache.drill.test.BaseTest) SecurityTest(org.apache.drill.categories.SecurityTest)

Aggregations

SecurityTest (org.apache.drill.categories.SecurityTest)8 DrillConfig (org.apache.drill.common.config.DrillConfig)8 DrillException (org.apache.drill.common.exceptions.DrillException)8 SpnegoConfig (org.apache.drill.exec.server.rest.auth.SpnegoConfig)8 Test (org.junit.Test)8 BaseTest (org.apache.drill.test.BaseTest)4 UserGroupInformation (org.apache.hadoop.security.UserGroupInformation)2