From 63a9a57b2c01d8a0810d7c8b42a265fa10cc7cef Mon Sep 17 00:00:00 2001 From: John Blum Date: Sun, 27 May 2018 01:56:51 -0700 Subject: [PATCH] Add test suite method on tear down to clear all SSL System properties. Add overloaded locateKeyStoreInFileSystem(keystoreFilename:String) method. --- .../AutoConfiguredSslIntegrationTests.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/geode-spring-boot-starter/src/test/java/org/springframework/boot/data/geode/security/ssl/AutoConfiguredSslIntegrationTests.java b/geode-spring-boot-starter/src/test/java/org/springframework/boot/data/geode/security/ssl/AutoConfiguredSslIntegrationTests.java index f92e33fe..b40c6ab6 100644 --- a/geode-spring-boot-starter/src/test/java/org/springframework/boot/data/geode/security/ssl/AutoConfiguredSslIntegrationTests.java +++ b/geode-spring-boot-starter/src/test/java/org/springframework/boot/data/geode/security/ssl/AutoConfiguredSslIntegrationTests.java @@ -22,11 +22,14 @@ import static org.springframework.data.gemfire.util.RuntimeExceptionFactory.newI import java.io.File; import java.io.IOException; +import java.util.List; import java.util.Optional; +import java.util.stream.Collectors; import org.apache.geode.cache.GemFireCache; import org.apache.geode.cache.Region; import org.apache.geode.cache.client.ClientRegionShortcut; +import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; @@ -130,6 +133,10 @@ public class AutoConfiguredSslIntegrationTests extends ForkingClientServerIntegr return locateKeyStoreInFileSystem(directory, TRUSTED_KEYSTORE_FILENAME); } + private static Optional locateKeyStoreInFileSystem(String keystoreFileName) { + return locateKeyStoreInFileSystem(FileSystemUtils.WORKING_DIRECTORY, keystoreFileName); + } + @SuppressWarnings("all") private static Optional locateKeyStoreInFileSystem(File directory, String keystoreFilename) { @@ -162,6 +169,20 @@ public class AutoConfiguredSslIntegrationTests extends ForkingClientServerIntegr return Optional.empty(); } + @AfterClass + public static void clearSslSystemProperties() { + + List sslSystemProperties = System.getProperties().keySet().stream() + .map(String::valueOf) + .map(String::toLowerCase) + .filter(property -> property.contains("ssl")) + .collect(Collectors.toList()); + + //System.err.printf("SSL System Properties [%s]%n", sslSystemProperties); + + sslSystemProperties.forEach(System::clearProperty); + } + @javax.annotation.Resource(name = "Echo") private Region echo;