NIFI-7223 - Added another test for when keyPasswd is not present.

This commit is contained in:
Nathan Gough 2020-03-14 04:19:39 +11:00 committed by Joe Witt
parent f9d75056fa
commit 69b6c231fd
No known key found for this signature in database
GPG Key ID: 9093BF854F811A1A
1 changed files with 23 additions and 0 deletions

View File

@ -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