aboutsummaryrefslogtreecommitdiff
path: root/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/ReceiveEidasResponseTaskTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/ReceiveEidasResponseTaskTest.java')
-rw-r--r--modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/ReceiveEidasResponseTaskTest.java69
1 files changed, 31 insertions, 38 deletions
diff --git a/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/ReceiveEidasResponseTaskTest.java b/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/ReceiveEidasResponseTaskTest.java
index 3fa66aa8..4148b138 100644
--- a/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/ReceiveEidasResponseTaskTest.java
+++ b/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/ReceiveEidasResponseTaskTest.java
@@ -14,7 +14,6 @@ import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.powermock.core.classloader.annotations.PrepareForTest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse;
@@ -29,8 +28,7 @@ import at.asitplus.eidas.specific.core.test.config.dummy.MsConnectorDummyConfigM
import at.asitplus.eidas.specific.core.test.config.dummy.MsConnectorDummySpConfiguration;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.service.EidasAttributeRegistry;
-import at.asitplus.eidas.specific.modules.auth.eidas.v2.tasks.CreateIdentityLinkTask;
-import at.asitplus.eidas.specific.modules.auth.eidas.v2.tasks.ReceiveAuthnResponseTask;
+import at.asitplus.eidas.specific.modules.auth.eidas.v2.tasks.ReceiveAuthnResponseAlternativeTask;
import at.gv.egiz.eaaf.core.api.IRequest;
import at.gv.egiz.eaaf.core.api.IRequestStorage;
import at.gv.egiz.eaaf.core.api.data.EaafConfigConstants;
@@ -50,7 +48,6 @@ import eu.eidas.auth.commons.protocol.impl.AuthenticationResponse;
import lombok.val;
@RunWith(SpringJUnit4ClassRunner.class)
-@PrepareForTest(CreateIdentityLinkTask.class)
@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
@ContextConfiguration(locations = {
"/SpringTest-context_tasks_test.xml",
@@ -58,21 +55,21 @@ import lombok.val;
public class ReceiveEidasResponseTaskTest {
@Autowired(required = true)
- private ReceiveAuthnResponseTask task;
+ private ReceiveAuthnResponseAlternativeTask task;
@Autowired(required = true)
private MsConnectorDummyConfigMap basicConfig;
@Autowired
protected EidasAttributeRegistry attrRegistry;
-
+
@Autowired private IRequestStorage storage;
-
+
final ExecutionContext executionContext = new ExecutionContextImpl();
private MockHttpServletRequest httpReq;
private MockHttpServletResponse httpResp;
private TestRequestImpl pendingReq;
private MsConnectorDummySpConfiguration oaParam;
-
+
/**
* jUnit test set-up.
*/
@@ -84,7 +81,6 @@ public class ReceiveEidasResponseTaskTest {
RequestContextHolder.resetRequestAttributes();
RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(httpReq, httpResp));
- basicConfig.putConfigValue("eidas.ms.auth.eIDAS.szrclient.debug.useDummySolution", "false");
basicConfig.putConfigValue("eidas.ms.auth.eIDAS.eid.testidentity.default", "false");
final Map<String, String> spConfig = new HashMap<>();
@@ -100,54 +96,53 @@ public class ReceiveEidasResponseTaskTest {
pendingReq.setAuthUrl("http://test.com/");
pendingReq.setTransactionId("avaasbav");
pendingReq.setPiiTransactionId(RandomStringUtils.randomAlphanumeric(10));
-
+
executionContext.put(MsEidasNodeConstants.REQ_PARAM_SELECTED_COUNTRY, "LU");
executionContext.put(EaafConstants.PROCESS_ENGINE_REQUIRES_NO_POSTAUTH_REDIRECT, true);
}
-
+
@Test
- public void missingEidasResponse() {
+ public void missingEidasResponse() {
try {
task.execute(pendingReq, executionContext);
Assert.fail("No eIDAS response not detected");
-
+
} catch (TaskExecutionException e) {
- Assert.assertEquals("ErrorId", "eidas.01",
+ Assert.assertEquals("ErrorId", "eidas.01",
((EaafException) e.getOriginalException()).getErrorId());
-
- }
+
+ }
}
-
+
@Test
- public void notSuccessEidasResponse() throws URISyntaxException {
+ public void notSuccessEidasResponse() throws URISyntaxException {
String statusCode = RandomStringUtils.randomAlphabetic(10);
- httpReq.setAttribute(Constants.DATA_FULL_EIDAS_RESPONSE,
+ httpReq.setAttribute(Constants.DATA_FULL_EIDAS_RESPONSE,
buildDummyAuthResponse(statusCode));
-
-
+
+
try {
task.execute(pendingReq, executionContext);
Assert.fail("No eIDAS response not detected");
-
+
} catch (TaskExecutionException e) {
- Assert.assertEquals("ErrorId", "eidas.02",
+ Assert.assertEquals("ErrorId", "eidas.02",
((EaafException) e.getOriginalException()).getErrorId());
Assert.assertEquals("wrong parameter size", 2, ((EaafException) e.getOriginalException())
.getParams().length);
Assert.assertEquals("wrong errorMsg", statusCode, ((EaafException) e
.getOriginalException()).getParams()[0]);
- }
+ }
}
-
+
@Test
public void successAndForward() throws URISyntaxException, TaskExecutionException,
PendingReqIdValidationException, EaafStorageException {
AuthenticationResponse eidasResponse = buildDummyAuthResponse(Constants.SUCCESS_URI);
httpReq.setAttribute(Constants.DATA_FULL_EIDAS_RESPONSE, eidasResponse);
- executionContext.put(MsEidasNodeConstants.REQ_PARAM_SELECTED_COUNTRY, "LU");
String alternativReturnEndpoint = "http://ms-connector.alternative/" + RandomStringUtils.randomAlphabetic(10);
pendingReq.setRawDataToTransaction(
@@ -174,25 +169,24 @@ public class ReceiveEidasResponseTaskTest {
}
- @Test
- public void success() throws URISyntaxException, TaskExecutionException, PendingReqIdValidationException {
+ public void success() throws URISyntaxException, TaskExecutionException, PendingReqIdValidationException {
@Nonnull
AuthenticationResponse eidasResponse = buildDummyAuthResponse(Constants.SUCCESS_URI);
httpReq.setAttribute(Constants.DATA_FULL_EIDAS_RESPONSE, eidasResponse);
-
+
//execute test
task.execute(pendingReq, executionContext);
-
+
//validate state
IRequest storedReq = storage.getPendingRequest(pendingReq.getPendingRequestId());
Assert.assertNotNull("pendingReq not stored", storedReq);
-
final EidAuthProcessDataWrapper authProcessData = storedReq.getSessionData(EidAuthProcessDataWrapper.class);
Assert.assertEquals("LoA", eidasResponse.getLevelOfAssurance(), authProcessData.getQaaLevel());
- Assert.assertNotNull("eIDAS response",
+ Assert.assertNotNull("eIDAS response",
authProcessData.getGenericDataFromSession(Constants.DATA_FULL_EIDAS_RESPONSE));
- Assert.assertEquals("eIDAS response", eidasResponse,
+ Assert.assertEquals("eIDAS response", eidasResponse,
authProcessData.getGenericDataFromSession(Constants.DATA_FULL_EIDAS_RESPONSE));
+
Assert.assertFalse("testIdentity flag", authProcessData.isTestIdentity());
Assert.assertEquals("msConnectorStage", false,
@@ -206,7 +200,6 @@ public class ReceiveEidasResponseTaskTest {
@Nonnull
AuthenticationResponse eidasResponse = buildDummyAuthResponse(Constants.SUCCESS_URI);
httpReq.setAttribute(Constants.DATA_FULL_EIDAS_RESPONSE, eidasResponse);
- executionContext.put(MsEidasNodeConstants.REQ_PARAM_SELECTED_COUNTRY, "LU");
//execute test
task.execute(pendingReq, executionContext);
@@ -218,9 +211,9 @@ public class ReceiveEidasResponseTaskTest {
final EidAuthProcessDataWrapper authProcessData = storedReq.getSessionData(EidAuthProcessDataWrapper.class);
Assert.assertEquals("LoA", eidasResponse.getLevelOfAssurance(), authProcessData.getQaaLevel());
Assert.assertNotNull("eIDAS response",
- authProcessData.getGenericDataFromSession(Constants.DATA_FULL_EIDAS_RESPONSE));
+ authProcessData.getGenericDataFromSession(Constants.DATA_FULL_EIDAS_RESPONSE_ALTERNATIVE));
Assert.assertEquals("eIDAS response", eidasResponse,
- authProcessData.getGenericDataFromSession(Constants.DATA_FULL_EIDAS_RESPONSE));
+ authProcessData.getGenericDataFromSession(Constants.DATA_FULL_EIDAS_RESPONSE_ALTERNATIVE));
Assert.assertTrue("testIdentity flag", authProcessData.isTestIdentity());
}
@@ -237,7 +230,7 @@ public class ReceiveEidasResponseTaskTest {
Constants.eIDAS_ATTR_CURRENTGIVENNAME).first();
final AttributeDefinition attributeDef4 = attrRegistry.getCoreAttributeRegistry().getByFriendlyName(
Constants.eIDAS_ATTR_DATEOFBIRTH).first();
-
+
final ImmutableAttributeMap attributeMap = ImmutableAttributeMap.builder()
.put(attributeDef, "LU/AT/" + RandomStringUtils.randomNumeric(64))
.put(attributeDef2, RandomStringUtils.randomAlphabetic(10))
@@ -254,5 +247,5 @@ public class ReceiveEidasResponseTaskTest {
.attributes(attributeMap)
.build();
}
-
+
}