airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From goshe...@apache.org
Subject [airavata] branch develop updated: Fix unit test to read escaped keystore file path
Date Fri, 26 Jan 2018 21:14:52 GMT
This is an automated email from the ASF dual-hosted git repository.

goshenoy pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/airavata.git


The following commit(s) were added to refs/heads/develop by this push:
     new 179ad80  Fix unit test to read escaped keystore file path
     new aff441a  Merge branch 'develop' of github.com:apache/airavata into develop
179ad80 is described below

commit 179ad8066da28999b63c32e50bd0a4088e0fc427
Author: Gourav Shenoy <shenoy.200@gmail.com>
AuthorDate: Fri Jan 26 16:14:30 2018 -0500

    Fix unit test to read escaped keystore file path
---
 .../airavata/common/utils/SecurityUtilTest.java    | 23 +++++++++++-----------
 .../store/store/impl/db/CredentialsDAOTest.java    | 10 ++++++----
 2 files changed, 18 insertions(+), 15 deletions(-)

diff --git a/modules/commons/src/test/java/org/apache/airavata/common/utils/SecurityUtilTest.java
b/modules/commons/src/test/java/org/apache/airavata/common/utils/SecurityUtilTest.java
index 26c6344..9ee6753 100644
--- a/modules/commons/src/test/java/org/apache/airavata/common/utils/SecurityUtilTest.java
+++ b/modules/commons/src/test/java/org/apache/airavata/common/utils/SecurityUtilTest.java
@@ -23,6 +23,7 @@ import junit.framework.Assert;
 import org.junit.Test;
 
 import java.io.InputStream;
+import java.net.URI;
 import java.net.URL;
 import java.security.KeyStore;
 
@@ -36,14 +37,14 @@ public class SecurityUtilTest {
     @Test
      public void testEncryptString() throws Exception {
 
-        URL url = this.getClass().getClassLoader().getResource("mykeystore.jks");
+        URI uri = this.getClass().getClassLoader().getResource("mykeystore.jks").toURI();
 
-        assert url != null;
+        assert uri != null;
 
         String stringToEncrypt = "Test string to encrypt";
-        byte[] encrypted = SecurityUtil.encryptString(url.getPath(), "mykey", new TestKeyStoreCallback(),
stringToEncrypt);
+        byte[] encrypted = SecurityUtil.encryptString(uri.getPath(), "mykey", new TestKeyStoreCallback(),
stringToEncrypt);
 
-        String decrypted = SecurityUtil.decryptString(url.getPath(), "mykey", new TestKeyStoreCallback(),
encrypted);
+        String decrypted = SecurityUtil.decryptString(uri.getPath(), "mykey", new TestKeyStoreCallback(),
encrypted);
         Assert.assertTrue(stringToEncrypt.equals(decrypted));
 
     }
@@ -51,15 +52,15 @@ public class SecurityUtilTest {
     @Test
     public void testEncryptBytes() throws Exception {
 
-        URL url = this.getClass().getClassLoader().getResource("mykeystore.jks");
+        URI uri = this.getClass().getClassLoader().getResource("mykeystore.jks").toURI();
 
-        assert url != null;
+        assert uri != null;
 
         String stringToEncrypt = "Test string to encrypt";
-        byte[] encrypted = SecurityUtil.encrypt(url.getPath(), "mykey", new TestKeyStoreCallback(),
+        byte[] encrypted = SecurityUtil.encrypt(uri.getPath(), "mykey", new TestKeyStoreCallback(),
                 stringToEncrypt.getBytes("UTF-8"));
 
-        byte[] decrypted = SecurityUtil.decrypt(url.getPath(), "mykey", new TestKeyStoreCallback(),
encrypted);
+        byte[] decrypted = SecurityUtil.decrypt(uri.getPath(), "mykey", new TestKeyStoreCallback(),
encrypted);
         Assert.assertTrue(stringToEncrypt.equals(new String(decrypted, "UTF-8")));
 
     }
@@ -75,10 +76,10 @@ public class SecurityUtilTest {
 
     @Test
     public void testLoadKeyStoreFromFile() throws Exception{
-        URL url = this.getClass().getClassLoader().getResource("mykeystore.jks");
+        URI uri = this.getClass().getClassLoader().getResource("mykeystore.jks").toURI();
 
-        assert url != null;
-        KeyStore ks = SecurityUtil.loadKeyStore(url.getPath(), "jceks", new TestKeyStoreCallback());
+        assert uri != null;
+        KeyStore ks = SecurityUtil.loadKeyStore(uri.getPath(), "jceks", new TestKeyStoreCallback());
         Assert.assertNotNull(ks);
 
     }
diff --git a/modules/credential-store/credential-store-service/src/test/java/org/apache/airavata/credential/store/store/impl/db/CredentialsDAOTest.java
b/modules/credential-store/credential-store-service/src/test/java/org/apache/airavata/credential/store/store/impl/db/CredentialsDAOTest.java
index b736ddc..4394d62 100644
--- a/modules/credential-store/credential-store-service/src/test/java/org/apache/airavata/credential/store/store/impl/db/CredentialsDAOTest.java
+++ b/modules/credential-store/credential-store-service/src/test/java/org/apache/airavata/credential/store/store/impl/db/CredentialsDAOTest.java
@@ -37,6 +37,8 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import java.io.File;
+import java.net.URI;
+import java.net.URISyntaxException;
 import java.net.URL;
 import java.security.KeyStore;
 import java.security.PrivateKey;
@@ -239,16 +241,16 @@ public class CredentialsDAOTest extends DatabaseTestCases {
     }
 
     @Test
-    public void testSerializationWithEncryption() throws CredentialStoreException {
+    public void testSerializationWithEncryption() throws CredentialStoreException, URISyntaxException
{
 
-        URL url = this.getClass().getClassLoader().getResource("mykeystore.jks");
+        URI uri = this.getClass().getClassLoader().getResource("mykeystore.jks").toURI();
         String secretKeyAlias = "mykey";
 
-        assert url != null;
+        assert uri != null;
 
         CertificateCredential certificateCredential = getTestCredentialObject();
 
-        CredentialsDAO credentialsDAO1 = new CredentialsDAO(url.getPath(), secretKeyAlias,
+        CredentialsDAO credentialsDAO1 = new CredentialsDAO(uri.getPath(), secretKeyAlias,
                 new TestACSKeyStoreCallback());
 
         byte[] array = credentialsDAO1.convertObjectToByteArray(certificateCredential);

-- 
To stop receiving notification emails like this one, please contact
goshenoy@apache.org.

Mime
View raw message