aboutsummaryrefslogtreecommitdiff
path: root/connector/src/test/java
diff options
context:
space:
mode:
authorThomas Lenz <thomas.lenz@egiz.gv.at>2021-01-25 16:30:07 +0100
committerThomas <>2022-03-03 16:31:56 +0100
commitfa2384985454568439dc286a6a9051fba47322ed (patch)
treef81f2e61e0f610197ae9992579d93e25177a6315 /connector/src/test/java
parent069b4226dc854817f956a58a59ce44049eda99fb (diff)
downloadNational_eIDAS_Gateway-fa2384985454568439dc286a6a9051fba47322ed.tar.gz
National_eIDAS_Gateway-fa2384985454568439dc286a6a9051fba47322ed.tar.bz2
National_eIDAS_Gateway-fa2384985454568439dc286a6a9051fba47322ed.zip
add ID Austria communication-module and additional jUnit test
It's first alpha-version of eIDAS MS-specific Proxy-Service with ID Austria authentication
Diffstat (limited to 'connector/src/test/java')
-rw-r--r--connector/src/test/java/at/asitplus/eidas/specific/connector/test/utils/AuthenticationDataBuilderTest.java80
1 files changed, 73 insertions, 7 deletions
diff --git a/connector/src/test/java/at/asitplus/eidas/specific/connector/test/utils/AuthenticationDataBuilderTest.java b/connector/src/test/java/at/asitplus/eidas/specific/connector/test/utils/AuthenticationDataBuilderTest.java
index 17ecb2ca..552c448e 100644
--- a/connector/src/test/java/at/asitplus/eidas/specific/connector/test/utils/AuthenticationDataBuilderTest.java
+++ b/connector/src/test/java/at/asitplus/eidas/specific/connector/test/utils/AuthenticationDataBuilderTest.java
@@ -32,6 +32,7 @@ import org.w3c.dom.Element;
import at.asitplus.eidas.specific.connector.builder.AuthenticationDataBuilder;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants;
+import at.asitplus.eidas.specific.modules.msproxyservice.MsProxyServiceConstants;
import at.gv.egiz.eaaf.core.api.data.EaafConfigConstants;
import at.gv.egiz.eaaf.core.api.data.EaafConstants;
import at.gv.egiz.eaaf.core.api.data.ExtendedPvpAttributeDefinitions;
@@ -72,6 +73,7 @@ public class AuthenticationDataBuilderTest {
private TestRequestImpl pendingReq;
private DummySpConfiguration oaParam;
+ private Map<String, String> spConfig;
private String eidasBind;
private String authBlock;
@@ -92,7 +94,7 @@ public class AuthenticationDataBuilderTest {
RequestContextHolder.resetRequestAttributes();
RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(httpReq, httpResp));
- final Map<String, String> spConfig = new HashMap<>();
+ spConfig = new HashMap<>();
spConfig.put(EaafConfigConstants.SERVICE_UNIQUEIDENTIFIER, "testSp");
spConfig.put("target", "urn:publicid:gv.at:cdid+XX");
spConfig.put(PROP_CONFIG_SP_NEW_EID_MODE, "true");
@@ -106,25 +108,89 @@ public class AuthenticationDataBuilderTest {
authBlock = RandomStringUtils.randomAlphanumeric(20);
eidasBind = RandomStringUtils.randomAlphanumeric(20);
pendingReq.getSessionData(AuthProcessDataWrapper.class)
- .setGenericDataToSession(Constants.SZR_AUTHBLOCK, authBlock);
- pendingReq.getSessionData(AuthProcessDataWrapper.class)
- .setGenericDataToSession(Constants.EIDAS_BIND, eidasBind);
- pendingReq.getSessionData(AuthProcessDataWrapper.class)
.setQaaLevel(EaafConstants.EIDAS_LOA_PREFIX + RandomStringUtils.randomAlphabetic(5));
pendingReq.getSessionData(AuthProcessDataWrapper.class).setGenericDataToSession(
PvpAttributeDefinitions.EID_ISSUING_NATION_NAME,
- RandomStringUtils.randomAlphabetic(2));
+ RandomStringUtils.randomAlphabetic(2).toUpperCase());
LocaleContextHolder.resetLocaleContext();
}
@Test
- public void eidMode() throws EaafAuthenticationException {
+ public void eidasProxyMode() throws EaafAuthenticationException, EaafStorageException {
// initialize state
boolean isTestIdentity = RandomUtils.nextBoolean();
+ pendingReq.getSessionData(EidAuthProcessDataWrapper.class).setTestIdentity(isTestIdentity);
pendingReq.getSessionData(AuthProcessDataWrapper.class).setEidProcess(true);
+
+ String givenName = RandomStringUtils.randomAlphabetic(10);
+ String familyName = RandomStringUtils.randomAlphabetic(10);
+ String dateOfBirth = "1956-12-08";
+ String bpk = RandomStringUtils.randomAlphanumeric(10);
+ String cc = pendingReq.getSessionData(AuthProcessDataWrapper.class)
+ .getGenericDataFromSession(PvpAttributeDefinitions.EID_ISSUING_NATION_NAME, String.class);
+ String spC = RandomStringUtils.randomAlphabetic(2).toUpperCase();
+
+ spConfig.put("target", EaafConstants.URN_PREFIX_EIDAS + cc + "+" + spC);
+
+ pendingReq.getSessionData(AuthProcessDataWrapper.class).setEidProcess(true);
+ pendingReq.getSessionData(AuthProcessDataWrapper.class).setForeigner(false);
+ pendingReq.getSessionData(AuthProcessDataWrapper.class)
+ .setGenericDataToSession(PvpAttributeDefinitions.GIVEN_NAME_NAME, givenName);
+ pendingReq.getSessionData(AuthProcessDataWrapper.class)
+ .setGenericDataToSession(PvpAttributeDefinitions.PRINCIPAL_NAME_NAME, familyName);
+ pendingReq.getSessionData(AuthProcessDataWrapper.class)
+ .setGenericDataToSession(PvpAttributeDefinitions.BIRTHDATE_NAME, dateOfBirth);
+ pendingReq.getSessionData(AuthProcessDataWrapper.class)
+ .setGenericDataToSession(MsProxyServiceConstants.ATTR_EIDAS_PERSONAL_IDENTIFIER, bpk);
+
+ //set LoA level attribute instead of explicit session-data
+ pendingReq.getSessionData(AuthProcessDataWrapper.class)
+ .setGenericDataToSession(PvpAttributeDefinitions.EID_CITIZEN_EIDAS_QAA_LEVEL_NAME,
+ pendingReq.getSessionData(AuthProcessDataWrapper.class).getQaaLevel());
+ pendingReq.getSessionData(AuthProcessDataWrapper.class).setQaaLevel(null);
+
+
+
+ // execute test
+ IAuthData authData = authenticationDataBuilder.buildAuthenticationData(pendingReq);
+
+
+ // validate state
+ Assert.assertNotNull("AuthData null", authData);
+ Assert.assertNull("authBlock null", authData.getGenericData(Constants.SZR_AUTHBLOCK, String.class));
+ Assert.assertNull("eidasBind null", authData.getGenericData(Constants.EIDAS_BIND, String.class));
+
+ Assert.assertEquals("LoA", pendingReq.getSessionData(AuthProcessDataWrapper.class)
+ .getGenericDataFromSession(PvpAttributeDefinitions.EID_CITIZEN_EIDAS_QAA_LEVEL_NAME, String.class),
+ authData.getEidasQaaLevel());
+ Assert.assertEquals("CitizenCountry", cc, authData.getCiticenCountryCode());
+ Assert.assertEquals("familyName", familyName, authData.getFamilyName());
+ Assert.assertEquals("givenName", givenName, authData.getGivenName());
+ Assert.assertEquals("DateOfBirth", dateOfBirth, authData.getFormatedDateOfBirth());
+
+ Assert.assertEquals("bPK", pendingReq.getSessionData(AuthProcessDataWrapper.class)
+ .getGenericDataFromSession(MsProxyServiceConstants.ATTR_EIDAS_PERSONAL_IDENTIFIER, String.class),
+ authData.getGenericData(MsProxyServiceConstants.ATTR_EIDAS_PERSONAL_IDENTIFIER, String.class));
+
+ Assert.assertEquals("testIdentity flag",
+ isTestIdentity ? EidIdentityStatusLevelValues.TESTIDENTITY : EidIdentityStatusLevelValues.IDENTITY,
+ ((EidAuthenticationData)authData).getEidStatus());
+
+
+ }
+
+ @Test
+ public void eidMode() throws EaafAuthenticationException, EaafStorageException {
+ // initialize state
+ boolean isTestIdentity = RandomUtils.nextBoolean();
pendingReq.getSessionData(EidAuthProcessDataWrapper.class).setTestIdentity(isTestIdentity);
+ pendingReq.getSessionData(AuthProcessDataWrapper.class).setEidProcess(true);
+ pendingReq.getSessionData(AuthProcessDataWrapper.class)
+ .setGenericDataToSession(Constants.SZR_AUTHBLOCK, authBlock);
+ pendingReq.getSessionData(AuthProcessDataWrapper.class)
+ .setGenericDataToSession(Constants.EIDAS_BIND, eidasBind);
// execute
IAuthData authData = authenticationDataBuilder.buildAuthenticationData(pendingReq);