diff --git a/solr/core/src/java/org/apache/solr/util/configuration/providers/EnvSSLCredentialProvider.java b/solr/core/src/java/org/apache/solr/util/configuration/providers/EnvSSLCredentialProvider.java index ccfd8071b4e..6641cfeee2f 100644 --- a/solr/core/src/java/org/apache/solr/util/configuration/providers/EnvSSLCredentialProvider.java +++ b/solr/core/src/java/org/apache/solr/util/configuration/providers/EnvSSLCredentialProvider.java @@ -44,6 +44,10 @@ public class EnvSSLCredentialProvider extends AbstractSSLCredentialProvider { private Map envVars; + public EnvSSLCredentialProvider() { + this.envVars = System.getenv(); + } + protected EnumMap getCredentialKeyMap() { return Maps.newEnumMap(ImmutableMap.of( SSL_KEY_STORE_PASSWORD, EnvVars.SOLR_SSL_KEY_STORE_PASSWORD, diff --git a/solr/core/src/test/org/apache/solr/util/configuration/providers/EnvSSLCredentialProviderTest.java b/solr/core/src/test/org/apache/solr/util/configuration/providers/EnvSSLCredentialProviderTest.java index c355dce8924..2b85e7daf81 100644 --- a/solr/core/src/test/org/apache/solr/util/configuration/providers/EnvSSLCredentialProviderTest.java +++ b/solr/core/src/test/org/apache/solr/util/configuration/providers/EnvSSLCredentialProviderTest.java @@ -49,4 +49,13 @@ public class EnvSSLCredentialProviderTest { } } + @Test + public void testGetCredentialsWithEnvVars() throws Exception { + EnvSSLCredentialProvider sut = new EnvSSLCredentialProvider(); + // assuming not to fail + sut.getCredential(SSLCredentialProvider.CredentialType.SSL_KEY_STORE_PASSWORD); + sut.getCredential(SSLCredentialProvider.CredentialType.SSL_CLIENT_KEY_STORE_PASSWORD); + sut.getCredential(SSLCredentialProvider.CredentialType.SSL_TRUST_STORE_PASSWORD); + sut.getCredential(SSLCredentialProvider.CredentialType.SSL_CLIENT_TRUST_STORE_PASSWORD); + } } diff --git a/solr/core/src/test/org/apache/solr/util/configuration/providers/SysPropSSLCredentialProviderTest.java b/solr/core/src/test/org/apache/solr/util/configuration/providers/SysPropSSLCredentialProviderTest.java index e278cb5aef2..4a5894d786b 100644 --- a/solr/core/src/test/org/apache/solr/util/configuration/providers/SysPropSSLCredentialProviderTest.java +++ b/solr/core/src/test/org/apache/solr/util/configuration/providers/SysPropSSLCredentialProviderTest.java @@ -52,4 +52,15 @@ public class SysPropSSLCredentialProviderTest { assertThat(sut.getCredential(set.getKey()), is(pw)); } } + + + @Test + public void testGetCredentialsWithoutSetup() throws Exception { + SysPropSSLCredentialProvider sut = new SysPropSSLCredentialProvider(); + // assuming not to fail + sut.getCredential(SSLCredentialProvider.CredentialType.SSL_KEY_STORE_PASSWORD); + sut.getCredential(SSLCredentialProvider.CredentialType.SSL_CLIENT_KEY_STORE_PASSWORD); + sut.getCredential(SSLCredentialProvider.CredentialType.SSL_TRUST_STORE_PASSWORD); + sut.getCredential(SSLCredentialProvider.CredentialType.SSL_CLIENT_TRUST_STORE_PASSWORD); + } }