aboutsummaryrefslogtreecommitdiff
path: root/eidas_modules/authmodule-eIDAS-v2/src
diff options
context:
space:
mode:
Diffstat (limited to 'eidas_modules/authmodule-eIDAS-v2/src')
-rw-r--r--eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/Constants.java2
-rw-r--r--eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/dao/SimpleEidasData.java1
-rw-r--r--eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/ernb/DummyErnbClient.java26
-rw-r--r--eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/handler/DeSpecificDetailSearchProcessor.java10
-rw-r--r--eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/handler/ICountrySpecificDetailSearchProcessor.java10
-rw-r--r--eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/handler/ItSpecificDetailSearchProcessor.java9
-rw-r--r--eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/InitialSearchTask.java99
-rw-r--r--eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/zmr/DummyZmrClient.java27
-rw-r--r--eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskFirstTest.java289
9 files changed, 174 insertions, 299 deletions
diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/Constants.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/Constants.java
index 145cf262..767a2d12 100644
--- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/Constants.java
+++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/Constants.java
@@ -176,4 +176,6 @@ public class Constants {
"AJZyj/+sdCMDRq9RkvbFcgSTVn/OfS8EUE81ddwP8MNuJ1kd1SWBUJPaQX2JLJHrL54mkOhrkhH2M/zcuOTu8nW9TOEg"
+ "XGjrRB/0HpiYKpV+VDJViyyc/GacNLxN4Anw4pima6gHYaJIw9hQkL/nuO2hyh8PGJd7rxeFXJmbLy+X";
+ public static final String COUNTRY_CODE_DE = "DE";
+ public static final String COUNTRY_CODE_IT = "IT";
}
diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/dao/SimpleEidasData.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/dao/SimpleEidasData.java
index 43d85772..674f5b48 100644
--- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/dao/SimpleEidasData.java
+++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/dao/SimpleEidasData.java
@@ -83,7 +83,6 @@ public class SimpleEidasData {
if (!result.getTaxNumber().equals(taxNumber)) {
return false;
}
-
return true;
}
}
diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/ernb/DummyErnbClient.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/ernb/DummyErnbClient.java
index 978be4d0..2d2fa76d 100644
--- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/ernb/DummyErnbClient.java
+++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/ernb/DummyErnbClient.java
@@ -11,16 +11,7 @@ public class DummyErnbClient implements IErnbClient {
@Override
public ArrayList<RegisterResult> searchWithPersonIdentifer(String personIdentifer) {
- // NOTE: Are we using Mockito or these fixed strings for testing, why are those defined here?
- switch (personIdentifer) {
- case "a12345":
- case "a12345-":
- return result1();
- case "a123456":
- return result2();
- default:
- return resultEmpty();
- }
+ return resultEmpty();
}
@Override
@@ -48,20 +39,5 @@ public class DummyErnbClient implements IErnbClient {
return new ArrayList<RegisterResult>();//Nobody found
}
- private ArrayList<RegisterResult> result1() {
- ArrayList<RegisterResult> results = new ArrayList<>();
- RegisterResult result1 = new RegisterResult("a12345", "Tom", "Mustermann", "1950-01-01", "Wien");
- results.add(result1);
- RegisterResult result2 = new RegisterResult("a12345-", "Tom", "Mustermann", "1950-01-01", "Wien");
- results.add(result2);
- return results;
- }
-
- private ArrayList<RegisterResult> result2() {
- ArrayList<RegisterResult> results = new ArrayList<>();
- RegisterResult result = new RegisterResult("a123456", "Max", "Mustermann", "2000-01-01", "Wien");
- results.add(result);
- return results;
- }
}
diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/handler/DeSpecificDetailSearchProcessor.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/handler/DeSpecificDetailSearchProcessor.java
index b5e8551b..e8cb7a1a 100644
--- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/handler/DeSpecificDetailSearchProcessor.java
+++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/handler/DeSpecificDetailSearchProcessor.java
@@ -1,17 +1,23 @@
package at.asitplus.eidas.specific.modules.auth.eidas.v2.handler;
+import at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.MergedRegisterSearchResult;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.RegisterResult;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.SimpleEidasData;
+import at.asitplus.eidas.specific.modules.auth.eidas.v2.ernb.IErnbClient;
+import at.asitplus.eidas.specific.modules.auth.eidas.v2.zmr.IZmrClient;
import java.util.ArrayList;
public class DeSpecificDetailSearchProcessor extends ICountrySpecificDetailSearchProcessor {
+ public DeSpecificDetailSearchProcessor(IErnbClient ernbClient, IZmrClient zmrClient) {
+ super(ernbClient, zmrClient);
+ }
+
@Override
public boolean canHandle(String countryCode, SimpleEidasData eidData) {
- // NOTE: Please extract constant for "de"
- if (!countryCode.equalsIgnoreCase("de")) {
+ if (!countryCode.equalsIgnoreCase(Constants.COUNTRY_CODE_DE)) {
return false;
}
if (eidData.getBirthName() == null || eidData.getBirthName().isEmpty()) {
diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/handler/ICountrySpecificDetailSearchProcessor.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/handler/ICountrySpecificDetailSearchProcessor.java
index b9ab2ceb..6a2b2c0a 100644
--- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/handler/ICountrySpecificDetailSearchProcessor.java
+++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/handler/ICountrySpecificDetailSearchProcessor.java
@@ -27,22 +27,14 @@ import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.MergedRegisterSearch
import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.SimpleEidasData;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.ernb.IErnbClient;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.zmr.IZmrClient;
-import org.springframework.beans.factory.annotation.Autowired;
public abstract class ICountrySpecificDetailSearchProcessor {
- // NOTE: Please use constructor injection
-
protected IErnbClient ernbClient;
protected IZmrClient zmrClient;
- @Autowired
- public void setErnbClient(IErnbClient ernbClient) {
+ public ICountrySpecificDetailSearchProcessor(IErnbClient ernbClient, IZmrClient zmrClient) {
this.ernbClient = ernbClient;
- }
-
- @Autowired
- public void setZmrClient(IZmrClient zmrClient) {
this.zmrClient = zmrClient;
}
diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/handler/ItSpecificDetailSearchProcessor.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/handler/ItSpecificDetailSearchProcessor.java
index d055345a..a94a67b3 100644
--- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/handler/ItSpecificDetailSearchProcessor.java
+++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/handler/ItSpecificDetailSearchProcessor.java
@@ -1,16 +1,23 @@
package at.asitplus.eidas.specific.modules.auth.eidas.v2.handler;
+import at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.MergedRegisterSearchResult;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.RegisterResult;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.SimpleEidasData;
+import at.asitplus.eidas.specific.modules.auth.eidas.v2.ernb.IErnbClient;
+import at.asitplus.eidas.specific.modules.auth.eidas.v2.zmr.IZmrClient;
import java.util.ArrayList;
public class ItSpecificDetailSearchProcessor extends ICountrySpecificDetailSearchProcessor {
+ public ItSpecificDetailSearchProcessor(IErnbClient ernbClient, IZmrClient zmrClient) {
+ super(ernbClient, zmrClient);
+ }
+
@Override
public boolean canHandle(String countryCode, SimpleEidasData eidData) {
- if (!countryCode.equalsIgnoreCase("it")) {
+ if (!countryCode.equalsIgnoreCase(Constants.COUNTRY_CODE_IT)) {
return false;
}
if (eidData.getTaxNumber() == null || eidData.getTaxNumber().isEmpty()) {
diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/InitialSearchTask.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/InitialSearchTask.java
index 4142b68b..5906ee6c 100644
--- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/InitialSearchTask.java
+++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/InitialSearchTask.java
@@ -33,7 +33,6 @@ import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang3.StringUtils;
import org.joda.time.DateTime;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.google.common.collect.ImmutableMap;
@@ -76,9 +75,6 @@ public class InitialSearchTask extends AbstractAuthServletTask {
private List<ICountrySpecificDetailSearchProcessor> handlers = new ArrayList<>();
- // @Autowired
- // private ApplicationContext context;
-
private IErnbClient ernbClient;
private IZmrClient zmrClient;
@@ -98,14 +94,11 @@ public class InitialSearchTask extends AbstractAuthServletTask {
final ILightResponse eidasResponse = authProcessData
.getGenericDataFromSession(Constants.DATA_FULL_EIDAS_RESPONSE, ILightResponse.class);
- // NOTE: Why is eidas first converted to a map, and then to a SimpleEidasData?
- final Map<String, Object> simpleAttrMap = convertEidasAttrToSimpleMap(
- eidasResponse.getAttributes().getAttributeMap());
-
// post-process eIDAS attributes
- final SimpleEidasData eidData = convertSimpleMapToSimpleData(simpleAttrMap);
+ final SimpleEidasData eidData = convertSimpleMapToSimpleData(convertEidasAttrToSimpleMap(
+ eidasResponse.getAttributes().getAttributeMap()));
- String bpK = step2(eidData);
+ String bpK = step2RegisterSearchWithPersonidentifier(eidData);
authProcessData.setGenericDataToSession(Constants.DATA_RESULT_MATCHING_BPK, bpK);
} catch (final Exception e) {
log.error("Initial search FAILED.", e);
@@ -113,22 +106,16 @@ public class InitialSearchTask extends AbstractAuthServletTask {
}
}
- // NOTE: Please rename methods ... "step2" doesn't tell the reader anything
- private String step2(SimpleEidasData eidData) throws TaskExecutionException {
+ private String step2RegisterSearchWithPersonidentifier(SimpleEidasData eidData) throws TaskExecutionException {
String personIdentifier = eidData.getPseudonym();
- // NOTE: Is that comment really necessary?
- //search in register(step 2)
MergedRegisterSearchResult result = searchInZmrAndErnp(personIdentifier);
if (result.getResultCount() == 0) {
- return step5(result, eidData);
+ return step5CheckCountrySpecificSearchPossible(result, eidData);
} else if (result.getResultCount() == 1) {
- return step3(result, eidData);
- // NOTE: Why is that code commented-out?
- } //else if (result.getResultCount() > 1) {
+ return step3CheckRegisterUpdateNecessary(result, eidData);
+ }
throw new TaskExecutionException(pendingReq, "Initial search - Kitt Process necessary.",
new ManualFixNecessaryException(personIdentifier));
- // }
- // return null;
}
private SimpleEidasData convertSimpleMapToSimpleData(Map<String, Object> eidasAttrMap)
@@ -167,33 +154,31 @@ public class InitialSearchTask extends AbstractAuthServletTask {
return simpleEidasData;
}
- private String step3(MergedRegisterSearchResult result, SimpleEidasData eidData) throws TaskExecutionException {
+ private String step3CheckRegisterUpdateNecessary(MergedRegisterSearchResult result, SimpleEidasData eidData)
+ throws TaskExecutionException {
//check if data from eidas authentication matches with data from register
-
log.debug("Compare " + result + " with " + eidData);
- //TODO check if data matches
try {
if (eidData.equalsRegisterData(result)) {
- //TODO
+ //No update necessary, just return bpk
return result.getBpk();
} else {
- return step4(result, eidData);
+ return step4UpdateRegisterData(result, eidData);
}
} catch (WorkflowException e) {
throw new TaskExecutionException(pendingReq, "Initial search - Kitt Process necessary.", e);
}
}
- private String step4(MergedRegisterSearchResult result,
- SimpleEidasData eidData) throws WorkflowException {
+ private String step4UpdateRegisterData(MergedRegisterSearchResult result,
+ SimpleEidasData eidData) throws WorkflowException {
log.debug("Update " + result + " with " + eidData);
- //TODO
+ //TODO wann rechtlich möglich?
- // NOTE: Sometimes the bpk is returned, sometimes "105"?
return result.getBpk();
}
- private String step5(MergedRegisterSearchResult result, SimpleEidasData eidData)
+ private String step5CheckCountrySpecificSearchPossible(MergedRegisterSearchResult result, SimpleEidasData eidData)
throws TaskExecutionException {
String citizenCountry = eidData.getCitizenCountryCode();
ICountrySpecificDetailSearchProcessor foundHandler = null;
@@ -208,15 +193,15 @@ public class InitialSearchTask extends AbstractAuthServletTask {
}
if (foundHandler == null) {
//MDS search
- return step8(result, eidData);
+ return step8RegisterSearchWithMds(result, eidData);
} else {
//country specific search
- return step6(foundHandler, result, eidData);
+ return step6CountrySpecificSearch(foundHandler, result, eidData);
}
}
- private String step6(ICountrySpecificDetailSearchProcessor countrySpecificDetailSearchProcessor,
- MergedRegisterSearchResult initialSearchResult, SimpleEidasData eidData)
+ private String step6CountrySpecificSearch(ICountrySpecificDetailSearchProcessor countrySpecificDetailSearchProcessor,
+ MergedRegisterSearchResult initialSearchResult, SimpleEidasData eidData)
throws TaskExecutionException {
//6 country specific search
MergedRegisterSearchResult countrySpecificDetailSearchResult =
@@ -224,19 +209,19 @@ public class InitialSearchTask extends AbstractAuthServletTask {
switch (countrySpecificDetailSearchResult.getResultCount()) {
case 0:
- return step8(initialSearchResult, eidData);
+ return step8RegisterSearchWithMds(initialSearchResult, eidData);
case 1:
- return step7a(initialSearchResult, countrySpecificDetailSearchResult, eidData);
+ return step7aKittProcess(initialSearchResult, countrySpecificDetailSearchResult, eidData);
default://should not happen
throw new TaskExecutionException(pendingReq, "Detail search - Kitt Process necessary.",
new ManualFixNecessaryException(eidData));
}
}
- private String step7a(MergedRegisterSearchResult initialSearchResult,
- MergedRegisterSearchResult countrySpecificDetailSearchResult,
- SimpleEidasData eidData) throws TaskExecutionException {
- //TODO automerge
+ private String step7aKittProcess(MergedRegisterSearchResult initialSearchResult,
+ MergedRegisterSearchResult countrySpecificDetailSearchResult,
+ SimpleEidasData eidData) throws TaskExecutionException {
+ //Automerge data
log.debug("Automerge " + initialSearchResult + " with " + eidData + " " + countrySpecificDetailSearchResult);
try {
if (initialSearchResult.getResultCount() != 0) {
@@ -261,8 +246,8 @@ public class InitialSearchTask extends AbstractAuthServletTask {
}
}
- private String step8(MergedRegisterSearchResult initialSearchResult,
- SimpleEidasData eidData) {
+ private String step8RegisterSearchWithMds(MergedRegisterSearchResult initialSearchResult,
+ SimpleEidasData eidData) {
MergedRegisterSearchResult mdsSearchResult = new MergedRegisterSearchResult();
ArrayList<RegisterResult> resultsZmr =
@@ -274,9 +259,8 @@ public class InitialSearchTask extends AbstractAuthServletTask {
mdsSearchResult.setResultsErnb(resultsErnb);
log.debug("Automerge " + initialSearchResult + " with " + eidData + " " + mdsSearchResult);
- //TODO
- // NOTE: Sometimes the bpk is returned, sometimes "105"?
- return "105";
+ //TODO implement next phase and return correct value
+ return "TODO-Temporary-Endnode-105";
}
private MergedRegisterSearchResult searchInZmrAndErnp(String personIdentifier) {
@@ -341,24 +325,17 @@ public class InitialSearchTask extends AbstractAuthServletTask {
return result;
}
- //just for testing
- //TODO is there a nicer solution?
- // There is: Constructor Injection see https://reflectoring.io/constructor-injection/ or https://www.baeldung.com/constructor-injection-in-spring
- @Autowired
- public void setErnbClient(IErnbClient ernbClient) {
+ /**
+ * Constructor.
+ * @param handlers List of countrySpecificSearchProcessors
+ * @param ernbClient Ernb client
+ * @param zmrClient ZMR client
+ */
+ public InitialSearchTask(List<ICountrySpecificDetailSearchProcessor> handlers, IErnbClient ernbClient,
+ IZmrClient zmrClient) {
this.ernbClient = ernbClient;
- }
-
- @Autowired
- public void setZmrClient(IZmrClient zmrClient) {
this.zmrClient = zmrClient;
- }
-
- @Autowired
- public void setHandlers(List<ICountrySpecificDetailSearchProcessor> handlers) {
this.handlers = handlers;
- // NOTE: There's a typo in "registrated"
- log.info("# " + handlers.size() + " country specific detail search services are registrated");
+ log.info("# " + handlers.size() + " country specific detail search services are registered");
}
-
}
diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/zmr/DummyZmrClient.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/zmr/DummyZmrClient.java
index 3af2e39e..f4d77b03 100644
--- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/zmr/DummyZmrClient.java
+++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/zmr/DummyZmrClient.java
@@ -11,16 +11,7 @@ public class DummyZmrClient implements IZmrClient {
@Override
public ArrayList<RegisterResult> searchWithPersonIdentifer(String personIdentifer) {
- // NOTE: Are we using Mockito or these fixed strings for testing, why are those defined here?
- switch (personIdentifer) {
- case "a12345":
- case "a12345-":
- return result1();
- case "a123456":
- return result2();
- default:
- return resultEmpty();
- }
+ return resultEmpty();
}
@Override
@@ -48,20 +39,4 @@ public class DummyZmrClient implements IZmrClient {
return new ArrayList<RegisterResult>();//Nobody found
}
- private ArrayList<RegisterResult> result1() {
- ArrayList<RegisterResult> results = new ArrayList<>();
- RegisterResult result1 = new RegisterResult("12345", "Tom", "Mustermann", "1950-01-01", "Wien");
- results.add(result1);
- RegisterResult result2 = new RegisterResult("12345-", "Tom", "Mustermann", "1950-01-01", "Wien");
- results.add(result2);
- return results;
- }
-
- private ArrayList<RegisterResult> result2() {
- ArrayList<RegisterResult> results = new ArrayList<>();
- RegisterResult result = new RegisterResult("123456", "Max", "Mustermann", "2000-01-01", "Wien");
- results.add(result);
- return results;
- }
-
}
diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskFirstTest.java b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskFirstTest.java
index d366fefc..f7fc6b06 100644
--- a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskFirstTest.java
+++ b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskFirstTest.java
@@ -2,20 +2,17 @@ package at.asitplus.eidas.specific.modules.auth.eidas.v2.test.tasks;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.RegisterResult;
-import at.asitplus.eidas.specific.modules.auth.eidas.v2.ernb.DummyErnbClient;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.ernb.IErnbClient;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.ManualFixNecessaryException;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.handler.DeSpecificDetailSearchProcessor;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.handler.ICountrySpecificDetailSearchProcessor;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.handler.ItSpecificDetailSearchProcessor;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.tasks.InitialSearchTask;
-import at.asitplus.eidas.specific.modules.auth.eidas.v2.zmr.DummyZmrClient;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.zmr.IZmrClient;
import at.gv.egiz.eaaf.core.api.idp.process.ExecutionContext;
import at.gv.egiz.eaaf.core.exceptions.EaafStorageException;
import at.gv.egiz.eaaf.core.exceptions.TaskExecutionException;
import at.gv.egiz.eaaf.core.impl.idp.auth.data.AuthProcessDataWrapper;
-import at.gv.egiz.eaaf.core.impl.idp.module.test.DummySpConfiguration;
import at.gv.egiz.eaaf.core.impl.idp.module.test.TestRequestImpl;
import at.gv.egiz.eaaf.core.impl.idp.process.ExecutionContextImpl;
import eu.eidas.auth.commons.attribute.AttributeDefinition;
@@ -33,7 +30,6 @@ import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.powermock.api.mockito.PowerMockito;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse;
@@ -62,20 +58,16 @@ public class InitialSearchTaskFirstTest {
@InjectMocks
private InitialSearchTask task;
- // NOTE: Is defined as @Mock, but also manually mocked in "testNode100a" etc -- why?
- @Mock
private IZmrClient zmrClient;
-
- // NOTE: Is defined as @Mock, but also manually mocked in "testNode100a" etc -- why?
- @Mock
private IErnbClient ernbClient;
final ExecutionContext executionContext = new ExecutionContextImpl();
private MockHttpServletRequest httpReq;
private MockHttpServletResponse httpResp;
private TestRequestImpl pendingReq;
- private DummySpConfiguration oaParam;
-
+ private String randomIdentifier = RandomStringUtils.randomNumeric(10);
+ private String randomFamilyName = RandomStringUtils.randomNumeric(11);
+ private String randomGivenName = RandomStringUtils.randomNumeric(12);
/**
* jUnit class initializer.
*
@@ -86,7 +78,6 @@ public class InitialSearchTaskFirstTest {
final String current = new java.io.File(".").toURI().toString();
System.setProperty("eidas.ms.configuration", current
+ "src/test/resources/config/junit_config_1.properties");
-
}
/**
@@ -94,19 +85,15 @@ public class InitialSearchTaskFirstTest {
*/
@Before
public void setUp() throws URISyntaxException, EaafStorageException {
- // NOTE: PowerMockito should not be needed, as we don't want to test static and private methods
- task = PowerMockito.spy(task);
-
httpReq = new MockHttpServletRequest("POST", "https://localhost/authhandler");
httpResp = new MockHttpServletResponse();
RequestContextHolder.resetRequestAttributes();
RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(httpReq, httpResp));
- final AuthenticationResponse response = buildDummyAuthResponseMaxMustermann();
+ final AuthenticationResponse response = buildDummyAuthResponseRandomPerson();
pendingReq = new TestRequestImpl();
pendingReq.getSessionData(AuthProcessDataWrapper.class)
.setGenericDataToSession(Constants.DATA_FULL_EIDAS_RESPONSE, response);
-
}
@Test
@@ -120,22 +107,18 @@ public class InitialSearchTaskFirstTest {
//Mock ZMR
ArrayList<RegisterResult> zmrResult = new ArrayList<>();
String randomBpk = RandomStringUtils.randomNumeric(6);
- zmrResult.add(new RegisterResult(randomBpk,"de/st/max123", "Max_new", "Mustermann", "2011-01-01"));
+ zmrResult.add(new RegisterResult(randomBpk, "de/st/"+randomIdentifier, "Max_new", randomFamilyName, "2011-01-01"));
- // NOTE: Are we using Mockito or these fixed strings in DummyZmrClient?
- // NOTE: Please mock an interface, not a concrete class
- // NOTE: But DummyZmrClient is also defined as a bean "ZmrClientForeIDAS" in "eidas_v2_auth.beans.xml"?
- zmrClient = Mockito.mock(DummyZmrClient.class);
- Mockito.when(zmrClient.searchWithPersonIdentifer("max123")).thenReturn(zmrResult);//"de/st/max123"???
- task.setZmrClient(zmrClient);
+ zmrClient = Mockito.mock(IZmrClient.class);
+ Mockito.when(zmrClient.searchWithPersonIdentifer(randomIdentifier)).thenReturn(zmrResult);
//Mock ernb
ArrayList<RegisterResult> ernbResult = new ArrayList<>();
- ernbClient = Mockito.mock(DummyErnbClient.class);
- Mockito.when(ernbClient.searchWithPersonIdentifer("max123")).thenReturn(ernbResult);//"de/st/max123"???
- task.setErnbClient(ernbClient);
+ ernbClient = Mockito.mock(IErnbClient.class);
+ Mockito.when(ernbClient.searchWithPersonIdentifer(randomIdentifier)).thenReturn(ernbResult);
+ task = new InitialSearchTask(emptyHandlers(), ernbClient, zmrClient);
try {
task.execute(pendingReq, executionContext);
String bPk = (String)
@@ -159,19 +142,18 @@ public class InitialSearchTaskFirstTest {
//Mock ZMR
ArrayList<RegisterResult> zmrResult = new ArrayList<>();
- zmrClient = Mockito.mock(DummyZmrClient.class);
- Mockito.when(zmrClient.searchWithPersonIdentifer("max123")).thenReturn(zmrResult);//"de/st/max123"???
- task.setZmrClient(zmrClient);
+ zmrClient = Mockito.mock(IZmrClient.class);
+ Mockito.when(zmrClient.searchWithPersonIdentifer(randomIdentifier)).thenReturn(zmrResult);//"de/st/max123"???
//Mock ernb
ArrayList<RegisterResult> ernbResult = new ArrayList<>();
String randomBpk = RandomStringUtils.randomNumeric(6);
- ernbResult.add(new RegisterResult(randomBpk,"de/st/max123", "Max_new", "Mustermann", "2011-01-01"));
+ ernbResult.add(new RegisterResult(randomBpk, "de/st/"+randomIdentifier, "Max_new", randomFamilyName, "2011-01-01"));
- ernbClient = Mockito.mock(DummyErnbClient.class);
- Mockito.when(ernbClient.searchWithPersonIdentifer("max123")).thenReturn(ernbResult);//"de/st/max123"???
- task.setErnbClient(ernbClient);
+ ernbClient = Mockito.mock(IErnbClient.class);
+ Mockito.when(ernbClient.searchWithPersonIdentifer(randomIdentifier)).thenReturn(ernbResult);
+ task = new InitialSearchTask(emptyHandlers(), ernbClient, zmrClient);
try {
task.execute(pendingReq, executionContext);
String bPk = (String)
@@ -193,24 +175,20 @@ public class InitialSearchTaskFirstTest {
//Mock ZMR
ArrayList<RegisterResult> zmrResult = new ArrayList<>();
- zmrResult.add(new RegisterResult("bpkMax","de/st/max123", "Max", "Mustermann", "2011-01-01"));
- zmrResult.add(new RegisterResult("bpkMax","de/st/max123", "Maximilian", "Mustermann", "2011-01-01"));
- zmrClient = Mockito.mock(DummyZmrClient.class);
- Mockito.when(zmrClient.searchWithPersonIdentifer("max123")).thenReturn(zmrResult);//"de/st/max123"???
- task.setZmrClient(zmrClient);
+ zmrResult.add(new RegisterResult("bpkMax", "de/st/"+randomIdentifier, randomGivenName, randomFamilyName, "2011-01-01"));
+ zmrResult.add(new RegisterResult("bpkMax", "de/st/"+randomIdentifier, "Maximilian", randomFamilyName, "2011-01-01"));
+ zmrClient = Mockito.mock(IZmrClient.class);
+ Mockito.when(zmrClient.searchWithPersonIdentifer(randomIdentifier)).thenReturn(zmrResult);
//Mock ernb
ArrayList<RegisterResult> ernbResult = new ArrayList<>();
- ernbClient = Mockito.mock(DummyErnbClient.class);
- Mockito.when(ernbClient.searchWithPersonIdentifer("max123")).thenReturn(ernbResult);//"de/st/max123"???
- task.setErnbClient(ernbClient);
+ ernbClient = Mockito.mock(IErnbClient.class);
+ Mockito.when(ernbClient.searchWithPersonIdentifer(randomIdentifier)).thenReturn(ernbResult);
+ task = new InitialSearchTask(emptyHandlers(), ernbClient, zmrClient);
try {
task.execute(pendingReq, executionContext);
Assert.assertTrue("Wrong workflow, should not reach this point/ get a bpk", false);
- String bPk = (String)
- pendingReq.getSessionData(AuthProcessDataWrapper.class).getGenericDataFromSession(Constants.DATA_RESULT_MATCHING_BPK);
-
} catch (final TaskExecutionException e) {
Throwable origE = e.getOriginalException();
Assert.assertTrue("Wrong exception", (origE.getCause() instanceof ManualFixNecessaryException));
@@ -227,25 +205,21 @@ public class InitialSearchTaskFirstTest {
//Mock ZMR
ArrayList<RegisterResult> zmrResult = new ArrayList<>();
- zmrClient = Mockito.mock(DummyZmrClient.class);
- Mockito.when(zmrClient.searchWithPersonIdentifer("max123")).thenReturn(zmrResult);//"de/st/max123"???
- task.setZmrClient(zmrClient);
+ zmrClient = Mockito.mock(IZmrClient.class);
+ Mockito.when(zmrClient.searchWithPersonIdentifer(randomIdentifier)).thenReturn(zmrResult);
//Mock ernb
ArrayList<RegisterResult> ernbResult = new ArrayList<>();
- ernbResult.add(new RegisterResult("bpkMax","de/st/max123", "Max", "Mustermann", "2011-01-01"));
- ernbResult.add(new RegisterResult("bpkMax","de/st/max123", "Maximilian", "Mustermann", "2011-01-01"));
+ ernbResult.add(new RegisterResult("bpkMax", "de/st/"+randomIdentifier, randomGivenName, randomFamilyName, "2011-01-01"));
+ ernbResult.add(new RegisterResult("bpkMax", "de/st/"+randomIdentifier, "Maximilian", randomFamilyName, "2011-01-01"));
- ernbClient = Mockito.mock(DummyErnbClient.class);
- Mockito.when(ernbClient.searchWithPersonIdentifer("max123")).thenReturn(ernbResult);//"de/st/max123"???
- task.setErnbClient(ernbClient);
+ ernbClient = Mockito.mock(IErnbClient.class);
+ Mockito.when(ernbClient.searchWithPersonIdentifer(randomIdentifier)).thenReturn(ernbResult);
+ task = new InitialSearchTask(emptyHandlers(), ernbClient, zmrClient);
try {
task.execute(pendingReq, executionContext);
Assert.assertTrue("Wrong workflow, should not reach this point/ get a bpk", false);
- String bPk = (String)
- pendingReq.getSessionData(AuthProcessDataWrapper.class).getGenericDataFromSession(Constants.DATA_RESULT_MATCHING_BPK);
-
} catch (final TaskExecutionException e) {
Throwable origE = e.getOriginalException();
Assert.assertTrue("Wrong exception", (origE.getCause() instanceof ManualFixNecessaryException));
@@ -259,26 +233,25 @@ public class InitialSearchTaskFirstTest {
*/
public void testNode102a() throws Exception {
+ String randomBpk = RandomStringUtils.randomNumeric(12);;
//Mock ZMR
ArrayList<RegisterResult> zmrResult = new ArrayList<>();
- zmrClient = Mockito.mock(DummyZmrClient.class);
- Mockito.when(zmrClient.searchWithPersonIdentifer("max123")).thenReturn(zmrResult);//"de/st/max123"???
- task.setZmrClient(zmrClient);
+ zmrClient = Mockito.mock(IZmrClient.class);
+ Mockito.when(zmrClient.searchWithPersonIdentifer(randomIdentifier)).thenReturn(zmrResult);
//Mock ernb
ArrayList<RegisterResult> ernbResult = new ArrayList<>();
- ernbResult.add(new RegisterResult("bpkMax","de/st/max123", "Max", "Mustermann", "2011-01-01"));
+ ernbResult.add(new RegisterResult(randomBpk, "de/st/"+randomIdentifier, randomGivenName, randomFamilyName, "2011-01-01"));
- ernbClient = Mockito.mock(DummyErnbClient.class);
- Mockito.when(ernbClient.searchWithPersonIdentifer("max123")).thenReturn(ernbResult);//"de/st/max123"???
- task.setErnbClient(ernbClient);
+ ernbClient = Mockito.mock(IErnbClient.class);
+ Mockito.when(ernbClient.searchWithPersonIdentifer(randomIdentifier)).thenReturn(ernbResult);
+ task = new InitialSearchTask(emptyHandlers(), ernbClient, zmrClient);
try {
task.execute(pendingReq, executionContext);
String bPk = (String)
pendingReq.getSessionData(AuthProcessDataWrapper.class).getGenericDataFromSession(Constants.DATA_RESULT_MATCHING_BPK);
- Assert.assertTrue("Wrong bpk", bPk.equals("bpkMax"));
-
+ Assert.assertTrue("Wrong bpk", bPk.equals(randomBpk));
} catch (final TaskExecutionException e) {
Assert.assertTrue("Wrong workflow, should not reach this point", false);
}
@@ -290,27 +263,26 @@ public class InitialSearchTaskFirstTest {
* One match, no register update needed
*/
public void testNode102b() throws Exception {
-
+ String randomBpk = RandomStringUtils.randomNumeric(14);
//Mock ZMR
ArrayList<RegisterResult> zmrResult = new ArrayList<>();
- zmrResult.add(new RegisterResult("bpkMax","de/st/max123", "Max", "Mustermann", "2011-01-01"));
+ zmrResult.add(new RegisterResult(randomBpk, "de/st/"+randomIdentifier, randomGivenName, randomFamilyName, "2011-01-01"));
- zmrClient = Mockito.mock(DummyZmrClient.class);
- Mockito.when(zmrClient.searchWithPersonIdentifer("max123")).thenReturn(zmrResult);//"de/st/max123"???
- task.setZmrClient(zmrClient);
+ zmrClient = Mockito.mock(IZmrClient.class);
+ Mockito.when(zmrClient.searchWithPersonIdentifer(randomIdentifier)).thenReturn(zmrResult);
//Mock ernb
ArrayList<RegisterResult> ernbResult = new ArrayList<>();
- ernbClient = Mockito.mock(DummyErnbClient.class);
- Mockito.when(ernbClient.searchWithPersonIdentifer("max123")).thenReturn(ernbResult);//"de/st/max123"???
- task.setErnbClient(ernbClient);
+ ernbClient = Mockito.mock(IErnbClient.class);
+ Mockito.when(ernbClient.searchWithPersonIdentifer(randomIdentifier)).thenReturn(ernbResult);
+ task = new InitialSearchTask(emptyHandlers(), ernbClient, zmrClient);
try {
task.execute(pendingReq, executionContext);
String bPk = (String)
pendingReq.getSessionData(AuthProcessDataWrapper.class).getGenericDataFromSession(Constants.DATA_RESULT_MATCHING_BPK);
- Assert.assertTrue("Wrong bpk", bPk.equals("bpkMax"));
+ Assert.assertTrue("Wrong bpk", bPk.equals(randomBpk));
} catch (final TaskExecutionException e) {
Assert.assertTrue("Wrong workflow, should not reach this point", false);
@@ -323,40 +295,36 @@ public class InitialSearchTaskFirstTest {
* One match found in ZMR and ErnB with detail search
*/
public void testNode103IT() throws Exception {
- String bpkRegister = "bpkMax";
- String taxNumber = "tax123";
- final AuthenticationResponse response = buildDummyAuthResponseMaxMustermannIT_Tax(taxNumber);
+ String bpkRegister = RandomStringUtils.randomNumeric(14);
+ String taxNumber = RandomStringUtils.randomNumeric(14);
+ final AuthenticationResponse response = buildDummyAuthResponseRandomPersonIT_Tax(taxNumber);
TestRequestImpl pendingReq1 = new TestRequestImpl();
pendingReq1.getSessionData(AuthProcessDataWrapper.class)
.setGenericDataToSession(Constants.DATA_FULL_EIDAS_RESPONSE, response);
//Mock ZMR initial search
ArrayList<RegisterResult> zmrResultInitial = new ArrayList<>();
- zmrClient = Mockito.mock(DummyZmrClient.class);
- Mockito.when(zmrClient.searchWithPersonIdentifer("max123")).thenReturn(zmrResultInitial);
+ zmrClient = Mockito.mock(IZmrClient.class);
+ Mockito.when(zmrClient.searchWithPersonIdentifer(randomIdentifier)).thenReturn(zmrResultInitial);
ArrayList<RegisterResult> zmrResultSpecific = new ArrayList<>();
//String bpk, String pseudonym, String givenName, String familyName, String dateOfBirth,
// String placeOfBirth, String birthName, String taxNumber, PostalAddressType address
- zmrResultSpecific.add(new RegisterResult(bpkRegister,"it/st/max1234", "Max", "Mustermann", "2011-01-01", null,
- null, taxNumber, null));
+ zmrResultSpecific.add(new RegisterResult(bpkRegister, "it/st/"+randomIdentifier+"4", randomGivenName, randomFamilyName,
+ "2011-01-01", null, null, taxNumber, null));
Mockito.when(zmrClient.searchItSpecific(taxNumber)).thenReturn(zmrResultSpecific);
- task.setZmrClient(zmrClient);
//Mock ernb initial search
ArrayList<RegisterResult> ernbResultInitial = new ArrayList<>();
- ernbClient = Mockito.mock(DummyErnbClient.class);
- Mockito.when(ernbClient.searchWithPersonIdentifer("max123")).thenReturn(ernbResultInitial);//"de/st/max123"???
+ ernbClient = Mockito.mock(IErnbClient.class);
+ Mockito.when(ernbClient.searchWithPersonIdentifer(randomIdentifier)).thenReturn(ernbResultInitial);
- task.setErnbClient(ernbClient);
//Mock country specific search
List<ICountrySpecificDetailSearchProcessor> handlers = new ArrayList<>();
- ItSpecificDetailSearchProcessor it = new ItSpecificDetailSearchProcessor();
- it.setErnbClient(ernbClient);
- it.setZmrClient(zmrClient);
+ ItSpecificDetailSearchProcessor it = new ItSpecificDetailSearchProcessor(ernbClient, zmrClient);
handlers.add(it);
- task.setHandlers(handlers);
+ task = new InitialSearchTask(handlers, ernbClient, zmrClient);
try {
task.execute(pendingReq1, executionContext);
@@ -375,8 +343,8 @@ public class InitialSearchTaskFirstTest {
* Multiple matches found in ZMR and ErnB with detail search
*/
public void testNode103DE() throws Exception {
- String givenName = "Max";
- String familyName = "Mustermann";
+ String givenName = randomGivenName;
+ String familyName = randomFamilyName;
String pseudonym = "de/st/max1234";
String bpk = "bpkMax";
String dateOfBirth = "2011-01-01";
@@ -390,33 +358,26 @@ public class InitialSearchTaskFirstTest {
//Mock ZMR initial search
ArrayList<RegisterResult> zmrResultInitial = new ArrayList<>();
- zmrClient = Mockito.mock(DummyZmrClient.class);
- Mockito.when(zmrClient.searchWithPersonIdentifer("max123")).thenReturn(zmrResultInitial);
+ zmrClient = Mockito.mock(IZmrClient.class);
+ Mockito.when(zmrClient.searchWithPersonIdentifer(randomIdentifier)).thenReturn(zmrResultInitial);
ArrayList<RegisterResult> zmrResultSpecific = new ArrayList<>();
- zmrResultSpecific.add(new RegisterResult(bpk, pseudonym, givenName, familyName, dateOfBirth, placeOfBirth, birthName,
+ zmrResultSpecific.add(new RegisterResult(bpk, pseudonym, givenName, familyName, dateOfBirth, placeOfBirth,
+ birthName,
null, null));
- //.searchDeSpecific(eidData.getGivenName(), eidData.getFamilyName(), eidData.getDateOfBirth(),
- // eidData.getPlaceOfBirth(), eidData.getBirthName()
Mockito.when(zmrClient.searchDeSpecific(givenName, familyName, dateOfBirth, placeOfBirth, birthName)).thenReturn(zmrResultSpecific);
- task.setZmrClient(zmrClient);
-
//Mock ernb initial search
ArrayList<RegisterResult> ernbResultInitial = new ArrayList<>();
- ernbClient = Mockito.mock(DummyErnbClient.class);
- Mockito.when(ernbClient.searchWithPersonIdentifer("max123")).thenReturn(ernbResultInitial);//"de/st/max123"???
-
- task.setErnbClient(ernbClient);
+ ernbClient = Mockito.mock(IErnbClient.class);
+ Mockito.when(ernbClient.searchWithPersonIdentifer(randomIdentifier)).thenReturn(ernbResultInitial);
//Mock country specific search
List<ICountrySpecificDetailSearchProcessor> handlers = new ArrayList<>();
- DeSpecificDetailSearchProcessor de = new DeSpecificDetailSearchProcessor();
- de.setErnbClient(ernbClient);
- de.setZmrClient(zmrClient);
+ DeSpecificDetailSearchProcessor de = new DeSpecificDetailSearchProcessor(ernbClient, zmrClient);
handlers.add(de);
- task.setHandlers(handlers);
+ task = new InitialSearchTask(handlers, ernbClient, zmrClient);
try {
task.execute(pendingReq1, executionContext);
@@ -435,8 +396,8 @@ public class InitialSearchTaskFirstTest {
* Multiple matches found in ZMR and ErnB with detail search
*/
public void testNode104DE() throws Exception {
- String givenName = "Max";
- String familyName = "Mustermann";
+ String givenName = randomGivenName;
+ String familyName = randomFamilyName;
String pseudonym1 = "de/st/max1234";
String pseudonym2 = "de/st/max12345";
String bpk1 = "bpkMax";
@@ -452,34 +413,29 @@ public class InitialSearchTaskFirstTest {
//Mock ZMR initial search
ArrayList<RegisterResult> zmrResultInitial = new ArrayList<>();
- zmrClient = Mockito.mock(DummyZmrClient.class);
- Mockito.when(zmrClient.searchWithPersonIdentifer("max123")).thenReturn(zmrResultInitial);
+ zmrClient = Mockito.mock(IZmrClient.class);
+ Mockito.when(zmrClient.searchWithPersonIdentifer(randomIdentifier)).thenReturn(zmrResultInitial);
ArrayList<RegisterResult> zmrResultSpecific = new ArrayList<>();
- zmrResultSpecific.add(new RegisterResult(bpk1, pseudonym1, givenName, familyName, dateOfBirth, placeOfBirth, birthName,
+ zmrResultSpecific.add(new RegisterResult(bpk1, pseudonym1, givenName, familyName, dateOfBirth, placeOfBirth,
+ birthName,
null, null));
- zmrResultSpecific.add(new RegisterResult(bpk2, pseudonym2, givenName, familyName, dateOfBirth, placeOfBirth, birthName,
+ zmrResultSpecific.add(new RegisterResult(bpk2, pseudonym2, givenName, familyName, dateOfBirth, placeOfBirth,
+ birthName,
null, null));
- //.searchDeSpecific(eidData.getGivenName(), eidData.getFamilyName(), eidData.getDateOfBirth(),
- // eidData.getPlaceOfBirth(), eidData.getBirthName()
Mockito.when(zmrClient.searchDeSpecific(givenName, familyName, dateOfBirth, placeOfBirth, birthName)).thenReturn(zmrResultSpecific);
- task.setZmrClient(zmrClient);
//Mock ernb initial search
ArrayList<RegisterResult> ernbResultInitial = new ArrayList<>();
- ernbClient = Mockito.mock(DummyErnbClient.class);
- Mockito.when(ernbClient.searchWithPersonIdentifer("max123")).thenReturn(ernbResultInitial);//"de/st/max123"???
-
- task.setErnbClient(ernbClient);
+ ernbClient = Mockito.mock(IErnbClient.class);
+ Mockito.when(ernbClient.searchWithPersonIdentifer(randomIdentifier)).thenReturn(ernbResultInitial);
//Mock country specific search
List<ICountrySpecificDetailSearchProcessor> handlers = new ArrayList<>();
- DeSpecificDetailSearchProcessor de = new DeSpecificDetailSearchProcessor();
- de.setErnbClient(ernbClient);
- de.setZmrClient(zmrClient);
+ DeSpecificDetailSearchProcessor de = new DeSpecificDetailSearchProcessor(ernbClient, zmrClient);
handlers.add(de);
- task.setHandlers(handlers);
+ task = new InitialSearchTask(handlers, ernbClient, zmrClient);
try {
task.execute(pendingReq1, executionContext);
@@ -498,43 +454,34 @@ public class InitialSearchTaskFirstTest {
* Multiple matches found in ZMR and ErnB with detail search
*/
public void testNode104IT() throws Exception {
-
- String fakeTaxNumber = "tax123";
- final AuthenticationResponse response = buildDummyAuthResponseMaxMustermannIT_Tax(fakeTaxNumber);
+ String fakeTaxNumber = RandomStringUtils.randomNumeric(14);;
+ final AuthenticationResponse response = buildDummyAuthResponseRandomPersonIT_Tax(fakeTaxNumber);
TestRequestImpl pendingReq1 = new TestRequestImpl();
pendingReq1.getSessionData(AuthProcessDataWrapper.class)
.setGenericDataToSession(Constants.DATA_FULL_EIDAS_RESPONSE, response);
//Mock ZMR initial search
ArrayList<RegisterResult> zmrResultInitial = new ArrayList<>();
- zmrClient = Mockito.mock(DummyZmrClient.class);
- Mockito.when(zmrClient.searchWithPersonIdentifer("max123")).thenReturn(zmrResultInitial);
+ zmrClient = Mockito.mock(IZmrClient.class);
+ Mockito.when(zmrClient.searchWithPersonIdentifer(randomIdentifier)).thenReturn(zmrResultInitial);
ArrayList<RegisterResult> zmrResultSpecific = new ArrayList<>();
- //String bpk, String pseudonym, String givenName, String familyName, String dateOfBirth,
- // String placeOfBirth, String birthName, String taxNumber, PostalAddressType address
- zmrResultSpecific.add(new RegisterResult("bpkMax","it/st/max1234", "Max", "Mustermann", "2011-01-01", null, null,
+
+ zmrResultSpecific.add(new RegisterResult("bpkMax", "it/st/"+randomIdentifier+"4", randomGivenName, randomFamilyName, "2011-01-01", null, null,
fakeTaxNumber, null));
- zmrResultSpecific.add(new RegisterResult("bpkMax1","it/st/max1235", "Max", "Mustermann", "2011-01-01", null, null,
+ zmrResultSpecific.add(new RegisterResult("bpkMax1", "it/st/"+randomIdentifier+"5", randomGivenName, randomFamilyName, "2011-01-01", null, null,
fakeTaxNumber, null));
Mockito.when(zmrClient.searchItSpecific(fakeTaxNumber)).thenReturn(zmrResultSpecific);
-
- task.setZmrClient(zmrClient);
-
//Mock ernb initial search
ArrayList<RegisterResult> ernbResultInitial = new ArrayList<>();
- ernbClient = Mockito.mock(DummyErnbClient.class);
- Mockito.when(ernbClient.searchWithPersonIdentifer("max123")).thenReturn(ernbResultInitial);//"de/st/max123"???
-
- task.setErnbClient(ernbClient);
+ ernbClient = Mockito.mock(IErnbClient.class);
+ Mockito.when(ernbClient.searchWithPersonIdentifer(randomIdentifier)).thenReturn(ernbResultInitial);
//Mock country specific search
List<ICountrySpecificDetailSearchProcessor> handlers = new ArrayList<>();
- ItSpecificDetailSearchProcessor it = new ItSpecificDetailSearchProcessor();
- it.setErnbClient(ernbClient);
- it.setZmrClient(zmrClient);
+ ItSpecificDetailSearchProcessor it = new ItSpecificDetailSearchProcessor(ernbClient, zmrClient);
handlers.add(it);
- task.setHandlers(handlers);
+ task = new InitialSearchTask(handlers, ernbClient, zmrClient);
try {
task.execute(pendingReq1, executionContext);
@@ -552,27 +499,25 @@ public class InitialSearchTaskFirstTest {
/**
* NO match found in ZMR and ErnB with Initial search
*/
- public void testNode105() throws Exception {
+ public void testNode105() {
//Mock ZMR
ArrayList<RegisterResult> zmrResult = new ArrayList<>();
- zmrClient = Mockito.mock(DummyZmrClient.class);
- Mockito.when(zmrClient.searchWithPersonIdentifer("max123")).thenReturn(zmrResult);//"de/st/max123"???
- task.setZmrClient(zmrClient);
+ zmrClient = Mockito.mock(IZmrClient.class);
+ Mockito.when(zmrClient.searchWithPersonIdentifer(randomIdentifier)).thenReturn(zmrResult);
//Mock ernb
ArrayList<RegisterResult> ernbResult = new ArrayList<>();
- ernbClient = Mockito.mock(DummyErnbClient.class);
- Mockito.when(ernbClient.searchWithPersonIdentifer("max123")).thenReturn(ernbResult);//"de/st/max123"???
- task.setErnbClient(ernbClient);
+ ernbClient = Mockito.mock(IErnbClient.class);
+ Mockito.when(ernbClient.searchWithPersonIdentifer(randomIdentifier)).thenReturn(ernbResult);
+ task = new InitialSearchTask(emptyHandlers(), ernbClient, zmrClient);
try {
task.execute(pendingReq, executionContext);
String bPk = (String)
pendingReq.getSessionData(AuthProcessDataWrapper.class).getGenericDataFromSession(Constants.DATA_RESULT_MATCHING_BPK);
- // NOTE: Why "105"? Extract in a constant
- Assert.assertTrue("Wrong bpk", bPk.equals("105"));
+ Assert.assertTrue("Wrong bpk", bPk.equals("TODO-Temporary-Endnode-105"));
} catch (final TaskExecutionException e) {
Assert.assertTrue("Wrong workflow, should not reach this point", false);
}
@@ -580,27 +525,17 @@ public class InitialSearchTaskFirstTest {
@NotNull
- private AuthenticationResponse buildDummyAuthResponse() throws URISyntaxException {
- return buildDummyAuthResponse(RandomStringUtils.randomAlphabetic(10), RandomStringUtils.randomAlphabetic(10),
- "de/st/" + RandomStringUtils.randomNumeric(64), "2001-01-01");
- }
-
- @NotNull
- private AuthenticationResponse buildDummyAuthResponseMaxMustermann() throws URISyntaxException {
- // NOTE: Those strings "de/st/max123" seem to be somehow relevant, but where do we need to use that exact string again?
+ private AuthenticationResponse buildDummyAuthResponseRandomPerson() throws URISyntaxException {
+ // NOTE: Those strings "de/st/max123" seem to be somehow relevant, but where do we need to use that exact string
+ // again?
// NOTE: If not, why not using random strings?
- return buildDummyAuthResponse("Max", "Mustermann",
- "de/st/max123", "2011-01-01");
- }
-
- private AuthenticationResponse buildDummyAuthResponseMaxMustermannIT() throws URISyntaxException {
- return buildDummyAuthResponse("Max", "Mustermann",
- "it/st/max123", "2011-01-01");
+ return buildDummyAuthResponse(randomGivenName, randomFamilyName,
+ "de/st/"+randomIdentifier, "2011-01-01");
}
- private AuthenticationResponse buildDummyAuthResponseMaxMustermannIT_Tax(String taxNumber) throws URISyntaxException {
- return buildDummyAuthResponse("Max", "Mustermann",
- "it/st/max123", "2011-01-01", taxNumber, null, null);
+ private AuthenticationResponse buildDummyAuthResponseRandomPersonIT_Tax(String taxNumber) throws URISyntaxException {
+ return buildDummyAuthResponse(randomGivenName, randomFamilyName,
+ "it/st/"+randomIdentifier, "2011-01-01", taxNumber, null, null);
}
@NotNull
@@ -611,10 +546,11 @@ public class InitialSearchTaskFirstTest {
@NotNull
private AuthenticationResponse buildDummyAuthResponseDE(String givenName, String familyName, String identifier,
- String dateOfBirth, String placeOfBirth,
+ String dateOfBirth, String placeOfBirth,
String birthName) throws URISyntaxException {
return buildDummyAuthResponse(givenName, familyName, identifier, dateOfBirth, null, placeOfBirth, birthName);
}
+
@NotNull
private AuthenticationResponse buildDummyAuthResponse(String givenName, String familyName, String identifier,
String dateOfBirth, String taxNumber, String placeOfBirth,
@@ -653,13 +589,13 @@ public class InitialSearchTaskFirstTest {
.put(attributeDef3, givenName)
.put(attributeDef4, dateOfBirth);
- if(taxNumber != null) {
+ if (taxNumber != null) {
builder.put(attributeDef5, taxNumber);
}
- if(birthName != null) {
+ if (birthName != null) {
builder.put(attributeDef7, birthName);
}
- if(placeOfBirth != null) {
+ if (placeOfBirth != null) {
builder.put(attributeDef6, placeOfBirth);
}
final ImmutableAttributeMap attributeMap = builder.build();
@@ -669,4 +605,9 @@ public class InitialSearchTaskFirstTest {
"afaf")
.attributes(attributeMap).build();
}
+
+ private List<ICountrySpecificDetailSearchProcessor> emptyHandlers() {
+ return new ArrayList<>();
+ }
+
}