aboutsummaryrefslogtreecommitdiff
path: root/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/CreateIdentityLinkTaskTest.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/CreateIdentityLinkTaskTest.java')
-rw-r--r--modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/CreateIdentityLinkTaskTest.java350
1 files changed, 219 insertions, 131 deletions
diff --git a/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/CreateIdentityLinkTaskTest.java b/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/CreateIdentityLinkTaskTest.java
index a9d2f332..5c528532 100644
--- a/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/CreateIdentityLinkTaskTest.java
+++ b/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/CreateIdentityLinkTaskTest.java
@@ -5,20 +5,22 @@ import static org.mockito.ArgumentMatchers.any;
import java.net.URISyntaxException;
import java.util.HashMap;
+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;
+import org.jetbrains.annotations.NotNull;
+import org.joda.time.DateTime;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Rule;
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,12 +31,21 @@ import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import com.github.skjolber.mockito.soap.SoapServiceRule;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
import at.asitplus.eidas.specific.core.MsEidasNodeConstants;
import at.asitplus.eidas.specific.core.test.config.dummy.MsConnectorDummyConfigMap;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants;
+import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.MatchedPersonResult;
+import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.SimpleEidasData;
+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.service.EidasAttributeRegistry;
+import at.asitplus.eidas.specific.modules.auth.eidas.v2.service.ICcSpecificEidProcessingService;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.tasks.CreateIdentityLinkTask;
+import at.asitplus.eidas.specific.modules.auth.eidas.v2.utils.EidasResponseUtils;
+import at.asitplus.eidas.specific.modules.auth.eidas.v2.utils.MatchingTaskUtils;
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;
@@ -51,7 +62,9 @@ import at.gv.egiz.eaaf.core.impl.idp.module.test.TestRequestImpl;
import at.gv.egiz.eaaf.core.impl.idp.process.ExecutionContextImpl;
import at.gv.egiz.eaaf.core.impl.utils.Random;
import eu.eidas.auth.commons.attribute.AttributeDefinition;
+import eu.eidas.auth.commons.attribute.AttributeValue;
import eu.eidas.auth.commons.attribute.ImmutableAttributeMap;
+import eu.eidas.auth.commons.protocol.eidas.impl.PostalAddress;
import eu.eidas.auth.commons.protocol.impl.AuthenticationResponse;
import lombok.val;
import szrservices.GetBPK;
@@ -62,7 +75,6 @@ import szrservices.SZR;
import szrservices.SZRException_Exception;
@RunWith(SpringJUnit4ClassRunner.class)
-@PrepareForTest(CreateIdentityLinkTask.class)
@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
@ContextConfiguration(locations = {
"/SpringTest-context_tasks_test.xml",
@@ -81,7 +93,10 @@ public class CreateIdentityLinkTaskTest {
EaafKeyStoreFactory keyStoreFactory;
@Autowired
- private IRequestStorage requestStorage;
+ ICcSpecificEidProcessingService eidPostProcessor;
+
+ @Autowired
+ IRequestStorage requestStorage;
final ExecutionContext executionContext = new ExecutionContextImpl();
private MockHttpServletRequest httpReq;
@@ -89,18 +104,21 @@ public class CreateIdentityLinkTaskTest {
private TestRequestImpl pendingReq;
private DummySpConfiguration oaParam;
private SZR szrMock;
-
+
+ private MatchedPersonResult matchingInfos;
private AuthenticationResponse response;
private Map<String, String> spConfig;
-
+
@Rule
public final SoapServiceRule soap = SoapServiceRule.newInstance();
/**
* jUnit test set-up.
+ * @throws EidasAttributeException
+ * @throws EidPostProcessingException
*/
@Before
- public void setUp() throws EaafStorageException, URISyntaxException {
+ public void setUp() throws EaafStorageException, URISyntaxException, EidPostProcessingException, EidasAttributeException {
httpReq = new MockHttpServletRequest("POST", "https://localhost/authhandler");
httpResp = new MockHttpServletResponse();
@@ -110,7 +128,7 @@ public class CreateIdentityLinkTaskTest {
basicConfig.putConfigValue("eidas.ms.auth.eIDAS.szrclient.debug.useDummySolution", "false");
basicConfig.putConfigValue("eidas.ms.auth.eIDAS.szrclient.revisionlog.eidmapping.active", "false");
basicConfig.putConfigValue("eidas.ms.auth.eIDAS.szrclient.params.useSZRForbPKCalculation", "false");
-
+
spConfig = new HashMap<>();
spConfig.put(EaafConfigConstants.SERVICE_UNIQUEIDENTIFIER, "testSp");
spConfig.put("target", "urn:publicid:gv.at:cdid+XX");
@@ -119,42 +137,55 @@ public class CreateIdentityLinkTaskTest {
pendingReq = new TestRequestImpl();
response = buildDummyAuthResponse();
-
+ final Map<String, Object> eidasAttributes = convertEidasAttrToSimpleMap(
+ response.getAttributes().getAttributeMap());
+ final SimpleEidasData eidData = eidPostProcessor.postProcess(eidasAttributes);
+ MatchingTaskUtils.storeInitialEidasData(pendingReq, eidData);
pendingReq.getSessionData(AuthProcessDataWrapper.class)
.setGenericDataToSession(Constants.DATA_FULL_EIDAS_RESPONSE, response);
+
+ 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());
pendingReq.setAuthUrl("http://test.com/");
pendingReq.setTransactionId("avaasbav");
pendingReq.setPiiTransactionId(RandomStringUtils.randomAlphanumeric(10));
-
+
executionContext.put(MsEidasNodeConstants.REQ_PARAM_SELECTED_COUNTRY, "XX");
executionContext.put(EaafConstants.PROCESS_ENGINE_REQUIRES_NO_POSTAUTH_REDIRECT, true);
szrMock = soap.mock(SZR.class, "http://localhost:1234/demoszr");
}
-
+
@Test
public void buildIdentityLink() throws Exception {
- //initialize test
+ //initialize test
setSzrResponseIdentityLink("/data/szr/szr_resp_valid_1.xml");
-
+
String randomTestSp = RandomStringUtils.randomAlphabetic(10);
pendingReq.setRawDataToTransaction(MsEidasNodeConstants.DATA_REQUESTERID, randomTestSp);
-
+
basicConfig.putConfigValue("eidas.ms.auth.eIDAS.szrclient.debug.useDummySolution", "false");
-
-
+
+
//perform test
task.execute(pendingReq, executionContext);
-
- //validate state
+
+ //validate state
// check if pendingRequest was stored
IRequest storedPendingReq = requestStorage.getPendingRequest(pendingReq.getPendingRequestId());
Assert.assertNotNull("pendingReq not stored", storedPendingReq);
-
+
//check data in session
final AuthProcessDataWrapper authProcessData = storedPendingReq.getSessionData(AuthProcessDataWrapper.class);
Assert.assertNotNull("AuthProcessData", authProcessData);
@@ -162,15 +193,12 @@ public class CreateIdentityLinkTaskTest {
String authBlock = authProcessData.getGenericDataFromSession(MsEidasNodeConstants.AUTH_DATA_SZR_AUTHBLOCK, String.class);
Assert.assertNull("AuthBlock", authBlock);
-
+
Assert.assertFalse("EID process", authProcessData.isEidProcess());
Assert.assertTrue("foreigner process", authProcessData.isForeigner());
- Assert.assertEquals("EID-ISSUING_NATION", "LU",
+ Assert.assertEquals("EID-ISSUING_NATION", "LU",
authProcessData.getGenericDataFromSession(PvpAttributeDefinitions.EID_ISSUING_NATION_NAME, String.class));
- Assert.assertNotNull("LoA is null", authProcessData.getQaaLevel());
- Assert.assertEquals("LoA", response.getLevelOfAssurance(),
- authProcessData.getQaaLevel());
-
+
Assert.assertNotNull("IDL", authProcessData.getIdentityLink());
checkElement("Mustermann", authProcessData.getIdentityLink().getFamilyName());
checkElement("Hans", authProcessData.getIdentityLink().getGivenName());
@@ -178,12 +206,69 @@ public class CreateIdentityLinkTaskTest {
checkElement("urn:publicid:gv.at:baseid", authProcessData.getIdentityLink().getIdentificationType());
checkElement("k+zDM1BVpN1WJO4x7ZQ3ng==", authProcessData.getIdentityLink().getIdentificationValue());
Assert.assertNotNull(authProcessData.getIdentityLink().getSerializedSamlAssertion());
- Assert.assertNotNull(authProcessData.getIdentityLink().getSamlAssertion());
-
+ Assert.assertNotNull(authProcessData.getIdentityLink().getSamlAssertion());
+
Assert.assertNotNull("no bPK", authProcessData.getGenericDataFromSession(PvpAttributeDefinitions.BPK_NAME));
- Assert.assertEquals("wrong bPK", "XX:FkXtOaSSeR3elyL9KLLvijIYDMU=",
+ Assert.assertEquals("wrong bPK", "XX:FkXtOaSSeR3elyL9KLLvijIYDMU=",
authProcessData.getGenericDataFromSession(PvpAttributeDefinitions.BPK_NAME));
+
+ }
+
+ @Test
+ public void successfulProcessWithDataFromMatching() throws Exception {
+ //initialize test
+ setSzrResponseIdentityLink("/data/szr/szr_resp_valid_1.xml");
+
+ String randomTestSp = RandomStringUtils.randomAlphabetic(10);
+ pendingReq.setRawDataToTransaction(MsEidasNodeConstants.DATA_REQUESTERID, randomTestSp);
+
+ basicConfig.putConfigValue("eidas.ms.auth.eIDAS.szrclient.debug.useDummySolution", "false");
+
+ 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);
+ //perform test
+ task.execute(pendingReq, executionContext);
+
+
+ //validate state
+ // check if pendingRequest was stored
+ IRequest storedPendingReq = requestStorage.getPendingRequest(pendingReq.getPendingRequestId());
+ Assert.assertNotNull("pendingReq not stored", storedPendingReq);
+
+ //check data in session
+ final AuthProcessDataWrapper authProcessData = storedPendingReq.getSessionData(AuthProcessDataWrapper.class);
+ Assert.assertNotNull("AuthProcessData", authProcessData);
+ Assert.assertNull("eidasBind", authProcessData.getGenericDataFromSession(MsEidasNodeConstants.AUTH_DATA_EIDAS_BIND, String.class));
+
+ String authBlock = authProcessData.getGenericDataFromSession(MsEidasNodeConstants.AUTH_DATA_SZR_AUTHBLOCK, String.class);
+ Assert.assertNull("AuthBlock", authBlock);
+
+ Assert.assertFalse("EID process", authProcessData.isEidProcess());
+ Assert.assertTrue("foreigner process", authProcessData.isForeigner());
+ Assert.assertEquals("EID-ISSUING_NATION", "LU",
+ authProcessData.getGenericDataFromSession(PvpAttributeDefinitions.EID_ISSUING_NATION_NAME, String.class));
+
+ Assert.assertNotNull("IDL", authProcessData.getIdentityLink());
+ checkElement("Mustermann", authProcessData.getIdentityLink().getFamilyName());
+ checkElement("Hans", authProcessData.getIdentityLink().getGivenName());
+ checkElement("1989-05-05", authProcessData.getIdentityLink().getDateOfBirth());
+ checkElement("urn:publicid:gv.at:baseid", authProcessData.getIdentityLink().getIdentificationType());
+ checkElement("k+zDM1BVpN1WJO4x7ZQ3ng==", authProcessData.getIdentityLink().getIdentificationValue());
+ Assert.assertNotNull(authProcessData.getIdentityLink().getSerializedSamlAssertion());
+ Assert.assertNotNull(authProcessData.getIdentityLink().getSamlAssertion());
+
+ Assert.assertNotNull("no bPK", authProcessData.getGenericDataFromSession(PvpAttributeDefinitions.BPK_NAME));
+ Assert.assertEquals("wrong bPK", "XX:FkXtOaSSeR3elyL9KLLvijIYDMU=",
+ authProcessData.getGenericDataFromSession(PvpAttributeDefinitions.BPK_NAME));
+
}
@Test
@@ -191,22 +276,22 @@ public class CreateIdentityLinkTaskTest {
//initialize test
setSzrResponseIdentityLink("/data/szr/szr_resp_valid_1.xml");
spConfig.put("target", EaafConstants.URN_PREFIX_WBPK + "FN+123456i");
-
+
String randomTestSp = RandomStringUtils.randomAlphabetic(10);
pendingReq.setRawDataToTransaction(MsEidasNodeConstants.DATA_REQUESTERID, randomTestSp);
-
+
basicConfig.putConfigValue("eidas.ms.auth.eIDAS.szrclient.debug.useDummySolution", "false");
basicConfig.putConfigValue("eidas.ms.auth.eIDAS.szrclient.revisionlog.eidmapping.active", "true");
-
+
//perform test
task.execute(pendingReq, executionContext);
-
- //validate state
+
+ //validate state
// check if pendingRequest was stored
IRequest storedPendingReq = requestStorage.getPendingRequest(pendingReq.getPendingRequestId());
Assert.assertNotNull("pendingReq not stored", storedPendingReq);
-
+
//check data in session
final AuthProcessDataWrapper authProcessData = storedPendingReq.getSessionData(AuthProcessDataWrapper.class);
Assert.assertNotNull("AuthProcessData", authProcessData);
@@ -214,42 +299,39 @@ public class CreateIdentityLinkTaskTest {
String authBlock = authProcessData.getGenericDataFromSession(MsEidasNodeConstants.AUTH_DATA_SZR_AUTHBLOCK, String.class);
Assert.assertNull("AuthBlock", authBlock);
-
+
Assert.assertFalse("EID process", authProcessData.isEidProcess());
Assert.assertTrue("foreigner process", authProcessData.isForeigner());
- Assert.assertEquals("EID-ISSUING_NATION", "LU",
+ Assert.assertEquals("EID-ISSUING_NATION", "LU",
authProcessData.getGenericDataFromSession(PvpAttributeDefinitions.EID_ISSUING_NATION_NAME, String.class));
- Assert.assertNotNull("LoA is null", authProcessData.getQaaLevel());
- Assert.assertEquals("LoA", response.getLevelOfAssurance(),
- authProcessData.getQaaLevel());
-
+
Assert.assertNotNull("no bPK", authProcessData.getGenericDataFromSession(PvpAttributeDefinitions.BPK_NAME));
- Assert.assertEquals("wrong bPK", "FN+123456i:D26vJncPS2W790RH/LP04V+vNOQ=",
+ Assert.assertEquals("wrong bPK", "FN+123456i:D26vJncPS2W790RH/LP04V+vNOQ=",
authProcessData.getGenericDataFromSession(PvpAttributeDefinitions.BPK_NAME));
-
+
}
-
+
@Test
public void buildIdentityLinkWithEidasBpk() throws Exception {
//initialize test
setSzrResponseIdentityLink("/data/szr/szr_resp_valid_2.xml");
spConfig.put("target", EaafConstants.URN_PREFIX_EIDAS + "AT+EU");
-
+
String randomTestSp = RandomStringUtils.randomAlphabetic(10);
pendingReq.setRawDataToTransaction(MsEidasNodeConstants.DATA_REQUESTERID, randomTestSp);
-
+
basicConfig.putConfigValue("eidas.ms.auth.eIDAS.szrclient.debug.useDummySolution", "false");
basicConfig.putConfigValue("eidas.ms.auth.eIDAS.szrclient.revisionlog.eidmapping.active", "true");
-
+
//perform test
task.execute(pendingReq, executionContext);
-
- //validate state
+
+ //validate state
// check if pendingRequest was stored
IRequest storedPendingReq = requestStorage.getPendingRequest(pendingReq.getPendingRequestId());
Assert.assertNotNull("pendingReq not stored", storedPendingReq);
-
+
//check data in session
final AuthProcessDataWrapper authProcessData = storedPendingReq.getSessionData(AuthProcessDataWrapper.class);
Assert.assertNotNull("AuthProcessData", authProcessData);
@@ -257,80 +339,77 @@ public class CreateIdentityLinkTaskTest {
String authBlock = authProcessData.getGenericDataFromSession(MsEidasNodeConstants.AUTH_DATA_SZR_AUTHBLOCK, String.class);
Assert.assertNull("AuthBlock", authBlock);
-
+
Assert.assertFalse("EID process", authProcessData.isEidProcess());
Assert.assertTrue("foreigner process", authProcessData.isForeigner());
- Assert.assertEquals("EID-ISSUING_NATION", "LU",
+ Assert.assertEquals("EID-ISSUING_NATION", "LU",
authProcessData.getGenericDataFromSession(PvpAttributeDefinitions.EID_ISSUING_NATION_NAME, String.class));
- Assert.assertNotNull("LoA is null", authProcessData.getQaaLevel());
- Assert.assertEquals("LoA", response.getLevelOfAssurance(),
- authProcessData.getQaaLevel());
-
+
Assert.assertNotNull("IDL", authProcessData.getIdentityLink());
checkElement("Musterfrau", authProcessData.getIdentityLink().getFamilyName());
checkElement("Martina", authProcessData.getIdentityLink().getGivenName());
checkElement("1991-04-15", authProcessData.getIdentityLink().getDateOfBirth());
checkElement("urn:publicid:gv.at:baseid", authProcessData.getIdentityLink().getIdentificationType());
checkElement("k+zDM1BV1312312332x7ZQ3ng==", authProcessData.getIdentityLink().getIdentificationValue());
-
+
Assert.assertNotNull("no bPK", authProcessData.getGenericDataFromSession(PvpAttributeDefinitions.BPK_NAME));
- Assert.assertEquals("wrong bPK", "AT+EU:AT/EU/1+wqDl059/02Ptny0g+LyuLDJV0=",
+ Assert.assertEquals("wrong bPK", "AT+EU:AT/EU/1+wqDl059/02Ptny0g+LyuLDJV0=",
authProcessData.getGenericDataFromSession(PvpAttributeDefinitions.BPK_NAME));
-
+
}
-
+
@Test
public void buildIdentityLinkWithUnknownBpk() throws Exception {
//initialize test
setSzrResponseIdentityLink("/data/szr/szr_resp_valid_1.xml");
spConfig.put("target", "urn:notextis:1234");
-
+
String randomTestSp = RandomStringUtils.randomAlphabetic(10);
pendingReq.setRawDataToTransaction(MsEidasNodeConstants.DATA_REQUESTERID, randomTestSp);
-
+
basicConfig.putConfigValue("eidas.ms.auth.eIDAS.szrclient.debug.useDummySolution", "false");
basicConfig.putConfigValue("eidas.ms.auth.eIDAS.szrclient.revisionlog.eidmapping.active", "true");
-
+
try {
task.execute(pendingReq, executionContext);
Assert.fail("unknown bPKType not detected");
-
+
} catch (TaskExecutionException e) {
- Assert.assertEquals("ErrorId", "builder.33",
+ Assert.assertEquals("ErrorId", "builder.33",
((EaafException) e.getOriginalException()).getErrorId());
Assert.assertEquals("wrong parameter size", 1, ((EaafException) e.getOriginalException())
.getParams().length);
- }
+ }
}
-
+
@Test
public void noBpkResult() throws Exception {
//initialize test
setSzrResponseIdentityLink("/data/szr/szr_resp_valid_1.xml");
GetBPKResponse getBpkResp = new GetBPKResponse();
org.mockito.Mockito.when(szrMock.getBPK(any(GetBPK.class))).thenReturn(getBpkResp );
-
+
spConfig.put("target", "urn:notextis:1234");
-
+
String randomTestSp = RandomStringUtils.randomAlphabetic(10);
pendingReq.setRawDataToTransaction(MsEidasNodeConstants.DATA_REQUESTERID, randomTestSp);
-
+
basicConfig.putConfigValue("eidas.ms.auth.eIDAS.szrclient.debug.useDummySolution", "false");
basicConfig.putConfigValue("eidas.ms.auth.eIDAS.szrclient.revisionlog.eidmapping.active", "true");
basicConfig.putConfigValue("eidas.ms.auth.eIDAS.szrclient.params.useSZRForbPKCalculation", "true");
-
+
try {
task.execute(pendingReq, executionContext);
Assert.fail("unknown bPKType not detected");
-
+
} catch (TaskExecutionException e) {
- Assert.assertEquals("ErrorId", "ernb.01",
+ Assert.assertEquals("ErrorId", "ernb.01",
((EaafException) e.getOriginalException()).getErrorId());
-
- }
+
+ }
}
-
+
@Test
public void bPKFromSzr() throws Exception {
//initialize test
@@ -339,25 +418,25 @@ public class CreateIdentityLinkTaskTest {
GetBPKResponse getBpkResp = new GetBPKResponse();
getBpkResp.getGetBPKReturn().add(bpk);
org.mockito.Mockito.when(szrMock.getBPK(any(GetBPK.class))).thenReturn(getBpkResp );
-
+
spConfig.put("target", "urn:notextis:1234");
-
+
String randomTestSp = RandomStringUtils.randomAlphabetic(10);
pendingReq.setRawDataToTransaction(MsEidasNodeConstants.DATA_REQUESTERID, randomTestSp);
-
+
basicConfig.putConfigValue("eidas.ms.auth.eIDAS.szrclient.debug.useDummySolution", "false");
basicConfig.putConfigValue("eidas.ms.auth.eIDAS.szrclient.revisionlog.eidmapping.active", "true");
basicConfig.putConfigValue("eidas.ms.auth.eIDAS.szrclient.params.useSZRForbPKCalculation", "true");
-
+
//execute test
task.execute(pendingReq, executionContext);
-
-
- //validate state
+
+
+ //validate state
// check if pendingRequest was stored
IRequest storedPendingReq = requestStorage.getPendingRequest(pendingReq.getPendingRequestId());
Assert.assertNotNull("pendingReq not stored", storedPendingReq);
-
+
//check data in session
final AuthProcessDataWrapper authProcessData = storedPendingReq.getSessionData(AuthProcessDataWrapper.class);
Assert.assertNotNull("AuthProcessData", authProcessData);
@@ -365,58 +444,17 @@ public class CreateIdentityLinkTaskTest {
String authBlock = authProcessData.getGenericDataFromSession(MsEidasNodeConstants.AUTH_DATA_SZR_AUTHBLOCK, String.class);
Assert.assertNull("AuthBlock", authBlock);
-
+
Assert.assertFalse("EID process", authProcessData.isEidProcess());
Assert.assertTrue("foreigner process", authProcessData.isForeigner());
- Assert.assertEquals("EID-ISSUING_NATION", "LU",
+ Assert.assertEquals("EID-ISSUING_NATION", "LU",
authProcessData.getGenericDataFromSession(PvpAttributeDefinitions.EID_ISSUING_NATION_NAME, String.class));
- Assert.assertNotNull("LoA is null", authProcessData.getQaaLevel());
- Assert.assertEquals("LoA", response.getLevelOfAssurance(),
- authProcessData.getQaaLevel());
-
+
Assert.assertNotNull("no bPK", authProcessData.getGenericDataFromSession(PvpAttributeDefinitions.BPK_NAME));
- Assert.assertEquals("wrong bPK", bpk,
+ Assert.assertEquals("wrong bPK", bpk,
authProcessData.getGenericDataFromSession(PvpAttributeDefinitions.BPK_NAME));
}
- @Test
- public void buildDummyIdl() throws Exception {
- //initialize test
- String randomTestSp = RandomStringUtils.randomAlphabetic(10);
- pendingReq.setRawDataToTransaction(MsEidasNodeConstants.DATA_REQUESTERID, randomTestSp);
-
- basicConfig.putConfigValue("eidas.ms.auth.eIDAS.szrclient.debug.useDummySolution", "true");
-
-
- //perform test
- task.execute(pendingReq, executionContext);
-
-
- //validate state
- // check if pendingRequest was stored
- IRequest storedPendingReq = requestStorage.getPendingRequest(pendingReq.getPendingRequestId());
- Assert.assertNotNull("pendingReq not stored", storedPendingReq);
-
- //check data in session
- final AuthProcessDataWrapper authProcessData = storedPendingReq.getSessionData(AuthProcessDataWrapper.class);
- Assert.assertNotNull("AuthProcessData", authProcessData);
- Assert.assertNull("eidasBind", authProcessData.getGenericDataFromSession(MsEidasNodeConstants.AUTH_DATA_EIDAS_BIND, String.class));
-
- String authBlock = authProcessData.getGenericDataFromSession(MsEidasNodeConstants.AUTH_DATA_SZR_AUTHBLOCK, String.class);
- Assert.assertNull("AuthBlock", authBlock);
-
- Assert.assertFalse("EID process", authProcessData.isEidProcess());
- Assert.assertTrue("foreigner process", authProcessData.isForeigner());
- Assert.assertEquals("EID-ISSUING_NATION", "LU",
- authProcessData.getGenericDataFromSession(PvpAttributeDefinitions.EID_ISSUING_NATION_NAME, String.class));
- Assert.assertNotNull("LoA is null", authProcessData.getQaaLevel());
- Assert.assertEquals("LoA", response.getLevelOfAssurance(),
- authProcessData.getQaaLevel());
-
- Assert.assertNotNull("IDL", authProcessData.getIdentityLink());
-
- }
-
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,
@@ -433,8 +471,8 @@ public class CreateIdentityLinkTaskTest {
Assert.assertEquals(expected, value);
}
-
- @Nonnull
+
+ @NotNull
private AuthenticationResponse buildDummyAuthResponse() throws URISyntaxException {
final AttributeDefinition attributeDef = attrRegistry.getCoreAttributeRegistry().getByFriendlyName(
Constants.eIDAS_ATTR_PERSONALIDENTIFIER).first();
@@ -444,7 +482,7 @@ public class CreateIdentityLinkTaskTest {
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))
@@ -461,4 +499,54 @@ public class CreateIdentityLinkTaskTest {
.attributes(attributeMap)
.build();
}
+
+ private Map<String, Object> convertEidasAttrToSimpleMap(
+ ImmutableMap<AttributeDefinition<?>, ImmutableSet<? extends AttributeValue<?>>> attributeMap) {
+ final Map<String, Object> result = new HashMap<>();
+ for (final AttributeDefinition<?> el : attributeMap.keySet()) {
+ final Class<?> parameterizedType = el.getParameterizedType();
+ if (DateTime.class.equals(parameterizedType)) {
+ convertDateTime(attributeMap, result, el);
+ } else if (PostalAddress.class.equals(parameterizedType)) {
+ convertPostalAddress(attributeMap, result, el);
+ } else {
+ convertString(attributeMap, result, el);
+ }
+ }
+ return result;
+ }
+
+ private void convertString(ImmutableMap<AttributeDefinition<?>,
+ ImmutableSet<? extends AttributeValue<?>>> attributeMap,
+ Map<String, Object> result, AttributeDefinition<?> el) {
+ final List<String> natPersonIdObj = EidasResponseUtils
+ .translateStringListAttribute(el, attributeMap.get(el));
+ final String stringAttr = natPersonIdObj.get(0);
+ if (StringUtils.isNotEmpty(stringAttr)) {
+ result.put(el.getFriendlyName(), stringAttr);
+
+ }
+ }
+
+ private void convertPostalAddress(ImmutableMap<AttributeDefinition<?>,
+ ImmutableSet<? extends AttributeValue<?>>> attributeMap,
+ Map<String, Object> result, AttributeDefinition<?> el) {
+ final PostalAddress addressAttribute = EidasResponseUtils
+ .translateAddressAttribute(el, attributeMap.get(el).asList());
+ if (addressAttribute != null) {
+ result.put(el.getFriendlyName(), addressAttribute);
+
+ }
+ }
+
+ private void convertDateTime(ImmutableMap<AttributeDefinition<?>,
+ ImmutableSet<? extends AttributeValue<?>>> attributeMap,
+ Map<String, Object> result, AttributeDefinition<?> el) {
+ final DateTime attribute = EidasResponseUtils.translateDateAttribute(el, attributeMap.get(el).asList());
+ if (attribute != null) {
+ result.put(el.getFriendlyName(), attribute);
+
+ }
+ }
+
}