diff options
author | Thomas <> | 2021-09-21 16:14:28 +0200 |
---|---|---|
committer | Thomas <> | 2021-09-21 16:14:28 +0200 |
commit | dfbd513a2cfefadc82bdc32fca171496332c13e2 (patch) | |
tree | ff8baff85e2da28f7577410376792e01f6614857 /eidas_modules/authmodule-eIDAS-v2 | |
parent | c33ea092652c44301db770f1db4a7243eb6b2363 (diff) | |
download | National_eIDAS_Gateway-dfbd513a2cfefadc82bdc32fca171496332c13e2.tar.gz National_eIDAS_Gateway-dfbd513a2cfefadc82bdc32fca171496332c13e2.tar.bz2 National_eIDAS_Gateway-dfbd513a2cfefadc82bdc32fca171496332c13e2.zip |
fix some bugs in ZMRClient that we found during first testing with ZMR T-Stage
Diffstat (limited to 'eidas_modules/authmodule-eIDAS-v2')
2 files changed, 178 insertions, 9 deletions
diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/clients/zmr/ZmrSoapClient.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/clients/zmr/ZmrSoapClient.java index baee2a58..0edfb357 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/clients/zmr/ZmrSoapClient.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/clients/zmr/ZmrSoapClient.java @@ -79,7 +79,7 @@ public class ZmrSoapClient extends AbstractSoapClient implements IZmrClient { private static final String LOGMSG_MISSING_CONFIG = "Missing configuration with key: {0}"; private static final String LOGMSG_ZMR_ERROR = - "Receive an error from ZMR during '{0}' operation with msg: {1}"; + "Receive an error from ZMR during '{}' operation with msg: {}"; private static final String LOGMSG_ZMR_RESP_PROCESS = "Proces ZMR response during '{}' operation failes with msg: {}"; @@ -94,7 +94,7 @@ public class ZmrSoapClient extends AbstractSoapClient implements IZmrClient { private static final String PROCESS_SEARCH_PERSONAL_IDENTIFIER = "Searching " + Constants.eIDAS_ATTR_PERSONALIDENTIFIER; private static final String PROCESS_SEARCH_MDS_ONLY = "Searching with MDS only"; - private static final String PROCESS_SEARCH_COUNTRY_SPECIFIC = "Searching {} specific"; + private static final String PROCESS_SEARCH_COUNTRY_SPECIFIC = "Searching {0} specific"; private static final String PROCESS_KITT_GENERAL = "KITT general-processing"; private static final String PROCESS_KITT_IDENITIES_GET = "KITT get-latest-version"; @@ -138,7 +138,8 @@ public class ZmrSoapClient extends AbstractSoapClient implements IZmrClient { req.setClientInfo(generateClientInfos()); // set additionl search parameters - searchPersonReq.setPersonensucheInfo(generateSearchCriteria(false, true, false)); + searchPersonReq.setPersonensucheInfo(generateSearchCriteria( + PROCESS_SEARCH_PERSONAL_IDENTIFIER, false, true, false)); // request ZMR log.trace("Requesting ZMR for '{}' operation", PROCESS_SEARCH_PERSONAL_IDENTIFIER); @@ -187,7 +188,8 @@ public class ZmrSoapClient extends AbstractSoapClient implements IZmrClient { req.setClientInfo(generateClientInfos()); // set additionl search parameters - searchPersonReq.setPersonensucheInfo(generateSearchCriteria(false, true, false)); + searchPersonReq.setPersonensucheInfo(generateSearchCriteria( + PROCESS_SEARCH_MDS_ONLY, false, true, false)); // request ZMR log.trace("Requesting ZMR for '{}' operation", PROCESS_SEARCH_MDS_ONLY); @@ -230,7 +232,7 @@ public class ZmrSoapClient extends AbstractSoapClient implements IZmrClient { req.setClientInfo(generateClientInfos()); // set additionl search parameters - personSearchDao.setPersonensucheInfo(generateSearchCriteria(false, true, false)); + personSearchDao.setPersonensucheInfo(generateSearchCriteria(friendlyMsg, false, true, false)); // request ZMR log.trace("Requesting ZMR for '{}' operation", friendlyMsg); @@ -395,11 +397,13 @@ public class ZmrSoapClient extends AbstractSoapClient implements IZmrClient { } @Nonnull - private PersonensucheInfoType generateSearchCriteria(boolean searchInErnp, + private PersonensucheInfoType generateSearchCriteria(String infoElement, boolean searchInErnp, boolean searchInZmrHistory, boolean includeHistoryResults) { final PersonensucheInfoType personSearchInfo = new PersonensucheInfoType(); final SuchkriterienType searchCriteria = new SuchkriterienType(); final ErgebniskriterienType resultCriteria = new ErgebniskriterienType(); + + personSearchInfo.setBezugsfeld(infoElement); personSearchInfo.setSuchkriterien(searchCriteria); personSearchInfo.setErgebniskriterien(resultCriteria); @@ -410,6 +414,9 @@ public class ZmrSoapClient extends AbstractSoapClient implements IZmrClient { // TODO: check 'processSearchPersonResponse' if we change this to 'true' resultCriteria.setInclusivHistorie(includeHistoryResults); + // TODO: are these flags valid? + personSearchInfo.setAnzahlSaetze(10); + return personSearchInfo; } @@ -639,11 +646,12 @@ public class ZmrSoapClient extends AbstractSoapClient implements IZmrClient { bpkInfo.setType(EaafConstants.URN_PREFIX_CDID + "ZP"); // set work-flow client information - req.setWorkflowInfoClient(generateWorkFlowInfos(PROCESS_TASK_UPDATE, zmrProzessId)); + req.setWorkflowInfoClient(generateWorkFlowInfos(PROCESS_TASK_SEARCH, zmrProzessId)); req.setClientInfo(generateClientInfos()); // set additionl search parameters - searchPersonReq.setPersonensucheInfo(generateSearchCriteria(false, true, false)); + searchPersonReq.setPersonensucheInfo(generateSearchCriteria( + PROCESS_KITT_IDENITIES_GET, false, true, false)); // request ZMR log.trace("Requesting ZMR for '{}' operation", PROCESS_KITT_IDENITIES_GET); diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/clients/ZmrClientProductionTest.java b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/clients/ZmrClientProductionTest.java index 5f3c5a55..8ac6fff6 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/clients/ZmrClientProductionTest.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/clients/ZmrClientProductionTest.java @@ -1,19 +1,35 @@ package at.asitplus.eidas.specific.modules.auth.eidas.v2.test.clients; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; +import java.util.List; + +import org.apache.commons.lang3.RandomStringUtils; +import org.apache.commons.lang3.StringUtils; +import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.annotation.IfProfileValue; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +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.dao.SimpleEidasData; import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.EidasSAuthenticationException; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.utils.LoggingHandler; +import at.gv.bmi.namespace.zmr_su.zmr._20040201.EidasSuchdatenType; +import at.gv.bmi.namespace.zmr_su.zmr._20040201.PersonSuchenRequest; +import at.gv.e_government.reference.namespace.persondata.de._20040201.NatuerlichePersonTyp; +import at.gv.e_government.reference.namespace.persondata.de._20040201.PersonenNameTyp; import at.gv.egiz.eaaf.core.api.idp.IConfiguration; +import ch.qos.logback.classic.Level; +import ch.qos.logback.classic.Logger; @IfProfileValue(name = "spring.profiles.active", value = "devEnvironment") @RunWith(SpringJUnit4ClassRunner.class) @@ -29,14 +45,159 @@ public class ZmrClientProductionTest { @Autowired ZmrSoapClient client; @Autowired IConfiguration basicConfig; + @BeforeClass + public static void classInitializer() { + Logger logger1 = (Logger) LoggerFactory.getLogger(LoggingHandler.class); + logger1.setLevel(Level.TRACE); + + Logger logger2 = (Logger) LoggerFactory.getLogger(ZmrSoapClient.class); + logger2.setLevel(Level.TRACE); + + Logger rootLogger = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME); + rootLogger.setLevel(Level.INFO); + + } + @Test - public void mdsSearch() throws EidasSAuthenticationException { + public void searchWithMdsOnly() throws EidasSAuthenticationException { ZmrRegisterResult result = client.searchWithMds(null, "Thomas", "Lenz", "1982-09-06", "AT"); 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 { + + ZmrRegisterResult result = client.searchWithMds(null, + "XXXHildegard", "XXXĂ–hlinger", "1971-02-18", + "AT"); + + assertNotNull("ZMR response", result); + assertNotNull("ZMR processId", result.getProcessId()); + assertNotNull("ZMR personResult", result.getPersonResult()); + assertEquals("personResult size", 1, result.getPersonResult().size()); + + } + + @Test + public void searchWithCountrySpecificsNoExits() throws EidasSAuthenticationException { + ZmrRegisterResult result = client.searchCountrySpecific(null, + generateCustomRequest("AT", "Lenz", "Thomas", "1982-09-06", + null, + RandomStringUtils.randomAlphabetic(5), + RandomStringUtils.randomAlphabetic(5)), + "AT"); + + assertNotNull("ZMR response", result); + assertNotNull("ZMR processId", result.getProcessId()); + assertNotNull("ZMR personResult", result.getPersonResult()); + assertEquals("personResult size", 0, result.getPersonResult().size()); + + } + + @Test + public void searchWithPersonalIdOnly() throws EidasSAuthenticationException { + + ZmrRegisterResult result = client.searchWithPersonIdentifier(null, + RandomStringUtils.randomAlphanumeric(25), + "AT"); + + assertNotNull("ZMR response", result); + assertNotNull("ZMR processId", result.getProcessId()); + assertNotNull("ZMR personResult", result.getPersonResult()); + assertEquals("personResult size", 0, result.getPersonResult().size()); + + } + + @Test + public void updateZmrEntry() throws EidasSAuthenticationException { + String personalIdentifier = "7cEYSvKZvon+V4CDVzNT4E7cjkU4Vq"; + String cc = "EE"; + + SimpleEidasData eidasData = SimpleEidasData.builder() + .citizenCountryCode(cc) + .familyName("Lenz") + .givenName("Thomas") + .dateOfBirth("1982-09-06") + .personalIdentifier(cc + "/AT/" + personalIdentifier) + .pseudonym(personalIdentifier) + .build(); + + // get initial result + ZmrRegisterResult result = client.searchWithMds(null, + eidasData.getGivenName(), + eidasData.getFamilyName(), + eidasData.getDateOfBirth(), + eidasData.getCitizenCountryCode()); + assertNotNull("ZMR response", result); + assertEquals("personResult size", 1, result.getPersonResult().size()); + + + //update ZMR entry + ZmrRegisterResult updateResult = + client.update(result.getProcessId(), + result.getPersonResult().get(0), + eidasData); + + assertNotNull("ZMR response", updateResult); + assertEquals("personResult size", 1, updateResult.getPersonResult().size()); + + + + ZmrRegisterResult afterUpdateResult = client.searchWithPersonIdentifier(null, + personalIdentifier, cc); + + assertNotNull("ZMR response", afterUpdateResult); + assertEquals("personResult size", 1, afterUpdateResult.getPersonResult().size()); + + + } + + + + private PersonSuchenRequest generateCustomRequest(String cc, String familyName, String givenName, + String dateOfBirth, String personalId, String placeOfBirth, String birthName) { + PersonSuchenRequest req = new PersonSuchenRequest(); + + //set basic MDS information + final NatuerlichePersonTyp searchNatPerson = new NatuerlichePersonTyp(); + req.setNatuerlichePerson(searchNatPerson); + final PersonenNameTyp searchNatPersonName = new PersonenNameTyp(); + searchNatPerson.setPersonenName(searchNatPersonName); + searchNatPersonName.setFamilienname(familyName); + searchNatPersonName.setVorname(givenName); + searchNatPerson.setGeburtsdatum(dateOfBirth); + + //add addtional eIDAS attributes if available + addIfAvailable(req.getEidasSuchdaten(), cc, Constants.eIDAS_ATTRURN_PLACEOFBIRTH, placeOfBirth); + addIfAvailable(req.getEidasSuchdaten(), cc, Constants.eIDAS_ATTRURN_BIRTHNAME, birthName); + addIfAvailable(req.getEidasSuchdaten(), cc, Constants.eIDAS_ATTRURN_PERSONALIDENTIFIER, personalId); + + return req; + + } + + private void addIfAvailable(List<EidasSuchdatenType> eidasSuchdaten, + String cc, String attrName, String attrValue) { + if (StringUtils.isNotEmpty(attrValue)) { + eidasSuchdaten.add(buildEidasSuchData(cc, attrName, attrValue)); + + } + } + + private EidasSuchdatenType buildEidasSuchData(String cc, String attrName, String attrValue) { + EidasSuchdatenType eidasInfos = new EidasSuchdatenType(); + eidasInfos.setStaatscode2(cc); + eidasInfos.setEidasArt(attrName); + eidasInfos.setEidasWert(attrValue); + return eidasInfos; } |