aboutsummaryrefslogtreecommitdiff
path: root/eidas_modules/authmodule-eIDAS-v2/src/test/java
diff options
context:
space:
mode:
authorThomas Lenz <thomas.lenz@egiz.gv.at>2018-08-31 13:13:07 +0200
committerThomas Lenz <thomas.lenz@egiz.gv.at>2018-08-31 13:13:07 +0200
commitdd9e461075a23bc75f9db708609a9d0f0ece3901 (patch)
treed75e0dbbc91bca967ec4abd88d67d28f917aaec6 /eidas_modules/authmodule-eIDAS-v2/src/test/java
parent882505075b04f20f35f21cbd2e279d73c9eb24db (diff)
downloadNational_eIDAS_Gateway-dd9e461075a23bc75f9db708609a9d0f0ece3901.tar.gz
National_eIDAS_Gateway-dd9e461075a23bc75f9db708609a9d0f0ece3901.tar.bz2
National_eIDAS_Gateway-dd9e461075a23bc75f9db708609a9d0f0ece3901.zip
more updates
Diffstat (limited to 'eidas_modules/authmodule-eIDAS-v2/src/test/java')
-rw-r--r--eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/test/eidas/specific/modules/authmodule_eIDASv2/SZRClientTest.java62
-rw-r--r--eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/test/eidas/specific/modules/authmodule_eIDASv2/eIDASDataStoreTest.java87
2 files changed, 116 insertions, 33 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 7f9497fc..ca993554 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
@@ -4,7 +4,6 @@ import java.io.IOException;
import java.security.InvalidKeyException;
import java.security.MessageDigest;
import java.security.NoSuchProviderException;
-import java.util.ArrayList;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
@@ -17,7 +16,6 @@ import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.util.Base64Utils;
import org.w3._2000._09.xmldsig.KeyValueType;
-import org.w3._2000._09.xmldsig.RSAKeyValueType;
import org.w3c.dom.Element;
import at.asitplus.eidas.specific.modules.authmodule_eIDASv2.Constants;
@@ -48,8 +46,8 @@ public class SZRClientTest {
private static final String givenName = "Franz";
private static final String familyName = "Mustermann";
- private static final String dateOfBirth = "1988-05-05";
- private static final String eIDASeID = "IS/AT/123456789ABCDEF";
+ private static final String dateOfBirth = "1989-05-05";
+ private static final String eIDASeID = "IS/AT/1234sdgsdfg56789ABCDEF";
//Dummy public RSA Key
private static final String PUBKEY_EXPONENT = "AQAB";
@@ -84,7 +82,7 @@ public class SZRClientTest {
//
// }
-// @Test
+ @Test
public void getIdentityLinkRawMode() throws SZRException_Exception, EAAFParserException, NoSuchProviderException, IOException, InvalidKeyException, eIDASAuthenticationException {
log.debug("Starting connecting SZR Gateway");
IdentityLinkType result = szrClient.getIdentityLinkInRawMode(
@@ -183,40 +181,38 @@ public class SZRClientTest {
Constants.SZR_CONSTANTS_DEFAULT_DOCUMENT_TYPE));
//TODO: that should be removed
- eDocument.setIssueDate(basicConfig.getBasicConfiguration(
- Constants.CONIG_PROPS_EIDAS_SZRCLIENT_PARAMS_ISSUING_DATE,
- Constants.SZR_CONSTANTS_DEFAULT_ISSUING_DATE));
- eDocument.setIssuingAuthority(basicConfig.getBasicConfiguration(
- Constants.CONIG_PROPS_EIDAS_SZRCLIENT_PARAMS_ISSUING_AUTHORITY,
- Constants.SZR_CONSTANTS_DEFAULT_ISSUING_AUTHORITY));
+// eDocument.setIssueDate(basicConfig.getBasicConfiguration(
+// Constants.CONIG_PROPS_EIDAS_SZRCLIENT_PARAMS_ISSUING_DATE));
+// eDocument.setIssuingAuthority(basicConfig.getBasicConfiguration(
+// Constants.CONIG_PROPS_EIDAS_SZRCLIENT_PARAMS_ISSUING_AUTHORITY));
return personInfo;
}
private List<KeyValueType> dummyCodeForKeys() throws IOException, NoSuchProviderException, InvalidKeyException {
- if (basicConfig.getBasicMOAIDConfigurationBoolean(
- Constants.CONIG_PROPS_EIDAS_SZRCLIENT_PARAMS_KEYS_USEDUMMY,
- false)) {
- List<KeyValueType> keyvalueList = new ArrayList<KeyValueType>();
- try {
- // set key values
- RSAKeyValueType rsa = new RSAKeyValueType();
- rsa.setExponent(PUBKEY_EXPONENT);
- rsa.setModulus(PUBKEY_MODULUS);
-
- KeyValueType key = new KeyValueType();
- key.setRSAKeyValue(rsa);
- keyvalueList.add(key);
-
- return keyvalueList;
- } catch (Exception e) {
- log.error("TestCode has an internal ERROR", e);
- throw e;
-
- }
-
- }
+// if (basicConfig.getBasicMOAIDConfigurationBoolean(
+// Constants.CONIG_PROPS_EIDAS_SZRCLIENT_PARAMS_KEYS_USEDUMMY,
+// false)) {
+// List<KeyValueType> keyvalueList = new ArrayList<KeyValueType>();
+// try {
+// // set key values
+// RSAKeyValueType rsa = new RSAKeyValueType();
+// rsa.setExponent(PUBKEY_EXPONENT);
+// rsa.setModulus(PUBKEY_MODULUS);
+//
+// KeyValueType key = new KeyValueType();
+// key.setRSAKeyValue(rsa);
+// keyvalueList.add(key);
+//
+// return keyvalueList;
+// } catch (Exception e) {
+// log.error("TestCode has an internal ERROR", e);
+// throw e;
+//
+// }
+//
+// }
return null;
diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/test/eidas/specific/modules/authmodule_eIDASv2/eIDASDataStoreTest.java b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/test/eidas/specific/modules/authmodule_eIDASv2/eIDASDataStoreTest.java
new file mode 100644
index 00000000..16865b33
--- /dev/null
+++ b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/test/eidas/specific/modules/authmodule_eIDASv2/eIDASDataStoreTest.java
@@ -0,0 +1,87 @@
+package at.asitplus.test.eidas.specific.modules.authmodule_eIDASv2;
+
+import java.security.MessageDigest;
+
+import org.apache.commons.lang3.StringUtils;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.util.Base64Utils;
+
+import at.asitplus.eidas.specific.modules.authmodule_eIDASv2.exception.SQLiteServiceException;
+import at.asitplus.eidas.specific.modules.authmodule_eIDASv2.exception.eIDASAuthenticationException;
+import at.asitplus.eidas.specific.modules.authmodule_eIDASv2.service.eIDASDataStore;
+import at.asitplus.eidas.specific.modules.authmodule_eIDASv2.utils.eIDASResponseUtils;
+import at.gv.egiz.eaaf.core.impl.data.Trible;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration("/SpringTest-context_basic_test.xml")
+public class eIDASDataStoreTest {
+
+ @Autowired private eIDASDataStore dataStore;
+
+ private static final String P1_TRANSID = "123456789";
+ private static final String P1_eIDASID = "DE/AT/121asdf1as5f1as6f1asd2f1asdf1asdf1asd23f1asdf1asdf4sd7fsdf1asdf1asd2f1asd56f7asdf4asdfasdf1";
+
+ private static final String P2_TRANSID = "987654321";
+ private static final String P2_eIDASID = "EE/AT/asfasfasdfasdfasdfasdfasdfasvafasdfasdfasdfasdfasdfasvascasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasd";
+
+ @Test
+ public void dummyTest() {
+
+ }
+
+ @Test
+ public void insertTestOne() throws SQLiteServiceException, eIDASAuthenticationException {
+ Trible<String, String, String> eidasId = eIDASResponseUtils.parseEidasPersonalIdentifier(P1_eIDASID);
+ String ernbId = createHashFromUniqueId(eidasId.getThird());
+ dataStore.storeNationalId(
+ P1_TRANSID,
+ eidasId,
+ ernbId);
+
+
+ if (StringUtils.isEmpty(dataStore.getEidasRawNationalId(ernbId))
+ && dataStore.getEidasRawNationalId(ernbId).equals(eidasId.getThird()))
+ throw new SQLiteServiceException("No eIDAS RAW Id in SQLite DB", null);
+
+ if (StringUtils.isEmpty(dataStore.getErnbNationalId(eidasId))
+ && dataStore.getErnbNationalId(eidasId).equals(ernbId) )
+ throw new SQLiteServiceException("No ERnB Id in SQLite DB", null);
+
+ }
+
+ @Test
+ public void insertTestTwo() throws SQLiteServiceException, eIDASAuthenticationException {
+ Trible<String, String, String> eidasId = eIDASResponseUtils.parseEidasPersonalIdentifier(P2_eIDASID);
+ String ernbId = createHashFromUniqueId(eidasId.getThird());
+ dataStore.storeNationalId(
+ P2_TRANSID,
+ eidasId,
+ ernbId);
+
+ if (StringUtils.isEmpty(dataStore.getEidasRawNationalId(ernbId))
+ && dataStore.getEidasRawNationalId(ernbId).equals(eidasId.getThird()))
+ throw new SQLiteServiceException("No eIDAS RAW Id in SQLite DB", null);
+
+ if (StringUtils.isEmpty(dataStore.getErnbNationalId(eidasId))
+ && dataStore.getErnbNationalId(eidasId).equals(ernbId))
+ throw new SQLiteServiceException("No ERnB Id in SQLite DB", null);
+
+ }
+
+ private String createHashFromUniqueId(String uniqueId) throws eIDASAuthenticationException {
+ try {
+ MessageDigest md = MessageDigest.getInstance("SHA-256");
+ byte[] hash = md.digest(uniqueId.getBytes("UTF-8"));
+ String hashBase64 = new String(Base64Utils.encode(hash), "UTF-8").replaceAll("\r\n", "");
+ return hashBase64;
+
+ } catch (Exception ex) {
+ throw new eIDASAuthenticationException("internal.03", new Object[]{}, ex);
+
+ }
+ }
+}