aboutsummaryrefslogtreecommitdiff
path: root/modules/authmodule-eIDAS-v2/src/test/java
diff options
context:
space:
mode:
authorThomas <>2022-10-21 11:11:36 +0200
committerThomas <>2022-10-21 11:11:36 +0200
commit55ab5856a90b065b2a645a62112b380f06cf751c (patch)
tree4c0be982a90e655a816464d0b51d272bf94c6bce /modules/authmodule-eIDAS-v2/src/test/java
parent8c09e7fbee0f8e1bc5e1c6e89e2aaf6fa4bec7a5 (diff)
downloadNational_eIDAS_Gateway-55ab5856a90b065b2a645a62112b380f06cf751c.tar.gz
National_eIDAS_Gateway-55ab5856a90b065b2a645a62112b380f06cf751c.tar.bz2
National_eIDAS_Gateway-55ab5856a90b065b2a645a62112b380f06cf751c.zip
feat(matching): distiguish between create ERnP entry by automated process or by user decision
Diffstat (limited to 'modules/authmodule-eIDAS-v2/src/test/java')
-rw-r--r--modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/CreateNewErnpEntryTaskTest.java63
1 files changed, 61 insertions, 2 deletions
diff --git a/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/CreateNewErnpEntryTaskTest.java b/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/CreateNewErnpEntryTaskTest.java
index 6298e250..c3beff33 100644
--- a/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/CreateNewErnpEntryTaskTest.java
+++ b/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/CreateNewErnpEntryTaskTest.java
@@ -27,6 +27,9 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
+import at.asitplus.eidas.specific.core.MsEidasNodeConstants;
+import at.asitplus.eidas.specific.core.MsEidasNodeConstants.MatchingStates;
+import at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.clients.ernp.ErnpRestClient;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.clients.ernp.ErnpRestClient.ErnpRegisterResult;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.ErnpPersonRegisterResult;
@@ -55,7 +58,7 @@ public class CreateNewErnpEntryTaskTest {
@Mock ErnpRestClient ernpClient;
- final ExecutionContext executionContext = new ExecutionContextImpl();
+ private ExecutionContext executionContext;
private TestRequestImpl pendingReq;
/**
@@ -70,6 +73,8 @@ public class CreateNewErnpEntryTaskTest {
RequestContextHolder.resetRequestAttributes();
RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(httpReq, httpResp));
+ executionContext = new ExecutionContextImpl();
+
pendingReq = new TestRequestImpl();
pendingReq.setPendingReqId(RandomStringUtils.randomAlphanumeric(10));
@@ -145,10 +150,64 @@ public class CreateNewErnpEntryTaskTest {
assertEquals("givenyname", input.getGivenName(), result.getGivenName());
assertEquals("dateOfBirth", input.getDateOfBirth(), result.getDateOfBirth());
assertEquals("bpk", bpk, result.getBpk());
- assertEquals("countryCode", input.getCitizenCountryCode(), result.getCountryCode());
+ assertEquals("countryCode", input.getCitizenCountryCode(), result.getCountryCode());
+ assertEquals("matching state", MatchingStates.BY_NEW_ERNP_ENTRY,
+ pendingReq.getRawData(MsEidasNodeConstants.DATA_MATCHING_STATE));
}
+ @Test
+ @SneakyThrows
+ public void insertErnpByAutoselectionSuccess() {
+ String bpk = RandomStringUtils.randomAlphabetic(5);
+ SimpleEidasData input = buildInputData();
+ Mockito.when(ernpClient.add(input))
+ .thenReturn(ernpRegisterResult(Arrays.asList(buildErnpResultEntry(input, bpk))));
+
+ executionContext.put(Constants.TRANSITION_TO_CREATE_NEW_ERNP_ENTRY_TASK, true);
+
+ // perform test
+ task.execute(pendingReq, executionContext);
+
+ // validate state
+ MatchedPersonResult result = MatchingTaskUtils.getFinalMatchingResult(pendingReq);
+ assertNotNull("no matching result", result);
+ assertEquals("familyname", input.getFamilyName(), result.getFamilyName());
+ assertEquals("givenyname", input.getGivenName(), result.getGivenName());
+ assertEquals("dateOfBirth", input.getDateOfBirth(), result.getDateOfBirth());
+ assertEquals("bpk", bpk, result.getBpk());
+ assertEquals("countryCode", input.getCitizenCountryCode(), result.getCountryCode());
+ assertEquals("matching state", MatchingStates.BY_NEW_ERNP_ENTRY,
+ pendingReq.getRawData(MsEidasNodeConstants.DATA_MATCHING_STATE));
+
+ }
+
+ @Test
+ @SneakyThrows
+ public void insertErnpByUserSuccess() {
+ String bpk = RandomStringUtils.randomAlphabetic(5);
+ SimpleEidasData input = buildInputData();
+ Mockito.when(ernpClient.add(input))
+ .thenReturn(ernpRegisterResult(Arrays.asList(buildErnpResultEntry(input, bpk))));
+
+ executionContext.put(Constants.TRANSITION_TO_CREATE_NEW_ERNP_ENTRY_BY_USER_TASK, true);
+
+ // perform test
+ task.execute(pendingReq, executionContext);
+
+ // validate state
+ MatchedPersonResult result = MatchingTaskUtils.getFinalMatchingResult(pendingReq);
+ assertNotNull("no matching result", result);
+ assertEquals("familyname", input.getFamilyName(), result.getFamilyName());
+ assertEquals("givenyname", input.getGivenName(), result.getGivenName());
+ assertEquals("dateOfBirth", input.getDateOfBirth(), result.getDateOfBirth());
+ assertEquals("bpk", bpk, result.getBpk());
+ assertEquals("countryCode", input.getCitizenCountryCode(), result.getCountryCode());
+ assertEquals("matching state", MatchingStates.BY_USER_TO_NEW_ERNP_ENTRY,
+ pendingReq.getRawData(MsEidasNodeConstants.DATA_MATCHING_STATE));
+
+ }
+
@NotNull
private ErnpRegisterResult ernpRegisterResult(List<RegisterResult> registerResult) {