rlevas commented on a change in pull request #56: KNOX-1756 - Knox Gateway TLS
Keystore and Alias Should be Configurable
URL: https://github.com/apache/knox/pull/56#discussion_r259082098
##########
File path:
gateway-server/src/test/java/org/apache/knox/gateway/config/impl/GatewayConfigImplTest.java
##########
@@ -292,5 +295,55 @@ public void testGetReadOnlyOverrideTopologyNames() {
assertTrue(names.contains("default"));
}
+ // KNOX-1756
+ @Test
+ public void testCustomIdentityKeystoreOptions() {
+ GatewayConfigImpl config = new GatewayConfigImpl();
+
+ // Validate default options (backwards compatibility)
+ assertEquals("gateway-identity", config.getIdentityKeyAlias());
+ assertEquals("gateway-identity-passphrase",
config.getIdentityKeyPassphraseAlias());
+ assertEquals("gateway-identity", config.getSigningKeyAlias());
+ assertEquals("gateway-identity-passphrase",
config.getSigningKeyPassphraseAlias());
+ assertNull(config.getSigningKeystoreName());
+
+ // Validate default options (new)
+ assertEquals(GatewayConfig.DEFAULT_IDENTITY_KEYSTORE_PASSWORD_ALIAS,
config.getIdentityKeystorePasswordAlias());
+ assertEquals(GatewayConfig.DEFAULT_IDENTITY_KEYSTORE_TYPE,
config.getIdentityKeystoreType());
+ assertEquals(Paths.get(config.getGatewayKeystoreDir(),
"gateway.jks").toAbsolutePath().toString(),
+ config.getIdentityKeystorePath());
+
+ // By default the signing keystore name will not be set, so the values
will be taken from the identity's configs
+ assertEquals(config.getIdentityKeystorePath(),
config.getSigningKeystorePath());
+ assertEquals(config.getIdentityKeystorePasswordAlias(),
config.getSigningKeystorePasswordAlias());
+ assertEquals(config.getIdentityKeystoreType(),
config.getSigningKeystoreType());
+ assertEquals(config.getIdentityKeyAlias(), config.getSigningKeyAlias());
+ assertEquals(config.getIdentityKeyPassphraseAlias(),
config.getSigningKeyPassphraseAlias());
+
+ // Validate changed options
+ config.set("gateway.tls.key.alias", "custom_key_alias");
+ config.set("gateway.tls.key.passphrase.alias",
"custom_key_passphrase_alias");
+ config.set("gateway.tls.keystore.path",
"/custom/keystore/path/keystore.p12");
+ config.set("gateway.tls.keystore.type", "PKCS12");
+ config.set("gateway.tls.keystore.password.alias",
"custom_keystore_password_alias");
+
+ config.set("gateway.signing.key.alias", "custom_key_alias");
+ config.set("gateway.signing.key.passphrase.alias",
"custom_key_passphrase_alias");
+ config.set("gateway.signing.keystore.name", "custom_keystore_name");
+ config.set("gateway.signing.keystore.type", "PKCS12");
+ config.set("gateway.signing.keystore.password.alias",
"custom_keystore_password_alias");
+
+ assertEquals("custom_key_alias", config.getIdentityKeyAlias());
+ assertEquals("custom_key_passphrase_alias",
config.getIdentityKeyPassphraseAlias());
+ assertEquals("/custom/keystore/path/keystore.p12",
config.getIdentityKeystorePath());
Review comment:
fixing
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services