diff options
Diffstat (limited to 'modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/validation/EidasRequestPreProcessingSecondTest.java')
-rw-r--r-- | modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/validation/EidasRequestPreProcessingSecondTest.java | 51 |
1 files changed, 50 insertions, 1 deletions
diff --git a/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/validation/EidasRequestPreProcessingSecondTest.java b/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/validation/EidasRequestPreProcessingSecondTest.java index 9b061b55..0453ca1d 100644 --- a/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/validation/EidasRequestPreProcessingSecondTest.java +++ b/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/validation/EidasRequestPreProcessingSecondTest.java @@ -23,6 +23,9 @@ package at.asitplus.eidas.specific.modules.auth.eidas.v2.test.validation; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; + import java.util.HashMap; import java.util.Map; import java.util.UUID; @@ -39,6 +42,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import at.asitplus.eidas.specific.core.test.config.dummy.MsConnectorDummyConfigMap; import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.EidPostProcessingException; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.EidPreProcessingException; import at.asitplus.eidas.specific.modules.auth.eidas.v2.service.CcSpecificEidProcessingService; import at.gv.egiz.eaaf.core.api.data.EaafConfigConstants; import at.gv.egiz.eaaf.core.api.data.EaafConstants; @@ -46,6 +50,7 @@ import at.gv.egiz.eaaf.core.impl.idp.module.test.DummySpConfiguration; import at.gv.egiz.eaaf.core.impl.idp.module.test.TestRequestImpl; import eu.eidas.auth.commons.light.impl.LightRequest; import eu.eidas.auth.commons.light.impl.LightRequest.Builder; +import lombok.SneakyThrows; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { @@ -85,13 +90,55 @@ public class EidasRequestPreProcessingSecondTest { authnRequestBuilder.id(UUID.randomUUID().toString()); authnRequestBuilder.issuer("Test"); authnRequestBuilder.levelOfAssurance(EaafConstants.EIDAS_LOA_HIGH); + + basicConfig.putConfigValue( + "eidas.ms.auth.eIDAS.node_v2.publicSectorTargets", ".*"); + basicConfig.putConfigValue( + "eidas.ms.auth.eIDAS.node_v2.requesterId.lu.useStaticRequesterForAll", "true"); + basicConfig.putConfigValue( + "eidas.ms.auth.eIDAS.node_v2.proxyservices.privatesp.notsupported", ""); + + } + @Test + @SneakyThrows + public void privateSpAllowed() { basicConfig.putConfigValue( - "eidas.ms.auth.eIDAS.node_v2.requesterId.lu.useStaticRequesterForAll", "true"); + "eidas.ms.auth.eIDAS.node_v2.proxyservices.privatesp.notsupported", "XX,XY"); + basicConfig.removeConfigValue("eidas.ms.auth.eIDAS.node_v2.publicSectorTargets"); + + oaParam.getFullConfiguration().put("target", "urn:publicid:gv.at:wbpk+XFN+123456a"); + final String testCountry = "DE"; + authnRequestBuilder.citizenCountryCode(testCountry); + preProcessor.preProcess(testCountry, pendingReq, authnRequestBuilder); + + final LightRequest lightReq = authnRequestBuilder.build(); + Assert.assertEquals("no PublicSP", "private", lightReq.getSpType()); + } + + @Test + @SneakyThrows + public void privateSpNotAllowed() { + basicConfig.putConfigValue( + "eidas.ms.auth.eIDAS.node_v2.proxyservices.privatesp.notsupported", "XX,XY"); + basicConfig.removeConfigValue("eidas.ms.auth.eIDAS.node_v2.publicSectorTargets"); + + oaParam.getFullConfiguration().put("target", "urn:publicid:gv.at:wbpk+XFN+123456a"); + + final String testCountry = "XY"; + authnRequestBuilder.citizenCountryCode(testCountry); + + EidPreProcessingException error = assertThrows("validation error not detected", EidPreProcessingException.class, + () -> preProcessor.preProcess(testCountry, pendingReq, authnRequestBuilder)); + assertEquals("wrong errorId", "module.eidasauth.07", error.getErrorId()); + + } + @Test + @SneakyThrows public void prePreProcessDeUnknownAttribute() throws EidPostProcessingException { basicConfig.putConfigValue("eidas.ms.auth.eIDAS.node_v2.staticProviderNameForPublicSPs", "myNode"); basicConfig.putConfigValue( @@ -114,6 +161,7 @@ public class EidasRequestPreProcessingSecondTest { * Set ProviderName according to general configuration */ @Test + @SneakyThrows public void prePreProcessLuPublicSpWithoutRequestId() throws EidPostProcessingException { basicConfig.putConfigValue( @@ -136,6 +184,7 @@ public class EidasRequestPreProcessingSecondTest { * Always set requesterId and providername in case of country LU */ @Test + @SneakyThrows public void prePreProcessLuPublicSpWithStaticRequesterId() throws EidPostProcessingException { |