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