aboutsummaryrefslogtreecommitdiff
path: root/modules/authmodule-eIDAS-v2/src/test/java
diff options
context:
space:
mode:
authorThomas <>2022-04-05 11:00:10 +0200
committerThomas <>2022-04-05 11:00:10 +0200
commitbc9eb2e62c863dae9fc9625cccb18ddfe4ff02d8 (patch)
tree7f01e64f0ede90908116f52419539d3dd9b96950 /modules/authmodule-eIDAS-v2/src/test/java
parent35bdf175478d1412ce39a7ce66f39ea26ead315c (diff)
parent9d1e1294c2825c6f9a422c9f9c51f9965258d19e (diff)
downloadNational_eIDAS_Gateway-bc9eb2e62c863dae9fc9625cccb18ddfe4ff02d8.tar.gz
National_eIDAS_Gateway-bc9eb2e62c863dae9fc9625cccb18ddfe4ff02d8.tar.bz2
National_eIDAS_Gateway-bc9eb2e62c863dae9fc9625cccb18ddfe4ff02d8.zip
Merge branch 'nightlybuild' into feature/matching_base
# Conflicts: # connector/pom.xml # connector/src/test/java/at/asitplus/eidas/specific/connector/test/FullStartUpAndProcessTest.java # modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/clients/szr/SzrClient.java # modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/CreateIdentityLinkTask.java # modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/SzrClientTestProduction.java # modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/CreateIdentityLinkTaskEidNewTest.java # pom.xml
Diffstat (limited to 'modules/authmodule-eIDAS-v2/src/test/java')
-rw-r--r--modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/CreateIdentityLinkTaskEidNewTest.java31
1 files changed, 27 insertions, 4 deletions
diff --git a/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/CreateIdentityLinkTaskEidNewTest.java b/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/CreateIdentityLinkTaskEidNewTest.java
index 44c2624e..bb4abfa2 100644
--- a/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/CreateIdentityLinkTaskEidNewTest.java
+++ b/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/CreateIdentityLinkTaskEidNewTest.java
@@ -18,6 +18,9 @@ import java.util.List;
import java.util.Map;
import javax.annotation.Nonnull;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Unmarshaller;
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.StringUtils;
@@ -86,9 +89,11 @@ import eu.eidas.auth.commons.attribute.ImmutableAttributeMap.Builder;
import eu.eidas.auth.commons.protocol.eidas.impl.PostalAddress;
import eu.eidas.auth.commons.protocol.impl.AuthenticationResponse;
import lombok.val;
+import szrservices.GetIdentityLinkEidasResponse;
import szrservices.JwsHeaderParam;
import szrservices.PersonInfoType;
import szrservices.SZR;
+import szrservices.SZRException_Exception;
import szrservices.SignContentEntry;
import szrservices.SignContentResponseType;
@@ -153,7 +158,7 @@ public class CreateIdentityLinkTaskEidNewTest {
RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(httpReq, httpResp));
basicConfig.putConfigValue("eidas.ms.auth.eIDAS.szrclient.debug.useDummySolution", "false");
-
+
final Map<String, String> spConfig = new HashMap<>();
spConfig.put(EaafConfigConstants.SERVICE_UNIQUEIDENTIFIER, "testSp");
spConfig.put("target", "urn:publicid:gv.at:cdid+XX");
@@ -197,6 +202,7 @@ public class CreateIdentityLinkTaskEidNewTest {
response = buildDummyAuthResponse(true);
pendingReq.getSessionData(AuthProcessDataWrapper.class)
.setGenericDataToSession(Constants.DATA_FULL_EIDAS_RESPONSE, response);
+
SimpleEidasData eidData = eidPostProcessor.postProcess(
convertEidasAttrToSimpleMap(response.getAttributes().getAttributeMap()));
MatchingTaskUtils.storeInitialEidasData(pendingReq, eidData);
@@ -329,6 +335,8 @@ public class CreateIdentityLinkTaskEidNewTest {
}
+
+
@Test
public void successfulProcessWithDataFromMatching() throws Exception {
//initialize test
@@ -480,15 +488,15 @@ public class CreateIdentityLinkTaskEidNewTest {
Assert.assertNull("PlaceOfBirth", person.getPerson().getPlaceOfBirth());
Assert.assertNull("BirthName", person.getPerson().getAlternativeName());
Assert.assertNull("TravelDocument", person.getTravelDocument());
-
-
+
}
-
+
@Test
public void getStammzahlEncryptedExceptionTest() throws Exception {
try {
when(szrMock.getStammzahlEncrypted(any(), any())).thenReturn(null);
task.execute(pendingReq, executionContext);
+
} catch (TaskExecutionException e) {
Assert.assertEquals("Incorrect exception thrown", e.getMessage(),
"IdentityLink generation for foreign person " + "FAILED.");
@@ -504,6 +512,7 @@ public class CreateIdentityLinkTaskEidNewTest {
when(szrMock.getStammzahlEncrypted(any(), any())).thenReturn(RandomStringUtils.randomNumeric(10));
when(szrMock.signContent(any(), any(), any())).thenReturn(null);
task.execute(pendingReq, executionContext);
+
} catch (TaskExecutionException e) {
Assert.assertEquals("Incorrect exception thrown", e.getMessage(),
"IdentityLink generation for foreign person " + "FAILED.");
@@ -536,6 +545,20 @@ public class CreateIdentityLinkTaskEidNewTest {
}
@Nonnull
+ private void setSzrResponseIdentityLink(String responseXmlPath) throws JAXBException, SZRException_Exception {
+ final JAXBContext jaxbContext = JAXBContext
+ .newInstance(szrservices.ObjectFactory.class, org.w3._2001._04.xmldsig_more.ObjectFactory.class,
+ org.w3._2000._09.xmldsig.ObjectFactory.class,
+ at.gv.e_government.reference.namespace.persondata._20020228.ObjectFactory.class);
+ final Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
+ final GetIdentityLinkEidasResponse szrResponse = (GetIdentityLinkEidasResponse) jaxbUnmarshaller
+ .unmarshal(this.getClass().getResourceAsStream(responseXmlPath));
+ org.mockito.Mockito.when(szrMock.getIdentityLinkEidas(any(PersonInfoType.class))).thenReturn(szrResponse.getGetIdentityLinkReturn());
+
+ }
+
+
+ @Nonnull
private AuthenticationResponse buildDummyAuthResponse(boolean withAll) throws URISyntaxException {
final AttributeDefinition attributeDef = attrRegistry.getCoreAttributeRegistry().getByFriendlyName(
Constants.eIDAS_ATTR_PERSONALIDENTIFIER).first();