aboutsummaryrefslogtreecommitdiff
path: root/eidas_modules/authmodule-eIDAS-v2/src/test
diff options
context:
space:
mode:
authorThomas <>2022-02-07 11:17:42 +0100
committerThomas <>2022-02-08 09:37:25 +0100
commit1a442f77692a0438cc9d43be563b0ca965ff6c2b (patch)
tree805c291d420d1d7418a9144230f584521640ccb3 /eidas_modules/authmodule-eIDAS-v2/src/test
parent8c08120d543f4eba2b1d1480d6649f13c46e9ef0 (diff)
downloadNational_eIDAS_Gateway-1a442f77692a0438cc9d43be563b0ca965ff6c2b.tar.gz
National_eIDAS_Gateway-1a442f77692a0438cc9d43be563b0ca965ff6c2b.tar.bz2
National_eIDAS_Gateway-1a442f77692a0438cc9d43be563b0ca965ff6c2b.zip
refactor(szr): remove 'insertErnp' functionality from SZR client.
After this, the person is directly added into ERnP by using ErnpRestClient
Diffstat (limited to 'eidas_modules/authmodule-eIDAS-v2/src/test')
-rw-r--r--eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/clients/SzrClientProductionTest.java75
-rw-r--r--eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/clients/SzrClientTest.java91
-rw-r--r--eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/CreateIdentityLinkTaskEidNewTest.java71
-rw-r--r--eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/CreateIdentityLinkTaskTest.java10
4 files changed, 46 insertions, 201 deletions
diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/clients/SzrClientProductionTest.java b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/clients/SzrClientProductionTest.java
index a5b83b13..fb52a729 100644
--- a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/clients/SzrClientProductionTest.java
+++ b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/clients/SzrClientProductionTest.java
@@ -23,16 +23,8 @@
package at.asitplus.eidas.specific.modules.auth.eidas.v2.test.clients;
-import at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants;
-import at.asitplus.eidas.specific.modules.auth.eidas.v2.clients.szr.SzrClient;
-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.exception.SzrCommunicationException;
-import at.gv.egiz.eaaf.core.api.data.EaafConstants;
-import at.gv.egiz.eaaf.core.api.idp.IConfiguration;
-import at.gv.egiz.eaaf.core.api.idp.auth.data.IIdentityLink;
-import at.gv.egiz.eaaf.core.exceptions.EaafParserException;
-import at.gv.egiz.eaaf.core.impl.idp.auth.data.SimpleIdentityLinkAssertionParser;
+import java.util.List;
+
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.StringUtils;
import org.bouncycastle.util.encoders.Base64;
@@ -47,10 +39,14 @@ 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 org.w3c.dom.Element;
-import szrservices.IdentityLinkType;
-import java.util.List;
+import at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants;
+import at.asitplus.eidas.specific.modules.auth.eidas.v2.clients.szr.SzrClient;
+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.exception.SzrCommunicationException;
+import at.gv.egiz.eaaf.core.api.data.EaafConstants;
+import at.gv.egiz.eaaf.core.api.idp.IConfiguration;
@IfProfileValue(name = "spring.profiles.active", value = "devEnvironment")
@@ -78,13 +74,6 @@ public class SzrClientProductionTest {
}
@Test
- public void getVsz() throws EidasSAuthenticationException {
- String vsz = szrClient.getEncryptedStammzahl(getEidData());
- Assert.assertNotNull("vsz", vsz);
-
- }
-
- @Test
public void getEidasBind() throws EidasSAuthenticationException {
String vsz = RandomStringUtils.randomAlphanumeric(10);
String bindingPubKey = Base64.toBase64String(RandomStringUtils.random(20).getBytes());
@@ -96,52 +85,6 @@ public class SzrClientProductionTest {
}
-
- @Test
- public void getIdentityLinkRawMode() throws EaafParserException, EidasSAuthenticationException {
- log.debug("Starting connecting SZR Gateway");
- final IdentityLinkType result = szrClient.getIdentityLinkInRawMode(getEidData());
-
- final Element idlFromSzr = (Element) result.getAssertion();
- final IIdentityLink identityLink = new SimpleIdentityLinkAssertionParser(idlFromSzr).parseIdentityLink();
-
- if (identityLink == null) {
- throw new SzrCommunicationException("ernb.00", new Object[] { "NO IDL object" });
- }
-
- System.out.println(identityLink.getSerializedSamlAssertion());
-
- if (StringUtils.isEmpty(identityLink.getFamilyName())) {
- throw new SzrCommunicationException("ernb.00", new Object[] { "NO FamilyName from IDL" });
- }
-
- if (StringUtils.isEmpty(identityLink.getGivenName())) {
- throw new SzrCommunicationException("ernb.00", new Object[] { "NO GivenName from IDL" });
- }
-
- if (StringUtils.isEmpty(identityLink.getDateOfBirth())) {
- throw new SzrCommunicationException("ernb.00", new Object[] { "NO DateOfBirthName from IDL" });
- }
-
- if (StringUtils.isEmpty(identityLink.getIdentificationType())) {
- throw new SzrCommunicationException("ernb.00", new Object[] { "NO baseIdType from IDL" });
- }
-
- if (StringUtils.isEmpty(identityLink.getIdentificationValue())) {
- throw new SzrCommunicationException("ernb.00", new Object[] { "NO baseId from IDL" });
- }
-
- if (StringUtils.isEmpty(identityLink.getSerializedSamlAssertion())) {
- throw new SzrCommunicationException("ernb.00", new Object[] { "NO serialized IDL" });
- }
-
- if (identityLink.getSamlAssertion() == null) {
- throw new SzrCommunicationException("ernb.00", new Object[] { "NO raw IDL" });
- }
-
- }
-
-
@Ignore
@Test
public void getBpkTest() throws EidasSAuthenticationException {
diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/clients/SzrClientTest.java b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/clients/SzrClientTest.java
index ee1ecf9f..c47c4fb0 100644
--- a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/clients/SzrClientTest.java
+++ b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/clients/SzrClientTest.java
@@ -34,7 +34,6 @@ import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.ws.soap.SOAPFaultException;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.RandomStringUtils;
@@ -63,15 +62,9 @@ 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.exception.SzrCommunicationException;
import at.gv.egiz.eaaf.core.api.data.EaafConstants;
-import at.gv.egiz.eaaf.core.api.idp.auth.data.IIdentityLink;
-import at.gv.egiz.eaaf.core.exceptions.EaafParserException;
-import at.gv.egiz.eaaf.core.impl.idp.auth.data.SimpleIdentityLinkAssertionParser;
import at.gv.egiz.eaaf.core.impl.utils.DomUtils;
import lombok.extern.slf4j.Slf4j;
-import szrservices.GetBPKFromStammzahlEncryptedResponse;
-import szrservices.GetBPKFromStammzahlEncryptedResponseType;
import szrservices.GetIdentityLinkEidasResponse;
-import szrservices.IdentityLinkType;
import szrservices.PersonInfoType;
import szrservices.SZR;
import szrservices.SZRException_Exception;
@@ -110,33 +103,6 @@ public class SzrClientTest {
}
-
-
-
- @Test
- public void getStammzahlenEcryptedTest() throws SZRException_Exception, SzrCommunicationException {
- final GetBPKFromStammzahlEncryptedResponse szrResponse = new GetBPKFromStammzahlEncryptedResponse();
- final GetBPKFromStammzahlEncryptedResponseType result1 = new GetBPKFromStammzahlEncryptedResponseType();
- szrResponse.getOut().add(result1);
-
- result1.setKey(RandomStringUtils.randomAlphanumeric(20));
-
- // when(szrMock.getBPKFromStammzahlEncrypted(anyList()))
- // .thenReturn(Arrays.asList(result1));
- when(szrMock.getStammzahlEncrypted(any(), any())).thenReturn(result1.getKey());
-
- String stammzahlEncrypted = szrClient.getEncryptedStammzahl(getEidData());
-
- Assert.assertEquals("bcBind not match", result1.getKey(), stammzahlEncrypted);
-
- when(szrMock.getStammzahlEncrypted(any(), any())).thenReturn(null);
- try {
- szrClient.getEncryptedStammzahl(getEidData());
- } catch (SzrCommunicationException e) {
- Assert.assertTrue("Not correct error", e.getMessage().contains("ernb.01"));
- }
- }
-
@Test
public void getEidasBindRealSzrResponse() throws SZRException_Exception, SzrCommunicationException, IOException {
final SignContentResponse szrResponse = new SignContentResponse();
@@ -254,63 +220,6 @@ public class SzrClientTest {
}
- @Test
- public void getIdentityLinkRawModeValidResponse()
- throws SZRException_Exception, EaafParserException, JAXBException {
- setSzrResponseIdentityLink("/data/szr/szr_resp_valid_1.xml");
-
- try {
- log.debug("Starting connecting SZR Gateway");
- final IdentityLinkType result = szrClient.getIdentityLinkInRawMode(getEidData());
-
- Assert.assertNotNull(result);
- Assert.assertNotNull(result.getAssertion());
-
- final IIdentityLink identityLink = new SimpleIdentityLinkAssertionParser((Element) result.getAssertion())
- .parseIdentityLink();
- Assert.assertNotNull(identityLink);
-
- System.out.println(identityLink.getSerializedSamlAssertion());
-
- checkElement("Mustermann", identityLink.getFamilyName());
- checkElement("Hans", identityLink.getGivenName());
- checkElement("1989-05-05", identityLink.getDateOfBirth());
- checkElement("urn:publicid:gv.at:baseid", identityLink.getIdentificationType());
- checkElement("k+zDM1BVpN1WJO4x7ZQ3ng==", identityLink.getIdentificationValue());
- Assert.assertNotNull(identityLink.getSerializedSamlAssertion());
- Assert.assertNotNull(identityLink.getSamlAssertion());
-
- } catch (final SzrCommunicationException e) {
- Assert.fail();
-
- }
-
- }
-
- @Test
- public void getIdentityLinkRawModeErrorTravelerDocExists()
- throws SZRException_Exception, IOException, ParserConfigurationException, SAXException {
- setSzrExceptionIdentityLink("/data/szr/szr_resp_error_travelerdocexists.xml");
-
- try {
- log.debug("Starting connecting SZR Gateway");
- szrClient.getIdentityLinkInRawMode(getEidData());
- Assert.fail();
-
- } catch (final SzrCommunicationException e) {
- checkElement("ernb.02", e.getErrorId());
- Assert.assertNotNull(e.getCause());
- org.springframework.util.Assert.isInstanceOf(SOAPFaultException.class, e.getCause());
- Assert.assertNotNull(((SOAPFaultException) e.getCause()).getFault());
- checkElement("p344:F455", ((SOAPFaultException) e.getCause()).getFault().getFaultCode());
- checkElement(
- "The travel document you sent to insert a person already exists for another person. " + "Either check the document or have the person altered accordingly",
- ((SOAPFaultException) e.getCause()).getFault().getFaultString());
-
- }
-
- }
-
@Ignore
@Test
public void getBpkTest() throws EidasSAuthenticationException {
diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/CreateIdentityLinkTaskEidNewTest.java b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/CreateIdentityLinkTaskEidNewTest.java
index e3757c0d..14ace0b8 100644
--- a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/CreateIdentityLinkTaskEidNewTest.java
+++ b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/CreateIdentityLinkTaskEidNewTest.java
@@ -133,6 +133,7 @@ public class CreateIdentityLinkTaskEidNewTest {
private static ObjectMapper mapper = new ObjectMapper();
private AuthenticationResponse response;
+ private MatchedPersonResult matchingInfos;
@Rule
public final SoapServiceRule soap = SoapServiceRule.newInstance();
@@ -168,7 +169,14 @@ public class CreateIdentityLinkTaskEidNewTest {
final SimpleEidasData eidData = eidPostProcessor.postProcess(eidasAttributes);
MatchingTaskUtils.storeInitialEidasData(pendingReq, eidData);
- MatchingTaskUtils.storeFinalMatchingResult(pendingReq, null);
+ matchingInfos = MatchedPersonResult.builder()
+ .bpk(RandomStringUtils.randomAlphabetic(5))
+ .givenName(eidData.getGivenName())
+ .familyName(eidData.getFamilyName())
+ .dateOfBirth(eidData.getDateOfBirth())
+ .countryCode(eidData.getCitizenCountryCode())
+ .build();
+ MatchingTaskUtils.storeFinalMatchingResult(pendingReq, matchingInfos);
pendingReq.setSpConfig(oaParam);
pendingReq.setPendingReqId(at.gv.egiz.eaaf.core.impl.utils.Random.nextProcessReferenceValue());
@@ -187,9 +195,19 @@ public class CreateIdentityLinkTaskEidNewTest {
//initialize test
response = buildDummyAuthResponse(true);
pendingReq.getSessionData(AuthProcessDataWrapper.class)
- .setGenericDataToSession(Constants.DATA_FULL_EIDAS_RESPONSE, response);
- MatchingTaskUtils.storeInitialEidasData(pendingReq, eidPostProcessor.postProcess(
- convertEidasAttrToSimpleMap(response.getAttributes().getAttributeMap())));
+ .setGenericDataToSession(Constants.DATA_FULL_EIDAS_RESPONSE, response);
+ SimpleEidasData eidData = eidPostProcessor.postProcess(
+ convertEidasAttrToSimpleMap(response.getAttributes().getAttributeMap()));
+ MatchingTaskUtils.storeInitialEidasData(pendingReq, eidData);
+
+ matchingInfos = MatchedPersonResult.builder()
+ .bpk(RandomStringUtils.randomAlphabetic(5))
+ .givenName(eidData.getGivenName())
+ .familyName(eidData.getFamilyName())
+ .dateOfBirth(eidData.getDateOfBirth())
+ .countryCode(eidData.getCitizenCountryCode())
+ .build();
+ MatchingTaskUtils.storeFinalMatchingResult(pendingReq, matchingInfos);
String vsz = RandomStringUtils.randomNumeric(10);
when(szrMock.getStammzahlEncrypted(any(), any())).thenReturn(vsz);
@@ -251,7 +269,7 @@ public class CreateIdentityLinkTaskEidNewTest {
verify(szrMock, times(1)).getStammzahlEncrypted(argument4.capture(), argument5.capture());
Boolean param5 = argument5.getValue();
- Assert.assertTrue("insertERnP flag", param5);
+ Assert.assertFalse("insertERnP flag", param5);
PersonInfoType person = argument4.getValue();
Assert.assertEquals("FamilyName",
response.getAttributes().getAttributeValuesByFriendlyName("FamilyName").getFirstValue(
@@ -267,23 +285,9 @@ public class CreateIdentityLinkTaskEidNewTest {
.toString().split("T")[0],
person.getPerson().getDateOfBirth());
- Assert.assertEquals("PlaceOfBirth",
- response.getAttributes().getAttributeValuesByFriendlyName("PlaceOfBirth").getFirstValue(
- response.getAttributes().getDefinitionsByFriendlyName("PlaceOfBirth").iterator().next()),
- person.getPerson().getPlaceOfBirth());
- Assert.assertEquals("BirthName",
- response.getAttributes().getAttributeValuesByFriendlyName("BirthName").getFirstValue(
- response.getAttributes().getDefinitionsByFriendlyName("BirthName").iterator().next()),
- person.getPerson().getAlternativeName().getFamilyName());
-
- Assert.assertEquals("CitizenCountry", "LU", person.getTravelDocument().getIssuingCountry());
- Assert.assertEquals("DocumentType", "ELEKTR_DOKUMENT", person.getTravelDocument().getDocumentType());
-
- Assert.assertEquals("Identifier",
- response.getAttributes().getAttributeValuesByFriendlyName("PersonIdentifier").getFirstValue(
- response.getAttributes().getDefinitionsByFriendlyName("PersonIdentifier").iterator().next())
- .toString().split("/")[2],
- person.getTravelDocument().getDocumentNumber());
+ Assert.assertNull("PlaceOfBirth", person.getPerson().getPlaceOfBirth());
+ Assert.assertNull("BirthName", person.getPerson().getAlternativeName());
+ Assert.assertNull("TravelDocument", person.getTravelDocument());
// check bcBind singing request
ArgumentCaptor<Boolean> argument1 = ArgumentCaptor.forClass(Boolean.class);
@@ -336,20 +340,9 @@ public class CreateIdentityLinkTaskEidNewTest {
when(szrMock.signContent(any(), any(), any())).thenReturn(signContentResp);
-
String randomTestSp = RandomStringUtils.randomAlphabetic(10);
String bindingPubKey = RandomStringUtils.randomAlphabetic(10);
pendingReq.setRawDataToTransaction(MsEidasNodeConstants.DATA_REQUESTERID, randomTestSp);
-
- MatchedPersonResult matchingInfos = MatchedPersonResult.builder()
- .bpk(RandomStringUtils.randomAlphabetic(5))
- .givenName(RandomStringUtils.randomAlphabetic(5))
- .familyName(RandomStringUtils.randomAlphabetic(5))
- .dateOfBirth(RandomStringUtils.randomAlphabetic(5))
- .countryCode(RandomStringUtils.randomAlphabetic(2).toUpperCase())
- .build();
- MatchingTaskUtils.storeFinalMatchingResult(pendingReq, matchingInfos);
-
pendingReq.setRawDataToTransaction(MsEidasNodeConstants.EID_BINDING_PUBLIC_KEY_NAME, bindingPubKey);
@@ -467,7 +460,7 @@ public class CreateIdentityLinkTaskEidNewTest {
verify(szrMock, times(1)).getStammzahlEncrypted(argument4.capture(), argument5.capture());
Boolean param5 = argument5.getValue();
- Assert.assertTrue("insertERnP flag", param5);
+ Assert.assertFalse("insertERnP flag", param5);
PersonInfoType person = argument4.getValue();
Assert.assertEquals("FamilyName",
response.getAttributes().getAttributeValuesByFriendlyName("FamilyName").getFirstValue(
@@ -485,15 +478,7 @@ public class CreateIdentityLinkTaskEidNewTest {
Assert.assertNull("PlaceOfBirth", person.getPerson().getPlaceOfBirth());
Assert.assertNull("BirthName", person.getPerson().getAlternativeName());
-
- Assert.assertEquals("CitizenCountry", "LU", person.getTravelDocument().getIssuingCountry());
- Assert.assertEquals("DocumentType", "ELEKTR_DOKUMENT", person.getTravelDocument().getDocumentType());
-
- Assert.assertEquals("Identifier",
- response.getAttributes().getAttributeValuesByFriendlyName("PersonIdentifier").getFirstValue(
- response.getAttributes().getDefinitionsByFriendlyName("PersonIdentifier").iterator().next())
- .toString().split("/")[2],
- person.getTravelDocument().getDocumentNumber());
+ Assert.assertNull("TravelDocument", person.getTravelDocument());
}
diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/CreateIdentityLinkTaskTest.java b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/CreateIdentityLinkTaskTest.java
index 7513501e..8dc106f2 100644
--- a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/CreateIdentityLinkTaskTest.java
+++ b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/CreateIdentityLinkTaskTest.java
@@ -105,6 +105,7 @@ public class CreateIdentityLinkTaskTest {
private DummySpConfiguration oaParam;
private SZR szrMock;
+ private MatchedPersonResult matchingInfos;
private AuthenticationResponse response;
private Map<String, String> spConfig;
@@ -143,7 +144,14 @@ public class CreateIdentityLinkTaskTest {
pendingReq.getSessionData(AuthProcessDataWrapper.class)
.setGenericDataToSession(Constants.DATA_FULL_EIDAS_RESPONSE, response);
- MatchingTaskUtils.storeFinalMatchingResult(pendingReq, null);
+ matchingInfos = MatchedPersonResult.builder()
+ .bpk(RandomStringUtils.randomAlphabetic(5))
+ .givenName(eidData.getGivenName())
+ .familyName(eidData.getFamilyName())
+ .dateOfBirth(eidData.getDateOfBirth())
+ .countryCode(eidData.getCitizenCountryCode())
+ .build();
+ MatchingTaskUtils.storeFinalMatchingResult(pendingReq, matchingInfos);
pendingReq.setSpConfig(oaParam);
pendingReq.setPendingReqId(at.gv.egiz.eaaf.core.impl.utils.Random.nextProcessReferenceValue());