aboutsummaryrefslogtreecommitdiff
path: root/modules/authmodule-eIDAS-v2/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'modules/authmodule-eIDAS-v2/src/test')
-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();