mirror of https://github.com/apache/nifi.git
NIFI-5967: Removed unused ALLOW_EXPLICIT_KEYTAB private variable
Updated Hive_1_1ConnectionPoolTest.testKerberosAuthException to use a mocked KerberosCredentialsService This closes #3272
This commit is contained in:
parent
cdf3c69208
commit
e4be06c7c8
|
@ -65,8 +65,6 @@ import org.apache.nifi.expression.ExpressionLanguageScope;
|
|||
@Tags({"hive", "dbcp", "jdbc", "database", "connection", "pooling", "store"})
|
||||
@CapabilityDescription("Provides Database Connection Pooling Service for Apache Hive 1.1.x. Connections can be asked from pool and returned after usage.")
|
||||
public class Hive_1_1ConnectionPool extends AbstractControllerService implements Hive_1_1DBCPService {
|
||||
private static final String ALLOW_EXPLICIT_KEYTAB = "NIFI_ALLOW_EXPLICIT_KEYTAB";
|
||||
|
||||
public static final PropertyDescriptor DATABASE_URL = new PropertyDescriptor.Builder()
|
||||
.name("hive-db-connect-url")
|
||||
.displayName("Database Connection URL")
|
||||
|
|
|
@ -30,17 +30,19 @@ import java.security.PrivilegedExceptionAction;
|
|||
import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.apache.commons.dbcp.BasicDataSource;
|
||||
import org.apache.hadoop.security.UserGroupInformation;
|
||||
import org.apache.nifi.components.PropertyDescriptor;
|
||||
import org.apache.nifi.controller.AbstractControllerService;
|
||||
import org.apache.nifi.hadoop.KerberosProperties;
|
||||
import org.apache.nifi.kerberos.KerberosCredentialsService;
|
||||
import org.apache.nifi.logging.ComponentLog;
|
||||
import org.apache.nifi.processor.exception.ProcessException;
|
||||
import org.apache.nifi.registry.VariableDescriptor;
|
||||
import org.apache.nifi.reporting.InitializationException;
|
||||
import org.apache.nifi.util.MockConfigurationContext;
|
||||
import org.apache.nifi.util.MockControllerServiceLookup;
|
||||
import org.apache.nifi.util.MockVariableRegistry;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
|
@ -154,23 +156,25 @@ public class Hive_1_1ConnectionPoolTest {
|
|||
final String conf = "src/test/resources/hive-site-security.xml";
|
||||
final String ktab = "src/test/resources/fake.keytab";
|
||||
final String kprinc = "bad@PRINCIPAL.COM";
|
||||
|
||||
KerberosProperties kerbProperties = new KerberosProperties(krb5conf);
|
||||
final String kerberosCredentialsServiceId = UUID.randomUUID().toString();
|
||||
|
||||
Map<PropertyDescriptor, String> props = new HashMap<PropertyDescriptor, String>() {{
|
||||
put(Hive_1_1ConnectionPool.DATABASE_URL, "${url}");
|
||||
put(Hive_1_1ConnectionPool.HIVE_CONFIGURATION_RESOURCES, "${conf}");
|
||||
put(kerbProperties.getKerberosKeytab(), "${ktab}");
|
||||
put(kerbProperties.getKerberosPrincipal(), "${kprinc}");
|
||||
put(Hive_1_1ConnectionPool.KERBEROS_CREDENTIALS_SERVICE, kerberosCredentialsServiceId);
|
||||
}};
|
||||
|
||||
MockVariableRegistry registry = new MockVariableRegistry();
|
||||
registry.setVariable(new VariableDescriptor("url"), URL);
|
||||
registry.setVariable(new VariableDescriptor("conf"), conf);
|
||||
registry.setVariable(new VariableDescriptor("ktab"), ktab);
|
||||
registry.setVariable(new VariableDescriptor("kprinc"), kprinc);
|
||||
|
||||
MockConfigurationContext context = new MockConfigurationContext(props, null, registry);
|
||||
MockControllerServiceLookup mockControllerServiceLookup = new MockControllerServiceLookup() {};
|
||||
KerberosCredentialsService kerberosCredentialsService = mock(KerberosCredentialsService.class);
|
||||
when(kerberosCredentialsService.getKeytab()).thenReturn(ktab);
|
||||
when(kerberosCredentialsService.getPrincipal()).thenReturn(kprinc);
|
||||
mockControllerServiceLookup.addControllerService(kerberosCredentialsService, kerberosCredentialsServiceId);
|
||||
|
||||
MockConfigurationContext context = new MockConfigurationContext(props, mockControllerServiceLookup, registry);
|
||||
hiveConnectionPool.onConfigured(context);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue