aboutsummaryrefslogtreecommitdiff
path: root/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/test/eidas/specific/modules/authmodule_eIDASv2/SZRClientTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/test/eidas/specific/modules/authmodule_eIDASv2/SZRClientTest.java')
-rw-r--r--eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/test/eidas/specific/modules/authmodule_eIDASv2/SZRClientTest.java92
1 files changed, 64 insertions, 28 deletions
diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/test/eidas/specific/modules/authmodule_eIDASv2/SZRClientTest.java b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/test/eidas/specific/modules/authmodule_eIDASv2/SZRClientTest.java
index 6f069596..01af6b00 100644
--- a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/test/eidas/specific/modules/authmodule_eIDASv2/SZRClientTest.java
+++ b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/test/eidas/specific/modules/authmodule_eIDASv2/SZRClientTest.java
@@ -22,13 +22,23 @@
*******************************************************************************/
package at.asitplus.test.eidas.specific.modules.authmodule_eIDASv2;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.when;
+
import java.io.IOException;
import java.security.InvalidKeyException;
import java.security.MessageDigest;
import java.security.NoSuchProviderException;
import java.util.List;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Unmarshaller;
+
import org.apache.commons.lang3.StringUtils;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
@@ -40,6 +50,8 @@ import org.springframework.util.Base64Utils;
import org.w3._2000._09.xmldsig.KeyValueType;
import org.w3c.dom.Element;
+import com.skjolberg.mockito.soap.SoapServiceRule;
+
import at.asitplus.eidas.specific.modules.authmodule_eIDASv2.Constants;
import at.asitplus.eidas.specific.modules.authmodule_eIDASv2.exception.SZRCommunicationException;
import at.asitplus.eidas.specific.modules.authmodule_eIDASv2.exception.eIDASAuthenticationException;
@@ -53,8 +65,10 @@ import at.gv.egiz.eaaf.core.api.idp.auth.data.IIdentityLink;
import at.gv.egiz.eaaf.core.exceptions.EAAFParserException;
import at.gv.egiz.eaaf.core.impl.data.Trible;
import at.gv.egiz.eaaf.core.impl.idp.auth.data.SimpleIdentityLinkAssertionParser;
+import szrservices.GetIdentityLinkEidasResponse;
import szrservices.IdentityLinkType;
import szrservices.PersonInfoType;
+import szrservices.SZR;
import szrservices.SZRException_Exception;
import szrservices.TravelDocumentType;
@@ -77,35 +91,20 @@ public class SZRClientTest {
private static final String DUMMY_TARGET = EAAFConstants.URN_PREFIX_CDID + "ZP";
- @Test
- public void dummyTest() {
-
- }
-
-
- /*
- * getIdentityLink without RAW mode does not contain a valid signature
- */
- //@Test
-// public void getIdentityLink() throws SZRException_Exception, EAAFParserException, NoSuchProviderException, IOException, InvalidKeyException, eIDASAuthenticationException {
-// log.debug("Starting connecting SZR Gateway");
-// IdentityLinkType result = szrClient.getIdentityLink(
-// getPersonInfo(),
-// dummyCodeForKeys(),
-// basicConfig.getBasicMOAIDConfigurationBoolean(
-// Constants.CONIG_PROPS_EIDAS_SZRCLIENT_DEBUG_INSERTERNB,
-// true)
-// );
-//
-// Element idlFromSZR = (Element)result.getAssertion();
-// IIdentityLink identityLink = new SimpleIdentityLinkAssertionParser(idlFromSZR).parseIdentityLink();
-// if (identityLink == null)
-// throw new SZRCommunicationException("ernb.00", new Object[] {"bPK is null or empty"});
-//
-// }
+ @BeforeClass
+ public static void classInitializer() throws IOException {
+ final String current = new java.io.File( "." ).toURI().toString();
+ System.setProperty("eidas.ms.configuration", current + "../../basicConfig/default_config.properties");
+
+ }
+ @Rule
+ public SoapServiceRule soap = SoapServiceRule.newInstance();
+
@Test
- public void getIdentityLinkRawMode() throws SZRException_Exception, EAAFParserException, NoSuchProviderException, IOException, InvalidKeyException, eIDASAuthenticationException {
+ public void getIdentityLinkRawMode() throws SZRException_Exception, EAAFParserException, NoSuchProviderException, IOException, InvalidKeyException, eIDASAuthenticationException, JAXBException {
+ setSZRResponse("/data/szr/szr_resp_valid_1.xml", "http://localhost/demoszr");
+
log.debug("Starting connecting SZR Gateway");
IdentityLinkType result = szrClient.getIdentityLinkInRawMode(
getPersonInfo());
@@ -143,7 +142,8 @@ public class SZRClientTest {
}
-// @Test
+ @Ignore
+ @Test
public void getbPKTest() throws SZRException_Exception, eIDASAuthenticationException {
String bPK = szrClient.getBPK(getPersonInfo(), DUMMY_TARGET,
basicConfig.getBasicConfiguration(
@@ -156,6 +156,21 @@ public class SZRClientTest {
}
+ private void setSZRResponse(String responseXmlPath, String serviceURL) throws JAXBException, SZRException_Exception {
+ final SZR szrServiceMock = soap.mock(SZR.class, serviceURL);
+ final JAXBContext jaxbContext = JAXBContext.newInstance(
+ szrservices.ObjectFactory.class,
+ org.xmlsoap.schemas.ws._2002._04.secext.ObjectFactory.class,
+ org.w3._2001._04.xmldsig_more.ObjectFactory.class,
+ org.w3._2000._09.xmldsig.ObjectFactory.class,
+ at.gv.egov.pvp1.ObjectFactory.class,
+ at.gv.e_government.reference.namespace.persondata._20020228.ObjectFactory.class);
+ final Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
+ final GetIdentityLinkEidasResponse szrResponse= (GetIdentityLinkEidasResponse) jaxbUnmarshaller.unmarshal(this.getClass().getResourceAsStream(responseXmlPath));
+ when(szrServiceMock.getIdentityLinkEidas(any(PersonInfoType.class))).thenReturn(szrResponse.getGetIdentityLinkReturn());
+
+ }
+
private String createHashFromUniqueId(String uniqueId) throws eIDASAuthenticationException {
try {
MessageDigest md = MessageDigest.getInstance("SHA-256");
@@ -234,4 +249,25 @@ public class SZRClientTest {
return null;
}
+
+ /*
+ * getIdentityLink without RAW mode does not contain a valid signature
+ */
+ //@Test
+// public void getIdentityLink() throws SZRException_Exception, EAAFParserException, NoSuchProviderException, IOException, InvalidKeyException, eIDASAuthenticationException {
+// log.debug("Starting connecting SZR Gateway");
+// IdentityLinkType result = szrClient.getIdentityLink(
+// getPersonInfo(),
+// dummyCodeForKeys(),
+// basicConfig.getBasicMOAIDConfigurationBoolean(
+// Constants.CONIG_PROPS_EIDAS_SZRCLIENT_DEBUG_INSERTERNB,
+// true)
+// );
+//
+// Element idlFromSZR = (Element)result.getAssertion();
+// IIdentityLink identityLink = new SimpleIdentityLinkAssertionParser(idlFromSZR).parseIdentityLink();
+// if (identityLink == null)
+// throw new SZRCommunicationException("ernb.00", new Object[] {"bPK is null or empty"});
+//
+// }
}