From 69b6c231fddb4c547905e85c4087af18ea77c38f Mon Sep 17 00:00:00 2001 From: Nathan Gough Date: Sat, 14 Mar 2020 04:19:39 +1100 Subject: [PATCH] NIFI-7223 - Added another test for when keyPasswd is not present. --- .../okhttp/OkHttpReplicationClientTest.groovy | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/groovy/org/apache/nifi/cluster/coordination/http/replication/okhttp/OkHttpReplicationClientTest.groovy b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/groovy/org/apache/nifi/cluster/coordination/http/replication/okhttp/OkHttpReplicationClientTest.groovy index 2cfb2cb2b5..c30c3e92ad 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/groovy/org/apache/nifi/cluster/coordination/http/replication/okhttp/OkHttpReplicationClientTest.groovy +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/groovy/org/apache/nifi/cluster/coordination/http/replication/okhttp/OkHttpReplicationClientTest.groovy @@ -162,6 +162,29 @@ class OkHttpReplicationClientTest extends GroovyTestCase { assert client.okHttpClient.sslSocketFactory.context.getX509KeyManager().credentialsMap["nifi-key"] } + @Test + void testShouldUseKeystorePasswdIfKeyPasswdIsNull() { + // Arrange + Map flowfileEncryptionProps = [ + (NiFiProperties.SECURITY_TRUSTSTORE): "./src/test/resources/conf/truststore.jks", + (NiFiProperties.SECURITY_TRUSTSTORE_TYPE): "JKS", + (NiFiProperties.SECURITY_TRUSTSTORE_PASSWD): "passwordpassword", + (NiFiProperties.SECURITY_KEYSTORE): "./src/test/resources/conf/keystore.jks", + (NiFiProperties.SECURITY_KEYSTORE_TYPE): "JKS", + (NiFiProperties.SECURITY_KEYSTORE_PASSWD): "passwordpassword", + (NiFiProperties.WEB_HTTPS_HOST): "localhost", + (NiFiProperties.WEB_HTTPS_PORT): "51552", + ] + NiFiProperties mockNiFiProperties = new StandardNiFiProperties(new Properties(flowfileEncryptionProps)) + + // Act + OkHttpReplicationClient client = new OkHttpReplicationClient(mockNiFiProperties) + + // Assert + assertNotNull(client.okHttpClient.sslSocketFactory) + assertEquals(SunX509KeyManagerImpl.class, client.okHttpClient.sslSocketFactory.context.getX509KeyManager().getClass()) + assertNotNull(client.okHttpClient.sslSocketFactory.context.getX509KeyManager().credentialsMap["nifi-key"]) } + @Test void testShouldFailIfKeyPasswordIsSetButKeystorePasswordIsBlank() { // Arrange