aboutsummaryrefslogtreecommitdiff
path: root/modules/authmodule-eIDAS-v2/src/test/java/at
diff options
context:
space:
mode:
authorThomas <>2022-05-17 20:47:53 +0200
committerThomas <>2022-05-17 20:47:53 +0200
commit7100b253fe4712f6c820d11ed341366b3ec67623 (patch)
tree71cb1d3125d9f1703f51e70f64fbada3b6785f3c /modules/authmodule-eIDAS-v2/src/test/java/at
parentb0869317938810db6bd79e3ccc2e84b9d18097b2 (diff)
parentac8b7edeefc1850fdcab859ee6f544aa4f614471 (diff)
downloadNational_eIDAS_Gateway-7100b253fe4712f6c820d11ed341366b3ec67623.tar.gz
National_eIDAS_Gateway-7100b253fe4712f6c820d11ed341366b3ec67623.tar.bz2
National_eIDAS_Gateway-7100b253fe4712f6c820d11ed341366b3ec67623.zip
Merge branch 'nightlybuild' into feature/ms_proxy_before_refactoring
# Conflicts: # build_reporting/pom.xml # modules/authmodule-eIDAS-v2/pom.xml
Diffstat (limited to 'modules/authmodule-eIDAS-v2/src/test/java/at')
-rw-r--r--modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/clients/ZmrClientProductionTest.java3
-rw-r--r--modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/AlternativeSearchTaskWithRegisterTest.java52
-rw-r--r--modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/validation/EidasAttributePostProcessingTest.java403
3 files changed, 181 insertions, 277 deletions
diff --git a/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/clients/ZmrClientProductionTest.java b/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/clients/ZmrClientProductionTest.java
index cada6f40..cb9df7e5 100644
--- a/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/clients/ZmrClientProductionTest.java
+++ b/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/clients/ZmrClientProductionTest.java
@@ -4,6 +4,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import java.util.List;
+import java.util.UUID;
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.StringUtils;
@@ -29,6 +30,7 @@ import at.gv.bmi.namespace.zmr_su.zmr._20040201.PersonSuchenRequest;
import at.gv.e_government.reference.namespace.persondata.de._20040201.NatuerlichePersonTyp;
import at.gv.e_government.reference.namespace.persondata.de._20040201.PersonenNameTyp;
import at.gv.egiz.eaaf.core.api.idp.IConfiguration;
+import at.gv.egiz.eaaf.core.impl.utils.TransactionIdUtils;
import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.Logger;
@@ -199,6 +201,7 @@ public class ZmrClientProductionTest {
@Test
public void updateZmrEntryTestIdentity() throws EidasSAuthenticationException {
+ TransactionIdUtils.setTransactionId(UUID.randomUUID().toString());
final String personalIdentifier = "7cEYSvKZasdfsafsaf4CDVzNT4E7cjkU4Vq";
final String cc = "EE";
diff --git a/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/AlternativeSearchTaskWithRegisterTest.java b/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/AlternativeSearchTaskWithRegisterTest.java
index 3814c632..682db41e 100644
--- a/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/AlternativeSearchTaskWithRegisterTest.java
+++ b/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/AlternativeSearchTaskWithRegisterTest.java
@@ -27,7 +27,6 @@ import javax.xml.namespace.QName;
import org.apache.commons.lang3.RandomStringUtils;
import org.jetbrains.annotations.NotNull;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Rule;
@@ -252,19 +251,17 @@ public class AlternativeSearchTaskWithRegisterTest {
Constants.DATA_FULL_EIDAS_RESPONSE_ALTERNATIVE,
buildDummyAuthResponse("XXXKlaus - Maria", "XXXvon Brandenburg",
"EE/AT/7cEYasdfsafsaf4CDVzNT4E7cjkU4VqForjUnit", "1994-12-31"));
-
-
+
// execute task
- TaskExecutionException exception = assertThrows(TaskExecutionException.class,
- () -> task.execute(pendingReq, executionContext));
+ task.execute(pendingReq, executionContext);
// validate state
- assertTrue("Wrong exception", (exception.getOriginalException() instanceof WorkflowException));
- assertEquals("wrong errorparam 1", "step11", ((EaafException) exception.getOriginalException()).getParams()[0]);
- assertTrue("Wrong flag 'step11'",
- ((WorkflowException) exception.getOriginalException()).isRequiresManualFix());
- assertEquals("wrong errorparam 1", "Country Code of alternative eIDAS authn not matching",
- ((EaafException) exception.getOriginalException()).getParams()[1]);
+ assertNotNull("find no eIDAS inbut data", MatchingTaskUtils.getInitialEidasData(pendingReq));
+ assertNull("final matching result", MatchingTaskUtils.getFinalMatchingResult(pendingReq));
+ assertEquals("wrong executionContextFlag 'alternative eIDAS result'", true,
+ executionContext.get(Constants.TRANSITION_TO_GENERATE_OTHER_LOGIN_METHOD_GUI_TASK));
+ assertEquals("matching failed flag", true, executionContext.get(Constants.CONTEXT_FLAG_ADVANCED_MATCHING_FAILED));
+ assertEquals("failed reason", "module.eidasauth.matching.26", executionContext.get(Constants.CONTEXT_FLAG_ADVANCED_MATCHING_FAILED_REASON));
}
@@ -301,16 +298,15 @@ public class AlternativeSearchTaskWithRegisterTest {
// execute task
- TaskExecutionException exception = assertThrows(TaskExecutionException.class,
- () -> task.execute(pendingReq, executionContext));
+ task.execute(pendingReq, executionContext);
// validate state
- assertTrue("Wrong exception", (exception.getOriginalException() instanceof WorkflowException));
- assertEquals("wrong errorparam 1", "step11", ((EaafException) exception.getOriginalException()).getParams()[0]);
- assertTrue("Wrong flag 'step11'",
- ((WorkflowException) exception.getOriginalException()).isRequiresManualFix());
- assertEquals("wrong errorparam 1", "MDS of alternative eIDAS authn does not match initial authn",
- ((EaafException) exception.getOriginalException()).getParams()[1]);
+ assertNotNull("find no eIDAS inbut data", MatchingTaskUtils.getInitialEidasData(pendingReq));
+ assertNull("final matching result", MatchingTaskUtils.getFinalMatchingResult(pendingReq));
+ assertEquals("wrong executionContextFlag 'alternative eIDAS result'", true,
+ executionContext.get(Constants.TRANSITION_TO_GENERATE_OTHER_LOGIN_METHOD_GUI_TASK));
+ assertEquals("matching failed flag", true, executionContext.get(Constants.CONTEXT_FLAG_ADVANCED_MATCHING_FAILED));
+ assertEquals("failed reason", "module.eidasauth.matching.26", executionContext.get(Constants.CONTEXT_FLAG_ADVANCED_MATCHING_FAILED_REASON));
}
@@ -887,8 +883,6 @@ public class AlternativeSearchTaskWithRegisterTest {
private void checkMatchingSuccessState(IRequest pendingReq, String bpk, String familyName, String givenName,
String birhday, String countryCode) {
- assertNull("Find intermediate matching data but matching should be finished",
- MatchingTaskUtils.getIntermediateMatchingResult(pendingReq));
assertNotNull("find no eIDAS inbut data", MatchingTaskUtils.getInitialEidasData(pendingReq));
MatchedPersonResult personInfo = MatchingTaskUtils.getFinalMatchingResult(pendingReq);
@@ -901,22 +895,6 @@ public class AlternativeSearchTaskWithRegisterTest {
}
- private void checkIntermediateResult(int resultSize) {
- Boolean transitionGUI = (Boolean) executionContext.get(Constants.TRANSITION_TO_GENERATE_OTHER_LOGIN_METHOD_GUI_TASK);
- Assert.assertTrue("Wrong transition", transitionGUI);
- Boolean transitionErnb = (Boolean) executionContext.get(Constants.TRANSITION_TO_CREATE_NEW_ERNP_ENTRY_TASK);
- Assert.assertNull("Wrong transition", transitionErnb);
-
- assertNotNull("find no eIDAS inbut data", MatchingTaskUtils.getInitialEidasData(pendingReq));
- assertNull("Find final matching data but no match sould be found",
- MatchingTaskUtils.getFinalMatchingResult(pendingReq));
-
- RegisterStatusResults result = MatchingTaskUtils.getIntermediateMatchingResult(pendingReq);
- assertNotNull("Find no intermediate matching data", result);
- assertEquals("wrong intermediate result size", resultSize, result.getResultCount());
-
- }
-
@NotNull
private AuthenticationResponse buildDummyAuthResponse(String givenName, String familyName, String identifier,
String dateOfBirth) throws URISyntaxException {
diff --git a/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/validation/EidasAttributePostProcessingTest.java b/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/validation/EidasAttributePostProcessingTest.java
index 0a4ab851..16efd84b 100644
--- a/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/validation/EidasAttributePostProcessingTest.java
+++ b/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/validation/EidasAttributePostProcessingTest.java
@@ -23,14 +23,14 @@
package at.asitplus.eidas.specific.modules.auth.eidas.v2.test.validation;
-import static org.junit.Assert.fail;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThrows;
import java.io.IOException;
-import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.Map;
-import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.SimpleEidasData;
+import org.apache.commons.lang3.RandomStringUtils;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -41,12 +41,15 @@ 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.SimpleEidasData;
+import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.EidasSAuthenticationException;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.service.CcSpecificEidProcessingService;
+import lombok.SneakyThrows;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {
"/SpringTest-context_tasks_test.xml",
- "/SpringTest-context_basic_mapConfig.xml"})
+ "/SpringTest-context_basic_mapConfig.xml" })
@DirtiesContext(classMode = ClassMode.AFTER_CLASS)
public class EidasAttributePostProcessingTest {
@@ -113,6 +116,16 @@ public class EidasAttributePostProcessingTest {
private static final String P2_PLACEOFBIRTH = "Nirgendwo";
private static final String P2_BIRTHNAME = "Musterkind";
+
+ private static final String P8_eIDASID_PID = RandomStringUtils.randomAlphabetic(10);
+ private static final String P8_eIDASID ="EL/AT/" + P8_eIDASID_PID;
+ private static final String P8_GIVENNAME = RandomStringUtils.randomAlphabetic(10);
+ private static final String P8_FAMILYNAME = RandomStringUtils.randomAlphabetic(10);
+ private static final String P8_DATEOFBIRTH = "2028-05-11";
+ private static final String P8_PLACEOFBIRTH = RandomStringUtils.randomAlphabetic(10);
+ private static final String P8_BIRTHNAME = RandomStringUtils.randomAlphabetic(10);
+
+
/**
* jUnit class initializer.
*
@@ -126,149 +139,140 @@ public class EidasAttributePostProcessingTest {
}
@Test
- public void deWithHexLowerCase() throws Exception {
- try {
- final SimpleEidasData result = postProcessor.postProcess(
- generateInputData(
- P1_eIDASID,
- P1_FAMILYNAME,
- P1_GIVENNAME,
- P1_DATEOFBIRTH,
- P1_PLACEOFBIRTH,
- P1_BIRTHNAME));
+ @SneakyThrows
+ public void deWithHexLowerCase() {
+ final SimpleEidasData result = postProcessor.postProcess(
+ generateInputData(
+ P1_eIDASID,
+ P1_FAMILYNAME,
+ P1_GIVENNAME,
+ P1_DATEOFBIRTH,
+ P1_PLACEOFBIRTH,
+ P1_BIRTHNAME));
+
+ validate(result,
+ "Uy6qvZV0iA2/drm4zACDLCCm7BE9aCKZVQ16bg80XiU=",
+ "DE",
+ 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 SimpleEidasData 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());
-
- }
+ @SneakyThrows
+ public void deWithHexMixedCase() {
+ final SimpleEidasData result = postProcessor.postProcess(
+ generateInputData(
+ P3_eIDASID,
+ P3_FAMILYNAME,
+ P3_GIVENNAME,
+ P3_DATEOFBIRTH,
+ P3_PLACEOFBIRTH,
+ P3_BIRTHNAME));
+
+ validate(result,
+ "Uy6qvZV0iA2/drm4zACDLCCm7BE9aCKZVQ16bg80XiU=",
+ "DE",
+ P3_FAMILYNAME,
+ P3_GIVENNAME,
+ P3_DATEOFBIRTH,
+ P3_PLACEOFBIRTH,
+ P3_BIRTHNAME);
}
@Test
- public void deWithHexUpperCase() throws Exception {
- try {
- final SimpleEidasData result = postProcessor.postProcess(
- generateInputData(
- P4_eIDASID,
- P4_FAMILYNAME,
- P4_GIVENNAME,
- P4_DATEOFBIRTH,
- P4_PLACEOFBIRTH,
- P4_BIRTHNAME));
+ @SneakyThrows
+ public void deWithHexUpperCase() {
+ final SimpleEidasData result = postProcessor.postProcess(
+ generateInputData(
+ P4_eIDASID,
+ P4_FAMILYNAME,
+ P4_GIVENNAME,
+ P4_DATEOFBIRTH,
+ P4_PLACEOFBIRTH,
+ P4_BIRTHNAME));
+
+ validate(result,
+ "Uy6qvZV0iA2/drm4zACDLCCm7BE9aCKZVQ16bg80XiU=",
+ "DE",
+ 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));
+ assertThrows("missing exception", EidasSAuthenticationException.class,
+ () -> 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));
+ assertThrows("missing exception", EidasSAuthenticationException.class,
+ () -> postProcessor.postProcess(
+ generateInputData(
+ P6_eIDASID,
+ P6_FAMILYNAME,
+ P6_GIVENNAME,
+ P6_DATEOFBIRTH,
+ P6_PLACEOFBIRTH,
+ P6_BIRTHNAME)));
- } catch (final Exception e) {
- return;
+ }
- }
+ @Test
+ public void deWithNoHexCase() throws Exception {
+ assertThrows("missing exception", EidasSAuthenticationException.class,
+ () -> postProcessor.postProcess(
+ generateInputData(
+ P7_eIDASID,
+ P7_FAMILYNAME,
+ P7_GIVENNAME,
+ P7_DATEOFBIRTH,
+ P7_PLACEOFBIRTH,
+ P7_BIRTHNAME)));
- fail("Too short input accepted");
}
@Test
- public void deWithNoHexCase() throws Exception {
- try {
- postProcessor.postProcess(
+ public void elTestCase() throws Exception {
+ final SimpleEidasData result = postProcessor.postProcess(
generateInputData(
- P7_eIDASID,
- P7_FAMILYNAME,
- P7_GIVENNAME,
- P7_DATEOFBIRTH,
- P7_PLACEOFBIRTH,
- P7_BIRTHNAME));
-
- } catch (final Exception e) {
- return;
+ P8_eIDASID,
+ P8_FAMILYNAME,
+ P8_GIVENNAME,
+ P8_DATEOFBIRTH,
+ P8_PLACEOFBIRTH,
+ P8_BIRTHNAME));
- }
+ validate(result,
+ P8_eIDASID_PID,
+ "EL",
+ P8_FAMILYNAME,
+ P8_GIVENNAME,
+ P8_DATEOFBIRTH,
+ P8_PLACEOFBIRTH,
+ P8_BIRTHNAME);
- fail("Not hex encoded input accepted");
}
-
+
+
@Test
public void eeTestCase() throws Exception {
- try {
final SimpleEidasData result = postProcessor.postProcess(
generateInputData(
P2_eIDASID,
@@ -280,137 +284,73 @@ public class EidasAttributePostProcessingTest {
validate(result,
"asfasfasdfasdfasdfasdfasdfasvafasdfasdfasdfasdfasdfasvascasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasd",
+ "EE",
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 SimpleEidasData result = postProcessor.postProcess(
+ assertThrows("missing exception", EidasSAuthenticationException.class,
+ () -> 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");
+ P2_BIRTHNAME)));
}
@Test
public void eeTestGivenNameMissingCase() throws Exception {
- try {
- final SimpleEidasData 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");
+ assertThrows("missing exception", EidasSAuthenticationException.class,
+ () -> postProcessor.postProcess(
+ generateInputData(
+ P2_eIDASID,
+ P2_FAMILYNAME,
+ null,
+ P2_DATEOFBIRTH,
+ P2_PLACEOFBIRTH,
+ P2_BIRTHNAME)));
}
@Test
public void eeTestDateOfBirthMissingCase() throws Exception {
- try {
- final SimpleEidasData 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");
+ assertThrows("missing exception", EidasSAuthenticationException.class,
+ () -> postProcessor.postProcess(
+ generateInputData(
+ P2_eIDASID,
+ P2_FAMILYNAME,
+ P2_GIVENNAME,
+ null,
+ P2_PLACEOFBIRTH,
+ P2_BIRTHNAME)));
}
@Test
public void eeTestIdMissingCase() throws Exception {
- try {
- final SimpleEidasData 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");
+ assertThrows("missing exception", EidasSAuthenticationException.class,
+ () -> postProcessor.postProcess(
+ generateInputData(
+ null,
+ P2_FAMILYNAME,
+ P2_GIVENNAME,
+ P2_DATEOFBIRTH,
+ P2_PLACEOFBIRTH,
+ P2_BIRTHNAME)));
}
private Map<String, Object> generateInputData(String id, String familyName, String givenName,
- String dateOfBirth, String placeOfBirth, String birthName) {
+ String 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);
@@ -422,32 +362,15 @@ public class EidasAttributePostProcessingTest {
}
- private void validate(SimpleEidasData result, String id, String familyName, String givenName,
- String 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.getPlaceOfBirth().equals(placeOfBirth)) {
- fail(result.getPlaceOfBirth() + "is not equal to " + placeOfBirth);
- }
-
- if (!result.getBirthName().equals(birthName)) {
- fail(result.getBirthName() + "is not equal to " + birthName);
- }
+ private void validate(SimpleEidasData result, String id, String cc, String familyName, String givenName,
+ String dateOfBirth, String placeOfBirth, String birthName) {
+ assertEquals("pseudonym", id, result.getPseudonym());
+ assertEquals("countrycode", cc, result.getCitizenCountryCode());
+ assertEquals("familyName", familyName, result.getFamilyName());
+ assertEquals("givenName", givenName, result.getGivenName());
+ assertEquals("dateOfBirth", dateOfBirth, result.getDateOfBirth());
+ assertEquals("placeOfBirth", placeOfBirth, result.getPlaceOfBirth());
+ assertEquals("birthName", birthName, result.getBirthName());
}
-
}