aboutsummaryrefslogtreecommitdiff
path: root/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/validation
diff options
context:
space:
mode:
Diffstat (limited to 'eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/validation')
-rw-r--r--eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/validation/EidasAttributePostProcessingTest.java460
-rw-r--r--eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/validation/EidasRequestPreProcessingFirstTest.java155
-rw-r--r--eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/validation/EidasRequestPreProcessingSecondTest.java157
-rw-r--r--eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/validation/EidasResponseValidatorTest.java333
4 files changed, 0 insertions, 1105 deletions
diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/validation/EidasAttributePostProcessingTest.java b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/validation/EidasAttributePostProcessingTest.java
deleted file mode 100644
index 9bb51cd9..00000000
--- a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/validation/EidasAttributePostProcessingTest.java
+++ /dev/null
@@ -1,460 +0,0 @@
-/*
- * Copyright 2018 A-SIT Plus GmbH
- * AT-specific eIDAS Connector has been developed in a cooperation between EGIZ,
- * A-SIT Plus GmbH, A-SIT, and Graz University of Technology.
- *
- * Licensed under the EUPL, Version 1.2 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "License");
- * You may not use this work except in compliance with the License.
- * You may obtain a copy of the License at:
- * https://joinup.ec.europa.eu/news/understanding-eupl-v12
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * This product combines work with different licenses. See the "NOTICE" text
- * file for details on the various modules and licenses.
- * The "NOTICE" text file is part of the distribution. Any derivative works
- * that you distribute must include a readable copy of the "NOTICE" text file.
-*/
-
-package at.asitplus.eidas.specific.modules.auth.eidas.v2.test.validation;
-
-import static org.junit.Assert.fail;
-
-import java.io.IOException;
-import java.text.SimpleDateFormat;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.joda.time.DateTime;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.test.annotation.DirtiesContext;
-import org.springframework.test.annotation.DirtiesContext.ClassMode;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-
-import at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants;
-import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.ErnbEidData;
-import at.asitplus.eidas.specific.modules.auth.eidas.v2.service.CcSpecificEidProcessingService;
-
-@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(locations = {
- "/SpringTest-context_tasks_test.xml",
- "/SpringTest-context_basic_mapConfig.xml"})
-@DirtiesContext(classMode = ClassMode.AFTER_CLASS)
-public class EidasAttributePostProcessingTest {
-
- @Autowired
- private CcSpecificEidProcessingService postProcessor;
-
- // lower case
- private static final String P1_eIDASID =
- "DE/AT/532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25";
- private static final String P1_GIVENNAME = "Max";
- private static final String P1_FAMILYNAME = "Mustermann";
- private static final DateTime P1_DATEOFBIRTH = DateTime.now();
- private static final String P1_PLACEOFBIRTH = "Nirgendwo";
- private static final String P1_BIRTHNAME = "Musterkind";
-
- // mixed
- private static final String P3_eIDASID =
- "DE/AT/532eaabd9574880dbf76b9b8cc00832c20A6ec113d682299550d7a6e0f345e25";
- private static final String P3_GIVENNAME = "Max";
- private static final String P3_FAMILYNAME = "Mustermann";
- private static final DateTime P3_DATEOFBIRTH = DateTime.now();
- private static final String P3_PLACEOFBIRTH = "Nirgendwo";
- private static final String P3_BIRTHNAME = "Musterkind";
-
- // upper case
- private static final String P4_eIDASID =
- "DE/AT/532EAABD9574880DBF76B9B8CC00832C20A6EC113D682299550D7A6E0F345E25";
- private static final String P4_GIVENNAME = "Max";
- private static final String P4_FAMILYNAME = "Mustermann";
- private static final DateTime P4_DATEOFBIRTH = DateTime.now();
- private static final String P4_PLACEOFBIRTH = "Nirgendwo";
- private static final String P4_BIRTHNAME = "Musterkind";
-
- // To long identifier
- private static final String P5_eIDASID =
- "DE/AT/532EAABD9574880DBF76B9B8CC00832C20A6EC113D682299550D7A6E0F345E251";
- private static final String P5_GIVENNAME = "Max";
- private static final String P5_FAMILYNAME = "Mustermann";
- private static final DateTime P5_DATEOFBIRTH = DateTime.now();
- private static final String P5_PLACEOFBIRTH = "Nirgendwo";
- private static final String P5_BIRTHNAME = "Musterkind";
-
- // to short identifier
- private static final String P6_eIDASID = "DE/AT/532EAABD9574880DBF76B9B8CC00832C20A6EC113D682299550D7A6E0F";
- private static final String P6_GIVENNAME = "Max";
- private static final String P6_FAMILYNAME = "Mustermann";
- private static final DateTime P6_DATEOFBIRTH = DateTime.now();
- private static final String P6_PLACEOFBIRTH = "Nirgendwo";
- private static final String P6_BIRTHNAME = "Musterkind";
-
- // no hex encoded identifier
- private static final String P7_eIDASID = "DE/AT/532EAABD9574880DBF76B9B8CC00832C20A6EC113D682299550D7A6E0F";
- private static final String P7_GIVENNAME = "Max";
- private static final String P7_FAMILYNAME = "Mustermann";
- private static final DateTime P7_DATEOFBIRTH = DateTime.now();
- private static final String P7_PLACEOFBIRTH = "Nirgendwo";
- private static final String P7_BIRTHNAME = "Musterkind";
-
- private static final String P2_eIDASID =
- "EE/AT/asfasfasdfasdfasdfasdfasdfasvafasdfasdfasdfasdfasdfasvascasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasd";
- private static final String P2_GIVENNAME = "Max";
- private static final String P2_FAMILYNAME = "Mustermann";
- private static final DateTime P2_DATEOFBIRTH = DateTime.now();
- private static final String P2_PLACEOFBIRTH = "Nirgendwo";
- private static final String P2_BIRTHNAME = "Musterkind";
-
- /**
- * jUnit class initializer.
- *
- * @throws IOException In case of an error
- */
- @BeforeClass
- public static void classInitializer() throws IOException {
- final String current = new java.io.File(".").toURI().toString();
- System.setProperty("eidas.ms.configuration", current + "../../basicConfig/default_config.properties");
-
- }
-
- @Test
- public void deWithHexLowerCase() throws Exception {
- try {
- final ErnbEidData result = postProcessor.postProcess(
- generateInputData(
- P1_eIDASID,
- P1_FAMILYNAME,
- P1_GIVENNAME,
- P1_DATEOFBIRTH,
- P1_PLACEOFBIRTH,
- P1_BIRTHNAME));
-
- validate(result,
- "Uy6qvZV0iA2/drm4zACDLCCm7BE9aCKZVQ16bg80XiU=",
- P1_FAMILYNAME,
- P1_GIVENNAME,
- P1_DATEOFBIRTH,
- P1_PLACEOFBIRTH,
- P1_BIRTHNAME);
-
- } catch (final Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
-
- }
- }
-
- @Test
- public void deWithHexMixedCase() throws Exception {
- try {
- final ErnbEidData result = postProcessor.postProcess(
- generateInputData(
- P3_eIDASID,
- P3_FAMILYNAME,
- P3_GIVENNAME,
- P3_DATEOFBIRTH,
- P3_PLACEOFBIRTH,
- P3_BIRTHNAME));
-
- validate(result,
- "Uy6qvZV0iA2/drm4zACDLCCm7BE9aCKZVQ16bg80XiU=",
- P3_FAMILYNAME,
- P3_GIVENNAME,
- P3_DATEOFBIRTH,
- P3_PLACEOFBIRTH,
- P3_BIRTHNAME);
-
- } catch (final Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
-
- }
- }
-
- @Test
- public void deWithHexUpperCase() throws Exception {
- try {
- final ErnbEidData result = postProcessor.postProcess(
- generateInputData(
- P4_eIDASID,
- P4_FAMILYNAME,
- P4_GIVENNAME,
- P4_DATEOFBIRTH,
- P4_PLACEOFBIRTH,
- P4_BIRTHNAME));
-
- validate(result,
- "Uy6qvZV0iA2/drm4zACDLCCm7BE9aCKZVQ16bg80XiU=",
- P4_FAMILYNAME,
- P4_GIVENNAME,
- P4_DATEOFBIRTH,
- P4_PLACEOFBIRTH,
- P4_BIRTHNAME);
-
- } catch (final Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
-
- }
- }
-
- @Test
- public void deWithHexTooLongCase() throws Exception {
- try {
- postProcessor.postProcess(
- generateInputData(
- P5_eIDASID,
- P5_FAMILYNAME,
- P5_GIVENNAME,
- P5_DATEOFBIRTH,
- P5_PLACEOFBIRTH,
- P5_BIRTHNAME));
-
- } catch (final Exception e) {
- return;
-
- }
-
- fail("Too long input accepted");
- }
-
- @Test
- public void deWithHexTooShortCase() throws Exception {
- try {
- postProcessor.postProcess(
- generateInputData(
- P6_eIDASID,
- P6_FAMILYNAME,
- P6_GIVENNAME,
- P6_DATEOFBIRTH,
- P6_PLACEOFBIRTH,
- P6_BIRTHNAME));
-
- } catch (final Exception e) {
- return;
-
- }
-
- fail("Too short input accepted");
- }
-
- @Test
- public void deWithNoHexCase() throws Exception {
- try {
- postProcessor.postProcess(
- generateInputData(
- P7_eIDASID,
- P7_FAMILYNAME,
- P7_GIVENNAME,
- P7_DATEOFBIRTH,
- P7_PLACEOFBIRTH,
- P7_BIRTHNAME));
-
- } catch (final Exception e) {
- return;
-
- }
-
- fail("Not hex encoded input accepted");
- }
-
- @Test
- public void eeTestCase() throws Exception {
- try {
- final ErnbEidData result = postProcessor.postProcess(
- generateInputData(
- P2_eIDASID,
- P2_FAMILYNAME,
- P2_GIVENNAME,
- P2_DATEOFBIRTH,
- P2_PLACEOFBIRTH,
- P2_BIRTHNAME));
-
- validate(result,
- "asfasfasdfasdfasdfasdfasdfasvafasdfasdfasdfasdfasdfasvascasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasd",
- P2_FAMILYNAME,
- P2_GIVENNAME,
- P2_DATEOFBIRTH,
- P2_PLACEOFBIRTH,
- P2_BIRTHNAME);
-
- } catch (final Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
-
- }
- }
-
- @Test
- public void eeTestFamilyNameMissingCase() throws Exception {
- try {
- final ErnbEidData result = postProcessor.postProcess(
- generateInputData(
- P2_eIDASID,
- null,
- P2_GIVENNAME,
- P2_DATEOFBIRTH,
- P2_PLACEOFBIRTH,
- P2_BIRTHNAME));
-
- validate(result,
- "asfasfasdfasdfasdfasdfasdfasvafasdfasdfasdfasdfasdfasvascasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasd",
- P2_FAMILYNAME,
- P2_GIVENNAME,
- P2_DATEOFBIRTH,
- P2_PLACEOFBIRTH,
- P2_BIRTHNAME);
-
- } catch (final Exception e) {
- return;
-
- }
-
- fail("FamilyName missing input accepted");
-
- }
-
- @Test
- public void eeTestGivenNameMissingCase() throws Exception {
- try {
- final ErnbEidData result = postProcessor.postProcess(
- generateInputData(
- P2_eIDASID,
- P2_FAMILYNAME,
- null,
- P2_DATEOFBIRTH,
- P2_PLACEOFBIRTH,
- P2_BIRTHNAME));
-
- validate(result,
- "asfasfasdfasdfasdfasdfasdfasvafasdfasdfasdfasdfasdfasvascasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasd",
- P2_FAMILYNAME,
- P2_GIVENNAME,
- P2_DATEOFBIRTH,
- P2_PLACEOFBIRTH,
- P2_BIRTHNAME);
-
- } catch (final Exception e) {
- return;
-
- }
-
- fail("GivenName missing input accepted");
-
- }
-
- @Test
- public void eeTestDateOfBirthMissingCase() throws Exception {
- try {
- final ErnbEidData result = postProcessor.postProcess(
- generateInputData(
- P2_eIDASID,
- P2_FAMILYNAME,
- P2_GIVENNAME,
- null,
- P2_PLACEOFBIRTH,
- P2_BIRTHNAME));
-
- validate(result,
- "asfasfasdfasdfasdfasdfasdfasvafasdfasdfasdfasdfasdfasvascasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasd",
- P2_FAMILYNAME,
- P2_GIVENNAME,
- P2_DATEOFBIRTH,
- P2_PLACEOFBIRTH,
- P2_BIRTHNAME);
-
- } catch (final Exception e) {
- return;
-
- }
-
- fail("DateOfBirth missing input accepted");
-
- }
-
- @Test
- public void eeTestIdMissingCase() throws Exception {
- try {
- final ErnbEidData result = postProcessor.postProcess(
- generateInputData(
- null,
- P2_FAMILYNAME,
- P2_GIVENNAME,
- P2_DATEOFBIRTH,
- P2_PLACEOFBIRTH,
- P2_BIRTHNAME));
-
- validate(result,
- "asfasfasdfasdfasdfasdfasdfasvafasdfasdfasdfasdfasdfasvascasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasd",
- P2_FAMILYNAME,
- P2_GIVENNAME,
- P2_DATEOFBIRTH,
- P2_PLACEOFBIRTH,
- P2_BIRTHNAME);
-
- } catch (final Exception e) {
- return;
-
- }
-
- fail("eIDAS-Id missing input accepted");
-
- }
-
- private Map<String, Object> generateInputData(String id, String familyName, String givenName,
- DateTime dateOfBirth, String placeOfBirth, String birthName) {
- final Map<String, Object> result = new HashMap<>();
- result.put(Constants.eIDAS_ATTR_PERSONALIDENTIFIER, id);
- result.put(Constants.eIDAS_ATTR_CURRENTGIVENNAME, givenName);
- result.put(Constants.eIDAS_ATTR_CURRENTFAMILYNAME, familyName);
- result.put(Constants.eIDAS_ATTR_DATEOFBIRTH, dateOfBirth);
- result.put(Constants.eIDAS_ATTR_PLACEOFBIRTH, placeOfBirth);
- result.put(Constants.eIDAS_ATTR_BIRTHNAME, birthName);
- return result;
-
- }
-
- private void validate(ErnbEidData result, String id, String familyName, String givenName,
- DateTime dateOfBirth, String placeOfBirth, String birthName) {
- if (!result.getPseudonym().equals(id)) {
- fail(result.getPseudonym() + "is not equal to " + id);
- }
-
- if (!result.getFamilyName().equals(familyName)) {
- fail(result.getFamilyName() + "is not equal to " + familyName);
- }
-
- if (!result.getGivenName().equals(givenName)) {
- fail(result.getGivenName() + "is not equal to " + givenName);
- }
-
- if (!result.getDateOfBirth().equals(dateOfBirth)) {
- fail(result.getDateOfBirth() + "is not equal to " + dateOfBirth);
- }
-
- if (!result.getFormatedDateOfBirth().equals(new SimpleDateFormat("yyyy-MM-dd").format(dateOfBirth
- .toDate()))) {
- fail(result.getDateOfBirth() + "is not equal to " + new SimpleDateFormat("yyyy-MM-dd").format(
- dateOfBirth.toDate()));
- }
-
- if (!result.getPlaceOfBirth().equals(placeOfBirth)) {
- fail(result.getPlaceOfBirth() + "is not equal to " + placeOfBirth);
- }
-
- if (!result.getBirthName().equals(birthName)) {
- fail(result.getBirthName() + "is not equal to " + birthName);
- }
-
- }
-
-}
diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/validation/EidasRequestPreProcessingFirstTest.java b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/validation/EidasRequestPreProcessingFirstTest.java
deleted file mode 100644
index 7ac41500..00000000
--- a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/validation/EidasRequestPreProcessingFirstTest.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * Copyright 2018 A-SIT Plus GmbH
- * AT-specific eIDAS Connector has been developed in a cooperation between EGIZ,
- * A-SIT Plus GmbH, A-SIT, and Graz University of Technology.
- *
- * Licensed under the EUPL, Version 1.2 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "License");
- * You may not use this work except in compliance with the License.
- * You may obtain a copy of the License at:
- * https://joinup.ec.europa.eu/news/understanding-eupl-v12
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * This product combines work with different licenses. See the "NOTICE" text
- * file for details on the various modules and licenses.
- * The "NOTICE" text file is part of the distribution. Any derivative works
- * that you distribute must include a readable copy of the "NOTICE" text file.
-*/
-
-package at.asitplus.eidas.specific.modules.auth.eidas.v2.test.validation;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.UUID;
-
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.test.annotation.DirtiesContext;
-import org.springframework.test.annotation.DirtiesContext.ClassMode;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.TestPropertySource;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-
-import at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants;
-import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.EidPostProcessingException;
-import at.asitplus.eidas.specific.modules.auth.eidas.v2.service.CcSpecificEidProcessingService;
-import at.gv.egiz.eaaf.core.api.data.EaafConfigConstants;
-import at.gv.egiz.eaaf.core.api.data.EaafConstants;
-import at.gv.egiz.eaaf.core.api.idp.IConfigurationWithSP;
-import at.gv.egiz.eaaf.core.impl.idp.module.test.DummySpConfiguration;
-import at.gv.egiz.eaaf.core.impl.idp.module.test.TestRequestImpl;
-import eu.eidas.auth.commons.light.impl.LightRequest;
-import eu.eidas.auth.commons.light.impl.LightRequest.Builder;
-
-@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(locations = {
- "/SpringTest-context_tasks_test.xml",
- "/SpringTest-context_basic_realConfig.xml"})
-@TestPropertySource(locations = {"classpath:/config/junit_config_de_attributes.properties"})
-@DirtiesContext(classMode = ClassMode.AFTER_CLASS)
-public class EidasRequestPreProcessingFirstTest {
-
- @Autowired
- private IConfigurationWithSP basicConfig;
- @Autowired
- private CcSpecificEidProcessingService preProcessor;
-
- private TestRequestImpl pendingReq;
- private DummySpConfiguration oaParam;
- private Builder authnRequestBuilder;
-
- /**
- * jUnit class initializer.
- *
- * @throws IOException In case of an error
- */
- @BeforeClass
- public static void classInitializer() throws IOException {
-// final String current = new java.io.File(".").toURI().toString();
-// System.setProperty("eidas.ms.configuration",
-// current + "src/test/resources/config/junit_config_de_attributes.properties");
-
- }
-
- /**
- * jUnit test set-up.
- *
- */
- @Before
- public void setUp() {
-
- final Map<String, String> spConfig = new HashMap<>();
- spConfig.put(EaafConfigConstants.SERVICE_UNIQUEIDENTIFIER, "testSp");
- spConfig.put("target", "urn:publicid:gv.at:cdid+XX");
- oaParam = new DummySpConfiguration(spConfig, basicConfig);
-
- pendingReq = new TestRequestImpl();
- pendingReq.setSpConfig(oaParam);
- pendingReq.setPendingReqId(at.gv.egiz.eaaf.core.impl.utils.Random.nextProcessReferenceValue());
- pendingReq.setAuthUrl("http://test.com/");
-
- authnRequestBuilder = LightRequest.builder();
- authnRequestBuilder.id(UUID.randomUUID().toString());
- authnRequestBuilder.issuer("Test");
- authnRequestBuilder.levelOfAssurance(EaafConstants.EIDAS_LOA_HIGH);
-
- }
-
- @Test
- public void prePreProcessGeneric() throws EidPostProcessingException {
- final String testCountry = "XX";
- authnRequestBuilder.citizenCountryCode(testCountry);
- preProcessor.preProcess(testCountry, pendingReq, authnRequestBuilder);
-
- final LightRequest lightReq = authnRequestBuilder.build();
-
- Assert.assertEquals("ProviderName is not Static",
- Constants.DEFAULT_PROPS_EIDAS_NODE_STATIC_PROVIDERNAME_FOR_PUBLIC_SP, lightReq.getProviderName());
- Assert.assertEquals("no PublicSP", "public", lightReq.getSpType());
- Assert.assertEquals("Requested attribute size not match", 4, lightReq.getRequestedAttributes().size());
-
- }
-
- @Test
- public void prePreProcessGenericNoCountryCode() throws EidPostProcessingException {
- final String testCountry = "XX";
- authnRequestBuilder.citizenCountryCode(testCountry);
- preProcessor.preProcess(null, pendingReq, authnRequestBuilder);
-
- final LightRequest lightReq = authnRequestBuilder.build();
-
- Assert.assertEquals("ProviderName is not Static",
- Constants.DEFAULT_PROPS_EIDAS_NODE_STATIC_PROVIDERNAME_FOR_PUBLIC_SP, lightReq.getProviderName());
- Assert.assertEquals("no PublicSP", "public", lightReq.getSpType());
- Assert.assertEquals("Requested attribute size not match", 4, lightReq.getRequestedAttributes().size());
-
- }
-
- @Test
- public void prePreProcessDE() throws EidPostProcessingException {
-
- final String testCountry = "DE";
- authnRequestBuilder.citizenCountryCode(testCountry);
- preProcessor.preProcess(testCountry, pendingReq, authnRequestBuilder);
-
- final LightRequest lightReq = authnRequestBuilder.build();
-
- Assert.assertEquals("ProviderName is not Static",
- Constants.DEFAULT_PROPS_EIDAS_NODE_STATIC_PROVIDERNAME_FOR_PUBLIC_SP, lightReq.getProviderName());
- Assert.assertNotSame("RequesterId was set", lightReq.getRequesterId());
- Assert.assertEquals("no PublicSP", "public", lightReq.getSpType());
- Assert.assertEquals("Requested attribute size not match", 8, lightReq.getRequestedAttributes().size());
-
- }
-
-}
diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/validation/EidasRequestPreProcessingSecondTest.java b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/validation/EidasRequestPreProcessingSecondTest.java
deleted file mode 100644
index 9ee38296..00000000
--- a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/validation/EidasRequestPreProcessingSecondTest.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * Copyright 2018 A-SIT Plus GmbH
- * AT-specific eIDAS Connector has been developed in a cooperation between EGIZ,
- * A-SIT Plus GmbH, A-SIT, and Graz University of Technology.
- *
- * Licensed under the EUPL, Version 1.2 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "License");
- * You may not use this work except in compliance with the License.
- * You may obtain a copy of the License at:
- * https://joinup.ec.europa.eu/news/understanding-eupl-v12
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * This product combines work with different licenses. See the "NOTICE" text
- * file for details on the various modules and licenses.
- * The "NOTICE" text file is part of the distribution. Any derivative works
- * that you distribute must include a readable copy of the "NOTICE" text file.
-*/
-
-package at.asitplus.eidas.specific.modules.auth.eidas.v2.test.validation;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.UUID;
-
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.test.annotation.DirtiesContext;
-import org.springframework.test.annotation.DirtiesContext.ClassMode;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-
-import at.asitplus.eidas.specific.core.test.config.dummy.MsConnectorDummyConfigMap;
-import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.EidPostProcessingException;
-import at.asitplus.eidas.specific.modules.auth.eidas.v2.service.CcSpecificEidProcessingService;
-import at.gv.egiz.eaaf.core.api.data.EaafConfigConstants;
-import at.gv.egiz.eaaf.core.api.data.EaafConstants;
-import at.gv.egiz.eaaf.core.impl.idp.module.test.DummySpConfiguration;
-import at.gv.egiz.eaaf.core.impl.idp.module.test.TestRequestImpl;
-import eu.eidas.auth.commons.light.impl.LightRequest;
-import eu.eidas.auth.commons.light.impl.LightRequest.Builder;
-
-@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(locations = {
- "/SpringTest-context_tasks_test.xml",
- "/SpringTest-context_basic_mapConfig.xml"})
-@DirtiesContext(classMode = ClassMode.AFTER_CLASS)
-public class EidasRequestPreProcessingSecondTest {
-
- @Autowired
- private MsConnectorDummyConfigMap basicConfig;
- @Autowired
- private CcSpecificEidProcessingService preProcessor;
-
- private TestRequestImpl pendingReq;
- private DummySpConfiguration oaParam;
- private Builder authnRequestBuilder;
-
-
- /**
- * jUnit test set-up.
- *
- */
- @Before
- public void setUp() {
-
- final Map<String, String> spConfig = new HashMap<>();
- spConfig.put(EaafConfigConstants.SERVICE_UNIQUEIDENTIFIER, "testSp");
- spConfig.put("target", "urn:publicid:gv.at:cdid+XX");
- oaParam = new DummySpConfiguration(spConfig, basicConfig);
-
- pendingReq = new TestRequestImpl();
- pendingReq.setSpConfig(oaParam);
- pendingReq.setPendingReqId(at.gv.egiz.eaaf.core.impl.utils.Random.nextProcessReferenceValue());
- pendingReq.setAuthUrl("http://test.com/");
-
- authnRequestBuilder = LightRequest.builder();
- authnRequestBuilder.id(UUID.randomUUID().toString());
- authnRequestBuilder.issuer("Test");
- authnRequestBuilder.levelOfAssurance(EaafConstants.EIDAS_LOA_HIGH);
-
- basicConfig.putConfigValue(
- "eidas.ms.auth.eIDAS.node_v2.requesterId.lu.useStaticRequesterForAll", "true");
-
- }
-
- @Test
- public void prePreProcessDeUnknownAttribute() throws EidPostProcessingException {
- basicConfig.putConfigValue("eidas.ms.auth.eIDAS.node_v2.staticProviderNameForPublicSPs", "myNode");
- basicConfig.putConfigValue(
- "eidas.ms.auth.eIDAS.node_v2.workarounds.useStaticProviderNameForPublicSPs", "true");
-
- final String testCountry = "DE";
- authnRequestBuilder.citizenCountryCode(testCountry);
- preProcessor.preProcess(testCountry, pendingReq, authnRequestBuilder);
-
- final LightRequest lightReq = authnRequestBuilder.build();
-
- Assert.assertEquals("ProviderName is not Static", "myNode", lightReq.getProviderName());
- Assert.assertEquals("no PublicSP", "public", lightReq.getSpType());
- Assert.assertEquals("Requested attribute size not match", 8, lightReq.getRequestedAttributes().size());
-
- }
-
-
- /*
- * Set ProviderName according to general configuration
- */
- @Test
- public void prePreProcessLuPublicSpWithoutRequestId() throws EidPostProcessingException {
-
- basicConfig.putConfigValue(
- "eidas.ms.auth.eIDAS.node_v2.requesterId.lu.useStaticRequesterForAll", "false");
-
- final String testCountry = "LU";
- authnRequestBuilder.citizenCountryCode(testCountry);
- preProcessor.preProcess(testCountry, pendingReq, authnRequestBuilder);
-
- final LightRequest lightReq = authnRequestBuilder.build();
-
- Assert.assertEquals("ProviderName is not Static", "myNode", lightReq.getProviderName());
- Assert.assertNull("RequesterId", lightReq.getRequesterId());
- Assert.assertEquals("no PublicSP", "public", lightReq.getSpType());
- Assert.assertEquals("Requested attribute size not match", 4, lightReq.getRequestedAttributes().size());
-
- }
-
- /*
- * Always set requesterId and providername in case of country LU
- */
- @Test
- public void prePreProcessLuPublicSpWithStaticRequesterId() throws EidPostProcessingException {
-
-
- final String testCountry = "LU";
- authnRequestBuilder.citizenCountryCode(testCountry);
- preProcessor.preProcess(testCountry, pendingReq, authnRequestBuilder);
-
- final LightRequest lightReq = authnRequestBuilder.build();
-
- Assert.assertEquals("ProviderName is not Static",
- "myNode", lightReq.getProviderName());
- Assert.assertEquals("RequesterId is not Static",
- "myNode", lightReq.getRequesterId());
- Assert.assertEquals("no PublicSP", "public", lightReq.getSpType());
- Assert.assertEquals("Requested attribute size not match", 4, lightReq.getRequestedAttributes().size());
-
- }
-
-}
diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/validation/EidasResponseValidatorTest.java b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/validation/EidasResponseValidatorTest.java
deleted file mode 100644
index b1f1b164..00000000
--- a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/validation/EidasResponseValidatorTest.java
+++ /dev/null
@@ -1,333 +0,0 @@
-package at.asitplus.eidas.specific.modules.auth.eidas.v2.test.validation;
-
-import static at.asitplus.eidas.specific.core.MsEidasNodeConstants.PROP_CONFIG_SP_NEW_EID_MODE;
-
-import java.net.URISyntaxException;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.commons.lang3.RandomStringUtils;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.powermock.core.classloader.annotations.PrepareForTest;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.test.annotation.DirtiesContext;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-
-import com.google.common.collect.ImmutableSet;
-
-import at.asitplus.eidas.specific.core.test.config.dummy.MsConnectorDummyConfigMap;
-import at.asitplus.eidas.specific.core.test.config.dummy.MsConnectorDummySpConfiguration;
-import at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants;
-import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.EidasValidationException;
-import at.asitplus.eidas.specific.modules.auth.eidas.v2.service.EidasAttributeRegistry;
-import at.asitplus.eidas.specific.modules.auth.eidas.v2.tasks.CreateIdentityLinkTask;
-import at.asitplus.eidas.specific.modules.auth.eidas.v2.validator.EidasResponseValidator;
-import at.gv.egiz.eaaf.core.api.data.EaafConfigConstants;
-import at.gv.egiz.eaaf.core.api.data.EaafConstants;
-import at.gv.egiz.eaaf.core.exceptions.EaafStorageException;
-import at.gv.egiz.eaaf.core.impl.idp.module.test.TestRequestImpl;
-import at.gv.egiz.eaaf.core.impl.utils.Random;
-import eu.eidas.auth.commons.attribute.AttributeDefinition;
-import eu.eidas.auth.commons.attribute.ImmutableAttributeMap;
-import eu.eidas.auth.commons.attribute.ImmutableAttributeMap.Builder;
-import eu.eidas.auth.commons.attribute.impl.StringAttributeValue;
-import eu.eidas.auth.commons.light.ILightResponse;
-import eu.eidas.auth.commons.protocol.impl.AuthenticationResponse;
-import lombok.val;
-
-@RunWith(SpringJUnit4ClassRunner.class)
-@PrepareForTest(CreateIdentityLinkTask.class)
-@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
-@ContextConfiguration(locations = {
- "/SpringTest-context_tasks_test.xml",
- "/SpringTest-context_basic_mapConfig.xml"})
-public class EidasResponseValidatorTest {
-
- @Autowired private MsConnectorDummyConfigMap basicConfig;
- @Autowired protected EidasAttributeRegistry attrRegistry;
-
- private TestRequestImpl pendingReq;
- private MsConnectorDummySpConfiguration oaParam;
-
-
- /**
- * jUnit test set-up.
- */
- @Before
- public void setUp() throws EaafStorageException, URISyntaxException {
-
- final Map<String, String> spConfig = new HashMap<>();
- spConfig.put(EaafConfigConstants.SERVICE_UNIQUEIDENTIFIER, "testSp");
- spConfig.put("target", "urn:publicid:gv.at:cdid+XX");
- spConfig.put(PROP_CONFIG_SP_NEW_EID_MODE, "true");
- oaParam = new MsConnectorDummySpConfiguration(spConfig, basicConfig);
- oaParam.setLoa(Arrays.asList(EaafConstants.EIDAS_LOA_HIGH));
- pendingReq = new TestRequestImpl();
-
- pendingReq.setSpConfig(oaParam);
- pendingReq.setPendingReqId(at.gv.egiz.eaaf.core.impl.utils.Random.nextProcessReferenceValue());
- pendingReq.setAuthUrl("http://test.com/");
- pendingReq.setTransactionId("avaasbav");
- pendingReq.setPiiTransactionId(RandomStringUtils.randomAlphanumeric(10));
-
- }
-
-
- @Test
- public void loaFromResponseToLow() throws URISyntaxException {
- //set-up
- ILightResponse eidasResponse = buildDummyAuthResponse(
- "LU/AT/" + RandomStringUtils.randomNumeric(10),
- EaafConstants.EIDAS_LOA_LOW,
- false);
- String spCountry = "AT";
- String citizenCountryCode = "XX";
-
- //execute test
- try {
- EidasResponseValidator.validateResponse(pendingReq, eidasResponse, spCountry, citizenCountryCode, attrRegistry);
- Assert.fail("Wrong eIDAS response not detected");
-
- } catch (EidasValidationException e) {
- Assert.assertEquals("ErrorId", "eidas.06", e.getErrorId());
- Assert.assertEquals("wrong parameter size", 1, e.getParams().length);
- Assert.assertEquals("wrong errorMsg", "http://eidas.europa.eu/LoA/low",
- e.getParams()[0]);
-
- }
- }
-
- @Test
- public void noEidasSpCountry() throws URISyntaxException {
- //set-up
- ILightResponse eidasResponse = buildDummyAuthResponse(
- "LU/AT/" + RandomStringUtils.randomNumeric(10),
- EaafConstants.EIDAS_LOA_SUBSTANTIAL,
- false);
- String spCountry = null;
- String citizenCountryCode = "LU";
-
- oaParam.setLoa(Arrays.asList(EaafConstants.EIDAS_LOA_HIGH, EaafConstants.EIDAS_LOA_SUBSTANTIAL));
-
-
- //execute test
- try {
- EidasResponseValidator.validateResponse(pendingReq, eidasResponse, spCountry, citizenCountryCode, attrRegistry);
- Assert.fail("Wrong eIDAS response not detected");
-
- } catch (EidasValidationException e) {
- Assert.assertEquals("ErrorId", "eidas.07", e.getErrorId());
- Assert.assertEquals("wrong parameter size", 2, e.getParams().length);
- Assert.assertEquals("wrong errorMsg", "PersonIdentifier",
- e.getParams()[0]);
- Assert.assertEquals("wrong errorMsg",
- "Destination country does not match to SP country",
- e.getParams()[1]);
-
- }
- }
-
- @Test
- public void noEidasResponseCountry() throws URISyntaxException {
- //set-up
- ILightResponse eidasResponse = buildDummyAuthResponse(
- "LU/AT/" + RandomStringUtils.randomNumeric(10),
- EaafConstants.EIDAS_LOA_SUBSTANTIAL,
- false);
- String spCountry = "AT";
- String citizenCountryCode = null;
-
- oaParam.setLoa(Arrays.asList(EaafConstants.EIDAS_LOA_HIGH, EaafConstants.EIDAS_LOA_SUBSTANTIAL));
-
-
- //execute test
- try {
- EidasResponseValidator.validateResponse(pendingReq, eidasResponse, spCountry, citizenCountryCode, attrRegistry);
- Assert.fail("Wrong eIDAS response not detected");
-
- } catch (EidasValidationException e) {
- Assert.assertEquals("ErrorId", "eidas.07", e.getErrorId());
- Assert.assertEquals("wrong parameter size", 2, e.getParams().length);
- Assert.assertEquals("wrong errorMsg", "PersonIdentifier",
- e.getParams()[0]);
- Assert.assertEquals("wrong errorMsg",
- "Citizen country does not match to eIDAS-node country that generates the response",
- e.getParams()[1]);
-
- }
- }
-
- @Test
- public void wrongEidasResponseCountry() throws URISyntaxException {
- //set-up
- ILightResponse eidasResponse = buildDummyAuthResponse(
- "LU/AT/" + RandomStringUtils.randomNumeric(10),
- EaafConstants.EIDAS_LOA_SUBSTANTIAL,
- false);
- String spCountry = "AT";
- String citizenCountryCode = "XX";
-
- oaParam.setLoa(Arrays.asList(EaafConstants.EIDAS_LOA_HIGH, EaafConstants.EIDAS_LOA_SUBSTANTIAL));
-
-
- //execute test
- try {
- EidasResponseValidator.validateResponse(pendingReq, eidasResponse, spCountry, citizenCountryCode, attrRegistry);
- Assert.fail("Wrong eIDAS response not detected");
-
- } catch (EidasValidationException e) {
- Assert.assertEquals("ErrorId", "eidas.07", e.getErrorId());
- Assert.assertEquals("wrong parameter size", 2, e.getParams().length);
- Assert.assertEquals("wrong errorMsg", "PersonIdentifier",
- e.getParams()[0]);
- Assert.assertEquals("wrong errorMsg",
- "Citizen country does not match to eIDAS-node country that generates the response",
- e.getParams()[1]);
-
- }
- }
-
- @Test
- public void missingPersonalIdentifier() throws URISyntaxException {
- //set-up
- ILightResponse eidasResponse = buildDummyAuthResponse(
- null,
- EaafConstants.EIDAS_LOA_SUBSTANTIAL,
- false);
- String spCountry = "AT";
- String citizenCountryCode = "LU";
-
- oaParam.setLoa(Arrays.asList(EaafConstants.EIDAS_LOA_HIGH, EaafConstants.EIDAS_LOA_SUBSTANTIAL));
-
-
- //execute test
- try {
- EidasResponseValidator.validateResponse(pendingReq, eidasResponse, spCountry, citizenCountryCode, attrRegistry);
- Assert.fail("Wrong eIDAS response not detected");
-
- } catch (EidasValidationException e) {
- Assert.assertEquals("ErrorId", "eidas.05", e.getErrorId());
- Assert.assertEquals("wrong parameter size", 1, e.getParams().length);
- Assert.assertEquals("wrong errorMsg", "NO 'PersonalIdentifier' attriubte",
- e.getParams()[0]);
-
- }
- }
-
- @Test
- public void moreThanOnePersonalIdentifier() throws URISyntaxException {
- //set-up
- ILightResponse eidasResponse = buildDummyAuthResponse(
- null,
- EaafConstants.EIDAS_LOA_SUBSTANTIAL,
- true);
- String spCountry = "AT";
- String citizenCountryCode = "LU";
-
- oaParam.setLoa(Arrays.asList(EaafConstants.EIDAS_LOA_HIGH, EaafConstants.EIDAS_LOA_SUBSTANTIAL));
-
-
- //execute test
- try {
- EidasResponseValidator.validateResponse(pendingReq, eidasResponse, spCountry, citizenCountryCode, attrRegistry);
- Assert.fail("Wrong eIDAS response not detected");
-
- } catch (EidasValidationException e) {
- Assert.assertEquals("ErrorId", "eidas.05", e.getErrorId());
- Assert.assertEquals("wrong parameter size", 1, e.getParams().length);
- Assert.assertEquals("wrong errorMsg", "NO 'PersonalIdentifier' attriubte",
- e.getParams()[0]);
-
- }
- }
-
- @Test
- public void emptyPersonalIdentifier() throws URISyntaxException {
- //set-up
- ILightResponse eidasResponse = buildDummyAuthResponse(
- "",
- EaafConstants.EIDAS_LOA_SUBSTANTIAL,
- false);
- String spCountry = "AT";
- String citizenCountryCode = "LU";
-
- oaParam.setLoa(Arrays.asList(EaafConstants.EIDAS_LOA_HIGH, EaafConstants.EIDAS_LOA_SUBSTANTIAL));
-
-
- //execute test
- try {
- EidasResponseValidator.validateResponse(pendingReq, eidasResponse, spCountry, citizenCountryCode, attrRegistry);
- Assert.fail("Wrong eIDAS response not detected");
-
- } catch (EidasValidationException e) {
- Assert.assertEquals("ErrorId", "eidas.07", e.getErrorId());
- Assert.assertEquals("wrong parameter size", 2, e.getParams().length);
- Assert.assertEquals("wrong errorMsg", "PersonIdentifier",
- e.getParams()[0]);
- Assert.assertEquals("wrong errorMsg",
- "Wrong identifier format",
- e.getParams()[1]);
-
- }
- }
-
- @Test
- public void validResponse() throws URISyntaxException, EidasValidationException {
- //set-up
-
- String spCountry = RandomStringUtils.randomAlphabetic(2).toUpperCase();
- String cCountry = RandomStringUtils.randomAlphabetic(2).toUpperCase();
-
- ILightResponse eidasResponse = buildDummyAuthResponse(
- cCountry + "/" + spCountry + "/" + RandomStringUtils.randomAlphanumeric(20),
- EaafConstants.EIDAS_LOA_SUBSTANTIAL,
- false);
-
- oaParam.setLoa(Arrays.asList(EaafConstants.EIDAS_LOA_HIGH, EaafConstants.EIDAS_LOA_SUBSTANTIAL));
-
-
- //execute test
-
- EidasResponseValidator.validateResponse(pendingReq, eidasResponse, spCountry, cCountry, attrRegistry);
-
- }
-
-
- private AuthenticationResponse buildDummyAuthResponse(String personalId, String loa, boolean moreThanOnePersonalId)
- throws URISyntaxException {
-
-
- final AttributeDefinition personIdattributeDef = attrRegistry.getCoreAttributeRegistry().getByFriendlyName(
- Constants.eIDAS_ATTR_PERSONALIDENTIFIER).first();
-
- final Builder attributeMap = ImmutableAttributeMap.builder();
- if (personalId != null) {
- if (moreThanOnePersonalId) {
- ImmutableSet values = ImmutableSet.of(new StringAttributeValue(personalId),
- new StringAttributeValue("XX/YY/" + RandomStringUtils.randomAlphanumeric(10)));
- attributeMap.put(personIdattributeDef, values);
-
- } else {
- attributeMap.put(personIdattributeDef, personalId);
-
- }
- }
-
- val b = new AuthenticationResponse.Builder();
- return b.id("_".concat(Random.nextHexRandom16()))
- .issuer(RandomStringUtils.randomAlphabetic(10))
- .subject(RandomStringUtils.randomAlphabetic(10))
- .statusCode(Constants.SUCCESS_URI)
- .inResponseTo("_".concat(Random.nextHexRandom16()))
- .subjectNameIdFormat("afaf")
- .levelOfAssurance(loa)
- .attributes(attributeMap.build())
- .build();
- }
-}
-