aboutsummaryrefslogtreecommitdiff
path: root/connector
diff options
context:
space:
mode:
authorlalber <lukas.alber@iaik.tugraz.at>2020-11-13 08:39:00 +0100
committerlalber <lukas.alber@iaik.tugraz.at>2020-11-13 08:39:32 +0100
commit65baff23786c76746f4b188d3e6e59fd112e3030 (patch)
treeb94096d5fe912ef6e905bd5df7eb6b17fd113b48 /connector
parentb04c31afa0213048367ee6e4eec4fb52dfd59915 (diff)
downloadNational_eIDAS_Gateway-65baff23786c76746f4b188d3e6e59fd112e3030.tar.gz
National_eIDAS_Gateway-65baff23786c76746f4b188d3e6e59fd112e3030.tar.bz2
National_eIDAS_Gateway-65baff23786c76746f4b188d3e6e59fd112e3030.zip
improved Junit tests
Diffstat (limited to 'connector')
-rw-r--r--connector/src/main/java/at/asitplus/eidas/specific/connector/builder/AuthenticationDataBuilder.java13
-rw-r--r--connector/src/test/java/at/asitplus/eidas/specific/connector/test/AuthenticationDataBuilderTest.java32
-rw-r--r--connector/src/test/resources/config/junit_config_3.properties2
3 files changed, 28 insertions, 19 deletions
diff --git a/connector/src/main/java/at/asitplus/eidas/specific/connector/builder/AuthenticationDataBuilder.java b/connector/src/main/java/at/asitplus/eidas/specific/connector/builder/AuthenticationDataBuilder.java
index ef1a1f2b..13cceafb 100644
--- a/connector/src/main/java/at/asitplus/eidas/specific/connector/builder/AuthenticationDataBuilder.java
+++ b/connector/src/main/java/at/asitplus/eidas/specific/connector/builder/AuthenticationDataBuilder.java
@@ -57,7 +57,7 @@ public class AuthenticationDataBuilder extends AbstractAuthenticationDataBuilder
AuthenticationData authData = new AuthenticationData();
boolean isEidModeNew = pendingReq.getServiceProviderConfiguration()
- .isConfigurationValue(MsEidasNodeConstants.PROP_CONFIG_SP_NEW_EID_MODE, false);
+ .isConfigurationValue(MsEidasNodeConstants.PROP_CONFIG_SP_NEW_EID_MODE, false);
if (isEidModeNew) {
authData = (AuthenticationData) super.buildAuthenticationData(pendingReq);
@@ -66,11 +66,11 @@ public class AuthenticationDataBuilder extends AbstractAuthenticationDataBuilder
generateDeprecatedBasicAuthData(authData, pendingReq, authProcessData);
// set specific informations
- authData.setSsoSessionValidTo(new Date(new Date().getTime()
- + MsEidasNodeConstants.DEFAULT_PVP_ASSERTION_VALIDITY * 60 * 1000));
+ authData.setSsoSessionValidTo(
+ new Date(new Date().getTime() + MsEidasNodeConstants.DEFAULT_PVP_ASSERTION_VALIDITY * 60 * 1000));
- } catch (EaafBuilderException | EaafParserException | EaafConfigurationException
- | XPathException | DOMException e) {
+ } catch (EaafBuilderException | EaafParserException
+ | EaafConfigurationException | XPathException | DOMException e) {
log.warn("Can not build authentication data from auth. process information");
throw new EaafAuthenticationException("builder.11", new Object[]{e.getMessage()}, e);
@@ -108,8 +108,7 @@ public class AuthenticationDataBuilder extends AbstractAuthenticationDataBuilder
@Override
protected Pair<String, String> getEncryptedBpkFromPvpAttribute(IAuthProcessDataContainer arg0,
- AuthenticationData arg1,
- ISpConfiguration arg2) throws EaafBuilderException {
+ AuthenticationData arg1, ISpConfiguration arg2) throws EaafBuilderException {
return null;
}
diff --git a/connector/src/test/java/at/asitplus/eidas/specific/connector/test/AuthenticationDataBuilderTest.java b/connector/src/test/java/at/asitplus/eidas/specific/connector/test/AuthenticationDataBuilderTest.java
index 78d2ee1a..1721fe61 100644
--- a/connector/src/test/java/at/asitplus/eidas/specific/connector/test/AuthenticationDataBuilderTest.java
+++ b/connector/src/test/java/at/asitplus/eidas/specific/connector/test/AuthenticationDataBuilderTest.java
@@ -4,6 +4,7 @@ package at.asitplus.eidas.specific.connector.test;
import at.asitplus.eidas.specific.connector.builder.AuthenticationDataBuilder;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants;
import at.gv.egiz.eaaf.core.api.data.EaafConfigConstants;
+import at.gv.egiz.eaaf.core.api.idp.IAuthData;
import at.gv.egiz.eaaf.core.api.idp.IConfiguration;
import at.gv.egiz.eaaf.core.exceptions.EaafAuthenticationException;
import at.gv.egiz.eaaf.core.exceptions.EaafStorageException;
@@ -13,6 +14,7 @@ import at.gv.egiz.eaaf.core.impl.idp.module.test.TestRequestImpl;
import at.gv.egiz.eaaf.modules.pvp2.impl.opensaml.initialize.EaafOpenSaml3xInitializer;
import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
import org.apache.commons.lang3.RandomStringUtils;
+import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -34,12 +36,7 @@ import java.util.Map;
import static at.asitplus.eidas.specific.connector.MsEidasNodeConstants.PROP_CONFIG_SP_NEW_EID_MODE;
@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration({"/applicationContext.xml",
- "/SpringTest_connector.beans.xml",
- "/eaaf_core.beans.xml",
- "/eaaf_pvp.beans.xml",
- "/eaaf_pvp_idp.beans.xml",
- "/spring/SpringTest-context_simple_storage.xml" })
+@ContextConfiguration({"/applicationContext.xml", "/SpringTest_connector.beans.xml", "/eaaf_core.beans.xml", "/eaaf_pvp.beans.xml", "/eaaf_pvp_idp.beans.xml", "/spring/SpringTest-context_simple_storage.xml"})
@WebAppConfiguration
public class AuthenticationDataBuilderTest {
@@ -55,6 +52,9 @@ public class AuthenticationDataBuilderTest {
private DummySpConfiguration oaParam;
+ private String eidasBind;
+ private String authBlock;
+
@BeforeClass
public static void classInitializer() throws InitializationException, ComponentInitializationException {
@@ -82,16 +82,26 @@ public class AuthenticationDataBuilderTest {
pendingReq.setPendingReqId(RandomStringUtils.randomAlphanumeric(10));
pendingReq.setSpConfig(oaParam);
pendingReq.getSessionData(AuthProcessDataWrapper.class).setEidProcess(true);
- pendingReq.getSessionData(AuthProcessDataWrapper.class).setGenericDataToSession(Constants.SZR_AUTHBLOCK, RandomStringUtils.randomAlphanumeric(20));
- pendingReq.getSessionData(AuthProcessDataWrapper.class).setGenericDataToSession(Constants.EIDAS_BIND, RandomStringUtils.randomAlphanumeric(20));
-
-
+ authBlock = RandomStringUtils.randomAlphanumeric(20);
+ eidasBind = RandomStringUtils.randomAlphanumeric(20);
+ pendingReq.getSessionData(AuthProcessDataWrapper.class).setGenericDataToSession(Constants.SZR_AUTHBLOCK, authBlock);
+ pendingReq.getSessionData(AuthProcessDataWrapper.class).setGenericDataToSession(Constants.EIDAS_BIND, eidasBind);
LocaleContextHolder.resetLocaleContext();
}
@Test
public void first() throws EaafAuthenticationException {
- authenticationDataBuilder.buildAuthenticationData(pendingReq);
+ IAuthData authData = authenticationDataBuilder.buildAuthenticationData(pendingReq);
+
+ Assert.assertNotNull("AuthData null", authData);
+ Assert.assertNotNull("authBlock null", authData.getGenericData(Constants.SZR_AUTHBLOCK, String.class));
+ Assert.assertNotNull("eidasBind null", authData.getGenericData(Constants.EIDAS_BIND, String.class));
+ Assert.assertNotNull("eidasBind null", authData.getEidasQaaLevel());
+ String authBlock = authData.getGenericData(Constants.SZR_AUTHBLOCK, String.class);
+ String eidasBind = authData.getGenericData(Constants.EIDAS_BIND, String.class);
+
+ Assert.assertEquals("authBlock not equal", authBlock, this.authBlock);
+ Assert.assertEquals("eidasBind not equal", eidasBind, this.eidasBind);
}
}
diff --git a/connector/src/test/resources/config/junit_config_3.properties b/connector/src/test/resources/config/junit_config_3.properties
index 1199fdf5..32e30790 100644
--- a/connector/src/test/resources/config/junit_config_3.properties
+++ b/connector/src/test/resources/config/junit_config_3.properties
@@ -100,7 +100,7 @@ eidas.ms.pvp2.metadata.contact.email=max@junit.test
eidas.ms.sp.0.uniqueID=
eidas.ms.sp.0.pvp2.metadata.truststore=keys/junit.jks
eidas.ms.sp.0.pvp2.metadata.truststore.password=password
-eidas.ms.sp.0.eidMode=new
+eidas.ms.sp.0.newEidMode=true
#eidas.ms.sp.0.friendlyName=
#eidas.ms.sp.0.pvp2.metadata.url=