diff options
author | Thomas Lenz <thomas.lenz@egiz.gv.at> | 2021-01-25 16:30:07 +0100 |
---|---|---|
committer | Thomas <> | 2022-03-03 16:31:56 +0100 |
commit | fa2384985454568439dc286a6a9051fba47322ed (patch) | |
tree | f81f2e61e0f610197ae9992579d93e25177a6315 /eidas_modules/eidas_proxy-sevice/src/test/java/at/asitplus/eidas/specific | |
parent | 069b4226dc854817f956a58a59ce44049eda99fb (diff) | |
download | National_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 'eidas_modules/eidas_proxy-sevice/src/test/java/at/asitplus/eidas/specific')
-rw-r--r-- | eidas_modules/eidas_proxy-sevice/src/test/java/at/asitplus/eidas/specific/modules/auth/idaustria/test/protocol/ProxyServiceAuthenticationActionTest.java | 70 |
1 files changed, 58 insertions, 12 deletions
diff --git a/eidas_modules/eidas_proxy-sevice/src/test/java/at/asitplus/eidas/specific/modules/auth/idaustria/test/protocol/ProxyServiceAuthenticationActionTest.java b/eidas_modules/eidas_proxy-sevice/src/test/java/at/asitplus/eidas/specific/modules/auth/idaustria/test/protocol/ProxyServiceAuthenticationActionTest.java index eb5280b3..96429d71 100644 --- a/eidas_modules/eidas_proxy-sevice/src/test/java/at/asitplus/eidas/specific/modules/auth/idaustria/test/protocol/ProxyServiceAuthenticationActionTest.java +++ b/eidas_modules/eidas_proxy-sevice/src/test/java/at/asitplus/eidas/specific/modules/auth/idaustria/test/protocol/ProxyServiceAuthenticationActionTest.java @@ -5,10 +5,13 @@ import static org.junit.Assert.assertThrows; import java.net.URISyntaxException; import java.util.Arrays; +import java.util.Collections; import java.util.Date; import java.util.HashMap; import java.util.Map; +import java.util.UUID; +import org.apache.commons.lang3.RandomStringUtils; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -26,6 +29,7 @@ import org.springframework.web.context.request.ServletRequestAttributes; import at.asitplus.eidas.specific.connector.test.config.dummy.MsConnectorDummyConfigMap; import at.asitplus.eidas.specific.connector.test.config.dummy.MsConnectorDummySpConfiguration; import at.asitplus.eidas.specific.modules.auth.eidas.v2.tasks.CreateIdentityLinkTask; +import at.asitplus.eidas.specific.modules.msproxyservice.MsProxyServiceConstants; import at.asitplus.eidas.specific.modules.msproxyservice.protocol.ProxyServiceAuthenticationAction; import at.asitplus.eidas.specific.modules.msproxyservice.protocol.ProxyServicePendingRequest; import at.gv.egiz.eaaf.core.api.data.EaafConfigConstants; @@ -35,6 +39,7 @@ import at.gv.egiz.eaaf.core.api.idp.auth.data.IIdentityLink; import at.gv.egiz.eaaf.core.api.idp.slo.SloInformationInterface; import at.gv.egiz.eaaf.core.exceptions.EaafException; import at.gv.egiz.eaaf.core.impl.idp.module.test.TestRequestImpl; +import eu.eidas.auth.commons.light.impl.LightRequest; @RunWith(SpringJUnit4ClassRunner.class) @PrepareForTest(CreateIdentityLinkTask.class) @@ -65,6 +70,9 @@ public class ProxyServiceAuthenticationActionTest { RequestContextHolder.resetRequestAttributes(); RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(httpReq, httpResp)); + basicConfig.putConfigValue("eidas.ms.auth.eIDAS.node_v2.proxy.forward.endpoint", + "http://eidas.proxy/endpoint"); + final Map<String, String> spConfig = new HashMap<>(); spConfig.put(EaafConfigConstants.SERVICE_UNIQUEIDENTIFIER, "testSp"); spConfig.put("target", "urn:publicid:gv.at:cdid+XX"); @@ -76,6 +84,17 @@ public class ProxyServiceAuthenticationActionTest { pendingReq.initialize(httpReq, basicConfig); pendingReq.setOnlineApplicationConfiguration(oaParam); + LightRequest.Builder eidasRequestBuilder = LightRequest.builder() + .id(UUID.randomUUID().toString()) + .issuer(RandomStringUtils.randomAlphabetic(10)) + .citizenCountryCode(RandomStringUtils.randomAlphabetic(2).toUpperCase()) + .levelOfAssurance(EaafConstants.EIDAS_LOA_HIGH) + .spCountryCode(RandomStringUtils.randomAlphabetic(2).toUpperCase()) + .spType("public") + .requesterId(RandomStringUtils.randomAlphanumeric(10)) + .providerName(RandomStringUtils.randomAlphanumeric(10)); + pendingReq.setEidasRequest(eidasRequestBuilder.build()); + } @Test @@ -88,16 +107,35 @@ public class ProxyServiceAuthenticationActionTest { Assert.assertEquals("wrong errorCode", "eidas.proxyservice.99", exception.getErrorId()); } + + @Test + public void missingForwardUrl() { + Map<String, Object> attr = new HashMap<>(); + attr.put(MsProxyServiceConstants.ATTR_EIDAS_PERSONAL_IDENTIFIER, + "AT+XX:" + RandomStringUtils.randomAlphanumeric(10)); + IAuthData authData = generateDummyAuthData(attr , EaafConstants.EIDAS_LOA_HIGH, + RandomStringUtils.randomAlphanumeric(10), RandomStringUtils.randomAlphanumeric(10), "1945-04-18"); + basicConfig.removeConfigValue("eidas.ms.auth.eIDAS.node_v2.proxy.forward.endpoint"); + + EaafException exception = assertThrows(EaafException.class, + () -> action.processRequest(pendingReq, httpReq, httpResp, authData)); + Assert.assertEquals("wrong errorCode", "config.08", exception.getErrorId()); + + } @Test public void dummyResponseActionTest() throws EaafException { - IAuthData authData = generateDummyAuthData(); + Map<String, Object> attr = new HashMap<>(); + attr.put(MsProxyServiceConstants.ATTR_EIDAS_PERSONAL_IDENTIFIER, + "AT+XX:" + RandomStringUtils.randomAlphanumeric(10)); + IAuthData authData = generateDummyAuthData(attr , EaafConstants.EIDAS_LOA_HIGH, + RandomStringUtils.randomAlphanumeric(10), RandomStringUtils.randomAlphanumeric(10), "1945-04-18"); //perform test SloInformationInterface result = action.processRequest(pendingReq, httpReq, httpResp, authData); //validate state - Assert.assertNull("Result should be not null", result); + Assert.assertNotNull("Result should be not null", result); } @@ -112,6 +150,12 @@ public class ProxyServiceAuthenticationActionTest { } private IAuthData generateDummyAuthData() { + return generateDummyAuthData(Collections.emptyMap(), EaafConstants.EIDAS_LOA_LOW, + RandomStringUtils.randomAlphanumeric(10), RandomStringUtils.randomAlphanumeric(10), "1940-01-01"); + + } + + private IAuthData generateDummyAuthData(Map<String, Object> attrs, String loa, String familyName, String givenName, String dateOfBirth) { return new IAuthData() { @Override @@ -176,26 +220,28 @@ public class ProxyServiceAuthenticationActionTest { @Override public String getGivenName() { - // TODO Auto-generated method stub - return null; + return givenName; } @Override public <T> T getGenericData(String key, Class<T> clazz) { - // TODO Auto-generated method stub - return null; + if (attrs.containsKey(key)) { + return (T) attrs.get(key); + + } else { + return null; + } + } @Override public String getFormatedDateOfBirth() { - // TODO Auto-generated method stub - return null; + return dateOfBirth; } @Override public String getFamilyName() { - // TODO Auto-generated method stub - return null; + return familyName; } @Override @@ -212,8 +258,8 @@ public class ProxyServiceAuthenticationActionTest { @Override public String getEidasQaaLevel() { - // TODO Auto-generated method stub - return null; + return loa; + } @Override |