aboutsummaryrefslogtreecommitdiff
path: root/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus
diff options
context:
space:
mode:
authorChristian Kollmann <christian.kollmann@a-sit.at>2021-03-04 17:47:41 +0100
committerChristian Kollmann <christian.kollmann@a-sit.at>2021-03-04 17:47:41 +0100
commit27f2e48e6a585e2d1462b60214b5cfcd8f40680b (patch)
tree9825839ab326ba77c7c4682bd7fcc77bee924a70 /eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus
parent9df463ce8c8567a8f70c4f8f1988f5ae299b6369 (diff)
downloadNational_eIDAS_Gateway-27f2e48e6a585e2d1462b60214b5cfcd8f40680b.tar.gz
National_eIDAS_Gateway-27f2e48e6a585e2d1462b60214b5cfcd8f40680b.tar.bz2
National_eIDAS_Gateway-27f2e48e6a585e2d1462b60214b5cfcd8f40680b.zip
Copy post processing eIDAS attributes to InitialSearchTask
Diffstat (limited to 'eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus')
-rw-r--r--eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskTest.java37
1 files changed, 32 insertions, 5 deletions
diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskTest.java b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskTest.java
index c9f123dc..643afb90 100644
--- a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskTest.java
+++ b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskTest.java
@@ -25,13 +25,19 @@ package at.asitplus.eidas.specific.modules.auth.eidas.v2.test.tasks;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.RegisterResult;
+import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.SimpleEidasData;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.ernp.IErnpClient;
+import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.EidPostProcessingException;
+import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.EidasAttributeException;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.ManualFixNecessaryException;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.handler.DeSpecificDetailSearchProcessor;
+import at.asitplus.eidas.specific.modules.auth.eidas.v2.handler.GenericEidProcessor;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.handler.ItSpecificDetailSearchProcessor;
+import at.asitplus.eidas.specific.modules.auth.eidas.v2.service.ICcSpecificEidProcessingService;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.service.RegisterSearchService;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.tasks.InitialSearchTask;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.zmr.IZmrClient;
+import at.gv.egiz.eaaf.core.api.IRequest;
import at.gv.egiz.eaaf.core.api.idp.process.ExecutionContext;
import at.gv.egiz.eaaf.core.exceptions.EaafStorageException;
import at.gv.egiz.eaaf.core.exceptions.TaskExecutionException;
@@ -41,6 +47,7 @@ import at.gv.egiz.eaaf.core.impl.idp.process.ExecutionContextImpl;
import eu.eidas.auth.commons.attribute.AttributeDefinition;
import eu.eidas.auth.commons.attribute.ImmutableAttributeMap;
import eu.eidas.auth.commons.attribute.PersonType;
+import eu.eidas.auth.commons.light.impl.LightRequest;
import eu.eidas.auth.commons.protocol.impl.AuthenticationResponse;
import org.apache.commons.lang3.RandomStringUtils;
import org.jetbrains.annotations.NotNull;
@@ -65,6 +72,7 @@ import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Collections;
+import java.util.Map;
import java.util.Random;
import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic;
@@ -86,6 +94,7 @@ public class InitialSearchTaskTest {
private IZmrClient zmrClient;
@Mock
private IErnpClient ernpClient;
+ private final ICcSpecificEidProcessingService eidPostProcessor = createEidPostProcessor();
private RegisterSearchService registerSearchService;
final ExecutionContext executionContext = new ExecutionContextImpl();
@@ -106,7 +115,7 @@ public class InitialSearchTaskTest {
public void setUp() throws URISyntaxException, EaafStorageException {
MockitoAnnotations.initMocks(this);
registerSearchService = new RegisterSearchService(zmrClient, ernpClient);
- task = new InitialSearchTask(new ArrayList<>(), registerSearchService);
+ task = new InitialSearchTask(new ArrayList<>(), registerSearchService, eidPostProcessor);
MockHttpServletRequest httpReq = new MockHttpServletRequest("POST", "https://localhost/authhandler");
MockHttpServletResponse httpResp = new MockHttpServletResponse();
@@ -119,6 +128,24 @@ public class InitialSearchTaskTest {
.setGenericDataToSession(Constants.DATA_FULL_EIDAS_RESPONSE, response);
}
+ @NotNull
+ private ICcSpecificEidProcessingService createEidPostProcessor() {
+ return new ICcSpecificEidProcessingService() {
+
+ private final GenericEidProcessor genericEidProcessor = new GenericEidProcessor();
+
+ @Override
+ public SimpleEidasData postProcess(Map<String, Object> eidasAttrMap) throws EidPostProcessingException, EidasAttributeException {
+ return genericEidProcessor.postProcess(eidasAttrMap);
+ }
+
+ @Override
+ public void preProcess(String selectedCC, IRequest pendingReq, LightRequest.Builder authnRequestBuilder) {
+ genericEidProcessor.preProcess(pendingReq, authnRequestBuilder);
+ }
+ };
+ }
+
/**
* One match, but register update needed
*/
@@ -245,7 +272,7 @@ public class InitialSearchTaskTest {
Mockito.when(ernpClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(Collections.emptyList());
task = new InitialSearchTask(
Collections.singletonList(new ItSpecificDetailSearchProcessor(registerSearchService)),
- registerSearchService);
+ registerSearchService, eidPostProcessor);
task.execute(pendingReq1, executionContext);
@@ -273,7 +300,7 @@ public class InitialSearchTaskTest {
Mockito.when(ernpClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(Collections.emptyList());
task = new InitialSearchTask(
Collections.singletonList(new DeSpecificDetailSearchProcessor(registerSearchService)),
- registerSearchService);
+ registerSearchService, eidPostProcessor);
task.execute(pendingReq1, executionContext);
@@ -307,7 +334,7 @@ public class InitialSearchTaskTest {
Mockito.when(ernpClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(Collections.emptyList());
task = new InitialSearchTask(
Collections.singletonList(new DeSpecificDetailSearchProcessor(registerSearchService)),
- registerSearchService);
+ registerSearchService, eidPostProcessor);
TaskExecutionException exception = assertThrows(TaskExecutionException.class,
() -> task.execute(pendingReq1, executionContext));
@@ -340,7 +367,7 @@ public class InitialSearchTaskTest {
Mockito.when(ernpClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(Collections.emptyList());
task = new InitialSearchTask(
Collections.singletonList(new ItSpecificDetailSearchProcessor(registerSearchService)),
- registerSearchService);
+ registerSearchService, eidPostProcessor);
TaskExecutionException exception = assertThrows(TaskExecutionException.class,
() -> task.execute(pendingReq1, executionContext));