diff options
Diffstat (limited to 'eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/clients/ZmrClientProductionTest.java')
-rw-r--r-- | eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/clients/ZmrClientProductionTest.java | 478 |
1 files changed, 478 insertions, 0 deletions
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 new file mode 100644 index 00000000..97ea5bfa --- /dev/null +++ b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/clients/ZmrClientProductionTest.java @@ -0,0 +1,478 @@ +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.Ignore; +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) +@ContextConfiguration(locations = { + "/SpringTest-context_tasks_test.xml", + "/SpringTest-context_basic_realConfig.xml" }) +@TestPropertySource(locations = { + // "classpath:/application.properties", + "file:/home/tlenz/Projekte/config/ms_connector/default_config.properties", +}) +public class ZmrClientProductionTest { + + @Autowired + ZmrSoapClient client; + @Autowired + IConfiguration basicConfig; + + @BeforeClass + public static void classInitializer() { + final Logger logger1 = (Logger) LoggerFactory.getLogger(LoggingHandler.class); + logger1.setLevel(Level.TRACE); + + final Logger logger2 = (Logger) LoggerFactory.getLogger(ZmrSoapClient.class); + logger2.setLevel(Level.TRACE); + + final Logger rootLogger = (Logger) LoggerFactory.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME); + rootLogger.setLevel(Level.INFO); + + } + + @Ignore + @Test + public void searchWithMdsOnly() throws EidasSAuthenticationException { + + final 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 { + + final 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()); + + } + + /* + * Ignore this test because "javier", "Garcia", "1964-12-31", "EE" is used as test-identity + * in test-country on vidp.gv.at. vidp.gv.at uses Test-SZR, but Test-SZR is connected to + * Q-ZMR and Q-ERnP. There is a staging problem because this test uses T-ZMR and T-ERnP. + */ + @Ignore + @Test + public void searchWithMdsOnlyEidasIdentity() throws EidasSAuthenticationException { + + final ZmrRegisterResult result = client.searchWithMds(null, + "javier", "Garcia", "1964-12-31", + "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 searchWithCountrySpecificsNoExits() throws EidasSAuthenticationException { + final 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 searchWithCountrySpecificsWithPersonalId() throws EidasSAuthenticationException { + final ZmrRegisterResult result = client.searchCountrySpecific(null, + generateCustomRequest("EE", "Lenz", "Thomas", "1982-09-06", + "7cEYSvKZvon+V4CDVzNT4E7cjkU4Vq", + null, + null), + "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 searchWithPersonalIdOnlyNoExisting() throws EidasSAuthenticationException { + + final 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 { + final String personalIdentifier = "7cEYSvKZvon+V4CDVzNT4E7cjkU4Vq"; + final String cc = "EE"; + + final SimpleEidasData eidasData = SimpleEidasData.builder() + .citizenCountryCode(cc) + .familyName("Lenz") + .givenName("Thomas") + .dateOfBirth("1982-09-06") + .personalIdentifier(cc + "/AT/" + personalIdentifier) + .pseudonym(personalIdentifier) + .build(); + + // get initial result + final 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 + final ZmrRegisterResult updateResult = + client.update(result.getProcessId(), + result.getPersonResult().get(0), + eidasData); + + assertNotNull("ZMR response", updateResult); + assertEquals("personResult size", 1, updateResult.getPersonResult().size()); + + final ZmrRegisterResult afterUpdateResult = client.searchWithPersonIdentifier(null, + personalIdentifier, cc); + + assertNotNull("ZMR response", afterUpdateResult); + assertEquals("personResult size", 1, afterUpdateResult.getPersonResult().size()); + + } + + @Ignore + @Test + public void updateZmrEntryTestIdentity() throws EidasSAuthenticationException { + final String personalIdentifier = "7cEYSvKZasdfsafsaf4CDVzNT4E7cjkU4Vq"; + final String cc = "EE"; + + final SimpleEidasData eidasData = SimpleEidasData.builder() + .citizenCountryCode(cc) + .familyName("XXXÖhlinger") + .givenName("XXXHildegard") + .dateOfBirth("1971-02-18") + .personalIdentifier(cc + "/AT/" + personalIdentifier) + .pseudonym(personalIdentifier) + .build(); + + // get initial result + final 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 + final ZmrRegisterResult updateResult = + client.update(result.getProcessId(), + result.getPersonResult().get(0), + eidasData); + + assertNotNull("ZMR response", updateResult); + assertEquals("personResult size", 1, updateResult.getPersonResult().size()); + + + final ZmrRegisterResult afterUpdateResultMds = client.searchCountrySpecific(null, + generateCustomRequest("EE", "XXXHildegard", "XXXÖhlinger", "1971-02-18", + "7cEYSvKZasdfsafsaf4CDVzNT4E7cjkU4Vq", + null, + null), + cc); + + assertNotNull("ZMR response", afterUpdateResultMds); + assertNotNull("ZMR processId", afterUpdateResultMds.getProcessId()); + assertNotNull("ZMR personResult", afterUpdateResultMds.getPersonResult()); + assertEquals("personResult size", 1, afterUpdateResultMds.getPersonResult().size()); + + + // check if ZMR entry can be found by PersonalId + final ZmrRegisterResult afterUpdateResult = client.searchWithPersonIdentifier(null, + personalIdentifier, cc); + + assertNotNull("ZMR response", afterUpdateResult); + assertEquals("personResult size", 1, afterUpdateResult.getPersonResult().size()); + + } + + @Test + public void updateZmrEntryDeSpecific() throws EidasSAuthenticationException { + 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) + .placeOfBirth("Hintergigritzpotschn") + .birthName("XXXvon Heuburg") + .build(); + + // first login with update + // get initial result + final ZmrRegisterResult result = client.searchWithMds(null, + eidasDataFirst.getGivenName(), + eidasDataFirst.getFamilyName(), + eidasDataFirst.getDateOfBirth(), + eidasDataFirst.getCitizenCountryCode()); + assertNotNull("ZMR response", result); + assertEquals("personResult size", 1, result.getPersonResult().size()); + + // update ZMR entry + final ZmrRegisterResult updateResult = + client.update(result.getProcessId(), + result.getPersonResult().get(0), + eidasDataFirst); + + assertNotNull("ZMR response", updateResult); + assertEquals("personResult size", 1, updateResult.getPersonResult().size()); + + // check if ZMR entry can be found by first PersonalId + final ZmrRegisterResult firstPersonalIdResult = client.searchWithPersonIdentifier(null, + personalIdentifierFirst, cc); + assertNotNull("ZMR response", firstPersonalIdResult); + assertEquals("first personResult size", 1, firstPersonalIdResult.getPersonResult().size()); + + + // check if ZMR entry is not found by valid pseudonym but wrong country + final ZmrRegisterResult wrongPersonalIdResult = client.searchWithPersonIdentifier(null, + personalIdentifierFirst, "ES"); + assertNotNull("ZMR response", wrongPersonalIdResult); + assertEquals("first personResult size", 0, wrongPersonalIdResult.getPersonResult().size()); + + + // search CC-specific with MDS + placeOfBirth + birthName + final ZmrRegisterResult ccSpecificFirstEntry = client.searchCountrySpecific(null, + generateCustomRequest( + eidasDataFirst.getCitizenCountryCode(), + eidasDataFirst.getFamilyName(), + eidasDataFirst.getGivenName(), + eidasDataFirst.getDateOfBirth(), + null, + eidasDataFirst.getPlaceOfBirth(), + eidasDataFirst.getBirthName()), + cc); + + assertNotNull("ZMR response", ccSpecificFirstEntry); + assertNotNull("ZMR processId", ccSpecificFirstEntry.getProcessId()); + assertNotNull("ZMR personResult", ccSpecificFirstEntry.getPersonResult()); + assertEquals("personResult size", 1, ccSpecificFirstEntry.getPersonResult().size()); + + } + + @Test + public void updateZmrEntryTestIdentity2() throws EidasSAuthenticationException { + final String personalIdentifierFirst = "7cEYSvKZasdfsafsaf4CDVzNT4E7cjkU4Vq_first"; + final String personalIdentifierSecond = "7cEYSvKZasdfsafsaf4CDVzNT4E7cjkU4Vq_second"; + final String cc = "EE"; + + final SimpleEidasData eidasDataFirst = SimpleEidasData.builder() + .citizenCountryCode(cc) + .familyName("XXXTüzekçi") + .givenName("XXXŐzgür") + .dateOfBirth("1983-06-04") + .personalIdentifier(cc + "/AT/" + personalIdentifierFirst) + .pseudonym(personalIdentifierFirst) + .build(); + + final SimpleEidasData eidasDataSecond = SimpleEidasData.builder() + .citizenCountryCode(cc) + .familyName("XXXTüzekçi") + .givenName("XXXŐzgür") + .dateOfBirth("1983-06-04") + .personalIdentifier(cc + "/AT/" + personalIdentifierSecond) + .pseudonym(personalIdentifierSecond) + .build(); + + + // first login with update + // get initial result + final ZmrRegisterResult result = client.searchWithMds(null, + eidasDataFirst.getGivenName(), + eidasDataFirst.getFamilyName(), + eidasDataFirst.getDateOfBirth(), + eidasDataFirst.getCitizenCountryCode()); + assertNotNull("ZMR response", result); + assertEquals("personResult size", 1, result.getPersonResult().size()); + + // update ZMR entry + final ZmrRegisterResult updateResult = + client.update(result.getProcessId(), + result.getPersonResult().get(0), + eidasDataFirst); + + assertNotNull("ZMR response", updateResult); + assertEquals("personResult size", 1, updateResult.getPersonResult().size()); + + + // second login with update + // get initial result + final ZmrRegisterResult resultSecond = client.searchWithMds(null, + eidasDataSecond.getGivenName(), + eidasDataSecond.getFamilyName(), + eidasDataSecond.getDateOfBirth(), + eidasDataSecond.getCitizenCountryCode()); + assertNotNull("ZMR response", resultSecond); + assertEquals("personResult size", 1, resultSecond.getPersonResult().size()); + + // update ZMR entry + final ZmrRegisterResult updateResultSecond = + client.update(resultSecond.getProcessId(), + resultSecond.getPersonResult().get(0), + eidasDataSecond); + + assertNotNull("ZMR response", updateResultSecond); + assertEquals("personResult size", 1, updateResultSecond.getPersonResult().size()); + + + // check if ZMR entry can be found by first PersonalId + final ZmrRegisterResult firstPersonalIdResult = client.searchWithPersonIdentifier(null, + personalIdentifierFirst, cc); + assertNotNull("ZMR response", firstPersonalIdResult); + assertEquals("first personResult size", 1, firstPersonalIdResult.getPersonResult().size()); + + // check if ZMR entry can be found by second PersonalId + final ZmrRegisterResult secondPersonalIdResult = client.searchWithPersonIdentifier(null, + personalIdentifierFirst, cc); + assertNotNull("ZMR response", secondPersonalIdResult); + assertEquals("second personResult size", 1, secondPersonalIdResult.getPersonResult().size()); + + + // search CC-specific with first MDS + final ZmrRegisterResult ccSpecificFirstEntry = client.searchCountrySpecific(null, + generateCustomRequest( + eidasDataFirst.getCitizenCountryCode(), + eidasDataFirst.getFamilyName(), + eidasDataFirst.getGivenName(), + eidasDataFirst.getDateOfBirth(), + eidasDataFirst.getPseudonym(), + null, + null), + cc); + + assertNotNull("ZMR response", ccSpecificFirstEntry); + assertNotNull("ZMR processId", ccSpecificFirstEntry.getProcessId()); + assertNotNull("ZMR personResult", ccSpecificFirstEntry.getPersonResult()); + assertEquals("personResult size", 1, ccSpecificFirstEntry.getPersonResult().size()); + + + // search CC-specific with second MDS + final ZmrRegisterResult ccSpecificSecondEntry = client.searchCountrySpecific(null, + generateCustomRequest( + eidasDataSecond.getCitizenCountryCode(), + eidasDataSecond.getFamilyName(), + eidasDataSecond.getGivenName(), + eidasDataSecond.getDateOfBirth(), + eidasDataSecond.getPseudonym(), + null, + null), + cc); + + assertNotNull("ZMR response", ccSpecificSecondEntry); + assertNotNull("ZMR processId", ccSpecificSecondEntry.getProcessId()); + assertNotNull("ZMR personResult", ccSpecificSecondEntry.getPersonResult()); + assertEquals("personResult size", 1, ccSpecificSecondEntry.getPersonResult().size()); + + + } + + + private PersonSuchenRequest generateCustomRequest(String cc, String familyName, String givenName, + String dateOfBirth, String personalId, String placeOfBirth, String birthName) { + final 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) { + final EidasSuchdatenType eidasInfos = new EidasSuchdatenType(); + eidasInfos.setStaatscode2(cc); + eidasInfos.setEidasArt(attrName); + eidasInfos.setEidasWert(attrValue); + return eidasInfos; + + } + +} |