use of org.apache.nifi.util.NiFiProperties in project nifi by apache.
the class TestRangerNiFiAuthorizer method testKerberosEnabled.
@Test
public void testKerberosEnabled() {
when(configurationContext.getProperty(eq(RangerNiFiAuthorizer.RANGER_KERBEROS_ENABLED_PROP))).thenReturn(new MockPropertyValue("true"));
nifiProperties = Mockito.mock(NiFiProperties.class);
when(nifiProperties.getKerberosServiceKeytabLocation()).thenReturn("test");
when(nifiProperties.getKerberosServicePrincipal()).thenReturn("test");
authorizer = new MockRangerNiFiAuthorizer(rangerBasePlugin);
authorizer.setNiFiProperties(nifiProperties);
try {
authorizer.onConfigured(configurationContext);
Assert.fail("Should have thrown exception");
} catch (AuthorizerCreationException e) {
// getting a LoginException here means we attempted to login which is what we want
boolean foundLoginException = false;
Throwable cause = e.getCause();
while (cause != null) {
if (cause instanceof LoginException) {
foundLoginException = true;
break;
}
cause = cause.getCause();
}
assertTrue(foundLoginException);
}
}
use of org.apache.nifi.util.NiFiProperties in project nifi by apache.
the class RecordReaders method isEncryptionAvailable.
private static boolean isEncryptionAvailable() {
if (encryptionPropertiesRead) {
return isEncryptionAvailable;
} else {
try {
NiFiProperties niFiProperties = NiFiPropertiesLoader.loadDefaultWithKeyFromBootstrap();
isEncryptionAvailable = CryptoUtils.isProvenanceRepositoryEncryptionConfigured(niFiProperties);
encryptionPropertiesRead = true;
} catch (IOException e) {
logger.error("Encountered an error checking the provenance repository encryption configuration: ", e);
isEncryptionAvailable = false;
}
return isEncryptionAvailable;
}
}
use of org.apache.nifi.util.NiFiProperties in project nifi by apache.
the class NifiPropertiesTlsClientConfigWriterTest method testNoHostnameProperties.
@Test
public void testNoHostnameProperties() throws IOException {
nifiPropertiesTlsClientConfigWriter.getOverlayProperties().setProperty(NifiPropertiesTlsClientConfigWriter.HOSTNAME_PROPERTIES, "");
nifiPropertiesTlsClientConfigWriter.write(tlsClientConfig, outputStreamFactory);
testHostnamesAndPorts();
Properties nifiProperties = getNifiProperties();
nifiProperties.stringPropertyNames().forEach(s -> assertNotEquals(testHostname, nifiProperties.getProperty(s)));
}
use of org.apache.nifi.util.NiFiProperties in project nifi by apache.
the class TlsToolkitStandaloneTest method testFileArg.
@Test
public void testFileArg() throws Exception {
runAndAssertExitCode(ExitCode.SUCCESS, "-o", tempDir.getAbsolutePath(), "-f", TEST_NIFI_PROPERTIES, "-n", TlsConfig.DEFAULT_HOSTNAME);
X509Certificate x509Certificate = checkLoadCertPrivateKey(TlsConfig.DEFAULT_KEY_PAIR_ALGORITHM);
Properties nifiProperties = checkHostDirAndReturnNifiProperties(TlsConfig.DEFAULT_HOSTNAME, x509Certificate);
assertEquals(FAKE_VALUE, nifiProperties.get(NIFI_FAKE_PROPERTY));
}
use of org.apache.nifi.util.NiFiProperties in project nifi by apache.
the class TlsToolkitStandaloneTest method testTrustStorePasswordArg.
@Test
public void testTrustStorePasswordArg() throws Exception {
String testTrustStore = "testTrustStore";
runAndAssertExitCode(ExitCode.SUCCESS, "-o", tempDir.getAbsolutePath(), "-P", testTrustStore, "-n", TlsConfig.DEFAULT_HOSTNAME);
X509Certificate x509Certificate = checkLoadCertPrivateKey(TlsConfig.DEFAULT_KEY_PAIR_ALGORITHM);
Properties nifiProperties = checkHostDirAndReturnNifiProperties(TlsConfig.DEFAULT_HOSTNAME, x509Certificate);
assertEquals(testTrustStore, nifiProperties.getProperty(NiFiProperties.SECURITY_TRUSTSTORE_PASSWD));
}
Aggregations