From 7e7291581ca59bb8f5c8fbf18dba37e0d262fa7a Mon Sep 17 00:00:00 2001 From: Thomas <> Date: Mon, 17 Oct 2022 14:44:34 +0200 Subject: feat(zmr): requesting latest version for ZMR update by using bPK only --- .../auth/eidas/v2/test/clients/ZmrClientTest.java | 108 +++++++++++++++++++++ 1 file changed, 108 insertions(+) (limited to 'modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific') 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 1f0ddb02..eb1e68ce 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 @@ -38,6 +38,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import com.github.skjolber.mockito.soap.SoapServiceRule; import at.asitplus.eidas.specific.core.test.config.dummy.MsConnectorDummyConfigMap; +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; @@ -102,6 +103,9 @@ public class ZmrClientTest { if (zmrMock == null) { zmrMock = soap.mock(ServicePort.class, "http://localhost:1234/demozmr"); } + + basicConfig.putConfigValue(Constants.CONIG_PROPS_EIDAS_ZMRCLIENT_UPDATE_WITH_BPK_ONLY, "false"); + } @Test @@ -1078,6 +1082,7 @@ public class ZmrClientTest { assertEquals("1 req. givenName", "urn:publicid:gv.at:cdid+ZP", pSuche.getNatuerlichePerson().getIdentification().get(0).getType()); assertNotNull("1 mds", pSuche.getNatuerlichePerson()); + assertEquals("1 req. givenName", toUpdate.getGivenName(), pSuche.getNatuerlichePerson().getPersonenName().getVorname()); assertEquals("1 req. familyName", toUpdate.getFamilyName(), @@ -1120,6 +1125,109 @@ public class ZmrClientTest { } + @Test + @SneakyThrows + public void updateProcessRequiredWithBpkOnly() { + BigInteger processId = new BigInteger(RandomStringUtils.randomNumeric(6)); + + basicConfig.putConfigValue(Constants.CONIG_PROPS_EIDAS_ZMRCLIENT_UPDATE_WITH_BPK_ONLY, "true"); + + final String personalIdentifier = "7cEYWithDEElementsasdfsafsaf4CDVzNT4E7cjkU4VqForjUnit"; + final String cc = "DE"; + final SimpleEidasData eidasData = SimpleEidasData.builder() + .citizenCountryCode(cc) + .familyName("XXXvon Brandenburg") + .givenName("XXXClaus - Maria") + .dateOfBirth("1994-12-31") + .personalIdentifier(cc + "/AT/" + personalIdentifier) + .pseudonym(personalIdentifier) + .birthName("XXXvon Heuburg") + .placeOfBirth("Hintergigritzpotschn") + .build(); + + RegisterResult toUpdate = RegisterResult.builder() + .bpk("UgeknNsc26lVuB7U/uYGVmWtnnA=") + .dateOfBirth("1994-12-31") + .familyName("XXXvon Brandenburg") + .givenName("XXXClaus - Maria") + //.birthName("") + //.placeOfBirth("") + //.pseudonym(Arrays.asList("")) + .build(); + + + final ArgumentCaptor zmrReq = ArgumentCaptor.forClass(RequestType.class); + + // inject response + when(zmrMock.service(zmrReq.capture(), any())) + .thenReturn(loadResponseFromFile("/data/zmr/seq_1-4_kitt_get_latest_version_resp.xml")) + .thenReturn(loadResponseFromFile("/data/zmr/seq_1-6_kitt_update_resp.xml")) + .thenThrow(new RuntimeException("Request not needed any more")); + + + // execute operation + ZmrRegisterResult resp = client.update(processId, toUpdate, eidasData); + + // validate request + assertEquals("wrong number of req.", 2, zmrReq.getAllValues().size()); + + // check get laterst version request + RequestType firstReq = zmrReq.getAllValues().get(0); + assertNotNull("1 req.", firstReq.getPersonSuchenRequest()); + checkBasicRequestParameters(firstReq , PROCESS_TASK_SEARCH, processId, "jUnit123456"); + PersonSuchenRequest pSuche = firstReq .getPersonSuchenRequest(); + checkSearchParameters(pSuche.getPersonensucheInfo()); + assertNull("1 req. ZMR Zahl", pSuche.getZMRZahl()); + assertEquals("1 req. identifier size", 1, + pSuche.getNatuerlichePerson().getIdentification().size()); + assertEquals("1 req. givenName", toUpdate.getBpk(), + pSuche.getNatuerlichePerson().getIdentification().get(0).getValue()); + assertEquals("1 req. givenName", "urn:publicid:gv.at:cdid+ZP", + pSuche.getNatuerlichePerson().getIdentification().get(0).getType()); + assertNotNull("1 mds", pSuche.getNatuerlichePerson()); + + assertNull("1 req. givenName", + pSuche.getNatuerlichePerson().getPersonenName().getVorname()); + assertNull("1 req. familyName", + pSuche.getNatuerlichePerson().getPersonenName().getFamilienname()); + assertNull("1 req. dateOfBirth", + pSuche.getNatuerlichePerson().getGeburtsdatum()); + + + // check update request + RequestType secondReq = zmrReq.getAllValues().get(1); + assertNotNull("2 req.", secondReq.getPersonAendernRequest()); + checkBasicRequestParameters(secondReq , PROCESS_TASK_UPDATE, processId, "jUnit123456"); + PersonAendernRequest secondpSuche = secondReq.getPersonAendernRequest(); + + assertEquals("2 req. ZMR Zahl", "000430320173", secondpSuche.getPersonReferenz().getZMRZahl()); + assertEquals("2 req. tech. Ref. value", "44453600000000697", + secondpSuche.getPersonReferenz().getTechnisch().getEntityID()); + assertEquals("2 req. tech. Ref. date", "2020-02-05T13:07:06.311", + secondpSuche.getPersonReferenz().getTechnisch().getLetzteAenderung().toString()); + + assertEquals("eidas Docs. size", 6, secondpSuche.getEidasIdentitaetAnlage().size()); + checkEidasDocumentAdd(secondpSuche.getEidasIdentitaetAnlage(), + "http://eidas.europa.eu/attributes/naturalperson/PlaceOfBirth", cc, eidasData.getPlaceOfBirth()); + checkEidasDocumentAdd(secondpSuche.getEidasIdentitaetAnlage(), + "http://eidas.europa.eu/attributes/naturalperson/BirthName", cc, eidasData.getBirthName()); + checkEidasDocumentAdd(secondpSuche.getEidasIdentitaetAnlage(), + "http://eidas.europa.eu/attributes/naturalperson/PersonIdentifier", cc, eidasData.getPseudonym()); + checkEidasDocumentAdd(secondpSuche.getEidasIdentitaetAnlage(), + "http://eidas.europa.eu/attributes/naturalperson/CurrentGivenName", cc, eidasData.getGivenName()); + checkEidasDocumentAdd(secondpSuche.getEidasIdentitaetAnlage(), + "http://eidas.europa.eu/attributes/naturalperson/CurrentFamilyName", cc, eidasData.getFamilyName()); + checkEidasDocumentAdd(secondpSuche.getEidasIdentitaetAnlage(), + "http://eidas.europa.eu/attributes/naturalperson/DateOfBirth", cc, eidasData.getDateOfBirth()); + + + // validate state + assertNotNull("no ZMR response", resp); + assertEquals("wrong processId", "366200000000082", resp.getProcessId().toString()); + assertEquals("wrong resp size", 1, resp.getPersonResult().size()); + + } + @Test @SneakyThrows public void updateProcessNoUpdateRequired() { -- cgit v1.2.3