diff options
author | Thomas <> | 2022-10-07 17:13:27 +0200 |
---|---|---|
committer | Thomas <> | 2022-10-07 17:13:27 +0200 |
commit | 2491f68f97b8aa956a1f1e106fa2cf3540d8f86b (patch) | |
tree | c933bc073a11c43f39ef418b5e49e146c91c767f /modules/authmodule-eIDAS-v2/src/test | |
parent | 9da6640b1aa6ffd60866a6f34ea92f70ada1a3e6 (diff) | |
download | National_eIDAS_Gateway-2491f68f97b8aa956a1f1e106fa2cf3540d8f86b.tar.gz National_eIDAS_Gateway-2491f68f97b8aa956a1f1e106fa2cf3540d8f86b.tar.bz2 National_eIDAS_Gateway-2491f68f97b8aa956a1f1e106fa2cf3540d8f86b.zip |
fix(eIDAS-ERnP): eIDAS documents can by 'null' in ERnP response
Diffstat (limited to 'modules/authmodule-eIDAS-v2/src/test')
2 files changed, 94 insertions, 0 deletions
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 9404b5a5..93d8ab74 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 @@ -1054,6 +1054,67 @@ public class ErnpRestClientTest { } + @Test + @SneakyThrows + public void updateUpdateRequiredAnyEidasDocs() { + final String cc = "DE"; + final String personalIdentifierFirst = "nj1m79jm9z"; + final SimpleEidasData eidasDataFirst = SimpleEidasData.builder() + .citizenCountryCode(cc) + .familyName("mRjMKAQc") + .givenName("vdqZZIaA") + .dateOfBirth("1996-01-01") + .personalIdentifier(cc + "/AT/" + personalIdentifierFirst) + .pseudonym(personalIdentifierFirst) + .birthName(RandomStringUtils.randomAlphabetic(10)) + .build(); + + // set ERnP response + mockWebServer.enqueue(new MockResponse().setResponseCode(200) + .setBody(IOUtils.toString( + ErnpRestClientTest.class.getResourceAsStream("/data/ernp/2_kitt_search_latest_resp_no_eidas_docs.json"), + "UTF-8")) + .setHeader("Content-Type", "application/json;charset=utf-8")); + mockWebServer.enqueue(new MockResponse().setResponseCode(200) + .setBody(IOUtils.toString( + ErnpRestClientTest.class.getResourceAsStream("/data/ernp/2_kitt_update_resp.json"), + "UTF-8")) + .setHeader("Content-Type", "application/json;charset=utf-8")); + + RegisterResult ernpResult = RegisterResult.builder() + .familyName("mRjMKAQc") + .givenName("vdqZZIaA") + .dateOfBirth("1996-01-01") + .bpk("TBGoMlirU881e2jMGETa9WLx1+A=") + .pseudonym(Arrays.asList("88hvWzUaIX")) + .birthName("VRNCAylF") + .placeOfBirth("miEklFHC") + .build(); + + // execute operation + ErnpRegisterResult resp = client.update(ernpResult, eidasDataFirst); + + // validate request + // check get-latest-version request + mockWebServer.takeRequest(); + + // check update request + final RecordedRequest requestKitt = mockWebServer.takeRequest(); + String reqBodyKitt = requestKitt.getBody().readUtf8(); + assertFalse("no request body", reqBodyKitt.isEmpty()); + JsonNode reqJsonKitt = mapper.readTree(reqBodyKitt); + checkJsonElement(reqJsonKitt, "begruendung", "KITT update dataset"); + checkJsonElement(reqJsonKitt, "entityId", "1933000000000498"); + checkJsonElement(reqJsonKitt, "version", "2022-03-03T10:14:59.712Z"); + JsonNode personChange = getJsonObject(reqJsonKitt, "anlegen"); + checkEidasDocument(personChange, "http://eidas.europa.eu/attributes/naturalperson/PersonIdentifier", + cc, eidasDataFirst.getPseudonym()); + checkEidasDocument(personChange, "http://eidas.europa.eu/attributes/naturalperson/BirthName", + cc, eidasDataFirst.getBirthName()); + assertFalse("find 'aendern' element", reqJsonKitt.has("aendern")); + + } + private SimpleEidasData generateRandomEidasData(String cc) { final String personalIdentifierFirst = RandomStringUtils.randomAlphanumeric(10); diff --git a/modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/2_kitt_search_latest_resp_no_eidas_docs.json b/modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/2_kitt_search_latest_resp_no_eidas_docs.json new file mode 100644 index 00000000..c7131922 --- /dev/null +++ b/modules/authmodule-eIDAS-v2/src/test/resources/data/ernp/2_kitt_search_latest_resp_no_eidas_docs.json @@ -0,0 +1,33 @@ +{ + "person": [ + { + "type": "Person", + "entityId": "1933000000000498", + "gueltigAb": "2022-03-03T11:14:59.712+01:00", + "letzteOperation": { + "begruendung": "Add new person", + "durchgefuehrtVon": { + "behoerdenkennzeichen": "380630", + "benutzer": "eidtapp@bmi.gv.at" + }, + "vorgang": "PersonAnlegen", + "zeitpunkt": "2022-03-03T11:14:59.712+01:00" + }, + "personendaten": { + "basiszahl": "000951265372", + "bpkZp": "TBGoMlirU881e2jMGETa9WLx1+A=", + "entityId": "1933000000000498", + "familienname": "mRjMKAQc", + "geburtsdatum": { + "jahr": 1996, + "monat": 1, + "tag": 1 + }, + "geprueft": false, + "gueltigAb": "2022-03-03T11:14:59.712+01:00", + "vorname": "vdqZZIaA" + }, + "version": "2022-03-03T11:14:59.712+01:00" + } + ] +} |