diff options
Diffstat (limited to 'modules/authmodule-eIDAS-v2/src/test/java')
4 files changed, 351 insertions, 0 deletions
diff --git a/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/clients/ErnpRestClientProductionTest.java b/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/clients/ErnpRestClientProductionTest.java index 59cf4520..b834eb23 100644 --- a/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/clients/ErnpRestClientProductionTest.java +++ b/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/clients/ErnpRestClientProductionTest.java @@ -436,6 +436,74 @@ public class ErnpRestClientProductionTest { checkErnpResult(resp.getPersonResult().get(0), eidasDataFirst, 1); } + + @Test + @SneakyThrows + public void personWasWrongClosedByGovernment() { + final String personalIdentifierFirst = "eidasmatcherclosed19770707_01"; + final String cc = "XZ"; + final SimpleEidasData eidasDataFirst = SimpleEidasData.builder() + .citizenCountryCode(cc) + .familyName("EidasMatcher") + .givenName("Closed") + .dateOfBirth("1977-07-07") + .personalIdentifier(cc + "/AT/" + personalIdentifierFirst) + .pseudonym(personalIdentifierFirst) + .build(); + + // search with personalId + ErnpRegisterResult resp = client.searchWithPersonIdentifier(personalIdentifierFirst, cc); + + // validate state + assertNotNull("no ERnP response", resp); + assertEquals("wrong resp size", 1, resp.getPersonResult().size()); + //checkErnpResult(resp.getPersonResult().get(0), eidasDataFirst, 1); + + + // start update process + ErnpRegisterResult update = client.update(resp.getPersonResult().get(0), eidasDataFirst); + + // validate state + assertNotNull("no ERnP response", update); + assertEquals("wrong resp size", 1, update.getPersonResult().size()); + checkErnpResult(update.getPersonResult().get(0), eidasDataFirst, 1); + + } + + + @Test + @SneakyThrows + public void personWasClosedByGovernment() { + final String personalIdentifierFirst = "eidasmatcherclosed19740404_01"; + final String cc = "XZ"; + final SimpleEidasData eidasDataFirst = SimpleEidasData.builder() + .citizenCountryCode(cc) + .familyName("EidasMatcher") + .givenName("Closed") + .dateOfBirth("1974-04-04") + .personalIdentifier(cc + "/AT/" + personalIdentifierFirst) + .pseudonym(personalIdentifierFirst) + .build(); + + // search with personalId + ErnpRegisterResult respPersonal = client.searchWithPersonIdentifier(personalIdentifierFirst, cc); + + // search with mds + ErnpRegisterResult respMds = client.searchWithMds(eidasDataFirst.getGivenName(), + eidasDataFirst.getFamilyName(), eidasDataFirst.getDateOfBirth(), cc); + + + // validate state + assertNotNull("no ERnP response", respPersonal); + assertEquals("wrong resp size", 1, respPersonal.getPersonResult().size()); + //checkErnpResult(resp.getPersonResult().get(0), eidasDataFirst, 1); + + + assertNotNull("no ERnP response", respMds); + assertEquals("wrong resp size", 1, respMds.getPersonResult().size()); + + } + @Test @SneakyThrows diff --git a/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/clients/ErnpRestClientTest.java b/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/clients/ErnpRestClientTest.java index a9e10de6..9404b5a5 100644 --- a/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/clients/ErnpRestClientTest.java +++ b/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/clients/ErnpRestClientTest.java @@ -296,6 +296,31 @@ public class ErnpRestClientTest { @Test @SneakyThrows + public void searchWithMdsMultiResultAndClosedEntry() { + final String cc = "CZ"; + final SimpleEidasData eidasDataFirst = generateRandomEidasData(cc); + + // set ERnP response + mockWebServer.enqueue(new MockResponse().setResponseCode(200) + .setBody(IOUtils.toString( + ErnpRestClientTest.class.getResourceAsStream("/data/ernp/5_search_with_mds_multi_with_closed_resp.json"), + "UTF-8")) + .setHeader("Content-Type", "application/json;charset=utf-8")); + + // execute operation + ErnpRegisterResult resp = client.searchWithMds(eidasDataFirst.getGivenName(), eidasDataFirst.getFamilyName(), eidasDataFirst.getDateOfBirth(), cc); + + // validate state + mockWebServer.takeRequest(); + assertNotNull("no ERnP response", resp); + assertEquals("wrong resp size", 2, resp.getPersonResult().size()); + + } + + + + @Test + @SneakyThrows public void searchWithPersonalIdNoResponse() { final String cc = "CZ"; final SimpleEidasData eidasDataFirst = generateRandomEidasData(cc); @@ -366,6 +391,52 @@ public class ErnpRestClientTest { @Test @SneakyThrows + public void searchWithPersonalIdGetClosedEntry() { + final String cc = "XZ"; + final SimpleEidasData eidasDataFirst = generateRandomEidasData(cc); + + // set ERnP response + mockWebServer.enqueue(new MockResponse().setResponseCode(200) + .setBody(IOUtils.toString( + ErnpRestClientTest.class.getResourceAsStream( + "/data/ernp/1_search_with_personalId_closed_entry_resp.json"), + "UTF-8")) + .setHeader("Content-Type", "application/json;charset=utf-8")); + + // execute operation + EidasSAuthenticationException error = assertThrows("wrong Exception", EidasSAuthenticationException.class, + () -> client.searchWithPersonIdentifier(eidasDataFirst.getPseudonym(), cc)); + assertEquals("wrong errorCode", "module.eidasauth.matching.03", error.getErrorId()); + mockWebServer.takeRequest(); + + } + + @Test + @SneakyThrows + public void searchWithPersonalIdNotYetClosed() { + final String cc = "DE"; + final SimpleEidasData eidasDataFirst = generateRandomEidasData(cc); + + // set ERnP response + mockWebServer.enqueue(new MockResponse().setResponseCode(200) + .setBody(IOUtils.toString( + ErnpRestClientTest.class.getResourceAsStream( + "/data/ernp/1_search_with_personalId_not_yet_closed_entry_resp.json"), + "UTF-8")) + .setHeader("Content-Type", "application/json;charset=utf-8")); + + // execute operation + ErnpRegisterResult resp = client.searchWithPersonIdentifier(eidasDataFirst.getPseudonym(), cc); + + // validate state + mockWebServer.takeRequest(); + assertNotNull("no ERnP response", resp); + assertEquals("wrong resp size", 1, resp.getPersonResult().size()); + + } + + @Test + @SneakyThrows public void searchWithPersonalIdSingleResult() { final String cc = "DE"; final SimpleEidasData eidasDataFirst = generateRandomEidasData(cc); diff --git a/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/clients/ZmrClientProductionTest.java b/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/clients/ZmrClientProductionTest.java index af1867e7..0e45cb61 100644 --- a/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/clients/ZmrClientProductionTest.java +++ b/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/clients/ZmrClientProductionTest.java @@ -21,6 +21,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 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.SimpleEidasData; import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.EidasSAuthenticationException; import at.asitplus.eidas.specific.modules.auth.eidas.v2.utils.LoggingHandler; @@ -63,8 +64,45 @@ public class ZmrClientProductionTest { } + @Test + public void searchWithMdsOnlyEidasData() throws EidasSAuthenticationException { + + final ZmrRegisterResult result = client.searchWithMds(null, + "Ingun", "Walch", "1972-12-11", + "IT"); + + assertNotNull("ZMR response", result); + assertNotNull("ZMR processId", result.getProcessId()); + assertNotNull("ZMR personResult", result.getPersonResult()); + assertEquals("personResult size", 1, result.getPersonResult().size()); + + } + @Ignore @Test + public void searchWithRecidenceEidasData() throws EidasSAuthenticationException { + + AdresssucheOutput addressData = AdresssucheOutput.builder() +// .postleitzahl("1200") +// .street("Wallensteinstraße") +// .number("52") + .postleitzahl("1200") + .street("Wallensteinstraße") + .number("52") + .build(); + + final ZmrRegisterResult result = client.searchWithResidenceData( + null, "Ingun", "Walch", "1972-12-11", "IT", addressData); + + assertNotNull("ZMR response", result); + assertNotNull("ZMR processId", result.getProcessId()); + assertNotNull("ZMR personResult", result.getPersonResult()); + assertEquals("personResult size", 1, result.getPersonResult().size()); + + } + + + @Test public void searchWithMdsOnly() throws EidasSAuthenticationException { final ZmrRegisterResult result = client.searchWithMds(null, @@ -78,6 +116,22 @@ public class ZmrClientProductionTest { } + //@Ignore + @Test + public void searchWithPersonalIdentifier() throws EidasSAuthenticationException { + + final ZmrRegisterResult result = client.searchWithPersonIdentifier( + null, "7cEYSvKZvon+V4CDVzNT4E7cjkU4Vq", "EE"); + + assertNotNull("ZMR response", result); + assertNotNull("ZMR processId", result.getProcessId()); + assertNotNull("ZMR personResult", result.getPersonResult()); + assertEquals("personResult size", 1, result.getPersonResult().size()); + + } + + + @Test public void searchWithMdsOnlyTestIdentity() throws EidasSAuthenticationException { diff --git a/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/clients/ZmrClientTest.java b/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/clients/ZmrClientTest.java index ef9cc9b7..1f0ddb02 100644 --- a/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/clients/ZmrClientTest.java +++ b/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/clients/ZmrClientTest.java @@ -235,6 +235,70 @@ public class ZmrClientTest { } + @Test + @SneakyThrows + public void searchWithMdsWithClosedEntity() { + String familyName = RandomStringUtils.randomAlphabetic(10); + String givenName = RandomStringUtils.randomAlphabetic(10); + String dateOfBirth = RandomStringUtils.randomAlphabetic(10); + final String cc = "EE"; + + BigInteger processId = new BigInteger(RandomStringUtils.randomNumeric(6)); + + 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_closed_entity.xml")); + + // execute operation + ZmrRegisterResult resp = client.searchWithMds(processId, + givenName, familyName, dateOfBirth, cc); + + // validate state + assertNotNull("no ZMR response", resp); + assertEquals("wrong processId", "367100000000080", resp.getProcessId().toString()); + assertEquals("wrong resp size", 2, resp.getPersonResult().size()); + + // check first person + RegisterResult persInfo = resp.getPersonResult().get(0); + assertEquals("bPK", "9/MtsPZgBHQMBpQOD6aOY2TUqcY=", persInfo.getBpk()); + assertEquals("dateOfBirth", "1983-06-04", persInfo.getDateOfBirth()); + assertEquals("familyName", "XXXTüzekçi", persInfo.getFamilyName()); + assertEquals("givenName", "XXXŐzgür", persInfo.getGivenName()); + assertNull("placeOfBirth", persInfo.getPlaceOfBirth()); + assertNull("birthName", persInfo.getBirthName()); + assertEquals("num. stored eIDAS identifiers", 1, persInfo.getPseudonym().size()); + assertEquals("stored eIDAS identifiers", + "aabbcc_should_not_be_included_for_DE", persInfo.getPseudonym().get(0)); + + // check second person + RegisterResult persInfo2 = resp.getPersonResult().get(1); + assertEquals("bPK", "UgeknNsc26lVuB7U/uYGVmWtnnA=", persInfo2.getBpk()); + assertEquals("dateOfBirth", "1983-06-04", persInfo2.getDateOfBirth()); + assertEquals("familyName", "XXXTüzekçi", persInfo2.getFamilyName()); + assertEquals("givenName", "XXXŐzgür", persInfo2.getGivenName()); + assertEquals("num. stored eIDAS identifiers", 1, persInfo2.getPseudonym().size()); + assertEquals("stored eIDAS identifiers", + "7cEYSvKZasdfsafsaf4CDVzNT4E7cjkU4Vq_first", persInfo2.getPseudonym().get(0)); + + // 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()); + + assertEquals("eidas Docs. size", 0, pSuche.getEidasSuchdaten().size()); + 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()); + + } + + //TODO: test does not throw the valid exception to catch the error that we like to test. @Ignore @Test @@ -350,6 +414,58 @@ public class ZmrClientTest { @Test @SneakyThrows + public void searchWithPersonalIdentifierClosedEntry() { + final String personalIdentifierFirst = "7cEYWithDEElementsasdfsafsaf4CDVzNT4E7cjkU4VqForjUnit"; + final String cc = "DE"; + + 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_closed_entry.xml")); + + // execute operation + EidasSAuthenticationException error = assertThrows("wrong Exception", EidasSAuthenticationException.class, + () -> client.searchWithPersonIdentifier(null, personalIdentifierFirst, cc)); + + assertEquals("wrong errorCode", "module.eidasauth.matching.03", error.getErrorId()); + + } + + @Test + @SneakyThrows + public void searchWithPersonalIdentifierNotYetClosed() { + 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)); + + 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_closed_entry_future.xml")); + + // execute operation + ZmrRegisterResult resp = client.searchWithPersonIdentifier(processId, + eidasDataFirst.getPseudonym(), eidasDataFirst.getCitizenCountryCode()); + + // validate state + assertNotNull("no ZMR response", resp); + assertEquals("wrong resp size", 1, resp.getPersonResult().size()); + + } + + @Test + @SneakyThrows public void searchWithPersonalIdentifierSuccess() { final String personalIdentifierFirst = "7cEYWithDEElementsasdfsafsaf4CDVzNT4E7cjkU4VqForjUnit"; final String cc = "DE"; @@ -765,6 +881,48 @@ public class ZmrClientTest { } + @Test + @SneakyThrows + public void searchResidenceSuccessButClosedEntity() { + 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_closed_entry.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()); + + // we get zero results because address is found but entity was closed + assertEquals("wrong resp size", 0, resp.getPersonResult().size()); + + } @Test @SneakyThrows |