summaryrefslogtreecommitdiff
path: root/eaaf_core_utils/src/test
diff options
context:
space:
mode:
authorThomas Lenz <thomas.lenz@egiz.gv.at>2021-01-05 18:30:40 +0100
committerThomas Lenz <thomas.lenz@egiz.gv.at>2021-01-05 18:30:40 +0100
commit013febf9435d0aa3536897b3636787ae3ba15935 (patch)
tree5c424808d8bbb31b755736106639d3831c466f2e /eaaf_core_utils/src/test
parent228d4e40cfb8fc3fa7912064af3768a74beb9312 (diff)
parent07dcace901880965ea4b25816500f256f17899c0 (diff)
downloadEAAF-Components-013febf9435d0aa3536897b3636787ae3ba15935.tar.gz
EAAF-Components-013febf9435d0aa3536897b3636787ae3ba15935.tar.bz2
EAAF-Components-013febf9435d0aa3536897b3636787ae3ba15935.zip
Merge branch 'nightlyBuild' of gitlab.iaik.tugraz.at:egiz/eaaf_components into nightlyBuild
Diffstat (limited to 'eaaf_core_utils/src/test')
-rw-r--r--eaaf_core_utils/src/test/java/at/gv/egiz/eaaf/core/test/credentials/EaafKeyStoreFactoryTest.java34
1 files changed, 33 insertions, 1 deletions
diff --git a/eaaf_core_utils/src/test/java/at/gv/egiz/eaaf/core/test/credentials/EaafKeyStoreFactoryTest.java b/eaaf_core_utils/src/test/java/at/gv/egiz/eaaf/core/test/credentials/EaafKeyStoreFactoryTest.java
index 6d1b63d7..24fb271f 100644
--- a/eaaf_core_utils/src/test/java/at/gv/egiz/eaaf/core/test/credentials/EaafKeyStoreFactoryTest.java
+++ b/eaaf_core_utils/src/test/java/at/gv/egiz/eaaf/core/test/credentials/EaafKeyStoreFactoryTest.java
@@ -288,6 +288,9 @@ public class EaafKeyStoreFactoryTest {
Assert.assertNotNull("KeyStore is null", keyStore.getFirst());
Assert.assertNull("KeyStore is null", keyStore.getSecond());
+ Assert.assertEquals("Wrong HSM-Facade state", EaafKeyStoreFactory.HsmFacadeStatus.UNKNOWN,
+ keyStoreFactory.checkHsmFacadeStatus());
+
}
@Test
@@ -607,17 +610,44 @@ public class EaafKeyStoreFactoryTest {
final EaafKeyStoreFactory keyStoreFactory = context.getBean(EaafKeyStoreFactory.class);
Assert.assertTrue("HSM Facade state wrong", keyStoreFactory.isHsmFacadeInitialized());
+ Assert.assertEquals("Wrong HSM-Facade state", EaafKeyStoreFactory.HsmFacadeStatus.UP,
+ keyStoreFactory.checkHsmFacadeStatus());
}
@Test
@DirtiesContext(methodMode = MethodMode.BEFORE_METHOD)
+ public void hsmFacadeHealthCheckNoProvider() {
+ mapConfig.putConfigValue(EaafKeyStoreFactory.CONFIG_PROP_HSM_FACADE_HOST,
+ RandomStringUtils.randomNumeric(10));
+ mapConfig.putConfigValue(EaafKeyStoreFactory.CONFIG_PROP_HSM_FACADE_PORT,
+ RandomStringUtils.randomNumeric(4));
+ mapConfig.putConfigValue(EaafKeyStoreFactory.CONFIG_PROP_HSM_FACADE_CLIENT_USERNAME,
+ RandomStringUtils.randomNumeric(10));
+ mapConfig.putConfigValue(EaafKeyStoreFactory.CONFIG_PROP_HSM_FACADE_CLIENT_PASSWORD,
+ RandomStringUtils.randomAlphanumeric(10));
+ mapConfig.putConfigValue(EaafKeyStoreFactory.CONFIG_PROP_HSM_FACADE_SSLTRUST,
+ PATH_TO_HSM_FACADE_TRUST_CERT);
+
+ final EaafKeyStoreFactory keyStoreFactory = context.getBean(EaafKeyStoreFactory.class);
+ Assert.assertTrue("HSM Facade state wrong", keyStoreFactory.isHsmFacadeInitialized());
+
+ Security.removeProvider("HsmFacade");
+ Assert.assertEquals("Wrong HSM-Facade state", EaafKeyStoreFactory.HsmFacadeStatus.DOWN,
+ keyStoreFactory.checkHsmFacadeStatus());
+
+ }
+
+ @Test
+ @DirtiesContext(methodMode = MethodMode.BEFORE_METHOD)
public void hsmFacadeAlreadLoaded() {
HsmFacadeProvider provider = HsmFacadeProvider.getInstance();
Security.addProvider(provider);
final EaafKeyStoreFactory keyStoreFactory = context.getBean(EaafKeyStoreFactory.class);
Assert.assertTrue("HSM Facade state wrong", keyStoreFactory.isHsmFacadeInitialized());
+ Assert.assertEquals("Wrong HSM-Facade state", EaafKeyStoreFactory.HsmFacadeStatus.UP,
+ keyStoreFactory.checkHsmFacadeStatus());
}
@@ -769,7 +799,9 @@ public class EaafKeyStoreFactoryTest {
final EaafKeyStoreFactory keyStoreFactory = context.getBean(EaafKeyStoreFactory.class);
Assert.assertTrue("HSM Facade state wrong", keyStoreFactory.isHsmFacadeInitialized());
-
+ Assert.assertEquals("Wrong HSM-Facade state", EaafKeyStoreFactory.HsmFacadeStatus.UP,
+ keyStoreFactory.checkHsmFacadeStatus());
+
final KeyStoreConfiguration keyStoreConfig = new KeyStoreConfiguration();
keyStoreConfig.setKeyStoreType(KeyStoreType.HSMFACADE);
keyStoreConfig.setKeyStoreName("authhandler");