cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aweisb...@apache.org
Subject [2/3] cassandra git commit: Avoid seeding /dev/urandom on OS X by specifying SHA1PRNG in CipherFactoryTest.
Date Fri, 24 Mar 2017 17:17:38 GMT
Avoid seeding /dev/urandom on OS X by specifying SHA1PRNG in CipherFactoryTest.

Patch by Jay Zhuang; Reviewed by Ariel Weisberg for CASSANDRA-13370


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/ee7023e3
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/ee7023e3
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/ee7023e3

Branch: refs/heads/trunk
Commit: ee7023e324cdd3b3442b04ad4b0b1f4b33921d35
Parents: a10b807
Author: Jay Zhuang <jay.zhuang@yahoo.com>
Authored: Fri Mar 24 13:08:50 2017 -0400
Committer: Ariel Weisberg <aweisberg@apple.com>
Committed: Fri Mar 24 13:08:50 2017 -0400

----------------------------------------------------------------------
 CHANGES.txt                                        |  1 +
 .../cassandra/security/CipherFactoryTest.java      | 17 ++++++++++++++++-
 2 files changed, 17 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/ee7023e3/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 8b13109..071dd1a 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 3.11.0
+ * unittest CipherFactoryTest failed on MacOS (CASSANDRA-13370)
  * Forbid SELECT restrictions and CREATE INDEX over non-frozen UDT columns (CASSANDRA-13247)
  * Default logging we ship will incorrectly print "?:?" for "%F:%L" pattern (CASSANDRA-13317)
  * Possible AssertionError in UnfilteredRowIteratorWithLowerBound (CASSANDRA-13366)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/ee7023e3/test/unit/org/apache/cassandra/security/CipherFactoryTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/security/CipherFactoryTest.java b/test/unit/org/apache/cassandra/security/CipherFactoryTest.java
index 4ba265e..29302b7 100644
--- a/test/unit/org/apache/cassandra/security/CipherFactoryTest.java
+++ b/test/unit/org/apache/cassandra/security/CipherFactoryTest.java
@@ -21,6 +21,7 @@
 package org.apache.cassandra.security;
 
 import java.io.IOException;
+import java.security.NoSuchAlgorithmException;
 import java.security.SecureRandom;
 
 import javax.crypto.BadPaddingException;
@@ -34,6 +35,9 @@ import org.junit.Test;
 
 import org.apache.cassandra.config.TransparentDataEncryptionOptions;
 
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
 public class CipherFactoryTest
 {
     // http://www.gutenberg.org/files/4300/4300-h/4300-h.htm
@@ -47,7 +51,18 @@ public class CipherFactoryTest
     @Before
     public void setup()
     {
-        secureRandom = new SecureRandom(new byte[] {0,1,2,3,4,5,6,7,8,9} );
+        try
+        {
+            secureRandom = SecureRandom.getInstance("SHA1PRNG");
+            assertNotNull(secureRandom.getProvider());
+        }
+        catch (NoSuchAlgorithmException e)
+        {
+            fail("NoSuchAlgorithmException: SHA1PRNG not found.");
+        }
+        long seed = new java.util.Random().nextLong();
+        System.out.println("Seed: " + seed);
+        secureRandom.setSeed(seed);
         encryptionOptions = EncryptionContextGenerator.createEncryptionOptions();
         cipherFactory = new CipherFactory(encryptionOptions);
     }


Mime
View raw message