diff options
Diffstat (limited to 'eidas_modules/authmodule-eIDAS-v2/src/test')
| -rw-r--r-- | eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/ReceiveMobilePhoneSignatureResponseAndSearchInRegistersTaskTest.java | 78 | 
1 files changed, 75 insertions, 3 deletions
| diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/ReceiveMobilePhoneSignatureResponseAndSearchInRegistersTaskTest.java b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/ReceiveMobilePhoneSignatureResponseAndSearchInRegistersTaskTest.java index 2e3da7bc..fbf011b1 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/ReceiveMobilePhoneSignatureResponseAndSearchInRegistersTaskTest.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/ReceiveMobilePhoneSignatureResponseAndSearchInRegistersTaskTest.java @@ -6,6 +6,10 @@ import java.util.Base64;  import javax.xml.transform.TransformerException; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.MergedRegisterSearchResult; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.SimpleEidasData; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.InvalidUserInputException;  import at.asitplus.eidas.specific.modules.auth.eidas.v2.idaustriaclient.IdAustriaClientAuthConstants;  import at.asitplus.eidas.specific.modules.auth.eidas.v2.idaustriaclient.IdAustriaClientAuthCredentialProvider;  import at.asitplus.eidas.specific.modules.auth.eidas.v2.idaustriaclient.IdAustriaClientAuthMetadataProvider; @@ -13,6 +17,7 @@ import at.asitplus.eidas.specific.modules.auth.eidas.v2.tasks.ReceiveMobilePhone  import at.asitplus.eidas.specific.modules.auth.eidas.v2.test.dummy.DummyAuthConfigMap;  import at.asitplus.eidas.specific.modules.auth.eidas.v2.test.dummy.DummyOA;  import at.asitplus.eidas.specific.modules.auth.eidas.v2.test.dummy.DummyPendingRequest; +import at.gv.egiz.eaaf.core.exceptions.EaafStorageException;  import at.gv.egiz.eaaf.core.impl.idp.auth.data.AuthProcessDataWrapper;  import org.apache.commons.io.IOUtils;  import org.apache.commons.lang3.RandomStringUtils; @@ -520,7 +525,7 @@ public class ReceiveMobilePhoneSignatureResponseAndSearchInRegistersTaskTest {    @Test    public void httpPostValidSignedAssertionEidValid() throws IOException, SamlSigningException,        Pvp2MetadataException, CredentialsNotAvailableException, XMLParserException, UnmarshallingException, -      MarshallingException, TransformerException, TaskExecutionException { +      MarshallingException, TransformerException, TaskExecutionException, EaafStorageException {      oaParam.putGenericConfigurationKey(          IdAustriaClientAuthConstants.CONFIG_PROPS_APPSPECIFIC_EIDAS_NODE_URL, METADATA_PATH); @@ -536,6 +541,14 @@ public class ReceiveMobilePhoneSignatureResponseAndSearchInRegistersTaskTest {      httpReq.addParameter("SAMLResponse", Base64.getEncoder().encodeToString(          DomUtils.serializeNode(XMLObjectSupport.getMarshaller(response).marshall(response)).getBytes("UTF-8"))); +    //put SimpleEidasData in session +    final AuthProcessDataWrapper authProcessData = pendingReq.getSessionData(AuthProcessDataWrapper.class); +    SimpleEidasData eidData = new SimpleEidasData(); +    eidData.setFamilyName("Mustermann"); +    eidData.setGivenName("Max"); +    eidData.setDateOfBirth("1940-01-01"); +    authProcessData.setGenericDataToSession(Constants.DATA_SIMPLE_EIDAS, eidData); +      //perform task      task.execute(pendingReq, executionContext); @@ -580,9 +593,52 @@ public class ReceiveMobilePhoneSignatureResponseAndSearchInRegistersTaskTest {    }    @Test +  public void httpPostValidSignedAssertionEidValidButNameMissmatch() throws IOException, SamlSigningException, +      Pvp2MetadataException, CredentialsNotAvailableException, XMLParserException, UnmarshallingException, +      MarshallingException, TransformerException, TaskExecutionException, EaafStorageException { + +    oaParam.putGenericConfigurationKey( +        IdAustriaClientAuthConstants.CONFIG_PROPS_APPSPECIFIC_EIDAS_NODE_URL, METADATA_PATH); + +    metadataProvider.addMetadataResolverIntoChain(metadataFactory.createMetadataProvider( +        METADATA_PATH, null, "jUnit IDP", null)); + +    final Response response = initializeResponse( +        "classpath:/data/idp_metadata_classpath_entity.xml", +        "/data/Response_with_EID.xml", +        credentialProvider.getMessageSigningCredential(), +        true); +    httpReq.addParameter("SAMLResponse", Base64.getEncoder().encodeToString( +        DomUtils.serializeNode(XMLObjectSupport.getMarshaller(response).marshall(response)).getBytes("UTF-8"))); + +    //put SimpleEidasData in session +    final AuthProcessDataWrapper authProcessData = pendingReq.getSessionData(AuthProcessDataWrapper.class); +    SimpleEidasData eidData = new SimpleEidasData(); +    eidData.setFamilyName("Mustermann1"); +    eidData.setGivenName("Max"); +    eidData.setDateOfBirth("1940-01-01"); +    authProcessData.setGenericDataToSession(Constants.DATA_SIMPLE_EIDAS, eidData); + +    //perform task +    try { +      task.execute(pendingReq, executionContext); +      Assert.fail("Invalid response not detected"); + +    } catch (final TaskExecutionException e) { +      Assert.assertNotNull(e.getPendingRequestID()); +      Assert.assertEquals(pendingReq.getPendingRequestId(), e.getPendingRequestID()); +      Assert.assertNotNull(e.getOriginalException()); +      org.springframework.util.Assert.isInstanceOf(AuthnResponseValidationException.class, +          e.getOriginalException()); +      Assert.assertTrue(e.getOriginalException().getCause() instanceof InvalidUserInputException); +      } + +  } + +  @Test    public void httpPostValidSignedAssertionLegacyValid() throws IOException, SamlSigningException,        Pvp2MetadataException, CredentialsNotAvailableException, XMLParserException, UnmarshallingException, -      MarshallingException, TransformerException, TaskExecutionException { +      MarshallingException, TransformerException, TaskExecutionException, EaafStorageException {  //    authConfig.putConfigValue(AuthHandlerConstants.PROP_CONFIG_LEGACY_ALLOW, "true");      oaParam.putGenericConfigurationKey(          IdAustriaClientAuthConstants.CONFIG_PROPS_APPSPECIFIC_EIDAS_NODE_URL, METADATA_PATH); @@ -590,6 +646,14 @@ public class ReceiveMobilePhoneSignatureResponseAndSearchInRegistersTaskTest {      metadataProvider.addMetadataResolverIntoChain(metadataFactory.createMetadataProvider(          METADATA_PATH, null, "jUnit IDP", null)); +    //put SimpleEidasData in session +    final AuthProcessDataWrapper authProcessData = pendingReq.getSessionData(AuthProcessDataWrapper.class); +    SimpleEidasData eidData = new SimpleEidasData(); +    eidData.setFamilyName("Mustermann"); +    eidData.setGivenName("Max"); +    eidData.setDateOfBirth("1940-01-01"); +    authProcessData.setGenericDataToSession(Constants.DATA_SIMPLE_EIDAS, eidData); +      final Response response = initializeResponse(          "classpath:/data/idp_metadata_classpath_entity.xml",          "/data/Response_with_legacy.xml", @@ -647,7 +711,7 @@ public class ReceiveMobilePhoneSignatureResponseAndSearchInRegistersTaskTest {    @Test    public void httpPostValidSignedAssertionWithLegacyAndEid() throws IOException, SamlSigningException,        Pvp2MetadataException, CredentialsNotAvailableException, XMLParserException, UnmarshallingException, -      MarshallingException, TransformerException, TaskExecutionException { +      MarshallingException, TransformerException, TaskExecutionException, EaafStorageException {      oaParam.putGenericConfigurationKey(          IdAustriaClientAuthConstants.CONFIG_PROPS_APPSPECIFIC_EIDAS_NODE_URL, METADATA_PATH); @@ -655,6 +719,14 @@ public class ReceiveMobilePhoneSignatureResponseAndSearchInRegistersTaskTest {      metadataProvider.addMetadataResolverIntoChain(metadataFactory.createMetadataProvider(          METADATA_PATH, null, "jUnit IDP", null)); +    //put SimpleEidasData in session +    final AuthProcessDataWrapper authProcessData = pendingReq.getSessionData(AuthProcessDataWrapper.class); +    SimpleEidasData eidData = new SimpleEidasData(); +    eidData.setFamilyName("Mustermann"); +    eidData.setGivenName("Max"); +    eidData.setDateOfBirth("1940-01-01"); +    authProcessData.setGenericDataToSession(Constants.DATA_SIMPLE_EIDAS, eidData); +      final Response response = initializeResponse(          "classpath:/data/idp_metadata_classpath_entity.xml",          "/data/Response_with_legacy_and_EID.xml", | 
