use of org.apache.nifi.toolkit.tls.configuration.TlsClientConfig in project nifi by apache.
the class NifiPropertiesTlsClientConfigWriterTest method setup.
@Before
public void setup() throws IOException {
testHostname = "testHostname";
hostNum = 22;
keyStore = "testKeyStore.jks";
keyStoreType = TlsConfig.DEFAULT_KEY_STORE_TYPE;
keyStorePassword = "badKeyStorePassword";
keyPassword = "badKeyPassword";
trustStore = "testTrustStore.jks";
trustStoreType = TlsConfig.DEFAULT_KEY_STORE_TYPE;
trustStorePassword = "badTrustStorePassword";
outputFile = File.createTempFile("temp", "nifi");
outputStream = new ByteArrayOutputStream();
when(outputStreamFactory.create(outputFile)).thenReturn(outputStream);
tlsClientConfig = new TlsClientConfig();
tlsClientConfig.setKeyStore(keyStore);
tlsClientConfig.setKeyStoreType(keyStoreType);
tlsClientConfig.setKeyStorePassword(keyStorePassword);
tlsClientConfig.setKeyPassword(keyPassword);
tlsClientConfig.setTrustStore(trustStore);
tlsClientConfig.setTrustStoreType(trustStoreType);
tlsClientConfig.setTrustStorePassword(trustStorePassword);
niFiPropertiesWriter = new NiFiPropertiesWriter(new ArrayList<>());
when(niFiPropertiesWriterFactory.create()).thenReturn(niFiPropertiesWriter);
nifiPropertiesTlsClientConfigWriter = new NifiPropertiesTlsClientConfigWriter(niFiPropertiesWriterFactory, outputFile, testHostname, hostNum);
overlayProperties = nifiPropertiesTlsClientConfigWriter.getOverlayProperties();
}
use of org.apache.nifi.toolkit.tls.configuration.TlsClientConfig in project nifi by apache.
the class TlsCertificateAuthorityClientCommandLineTest method testKeyStoreType.
@Test
public void testKeyStoreType() throws CommandLineParseException, IOException {
String testType = "testType";
tlsCertificateAuthorityClientCommandLine.parse("-t", testToken, "-T", testType);
TlsClientConfig clientConfig = tlsCertificateAuthorityClientCommandLine.createClientConfig();
assertEquals(testType, clientConfig.getKeyStoreType());
String trustStoreType = KeystoreType.JKS.toString().toLowerCase();
assertEquals(trustStoreType, clientConfig.getTrustStoreType());
assertEquals(TlsCertificateAuthorityClientCommandLine.KEYSTORE + testType.toLowerCase(), clientConfig.getKeyStore());
assertEquals(TlsCertificateAuthorityClientCommandLine.TRUSTSTORE + trustStoreType, clientConfig.getTrustStore());
}
use of org.apache.nifi.toolkit.tls.configuration.TlsClientConfig in project nifi by apache.
the class TlsCertificateAuthorityClientCommandLineTest method testDefaults.
@Test
public void testDefaults() throws CommandLineParseException, IOException {
tlsCertificateAuthorityClientCommandLine.parse("-t", testToken);
TlsClientConfig clientConfig = tlsCertificateAuthorityClientCommandLine.createClientConfig();
assertEquals(TlsConfig.DEFAULT_HOSTNAME, clientConfig.getCaHostname());
Assert.assertEquals(new TlsConfig().calcDefaultDn(InetAddress.getLocalHost().getHostName()), clientConfig.getDn());
assertEquals(TlsCertificateAuthorityClientCommandLine.KEYSTORE + TlsConfig.DEFAULT_KEY_STORE_TYPE.toLowerCase(), clientConfig.getKeyStore());
assertEquals(TlsConfig.DEFAULT_KEY_STORE_TYPE, clientConfig.getKeyStoreType());
assertNull(clientConfig.getKeyStorePassword());
assertNull(clientConfig.getKeyPassword());
assertEquals(TlsCertificateAuthorityClientCommandLine.TRUSTSTORE + TlsConfig.DEFAULT_KEY_STORE_TYPE.toLowerCase(), clientConfig.getTrustStore());
assertEquals(TlsConfig.DEFAULT_KEY_STORE_TYPE, clientConfig.getTrustStoreType());
assertNull(clientConfig.getTrustStorePassword());
assertEquals(TlsConfig.DEFAULT_KEY_SIZE, clientConfig.getKeySize());
assertEquals(TlsConfig.DEFAULT_KEY_PAIR_ALGORITHM, clientConfig.getKeyPairAlgorithm());
assertEquals(testToken, clientConfig.getToken());
assertEquals(TlsConfig.DEFAULT_PORT, clientConfig.getPort());
assertEquals(TlsCertificateAuthorityClientCommandLine.DEFAULT_CONFIG_JSON, tlsCertificateAuthorityClientCommandLine.getConfigJsonOut());
assertNull(tlsCertificateAuthorityClientCommandLine.getConfigJsonIn());
assertEquals(TlsCertificateAuthorityClientCommandLine.DEFAULT_CERTIFICATE_DIRECTORY, tlsCertificateAuthorityClientCommandLine.getCertificateDirectory());
}
Aggregations