aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/clients/ernp/ErnpRestClient.java65
-rw-r--r--eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/clients/ernp/IErnpClient.java74
-rw-r--r--eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/ernp/DummyErnpClient.java43
-rw-r--r--eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/service/RegisterSearchService.java30
-rw-r--r--eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskTest.java185
5 files changed, 287 insertions, 110 deletions
diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/clients/ernp/ErnpRestClient.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/clients/ernp/ErnpRestClient.java
new file mode 100644
index 00000000..7763fc9d
--- /dev/null
+++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/clients/ernp/ErnpRestClient.java
@@ -0,0 +1,65 @@
+package at.asitplus.eidas.specific.modules.auth.eidas.v2.clients.ernp;
+
+import java.util.List;
+
+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.exception.EidasSAuthenticationException;
+import at.gv.bmi.namespace.zmr_su.zmr._20040201.PersonSuchenRequest;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+/**
+ * Implements an ERnP client that uses REST API for communication.
+ *
+ * @author tlenz
+ *
+ */
+public class ErnpRestClient implements IErnpClient {
+
+ @AllArgsConstructor
+ @Getter
+ public static class ErnpRegisterResult {
+ private final List<RegisterResult> personResult;
+
+ }
+
+ @Override
+ public ErnpRegisterResult searchWithPersonIdentifier(String personIdentifier, String citizenCountryCode)
+ throws EidasSAuthenticationException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public ErnpRegisterResult searchWithMds(String givenName, String familyName, String dateOfBirth,
+ String citizenCountryCode) throws EidasSAuthenticationException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public ErnpRegisterResult searchCountrySpecific(PersonSuchenRequest personSearchDao,
+ String citizenCountryCode) throws EidasSAuthenticationException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public ErnpRegisterResult update(RegisterResult registerResult, SimpleEidasData eidData)
+ throws EidasSAuthenticationException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public ErnpRegisterResult searchWithResidenceData(String givenName, String familyName, String dateOfBirth,
+ String zipcode, String city, String street) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+
+
+
+}
diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/clients/ernp/IErnpClient.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/clients/ernp/IErnpClient.java
index 377048d9..4c8bcd3e 100644
--- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/clients/ernp/IErnpClient.java
+++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/clients/ernp/IErnpClient.java
@@ -23,24 +23,80 @@
package at.asitplus.eidas.specific.modules.auth.eidas.v2.clients.ernp;
-import java.util.List;
+import javax.annotation.Nonnull;
+import at.asitplus.eidas.specific.modules.auth.eidas.v2.clients.ernp.ErnpRestClient.ErnpRegisterResult;
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.exception.EidasSAuthenticationException;
+import at.gv.bmi.namespace.zmr_su.zmr._20040201.PersonSuchenRequest;
public interface IErnpClient {
- List<RegisterResult> searchWithPersonIdentifier(String personIdentifier);
+ /**
+ * Search person based on eIDAS personal identifier.
+ *
+ * @param personIdentifier Full eIDAS personal identifier with prefix
+ * @param citizenCountryCode CountryCode of the eIDAS proxy-service
+ * @return Search result but never <code>null</code>
+ * @throws EidasSAuthenticationException In case of a communication error
+ */
+ @Nonnull
+ ErnpRegisterResult searchWithPersonIdentifier(@Nonnull String personIdentifier,
+ @Nonnull String citizenCountryCode) throws EidasSAuthenticationException;
- List<RegisterResult> searchWithMds(String givenName, String familyName, String dateOfBirth);
+ /**
+ * Search person based on eIDSA MDS information.
+ *
+ * @param givenName eIDAS given name
+ * @param familyName eIDAS principle name
+ * @param dateOfBirth eIDAS date-of-birth
+ * @param citizenCountryCode CountryCode of the eIDAS proxy-service
+ * @return Search result but never <code>null</code>
+ * @throws EidasSAuthenticationException In case of a communication error
+ */
+ @Nonnull
+ ErnpRegisterResult searchWithMds(@Nonnull String givenName, @Nonnull String familyName,
+ @Nonnull String dateOfBirth, @Nonnull String citizenCountryCode)
+ throws EidasSAuthenticationException;
- List<RegisterResult> searchDeSpecific(String givenName, String familyName, String dateOfBirth,
- String birthPlace, String birthName);
+ /**
+ * Search person based on country-specific natural person set.
+ *
+ * @param personSearchDao Specific set of natural person informations.
+ * @param citizenCountryCode CountryCode of the eIDAS proxy-service
+ * @return Search result but never <code>null</code>
+ * @throws EidasSAuthenticationException In case of a communication error
+ */
+ @Nonnull
+ ErnpRegisterResult searchCountrySpecific(@Nonnull PersonSuchenRequest personSearchDao,
+ @Nonnull String citizenCountryCode) throws EidasSAuthenticationException;
- List<RegisterResult> searchItSpecific(String taxNumber);
+ /**
+ * Update ERnP entry to KITT existing ERnP identity with this eIDAS authentication.
+ *
+ * @param registerResult Already matched eIDAS identity that should be KITT
+ * @param eidData eIDAS eID information from current authentication process
+ * @return Update result but never <code>null</code>
+ * @throws EidasSAuthenticationException In case of a communication error
+ */
+ @Nonnull
+ ErnpRegisterResult update(RegisterResult registerResult, SimpleEidasData eidData)
+ throws EidasSAuthenticationException;
- RegisterResult update(RegisterResult registerResult, SimpleEidasData eidData);
-
- List<RegisterResult> searchWithBpkZp(String bpkzp);
+ /**
+ * Search person based on address information.
+ *
+ * @param givenName eIDAS given name
+ * @param familyName eIDAS principle name
+ * @param dateOfBirth eIDAS date-of-birth
+ * @param zipcode ZipCode
+ * @param city City
+ * @param street Street
+ * @return Search result but never <code>null</code>
+ */
+ @Nonnull
+ ErnpRegisterResult searchWithResidenceData(String givenName, String familyName,
+ String dateOfBirth, String zipcode, String city, String street);
}
diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/ernp/DummyErnpClient.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/ernp/DummyErnpClient.java
index db10752b..52703232 100644
--- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/ernp/DummyErnpClient.java
+++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/ernp/DummyErnpClient.java
@@ -24,52 +24,53 @@
package at.asitplus.eidas.specific.modules.auth.eidas.v2.ernp;
import java.util.Collections;
-import java.util.List;
import org.springframework.stereotype.Service;
+import at.asitplus.eidas.specific.modules.auth.eidas.v2.clients.ernp.ErnpRestClient.ErnpRegisterResult;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.clients.ernp.IErnpClient;
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.exception.EidasSAuthenticationException;
+import at.gv.bmi.namespace.zmr_su.zmr._20040201.PersonSuchenRequest;
@Service("ErnbClientForeIDAS")
public class DummyErnpClient implements IErnpClient {
+
@Override
- public List<RegisterResult> searchWithPersonIdentifier(String personIdentifier) {
- return Collections.emptyList();
+ public ErnpRegisterResult searchWithPersonIdentifier(String personIdentifier, String citizenCountryCode)
+ throws EidasSAuthenticationException {
+ return buildEmptyResult();
}
@Override
- public List<RegisterResult> searchWithMds(String givenName, String familyName, String dateOfBirth) {
- //TODO will I only receive matches where all three values match perfectly?
- return Collections.emptyList();
+ public ErnpRegisterResult searchWithMds(String givenName, String familyName, String dateOfBirth,
+ String citizenCountryCode) throws EidasSAuthenticationException {
+ return buildEmptyResult();
}
@Override
- public List<RegisterResult> searchDeSpecific(String givenName, String familyName, String dateOfBirth,
- String birthPlace, String birthName) {
- //TODO
- return Collections.emptyList();
+ public ErnpRegisterResult searchCountrySpecific(PersonSuchenRequest personSearchDao,
+ String citizenCountryCode) throws EidasSAuthenticationException {
+ return buildEmptyResult();
}
@Override
- public List<RegisterResult> searchItSpecific(String taxNumber) {
- //TODO
- return Collections.emptyList();
+ public ErnpRegisterResult update(RegisterResult registerResult, SimpleEidasData eidData)
+ throws EidasSAuthenticationException {
+ return buildEmptyResult();
}
@Override
- public RegisterResult update(RegisterResult registerResult, SimpleEidasData eidData) {
- //TODO
- return null;
+ public ErnpRegisterResult searchWithResidenceData(String givenName, String familyName, String dateOfBirth,
+ String zipcode, String city, String street) {
+ return buildEmptyResult();
}
- @Override
- public List<RegisterResult> searchWithBpkZp(String bpkzp) {
- //TODO
- return Collections.emptyList();
+ private static ErnpRegisterResult buildEmptyResult() {
+ return new ErnpRegisterResult(Collections.emptyList());
+
}
-
}
diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/service/RegisterSearchService.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/service/RegisterSearchService.java
index 5f1e96a4..fd9a67a9 100644
--- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/service/RegisterSearchService.java
+++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/service/RegisterSearchService.java
@@ -11,6 +11,7 @@ import org.springframework.stereotype.Service;
import com.google.common.collect.Streams;
+import at.asitplus.eidas.specific.modules.auth.eidas.v2.clients.ernp.ErnpRestClient.ErnpRegisterResult;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.clients.ernp.IErnpClient;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.clients.zmr.IZmrClient;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.clients.zmr.ZmrSoapClient.ZmrRegisterResult;
@@ -77,8 +78,8 @@ public class RegisterSearchService {
final ZmrRegisterResult resultsZmr = zmrClient.searchWithPersonIdentifier(
operationStatus != null ? operationStatus.getZmrProcessId() : null,
eidasData.getPseudonym(), eidasData.getCitizenCountryCode());
- final List<RegisterResult> resultsErnp = ernpClient.searchWithPersonIdentifier(
- eidasData.getPersonalIdentifier());
+ final ErnpRegisterResult resultsErnp = ernpClient.searchWithPersonIdentifier(
+ eidasData.getPseudonym(), eidasData.getCitizenCountryCode());
return RegisterStatusResults.fromZmrAndErnp(resultsZmr, resultsErnp);
@@ -104,9 +105,9 @@ public class RegisterSearchService {
zmrClient.searchWithMds(operationStatus.getZmrProcessId(), eidasData.getGivenName(),
eidasData.getFamilyName(), eidasData.getDateOfBirth(), eidasData.getCitizenCountryCode());
- final List<RegisterResult> resultsErnp =
- ernpClient.searchWithMds(eidasData.getGivenName(), eidasData.getFamilyName(), eidasData
- .getDateOfBirth());
+ final ErnpRegisterResult resultsErnp =
+ ernpClient.searchWithMds(eidasData.getGivenName(),
+ eidasData.getFamilyName(), eidasData.getDateOfBirth(), eidasData.getCitizenCountryCode());
return RegisterStatusResults.fromZmrAndErnp(resultsZmr, resultsErnp);
@@ -141,7 +142,8 @@ public class RegisterSearchService {
} else {
// TODO: add search procesfor for ERnP searching
- return RegisterStatusResults.fromErnp(operationStatus, Collections.emptyList());
+ return RegisterStatusResults.fromErnp(operationStatus,
+ new ErnpRegisterResult(Collections.emptyList()));
}
@@ -193,8 +195,8 @@ public class RegisterSearchService {
return RegisterStatusResults.fromZmr(updateZmr);
} else {
RegisterResult entryErnp = registerResult.getResultsErnp().get(0);
- RegisterResult updateErnp = ernpClient.update(entryErnp, initialEidasData);
- return RegisterStatusResults.fromErnp(registerResult.operationStatus, Collections.singletonList(updateErnp));
+ ErnpRegisterResult updateErnp = ernpClient.update(entryErnp, initialEidasData);
+ return RegisterStatusResults.fromErnp(registerResult.operationStatus, updateErnp);
}
} catch (final EidasSAuthenticationException e) {
throw new WorkflowException("kittMatchedIdentitiess", e.getMessage(),
@@ -263,9 +265,9 @@ public class RegisterSearchService {
ernpClient.update(entryErnp, initialEidasData);
// update ZMR entry by using eIDAS information from alternative authentication
- RegisterResult updateAlt = ernpClient.update(entryErnp, altEidasData);
+ ErnpRegisterResult updateAlt = ernpClient.update(entryErnp, altEidasData);
- return RegisterStatusResults.fromErnp(altSearchResult.operationStatus, Collections.singletonList(updateAlt));
+ return RegisterStatusResults.fromErnp(altSearchResult.operationStatus, updateAlt);
}
} catch (final EidasSAuthenticationException e) {
throw new WorkflowException("kittMatchedIdentitiess", e.getMessage(),
@@ -373,13 +375,13 @@ public class RegisterSearchService {
result.getPersonResult(), Collections.emptyList());
}
- static RegisterStatusResults fromZmrAndErnp(ZmrRegisterResult result, List<RegisterResult> resultsErnp) {
+ static RegisterStatusResults fromZmrAndErnp(ZmrRegisterResult result, ErnpRegisterResult resultErnp) {
return new RegisterStatusResults(new RegisterOperationStatus(result.getProcessId()),
- result.getPersonResult(), resultsErnp);
+ result.getPersonResult(), resultErnp.getPersonResult());
}
- static RegisterStatusResults fromErnp(RegisterOperationStatus status, List<RegisterResult> resultsErnp) {
- return new RegisterStatusResults(status, Collections.emptyList(), resultsErnp);
+ static RegisterStatusResults fromErnp(RegisterOperationStatus status, ErnpRegisterResult updateErnp) {
+ return new RegisterStatusResults(status, Collections.emptyList(), updateErnp.getPersonResult());
}
}
diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskTest.java b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskTest.java
index c14af84c..d6d49370 100644
--- a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskTest.java
+++ b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskTest.java
@@ -23,7 +23,48 @@
package at.asitplus.eidas.specific.modules.auth.eidas.v2.test.tasks;
+import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertThrows;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+
+import java.math.BigInteger;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
+
+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.Ignore;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.mock.web.MockHttpServletRequest;
+import org.springframework.mock.web.MockHttpServletResponse;
+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 org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.context.request.ServletRequestAttributes;
+
import at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants;
+import at.asitplus.eidas.specific.modules.auth.eidas.v2.clients.ernp.ErnpRestClient.ErnpRegisterResult;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.clients.ernp.IErnpClient;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.clients.zmr.IZmrClient;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.clients.zmr.ZmrSoapClient;
@@ -31,7 +72,11 @@ import at.asitplus.eidas.specific.modules.auth.eidas.v2.clients.zmr.ZmrSoapClien
import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.MatchedPersonResult;
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.exception.*;
+import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.EidPostProcessingException;
+import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.EidasAttributeException;
+import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.EidasSAuthenticationException;
+import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.WorkflowException;
+import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.ZmrCommunicationException;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.handler.CountrySpecificDetailSearchProcessor;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.handler.GenericEidProcessor;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.service.ICcSpecificEidProcessingService;
@@ -52,36 +97,6 @@ import eu.eidas.auth.commons.attribute.ImmutableAttributeMap;
import eu.eidas.auth.commons.attribute.PersonType;
import eu.eidas.auth.commons.light.impl.LightRequest;
import eu.eidas.auth.commons.protocol.impl.AuthenticationResponse;
-import org.apache.commons.lang3.RandomStringUtils;
-import org.jetbrains.annotations.NotNull;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.mock.web.MockHttpServletRequest;
-import org.springframework.mock.web.MockHttpServletResponse;
-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 org.springframework.web.context.request.RequestContextHolder;
-import org.springframework.web.context.request.ServletRequestAttributes;
-
-import javax.xml.namespace.QName;
-import java.math.BigInteger;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.*;
-
-import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic;
-import static org.junit.Assert.*;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.eq;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {
@@ -176,6 +191,13 @@ public class InitialSearchTaskTest {
Mockito.when(zmrClient.update(any(), any(), any()))
.thenThrow(new IllegalStateException("ZMR update should not be neccessary"));
+ Mockito.when(ernpClient.searchWithPersonIdentifier(randomPseudonym, DE))
+ .thenReturn(emptyErnpRegisterResult());
+ Mockito.when(ernpClient.searchWithMds(any(), any(), any(), any()))
+ .thenThrow(new IllegalStateException("MDS search should not be neccessary"));
+ Mockito.when(ernpClient.update(any(), any()))
+ .thenThrow(new IllegalStateException("ERnP update should not be neccessary"));
+
// execute test
task.execute(pendingReq, executionContext);
@@ -200,8 +222,8 @@ public class InitialSearchTaskTest {
.thenReturn(emptyZmrRegisterResult());
String oldRandomGivenName = randomAlphabetic(10);
- Mockito.when(ernpClient.searchWithPersonIdentifier(randomPersonalIdentifier_DE))
- .thenReturn(Collections.singletonList(randomRegisterResult(oldRandomGivenName, randomBpk)));
+ Mockito.when(ernpClient.searchWithPersonIdentifier(randomPseudonym, DE))
+ .thenReturn(ernpRegisterResult(randomRegisterResult(oldRandomGivenName, randomBpk)));
// execute test
task.execute(pendingReq, executionContext);
@@ -210,11 +232,8 @@ public class InitialSearchTaskTest {
checkMatchingSuccessState(pendingReq, randomBpk, randomFamilyName, randomGivenName, randomBirthDate, DE);
}
- @NotNull
- private ZmrSoapClient.ZmrRegisterResult emptyZmrRegisterResult() {
- return new ZmrRegisterResult(Collections.emptyList(), generateRandomProcessId());
- }
+
/**
* Two matches by PersonalId found in ZMR
*
@@ -226,8 +245,8 @@ public class InitialSearchTaskTest {
String newRandomGivenName = randomAlphabetic(10);
Mockito.when(zmrClient.searchWithPersonIdentifier(null, randomPseudonym, DE))
.thenReturn(new ZmrRegisterResult(Arrays.asList(randomRegisterResult(), randomRegisterResult(newRandomGivenName, randomBpk)), generateRandomProcessId()));
- Mockito.when(ernpClient.searchWithPersonIdentifier(randomPersonalIdentifier_DE))
- .thenReturn(Collections.emptyList());
+ Mockito.when(ernpClient.searchWithPersonIdentifier(randomPseudonym, DE))
+ .thenReturn(emptyErnpRegisterResult());
// execute task
TaskExecutionException exception = assertThrows(TaskExecutionException.class,
@@ -251,8 +270,8 @@ public class InitialSearchTaskTest {
public void withErrorFromZmr() throws EidasSAuthenticationException {
Mockito.when(zmrClient.searchWithPersonIdentifier(null, randomPseudonym, DE))
.thenThrow(new ZmrCommunicationException("jUnit ZMR error", null));
- Mockito.when(ernpClient.searchWithPersonIdentifier(randomPersonalIdentifier_DE))
- .thenReturn(Collections.emptyList());
+ Mockito.when(ernpClient.searchWithPersonIdentifier(randomPseudonym, DE))
+ .thenReturn(emptyErnpRegisterResult());
// execute task
TaskExecutionException exception = assertThrows(TaskExecutionException.class,
@@ -277,8 +296,9 @@ public class InitialSearchTaskTest {
Mockito.when(zmrClient.searchWithPersonIdentifier(null, randomPseudonym, DE))
.thenReturn(emptyZmrRegisterResult());
String newRandomGivenName = randomAlphabetic(10);
- Mockito.when(ernpClient.searchWithPersonIdentifier(randomPersonalIdentifier_DE))
- .thenReturn(Arrays.asList(randomRegisterResult(), randomRegisterResult(newRandomGivenName, randomBpk)));
+ Mockito.when(ernpClient.searchWithPersonIdentifier(randomPseudonym, DE))
+ .thenReturn(ernpRegisterResult(
+ Arrays.asList(randomRegisterResult(), randomRegisterResult(newRandomGivenName, randomBpk))));
// execute task
TaskExecutionException exception = assertThrows(TaskExecutionException.class,
@@ -301,9 +321,8 @@ public class InitialSearchTaskTest {
public void multiPersonalIdMatch_ErnpAndZmr() throws EidasSAuthenticationException {
Mockito.when(zmrClient.searchWithPersonIdentifier(null, randomPseudonym, DE))
.thenReturn(zmrRegisterResult(randomRegisterResult()));
- String newRandomGivenName = randomAlphabetic(10);
- Mockito.when(ernpClient.searchWithPersonIdentifier(randomPersonalIdentifier_DE))
- .thenReturn(Collections.singletonList(randomRegisterResult()));
+ Mockito.when(ernpClient.searchWithPersonIdentifier(randomPseudonym, DE))
+ .thenReturn(ernpRegisterResult(randomRegisterResult()));
// execute task
TaskExecutionException exception = assertThrows(TaskExecutionException.class,
@@ -324,8 +343,13 @@ public class InitialSearchTaskTest {
public void singlePersonalIdMatchNoUpdate_Ernp() throws Exception {
Mockito.when(zmrClient.searchWithPersonIdentifier(null, randomPseudonym, DE))
.thenReturn(emptyZmrRegisterResult());
- Mockito.when(ernpClient.searchWithPersonIdentifier(randomPersonalIdentifier_DE))
- .thenReturn(Collections.singletonList(randomRegisterResult()));
+ Mockito.when(zmrClient.update(any(), any(), any()))
+ .thenThrow(new IllegalStateException("ZMR update should not be neccessary"));
+
+ Mockito.when(ernpClient.searchWithPersonIdentifier(randomPseudonym, DE))
+ .thenReturn(ernpRegisterResult(randomRegisterResult()));
+ Mockito.when(ernpClient.update(any(), any()))
+ .thenThrow(new IllegalStateException("ERnP update should not be neccessary"));
// execute test
task.execute(pendingReq, executionContext);
@@ -342,8 +366,8 @@ public class InitialSearchTaskTest {
public void singlePersonalIdMatchNoUpdate_Zmr() throws Exception {
Mockito.when(zmrClient.searchWithPersonIdentifier(null, randomPseudonym, DE))
.thenReturn(zmrRegisterResult(randomRegisterResult()));
- Mockito.when(ernpClient.searchWithPersonIdentifier(randomPersonalIdentifier_DE))
- .thenReturn(Collections.emptyList());
+ Mockito.when(ernpClient.searchWithPersonIdentifier(randomPseudonym, DE))
+ .thenReturn(emptyErnpRegisterResult());
Mockito.when(zmrClient.update(any(), any(), any()))
.thenThrow(new IllegalStateException("ZMR update should not be neccessary"));
@@ -394,8 +418,8 @@ public class InitialSearchTaskTest {
Mockito.when(zmrClient.searchWithMds(any(), any(), any(), any(), any()))
.thenThrow(new IllegalStateException("MDS search should not be neccessary"));
- Mockito.when(ernpClient.searchWithPersonIdentifier(randomPersonalIdentifier_DE))
- .thenReturn(Collections.emptyList());
+ Mockito.when(ernpClient.searchWithPersonIdentifier(randomPseudonym, DE))
+ .thenReturn(emptyErnpRegisterResult());
// execute test
task.execute(pendingReq1, executionContext);
@@ -444,8 +468,8 @@ public class InitialSearchTaskTest {
Mockito.when(zmrClient.searchCountrySpecific(eq(zmrProcessId), any(PersonSuchenRequest.class), eq(DE)))
.thenReturn(new ZmrRegisterResult(Arrays.asList(randomResult1, randomResult2), zmrProcessId));
- Mockito.when(ernpClient.searchWithPersonIdentifier(randomPersonalIdentifier_DE))
- .thenReturn(Collections.emptyList());
+ Mockito.when(ernpClient.searchWithPersonIdentifier(randomPseudonym, DE))
+ .thenReturn(emptyErnpRegisterResult());
// execute task
TaskExecutionException exception = assertThrows(TaskExecutionException.class,
@@ -480,9 +504,12 @@ public class InitialSearchTaskTest {
Mockito.when(zmrClient.update(any(), any(), any()))
.thenThrow(new IllegalStateException("ZMR update should not be neccessary"));
- Mockito.when(ernpClient.searchWithPersonIdentifier(randomPersonalIdentifier_EE))
- .thenReturn(Collections.emptyList());
-
+ Mockito.when(ernpClient.searchWithPersonIdentifier(randomPseudonym, EE))
+ .thenReturn(emptyErnpRegisterResult());
+ Mockito.when(ernpClient.searchWithMds(randomGivenName, randomFamilyName, randomBirthDate, EE))
+ .thenReturn(new ErnpRegisterResult(Collections.emptyList()));
+ Mockito.when(ernpClient.update(any(), any()))
+ .thenThrow(new IllegalStateException("ZMR update should not be neccessary"));
// execute task
task.execute(pendingReq, executionContext);
@@ -519,10 +546,10 @@ public class InitialSearchTaskTest {
Mockito.when(zmrClient.searchWithMds(zmrProcessId, randomGivenName, randomFamilyName, randomBirthDate, EE))
.thenReturn(new ZmrRegisterResult(Collections.emptyList(), zmrProcessId));
- Mockito.when(ernpClient.searchWithPersonIdentifier(randomPersonalIdentifier_EE))
- .thenReturn(Collections.emptyList());
- Mockito.when(ernpClient.searchWithMds(randomGivenName, randomFamilyName, randomBirthDate))
- .thenReturn(Collections.singletonList(randomRegisterResult()));
+ Mockito.when(ernpClient.searchWithPersonIdentifier(randomPseudonym, EE))
+ .thenReturn(emptyErnpRegisterResult());
+ Mockito.when(ernpClient.searchWithMds(randomGivenName, randomFamilyName, randomBirthDate, EE))
+ .thenReturn(ernpRegisterResult(randomRegisterResult()));
// execute test
task.execute(pendingReq, executionContext);
@@ -546,8 +573,14 @@ public class InitialSearchTaskTest {
Mockito.when(zmrClient.update(any(), any(), any()))
.thenThrow(new IllegalStateException("ZMR update should not be neccessary"));
- Mockito.when(ernpClient.searchWithPersonIdentifier(randomPersonalIdentifier_DE)).thenReturn(Collections.emptyList());
+ Mockito.when(ernpClient.searchWithPersonIdentifier(randomPseudonym, DE)).thenReturn(
+ emptyErnpRegisterResult());
+ Mockito.when(ernpClient.searchWithMds(randomGivenName, randomFamilyName, randomBirthDate, DE))
+ .thenReturn(emptyErnpRegisterResult());
+ Mockito.when(ernpClient.update(any(), any()))
+ .thenThrow(new IllegalStateException("ERnP update should not be neccessary"));
+
// execute test
task.execute(pendingReq, executionContext);
@@ -573,10 +606,10 @@ public class InitialSearchTaskTest {
Mockito.when(zmrClient.update(any(), any(), any()))
.thenThrow(new IllegalStateException("ZMR update should not be neccessary"));
- Mockito.when(ernpClient.searchWithPersonIdentifier(randomPersonalIdentifier_DE))
- .thenReturn(Collections.emptyList());
- Mockito.when(ernpClient.searchWithMds(randomGivenName, randomFamilyName, randomBirthDate))
- .thenReturn(Arrays.asList(randomRegisterResult(), randomRegisterResult(randomBpk + "1")));
+ Mockito.when(ernpClient.searchWithPersonIdentifier(randomPseudonym, DE))
+ .thenReturn(emptyErnpRegisterResult());
+ Mockito.when(ernpClient.searchWithMds(randomGivenName, randomFamilyName, randomBirthDate, DE))
+ .thenReturn(ernpRegisterResult(Arrays.asList(randomRegisterResult(), randomRegisterResult(randomBpk + "1"))));
// execute test
task.execute(pendingReq, executionContext);
@@ -587,6 +620,16 @@ public class InitialSearchTaskTest {
}
@NotNull
+ private ZmrSoapClient.ZmrRegisterResult emptyZmrRegisterResult() {
+ return new ZmrRegisterResult(Collections.emptyList(), generateRandomProcessId());
+ }
+
+ @NotNull
+ private ErnpRegisterResult emptyErnpRegisterResult() {
+ return new ErnpRegisterResult(Collections.emptyList());
+ }
+
+ @NotNull
private ZmrRegisterResult zmrRegisterResult(RegisterResult registerResult, BigInteger processId) {
return new ZmrRegisterResult(Collections.singletonList(registerResult), processId);
}
@@ -597,6 +640,16 @@ public class InitialSearchTaskTest {
}
@NotNull
+ private ErnpRegisterResult ernpRegisterResult(RegisterResult registerResult) {
+ return new ErnpRegisterResult(Collections.singletonList(registerResult));
+ }
+
+ @NotNull
+ private ErnpRegisterResult ernpRegisterResult(List<RegisterResult> registerResult) {
+ return new ErnpRegisterResult(registerResult);
+ }
+
+ @NotNull
private RegisterResult randomRegisterResult() {
return randomRegisterResult(randomGivenName, randomBpk);
}