aboutsummaryrefslogtreecommitdiff
path: root/eidas_modules/authmodule-eIDAS-v2
diff options
context:
space:
mode:
Diffstat (limited to 'eidas_modules/authmodule-eIDAS-v2')
-rw-r--r--eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/clients/ZmrClientTest.java165
1 files changed, 164 insertions, 1 deletions
diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/clients/ZmrClientTest.java b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/clients/ZmrClientTest.java
index beedfda0..290eefe4 100644
--- a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/clients/ZmrClientTest.java
+++ b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/clients/ZmrClientTest.java
@@ -41,6 +41,7 @@ import at.asitplus.eidas.specific.connector.test.config.dummy.MsConnectorDummyCo
import at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.clients.zmr.ZmrSoapClient;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.clients.zmr.ZmrSoapClient.ZmrRegisterResult;
+import at.asitplus.eidas.specific.modules.auth.eidas.v2.controller.AdresssucheController.AdresssucheOutput;
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;
@@ -605,6 +606,168 @@ public class ZmrClientTest {
@Test
@SneakyThrows
+ public void searchResidenceEmpty() {
+ BigInteger processId = new BigInteger(RandomStringUtils.randomNumeric(6));
+
+ final String cc = "DE";
+ String familyName = RandomStringUtils.randomAlphabetic(10);
+ String givenName = RandomStringUtils.randomAlphabetic(10);
+ String dateOfBirth = RandomStringUtils.randomAlphabetic(10);
+ AdresssucheOutput addressInfo = AdresssucheOutput.builder()
+ .municipality(RandomStringUtils.randomAlphabetic(10))
+ .number(RandomStringUtils.randomAlphabetic(10))
+ .postleitzahl(RandomStringUtils.randomAlphabetic(10))
+ .street(RandomStringUtils.randomAlphabetic(10))
+ .village(RandomStringUtils.randomAlphabetic(10))
+ .build();
+
+
+ final ArgumentCaptor<RequestType> zmrReq = ArgumentCaptor.forClass(RequestType.class);
+
+ // inject response
+ when(zmrMock.service(zmrReq.capture(), any())).thenReturn(
+ loadResponseFromFile("/data/zmr/empty_zmr_result.xml"));
+
+ // execute operation
+ ZmrRegisterResult resp = client.searchWithResidenceData(processId,
+ givenName, familyName, dateOfBirth, cc, addressInfo);
+
+ // validate state
+ assertNotNull("no ZMR response", resp);
+ assertEquals("wrong processId", "367100000000079", resp.getProcessId().toString());
+ assertEquals("wrong resp size", 0, resp.getPersonResult().size());
+
+ // validate request
+ assertEquals("wrong number of req.", 1, zmrReq.getAllValues().size());
+ assertNotNull("Personensuche req.", zmrReq.getValue().getPersonSuchenRequest());
+ checkBasicRequestParameters(zmrReq.getValue(), PROCESS_TASK_SEARCH, processId, "jUnit123456");
+ PersonSuchenRequest pSuche = zmrReq.getValue().getPersonSuchenRequest();
+ checkSearchParameters(pSuche.getPersonensucheInfo());
+
+ assertNotNull("mds", pSuche.getNatuerlichePerson());
+ assertEquals("req. givenName", givenName, pSuche.getNatuerlichePerson().getPersonenName().getVorname());
+ assertEquals("req. familyName", familyName, pSuche.getNatuerlichePerson().getPersonenName().getFamilienname());
+ assertEquals("req. dateOfBirth", dateOfBirth, pSuche.getNatuerlichePerson().getGeburtsdatum());
+
+ assertEquals("req. Municipality", addressInfo.getMunicipality(), pSuche.getPostAdresse().getGemeinde());
+ assertEquals("req. Postleitzahl", addressInfo.getPostleitzahl(), pSuche.getPostAdresse().getPostleitzahl());
+ assertEquals("req. Village", addressInfo.getVillage(), pSuche.getPostAdresse().getOrtschaft());
+ assertEquals("req. Street", addressInfo.getStreet(), pSuche.getPostAdresse().getZustelladresse().getStrassenname());
+ assertEquals("req. Number", addressInfo.getNumber(), pSuche.getPostAdresse().getZustelladresse().getOrientierungsnummer());
+
+ }
+
+ @Test
+ @SneakyThrows
+ public void searchResidenceMoreThanOneResult() {
+ BigInteger processId = new BigInteger(RandomStringUtils.randomNumeric(6));
+
+ final String cc = "DE";
+ String familyName = RandomStringUtils.randomAlphabetic(10);
+ String givenName = RandomStringUtils.randomAlphabetic(10);
+ String dateOfBirth = RandomStringUtils.randomAlphabetic(10);
+ AdresssucheOutput addressInfo = AdresssucheOutput.builder()
+ .municipality(RandomStringUtils.randomAlphabetic(10))
+ .postleitzahl(RandomStringUtils.randomAlphabetic(10))
+ .street(RandomStringUtils.randomAlphabetic(10))
+ .build();
+
+ final ArgumentCaptor<RequestType> zmrReq = ArgumentCaptor.forClass(RequestType.class);
+
+ // inject response
+ when(zmrMock.service(zmrReq.capture(), any())).thenReturn(
+ loadResponseFromFile("/data/zmr/search_with_personalId_only_resp_moreThanOne.xml"));
+
+ // execute operation
+ ZmrRegisterResult resp = client.searchWithResidenceData(processId,
+ givenName, familyName, dateOfBirth, cc, addressInfo);
+
+ // validate state
+ assertNotNull("no ZMR response", resp);
+ assertEquals("wrong processId", "367100000000079", resp.getProcessId().toString());
+ assertEquals("wrong resp size", 2, resp.getPersonResult().size());
+
+ // validate request
+ assertEquals("wrong number of req.", 1, zmrReq.getAllValues().size());
+ assertNotNull("Personensuche req.", zmrReq.getValue().getPersonSuchenRequest());
+ checkBasicRequestParameters(zmrReq.getValue(), PROCESS_TASK_SEARCH, processId, "jUnit123456");
+ PersonSuchenRequest pSuche = zmrReq.getValue().getPersonSuchenRequest();
+ assertEquals("req. Municipality", addressInfo.getMunicipality(), pSuche.getPostAdresse().getGemeinde());
+ assertEquals("req. Postleitzahl", addressInfo.getPostleitzahl(), pSuche.getPostAdresse().getPostleitzahl());
+ assertNull("req. Village", pSuche.getPostAdresse().getOrtschaft());
+ assertEquals("req. Street", addressInfo.getStreet(), pSuche.getPostAdresse().getZustelladresse().getStrassenname());
+ assertNull("req. Number", pSuche.getPostAdresse().getZustelladresse().getOrientierungsnummer());
+
+ }
+
+ @Test
+ @SneakyThrows
+ public void searchResidenceSuccess() {
+ final String personalIdentifierFirst = "7cEYWithDEElementsasdfsafsaf4CDVzNT4E7cjkU4VqForjUnit";
+ final String cc = "DE";
+ final SimpleEidasData eidasDataFirst = SimpleEidasData.builder()
+ .citizenCountryCode(cc)
+ .familyName("XXXvon Brandenburg")
+ .givenName("XXXClaus - Maria")
+ .dateOfBirth("1994-12-31")
+ .personalIdentifier(cc + "/AT/" + personalIdentifierFirst)
+ .pseudonym(personalIdentifierFirst)
+ .build();
+
+ BigInteger processId = new BigInteger(RandomStringUtils.randomNumeric(6));
+
+ String familyName = RandomStringUtils.randomAlphabetic(10);
+ String givenName = RandomStringUtils.randomAlphabetic(10);
+ String dateOfBirth = RandomStringUtils.randomAlphabetic(10);
+ AdresssucheOutput addressInfo = AdresssucheOutput.builder()
+ .municipality(RandomStringUtils.randomAlphabetic(10))
+ .postleitzahl(RandomStringUtils.randomAlphabetic(10))
+ .build();
+
+ final ArgumentCaptor<RequestType> zmrReq = ArgumentCaptor.forClass(RequestType.class);
+
+ // inject response
+ when(zmrMock.service(zmrReq.capture(), any())).thenReturn(
+ loadResponseFromFile("/data/zmr/search_with_personalId_only_resp.xml"));
+
+ // execute operation
+ ZmrRegisterResult resp = client.searchWithResidenceData(processId,
+ givenName, familyName, dateOfBirth, cc, addressInfo);
+
+ // validate state
+ assertNotNull("no ZMR response", resp);
+ assertEquals("wrong processId", "367100000000079", resp.getProcessId().toString());
+ assertEquals("wrong resp size", 1, resp.getPersonResult().size());
+
+ RegisterResult persInfo = resp.getPersonResult().get(0);
+ assertEquals("bPK", "UgeknNsc26lVuB7U/uYGVmWtnnA=", persInfo.getBpk());
+ assertEquals("dateOfBirth", eidasDataFirst.getDateOfBirth(), persInfo.getDateOfBirth());
+ assertEquals("familyName", eidasDataFirst.getFamilyName(), persInfo.getFamilyName());
+ assertEquals("givenName", eidasDataFirst.getGivenName(), persInfo.getGivenName());
+ assertEquals("placeOfBirth", "Hintergigritzpotschn", persInfo.getPlaceOfBirth());
+ assertEquals("birthName", "XXXvon Heuburg", persInfo.getBirthName());
+ assertEquals("num. stored eIDAS identifiers", 2, persInfo.getPseudonym().size());
+ assertEquals("stored eIDAS identifiers", "7cEYWithDEElementsasdfsafsaf4CDVzNT4E7cjkU4VqForjUnit",
+ persInfo.getPseudonym().get(0));
+ assertEquals("stored eIDAS identifiers",
+ "7cEYWithDEElementsasdfsafsaf4CDVzNT4E7cjkU4VqForjUnit_second_one",
+ persInfo.getPseudonym().get(1));
+
+ // validate request
+ assertEquals("wrong number of req.", 1, zmrReq.getAllValues().size());
+ assertNotNull("Personensuche req.", zmrReq.getValue().getPersonSuchenRequest());
+ checkBasicRequestParameters(zmrReq.getValue(), PROCESS_TASK_SEARCH, processId, "jUnit123456");
+ PersonSuchenRequest pSuche = zmrReq.getValue().getPersonSuchenRequest();
+ assertEquals("req. Municipality", addressInfo.getMunicipality(), pSuche.getPostAdresse().getGemeinde());
+ assertEquals("req. Postleitzahl", addressInfo.getPostleitzahl(), pSuche.getPostAdresse().getPostleitzahl());
+ assertNull("req. Village", pSuche.getPostAdresse().getOrtschaft());
+ assertNull("req. Number", pSuche.getPostAdresse().getZustelladresse());
+
+ }
+
+
+ @Test
+ @SneakyThrows
public void updateProcessNoLatestVersionResult() {
BigInteger processId = new BigInteger(RandomStringUtils.randomNumeric(6));
@@ -978,7 +1141,7 @@ public class ZmrClientTest {
return req;
}
-
+
private void addIfAvailable(List<EidasSuchdatenType> eidasSuchdaten,
String cc, String attrName, String attrValue) {
if (StringUtils.isNotEmpty(attrValue)) {