aboutsummaryrefslogtreecommitdiff
path: root/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/clients/ZmrClientTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/clients/ZmrClientTest.java')
-rw-r--r--modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/clients/ZmrClientTest.java158
1 files changed, 158 insertions, 0 deletions
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