You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@storm.apache.org by ka...@apache.org on 2016/07/07 14:26:33 UTC

[1/7] storm git commit: STORM-1249: port backtype.storm.security.serialization.BlowfishTupleSerializer-test to java

Repository: storm
Updated Branches:
  refs/heads/master d1280c2b9 -> 0348624ae


STORM-1249: port backtype.storm.security.serialization.BlowfishTupleSerializer-test to java


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

Branch: refs/heads/master
Commit: 473770d8bcd3f7cfc406643f79279e6ae8117328
Parents: b477939
Author: Abhishek Agarwal <ab...@inmobi.com>
Authored: Wed Mar 9 21:07:51 2016 +0530
Committer: Abhishek Agarwal <ab...@inmobi.com>
Committed: Thu Mar 10 18:08:08 2016 +0530

----------------------------------------------------------------------
 .../BlowfishTupleSerializer_test.clj            | 77 ------------------
 .../BlowfishTupleSerializerTest.java            | 86 ++++++++++++++++++++
 2 files changed, 86 insertions(+), 77 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/storm/blob/473770d8/storm-core/test/clj/org/apache/storm/security/serialization/BlowfishTupleSerializer_test.clj
----------------------------------------------------------------------
diff --git a/storm-core/test/clj/org/apache/storm/security/serialization/BlowfishTupleSerializer_test.clj b/storm-core/test/clj/org/apache/storm/security/serialization/BlowfishTupleSerializer_test.clj
deleted file mode 100644
index 824e1d8..0000000
--- a/storm-core/test/clj/org/apache/storm/security/serialization/BlowfishTupleSerializer_test.clj
+++ /dev/null
@@ -1,77 +0,0 @@
-;; Licensed to the Apache Software Foundation (ASF) under one
-;; or more contributor license agreements.  See the NOTICE file
-;; distributed with this work for additional information
-;; regarding copyright ownership.  The ASF licenses this file
-;; to you under the Apache License, Version 2.0 (the
-;; "License"); you may not use this file except in compliance
-;; with the License.  You may obtain a copy of the License at
-;;
-;; http://www.apache.org/licenses/LICENSE-2.0
-;;
-;; Unless required by applicable law or agreed to in writing, software
-;; distributed under the License is distributed on an "AS IS" BASIS,
-;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-;; See the License for the specific language governing permissions and
-;; limitations under the License.
-(ns org.apache.storm.security.serialization.BlowfishTupleSerializer-test
-  (:use [clojure test]
-        [clojure.string :only (join split)]
-  )
-  (:import [org.apache.storm.security.serialization BlowfishTupleSerializer]
-           [org.apache.storm.utils ListDelegate]
-           [com.esotericsoftware.kryo Kryo]
-           [com.esotericsoftware.kryo.io Input Output]
-  )
-)
-
-(deftest test-constructor-throws-on-null-key
-  (is (thrown? RuntimeException (new BlowfishTupleSerializer nil {}))
-      "Throws RuntimeException when no encryption key is given.")
-)
-
-(deftest test-constructor-throws-on-invalid-key
-  ; The encryption key must be hexadecimal.
-  (let [conf {BlowfishTupleSerializer/SECRET_KEY "0123456789abcdefg"}]
-    (is (thrown? RuntimeException (new BlowfishTupleSerializer nil conf))
-        "Throws RuntimeException when an invalid encryption key is given.")
-  )
-)
-
-(deftest test-encrypts-and-decrypts-message
-  (let [
-        test-text (str
-"Tetraodontidae is a family of primarily marine and estuarine fish of the order"
-" Tetraodontiformes. The family includes many familiar species, which are"
-" variously called pufferfish, puffers, balloonfish, blowfish, bubblefish,"
-" globefish, swellfish, toadfish, toadies, honey toads, sugar toads, and sea"
-" squab.[1] They are morphologically similar to the closely related"
-" porcupinefish, which have large external spines (unlike the thinner, hidden"
-" spines of Tetraodontidae, which are only visible when the fish has puffed up)."
-" The scientific name refers to the four large teeth, fused into an upper and"
-" lower plate, which are used for crushing the shells of crustaceans and"
-" mollusks, their natural prey."
-)
-        kryo (new Kryo)
-        arbitrary-key "7dd6fb3203878381b08f9c89d25ed105"
-        storm_conf {BlowfishTupleSerializer/SECRET_KEY arbitrary-key}
-        writer-bts (new BlowfishTupleSerializer kryo storm_conf)
-        reader-bts (new BlowfishTupleSerializer kryo storm_conf)
-        buf-size 1024
-        output (new Output buf-size buf-size)
-        input (new Input buf-size)
-        strlist (split test-text #" ")
-        delegate (new ListDelegate)
-       ]
-    (-> delegate (.addAll strlist))
-    (-> writer-bts (.write kryo output delegate))
-    (.setBuffer input (.getBuffer output))
-    (is 
-      (=
-        test-text
-        (join " " (map (fn [e] (str e)) 
-          (-> reader-bts (.read kryo input ListDelegate) (.toArray))))
-      )
-      "Reads a string encrypted by another instance with a shared key"
-    )
-  )
-)

http://git-wip-us.apache.org/repos/asf/storm/blob/473770d8/storm-core/test/jvm/org/apache/storm/security/serialization/BlowfishTupleSerializerTest.java
----------------------------------------------------------------------
diff --git a/storm-core/test/jvm/org/apache/storm/security/serialization/BlowfishTupleSerializerTest.java b/storm-core/test/jvm/org/apache/storm/security/serialization/BlowfishTupleSerializerTest.java
new file mode 100644
index 0000000..08ada9f
--- /dev/null
+++ b/storm-core/test/jvm/org/apache/storm/security/serialization/BlowfishTupleSerializerTest.java
@@ -0,0 +1,86 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.security.serialization;
+
+import com.google.common.base.Joiner;
+import com.google.common.collect.ImmutableMap;
+
+import com.esotericsoftware.kryo.Kryo;
+import com.esotericsoftware.kryo.io.Input;
+import com.esotericsoftware.kryo.io.Output;
+
+import org.apache.storm.utils.ListDelegate;
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+
+public class BlowfishTupleSerializerTest {
+
+    /**
+     * Throws RuntimeException when no encryption key is given.
+     */
+    @Test(expected = RuntimeException.class)
+    public void testConstructorThrowsOnNullKey() {
+        new BlowfishTupleSerializer(null, new HashMap());
+    }
+
+    /**
+     * Throws RuntimeException when an invalid encryption key is given.
+     */
+    @Test(expected = RuntimeException.class)
+    public void testConstructorThrowsOnInvalidKey() {
+        // The encryption key must be hexadecimal.
+        new BlowfishTupleSerializer(null, ImmutableMap.of(BlowfishTupleSerializer.SECRET_KEY, "0123456789abcdefg"));
+    }
+
+    /**
+     * Reads a string encrypted by another instance with a shared key
+     */
+    @Test
+    public void testEncryptsAndDecryptsMessage() {
+        String testText = "Tetraodontidae is a family of primarily marine and estuarine fish of the order" +
+                          " Tetraodontiformes. The family includes many familiar species, which are" +
+                          " variously called pufferfish, puffers, balloonfish, blowfish, bubblefish," +
+                          " globefish, swellfish, toadfish, toadies, honey toads, sugar toads, and sea" +
+                          " squab.[1] They are morphologically similar to the closely related" +
+                          " porcupinefish, which have large external spines (unlike the thinner, hidden" +
+                          " spines of Tetraodontidae, which are only visible when the fish has puffed up)." +
+                          " The scientific name refers to the four large teeth, fused into an upper and" +
+                          " lower plate, which are used for crushing the shells of crustaceans and" +
+                          " mollusks, their natural prey.";
+        Kryo kryo = new Kryo();
+        String arbitraryKey = "7dd6fb3203878381b08f9c89d25ed105";
+        Map stormConf = ImmutableMap.of(BlowfishTupleSerializer.SECRET_KEY, arbitraryKey);
+        BlowfishTupleSerializer writerBTS = new BlowfishTupleSerializer(kryo, stormConf);
+        BlowfishTupleSerializer readerBTS = new BlowfishTupleSerializer(kryo, stormConf);
+        int bufferSize = 1024;
+        Output output = new Output(bufferSize, bufferSize);
+        Input input = new Input(bufferSize);
+        String[] stringList = testText.split(" ");
+        ListDelegate delegate = new ListDelegate();
+        delegate.addAll(Arrays.asList(stringList));
+
+        writerBTS.write(kryo, output, delegate);
+        input.setBuffer(output.getBuffer());
+        ListDelegate outDelegate = readerBTS.read(kryo, input, ListDelegate.class);
+        Assert.assertEquals(testText, Joiner.on(" ").join(outDelegate.toArray()));
+    }
+}


[2/7] storm git commit: STORM-1235: port backtype.storm.security.auth.ReqContext-test to java

Posted by ka...@apache.org.
STORM-1235: port backtype.storm.security.auth.ReqContext-test to java


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

Branch: refs/heads/master
Commit: 7d43b39e44735e9863ee376e32899ceae46bed0b
Parents: fe5d37a
Author: Abhishek Agarwal <ab...@inmobi.com>
Authored: Wed Mar 9 22:27:34 2016 +0530
Committer: Abhishek Agarwal <ab...@inmobi.com>
Committed: Thu Mar 10 18:08:20 2016 +0530

----------------------------------------------------------------------
 .../storm/security/auth/ReqContext_test.clj     | 73 ----------------
 .../storm/security/auth/ReqContextTest.java     | 87 ++++++++++++++++++++
 2 files changed, 87 insertions(+), 73 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/storm/blob/7d43b39e/storm-core/test/clj/org/apache/storm/security/auth/ReqContext_test.clj
----------------------------------------------------------------------
diff --git a/storm-core/test/clj/org/apache/storm/security/auth/ReqContext_test.clj b/storm-core/test/clj/org/apache/storm/security/auth/ReqContext_test.clj
deleted file mode 100644
index dfce492..0000000
--- a/storm-core/test/clj/org/apache/storm/security/auth/ReqContext_test.clj
+++ /dev/null
@@ -1,73 +0,0 @@
-;; Licensed to the Apache Software Foundation (ASF) under one
-;; or more contributor license agreements.  See the NOTICE file
-;; distributed with this work for additional information
-;; regarding copyright ownership.  The ASF licenses this file
-;; to you under the Apache License, Version 2.0 (the
-;; "License"); you may not use this file except in compliance
-;; with the License.  You may obtain a copy of the License at
-;;
-;; http://www.apache.org/licenses/LICENSE-2.0
-;;
-;; Unless required by applicable law or agreed to in writing, software
-;; distributed under the License is distributed on an "AS IS" BASIS,
-;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-;; See the License for the specific language governing permissions and
-;; limitations under the License.
-(ns org.apache.storm.security.auth.ReqContext-test
-  (:import [org.apache.storm.security.auth ReqContext])
-  (:import [java.net InetAddress])
-  (:import [java.security AccessControlContext Principal])
-  (:import [javax.security.auth Subject])
-  (:use [clojure test])
-)
-
-(def test-subject
-  (let [rc (ReqContext/context)
-        expected (Subject.)]
-    (is (not (.isReadOnly expected)))
-    (.setSubject rc expected)
-    (is (= (.subject rc) expected))
-
-    ; Change the Subject by setting read-only.
-    (.setReadOnly expected)
-    (.setSubject rc expected)
-    (is (= (.subject rc) expected))
-  )
-)
-
-(deftest test-remote-address
-  (let [rc (ReqContext/context)
-        expected (InetAddress/getByAddress (.getBytes "ABCD"))]
-    (.setRemoteAddress rc expected)
-    (is (= (.remoteAddress rc) expected))
-  )
-)
-
-(deftest test-principal-returns-null-when-no-subject
-  (let [rc (ReqContext/context)]
-    (.setSubject rc (Subject.))
-    (is (nil? (.principal rc)))
-  )
-)
-
-(def principal-name "Test Principal")
-
-(defn TestPrincipal []
-  (reify Principal
-    (^String getName [this]
-      principal-name)
-  )
-)
-
-(deftest test-principal
-  (let [p (TestPrincipal)
-        principals (hash-set p)
-        creds (hash-set)
-        s (Subject. false principals creds, creds)
-        rc (ReqContext/context)]
-    (.setSubject rc s)
-    (is (not (nil? (.principal rc))))
-    (is (= (-> rc .principal .getName) principal-name))
-    (.setSubject rc nil)
-  )
-)

http://git-wip-us.apache.org/repos/asf/storm/blob/7d43b39e/storm-core/test/jvm/org/apache/storm/security/auth/ReqContextTest.java
----------------------------------------------------------------------
diff --git a/storm-core/test/jvm/org/apache/storm/security/auth/ReqContextTest.java b/storm-core/test/jvm/org/apache/storm/security/auth/ReqContextTest.java
new file mode 100644
index 0000000..ee93e2c
--- /dev/null
+++ b/storm-core/test/jvm/org/apache/storm/security/auth/ReqContextTest.java
@@ -0,0 +1,87 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.security.auth;
+
+import com.google.common.collect.ImmutableSet;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.security.Principal;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.security.auth.Subject;
+
+public class ReqContextTest {
+
+    private ReqContext rc;
+
+    @Before
+    public void setup() {
+        rc = ReqContext.context();
+    }
+
+    @Test
+    public void testSubject() {
+        Subject expected = new Subject();
+        Assert.assertFalse(expected.isReadOnly());
+        rc.setSubject(expected);
+        Assert.assertEquals(expected, rc.subject());
+
+        expected.setReadOnly();
+        rc.setSubject(expected);
+        Assert.assertEquals(expected, rc.subject());
+    }
+
+    @Test
+    public void testRemoteAddress() throws UnknownHostException {
+        InetAddress expected = InetAddress.getByAddress("ABCD".getBytes());
+        rc.setRemoteAddress(expected);
+        Assert.assertEquals(expected, rc.remoteAddress());
+    }
+
+    /**
+     * If subject has no principals, request context should return null principal
+     */
+    @Test
+    public void testPrincipalReturnsNullWhenNoSubject() {
+        rc.setSubject(new Subject());
+        Assert.assertNull(rc.principal());
+    }
+
+    @Test
+    public void testPrincipal() {
+        final String principalName = "Test Principal";
+        Principal testPrincipal = new Principal() {
+            @Override
+            public String getName() {
+                return principalName;
+            }
+        };
+        Set<Principal> principals = ImmutableSet.of(testPrincipal);
+        Subject subject = new Subject(false, principals, new HashSet<>(), new HashSet<>());
+        rc.setSubject(subject);
+        Assert.assertNotNull(rc.principal());
+        Assert.assertEquals(principalName, rc.principal().getName());
+        rc.setSubject(null);
+    }
+}


[5/7] storm git commit: STORM-1238: port backtype.storm.security.auth.ThriftServer-test to java

Posted by ka...@apache.org.
STORM-1238: port backtype.storm.security.auth.ThriftServer-test to java


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

Branch: refs/heads/master
Commit: e05a916bd2242f5fb31dee5e6a0230dabe043700
Parents: 487c05e
Author: Abhishek Agarwal <ab...@inmobi.com>
Authored: Thu Mar 10 17:48:23 2016 +0530
Committer: Abhishek Agarwal <ab...@inmobi.com>
Committed: Sun Mar 13 18:46:24 2016 +0530

----------------------------------------------------------------------
 .../storm/security/auth/ThriftServer_test.clj   | 32 -----------------
 .../storm/security/auth/ThriftClientTest.java   |  2 +-
 .../storm/security/auth/ThriftServerTest.java   | 38 ++++++++++++++++++++
 3 files changed, 39 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/storm/blob/e05a916b/storm-core/test/clj/org/apache/storm/security/auth/ThriftServer_test.clj
----------------------------------------------------------------------
diff --git a/storm-core/test/clj/org/apache/storm/security/auth/ThriftServer_test.clj b/storm-core/test/clj/org/apache/storm/security/auth/ThriftServer_test.clj
deleted file mode 100644
index e5ad7e8..0000000
--- a/storm-core/test/clj/org/apache/storm/security/auth/ThriftServer_test.clj
+++ /dev/null
@@ -1,32 +0,0 @@
-;; Licensed to the Apache Software Foundation (ASF) under one
-;; or more contributor license agreements.  See the NOTICE file
-;; distributed with this work for additional information
-;; regarding copyright ownership.  The ASF licenses this file
-;; to you under the Apache License, Version 2.0 (the
-;; "License"); you may not use this file except in compliance
-;; with the License.  You may obtain a copy of the License at
-;;
-;; http://www.apache.org/licenses/LICENSE-2.0
-;;
-;; Unless required by applicable law or agreed to in writing, software
-;; distributed under the License is distributed on an "AS IS" BASIS,
-;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-;; See the License for the specific language governing permissions and
-;; limitations under the License.
-(ns org.apache.storm.security.auth.ThriftServer-test
-  (:use [org.apache.storm util config])
-  (:use [clojure test])
-  (:import [org.apache.storm.security.auth ThriftServer ThriftConnectionType])
-  (:import [org.apache.thrift.transport TTransportException])
-  (:import [org.apache.storm.utils Utils])
-)
-
-(deftest test-stop-checks-for-null
-  (let [server (ThriftServer. (clojurify-structure (Utils/readDefaultConfig)) nil
-                              ThriftConnectionType/DRPC)]
-    (.stop server)))
-
-(deftest test-isServing-checks-for-null
-  (let [server (ThriftServer. (clojurify-structure (Utils/readDefaultConfig)) nil
-                              ThriftConnectionType/DRPC)]
-    (is (not (.isServing server)))))

http://git-wip-us.apache.org/repos/asf/storm/blob/e05a916b/storm-core/test/jvm/org/apache/storm/security/auth/ThriftClientTest.java
----------------------------------------------------------------------
diff --git a/storm-core/test/jvm/org/apache/storm/security/auth/ThriftClientTest.java b/storm-core/test/jvm/org/apache/storm/security/auth/ThriftClientTest.java
index 0e568dd..7e68e62 100644
--- a/storm-core/test/jvm/org/apache/storm/security/auth/ThriftClientTest.java
+++ b/storm-core/test/jvm/org/apache/storm/security/auth/ThriftClientTest.java
@@ -62,7 +62,7 @@ public class ThriftClientTest {
 
     @Test
     public void testConstructorThrowsIfHostEmpty() {
-        expectedException.expectCause(ThrowableNestedCauseMatcher.isCausedBy(TTransportException.class));
+        expectedException.expect(ThrowableNestedCauseMatcher.isCausedBy(TTransportException.class));
         new ThriftClient(conf, ThriftConnectionType.DRPC, "", 4242, NIMBUS_TIMEOUT);
     }
 }

http://git-wip-us.apache.org/repos/asf/storm/blob/e05a916b/storm-core/test/jvm/org/apache/storm/security/auth/ThriftServerTest.java
----------------------------------------------------------------------
diff --git a/storm-core/test/jvm/org/apache/storm/security/auth/ThriftServerTest.java b/storm-core/test/jvm/org/apache/storm/security/auth/ThriftServerTest.java
new file mode 100644
index 0000000..0dc9b54
--- /dev/null
+++ b/storm-core/test/jvm/org/apache/storm/security/auth/ThriftServerTest.java
@@ -0,0 +1,38 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.security.auth;
+
+import org.junit.Assert;
+
+import org.apache.storm.utils.Utils;
+import org.junit.Test;
+
+public class ThriftServerTest {
+
+    @Test
+    public void testStopChecksForNull() {
+        ThriftServer server = new ThriftServer(Utils.readDefaultConfig(), null, ThriftConnectionType.DRPC);
+        server.stop();
+    }
+
+    @Test
+    public void testIsServingChecksForNull() {
+        ThriftServer server = new ThriftServer(Utils.readDefaultConfig(), null, ThriftConnectionType.DRPC);
+        Assert.assertFalse(server.isServing());
+    }
+}


[4/7] storm git commit: STORM-1237: port backtype.storm.security.auth.ThriftClient-test to java

Posted by ka...@apache.org.
STORM-1237: port backtype.storm.security.auth.ThriftClient-test to java


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

Branch: refs/heads/master
Commit: 487c05eac0ead1c84ecde7bd08cca119fa372480
Parents: 7d43b39
Author: Abhishek Agarwal <ab...@inmobi.com>
Authored: Thu Mar 10 15:09:43 2016 +0530
Committer: Abhishek Agarwal <ab...@inmobi.com>
Committed: Sun Mar 13 18:46:18 2016 +0530

----------------------------------------------------------------------
 storm-core/pom.xml                              | 13 ++--
 .../storm/security/auth/ThriftClient_test.clj   | 61 ------------------
 .../storm/security/auth/ThriftClientTest.java   | 68 ++++++++++++++++++++
 .../utils/ThrowableNestedCauseMatcher.java      | 44 +++++++++++++
 4 files changed, 120 insertions(+), 66 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/storm/blob/487c05ea/storm-core/pom.xml
----------------------------------------------------------------------
diff --git a/storm-core/pom.xml b/storm-core/pom.xml
index 624e340..b3aad6a 100644
--- a/storm-core/pom.xml
+++ b/storm-core/pom.xml
@@ -146,7 +146,7 @@
           <artifactId>java.jmx</artifactId>
           <version>${java_jmx.version}</version>
         </dependency>
-        
+
         <!--java-->
         <dependency>
             <groupId>commons-cli</groupId>
@@ -286,14 +286,17 @@
             <groupId>metrics-clojure</groupId>
             <artifactId>metrics-clojure</artifactId>
         </dependency>
+        <!-- hamcrest-core dependency is shaded inside the mockito-all and junit depends on newer version of hamcrest-core.
+        To give higher precedence to classes from newer version of hamcrest-core, Junit has been placed above mockito.
+         -->
         <dependency>
-            <groupId>org.mockito</groupId>
-            <artifactId>mockito-all</artifactId>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
             <scope>test</scope>
         </dependency>
         <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
+            <groupId>org.mockito</groupId>
+            <artifactId>mockito-all</artifactId>
             <scope>test</scope>
         </dependency>
         <dependency>

http://git-wip-us.apache.org/repos/asf/storm/blob/487c05ea/storm-core/test/clj/org/apache/storm/security/auth/ThriftClient_test.clj
----------------------------------------------------------------------
diff --git a/storm-core/test/clj/org/apache/storm/security/auth/ThriftClient_test.clj b/storm-core/test/clj/org/apache/storm/security/auth/ThriftClient_test.clj
deleted file mode 100644
index 48e8421..0000000
--- a/storm-core/test/clj/org/apache/storm/security/auth/ThriftClient_test.clj
+++ /dev/null
@@ -1,61 +0,0 @@
-;; Licensed to the Apache Software Foundation (ASF) under one
-;; or more contributor license agreements.  See the NOTICE file
-;; distributed with this work for additional information
-;; regarding copyright ownership.  The ASF licenses this file
-;; to you under the Apache License, Version 2.0 (the
-;; "License"); you may not use this file except in compliance
-;; with the License.  You may obtain a copy of the License at
-;;
-;; http://www.apache.org/licenses/LICENSE-2.0
-;;
-;; Unless required by applicable law or agreed to in writing, software
-;; distributed under the License is distributed on an "AS IS" BASIS,
-;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-;; See the License for the specific language governing permissions and
-;; limitations under the License.
-(ns org.apache.storm.security.auth.ThriftClient-test
-  (:use [org.apache.storm config util])
-  (:use [clojure test])
-  (:require [org.apache.storm.security.auth [auth-test :refer [nimbus-timeout]]])
-  (:import [org.apache.storm.security.auth ThriftClient ThriftConnectionType])
-  (:import [org.apache.thrift.transport TTransportException])
-  (:import [org.apache.storm.utils Utils])
-)
-
-(deftest test-ctor-throws-if-port-invalid
-  (let [conf (merge
-               (clojurify-structure (Utils/readDefaultConfig))
-              {STORM-NIMBUS-RETRY-TIMES 0})]
-    (is (thrown-cause? java.lang.IllegalArgumentException
-      (ThriftClient. conf
-                     ThriftConnectionType/DRPC
-                     "bogushost"
-                     (int -1)
-                     nimbus-timeout)))
-    (is (thrown-cause? java.lang.IllegalArgumentException
-        (ThriftClient. conf
-                       ThriftConnectionType/DRPC
-                       "bogushost"
-                       (int 0)
-                       nimbus-timeout)))
-  )
-)
-
-(deftest test-ctor-throws-if-host-not-set
-  (let [conf (merge
-               (clojurify-structure (Utils/readDefaultConfig))
-              {STORM-NIMBUS-RETRY-TIMES 0})]
-    (is (thrown-cause? TTransportException
-         (ThriftClient. conf
-                        ThriftConnectionType/DRPC
-                        ""
-                        (int 4242)
-                        nimbus-timeout)))
-    (is (thrown-cause? IllegalArgumentException
-        (ThriftClient. conf
-                       ThriftConnectionType/DRPC
-                       nil
-                       (int 4242)
-                       nimbus-timeout)))
-  )
-)

http://git-wip-us.apache.org/repos/asf/storm/blob/487c05ea/storm-core/test/jvm/org/apache/storm/security/auth/ThriftClientTest.java
----------------------------------------------------------------------
diff --git a/storm-core/test/jvm/org/apache/storm/security/auth/ThriftClientTest.java b/storm-core/test/jvm/org/apache/storm/security/auth/ThriftClientTest.java
new file mode 100644
index 0000000..0e568dd
--- /dev/null
+++ b/storm-core/test/jvm/org/apache/storm/security/auth/ThriftClientTest.java
@@ -0,0 +1,68 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.security.auth;
+
+import org.apache.storm.Config;
+import org.apache.storm.utils.ThrowableNestedCauseMatcher;
+import org.apache.storm.utils.Utils;
+import org.apache.thrift.transport.TTransportException;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
+import java.util.Map;
+
+public class ThriftClientTest {
+
+    private int NIMBUS_TIMEOUT = 3 * 1000;
+    private Map conf;
+
+    @Before
+    public void setup() {
+        conf = Utils.readDefaultConfig();
+        conf.put(Config.STORM_NIMBUS_RETRY_TIMES, 0);
+    }
+
+    @Rule
+    public ExpectedException expectedException = ExpectedException.none();
+
+    @Test
+    public void testConstructorThrowsIfPortNegative() {
+        expectedException.expect(ThrowableNestedCauseMatcher.isCausedBy(IllegalArgumentException.class));
+        new ThriftClient(conf, ThriftConnectionType.DRPC, "bogushost", -1, NIMBUS_TIMEOUT);
+    }
+
+    @Test
+    public void testConstructorThrowsIfPortZero() {
+        expectedException.expect(ThrowableNestedCauseMatcher.isCausedBy(IllegalArgumentException.class));
+        new ThriftClient(conf, ThriftConnectionType.DRPC, "bogushost", 0, NIMBUS_TIMEOUT);
+    }
+
+    @Test
+    public void testConstructorThrowsIfHostNull() {
+        expectedException.expect(ThrowableNestedCauseMatcher.isCausedBy(IllegalArgumentException.class));
+        new ThriftClient(conf, ThriftConnectionType.DRPC, null, 4242, NIMBUS_TIMEOUT);
+    }
+
+    @Test
+    public void testConstructorThrowsIfHostEmpty() {
+        expectedException.expectCause(ThrowableNestedCauseMatcher.isCausedBy(TTransportException.class));
+        new ThriftClient(conf, ThriftConnectionType.DRPC, "", 4242, NIMBUS_TIMEOUT);
+    }
+}

http://git-wip-us.apache.org/repos/asf/storm/blob/487c05ea/storm-core/test/jvm/org/apache/storm/utils/ThrowableNestedCauseMatcher.java
----------------------------------------------------------------------
diff --git a/storm-core/test/jvm/org/apache/storm/utils/ThrowableNestedCauseMatcher.java b/storm-core/test/jvm/org/apache/storm/utils/ThrowableNestedCauseMatcher.java
new file mode 100644
index 0000000..ad6094e
--- /dev/null
+++ b/storm-core/test/jvm/org/apache/storm/utils/ThrowableNestedCauseMatcher.java
@@ -0,0 +1,44 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.utils;
+
+import org.hamcrest.BaseMatcher;
+import org.hamcrest.Description;
+
+public class ThrowableNestedCauseMatcher extends BaseMatcher<Throwable> {
+
+    private Class<? extends Throwable> exceptionCause;
+
+    public ThrowableNestedCauseMatcher(Class<? extends Throwable> exceptionCause) {
+        this.exceptionCause = exceptionCause;
+    }
+
+    @Override
+    public boolean matches(Object throwable) {
+        return Utils.exceptionCauseIsInstanceOf(exceptionCause, (Throwable) throwable);
+    }
+
+    @Override
+    public void describeTo(Description description) {
+        description.appendText(exceptionCause.getName());
+    }
+
+    public static ThrowableNestedCauseMatcher isCausedBy(Class<? extends Throwable> exceptionCause) {
+        return new ThrowableNestedCauseMatcher(exceptionCause);
+    }
+}


[3/7] storm git commit: STORM-1236: port backtype.storm.security.auth.SaslTransportPlugin-test to java

Posted by ka...@apache.org.
STORM-1236: port backtype.storm.security.auth.SaslTransportPlugin-test to java


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

Branch: refs/heads/master
Commit: fe5d37a3d9d605c4c10686bf8e9548241bdf4d74
Parents: 473770d
Author: Abhishek Agarwal <ab...@inmobi.com>
Authored: Wed Mar 9 21:57:17 2016 +0530
Committer: Abhishek Agarwal <ab...@inmobi.com>
Committed: Thu Mar 10 18:08:20 2016 +0530

----------------------------------------------------------------------
 .../security/auth/SaslTransportPlugin_test.clj  | 43 -----------------
 .../security/auth/SaslTransportPluginTest.java  | 49 ++++++++++++++++++++
 2 files changed, 49 insertions(+), 43 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/storm/blob/fe5d37a3/storm-core/test/clj/org/apache/storm/security/auth/SaslTransportPlugin_test.clj
----------------------------------------------------------------------
diff --git a/storm-core/test/clj/org/apache/storm/security/auth/SaslTransportPlugin_test.clj b/storm-core/test/clj/org/apache/storm/security/auth/SaslTransportPlugin_test.clj
deleted file mode 100644
index bfbd6ff..0000000
--- a/storm-core/test/clj/org/apache/storm/security/auth/SaslTransportPlugin_test.clj
+++ /dev/null
@@ -1,43 +0,0 @@
-;; Licensed to the Apache Software Foundation (ASF) under one
-;; or more contributor license agreements.  See the NOTICE file
-;; distributed with this work for additional information
-;; regarding copyright ownership.  The ASF licenses this file
-;; to you under the Apache License, Version 2.0 (the
-;; "License"); you may not use this file except in compliance
-;; with the License.  You may obtain a copy of the License at
-;;
-;; http://www.apache.org/licenses/LICENSE-2.0
-;;
-;; Unless required by applicable law or agreed to in writing, software
-;; distributed under the License is distributed on an "AS IS" BASIS,
-;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-;; See the License for the specific language governing permissions and
-;; limitations under the License.
-(ns org.apache.storm.security.auth.SaslTransportPlugin-test
-  (:use [clojure test])
-  (import [org.apache.storm.security.auth SaslTransportPlugin$User])
-)
-
-(deftest test-User-name
-  (let [nam "Andy"
-        user (SaslTransportPlugin$User. nam)]
-    (are [a b] (= a b)
-      nam (.toString user)
-      (.getName user) (.toString user)
-      (.hashCode nam) (.hashCode user)
-    )
-  )
-)
-
-(deftest test-User-equals
-  (let [nam "Andy"
-        user1 (SaslTransportPlugin$User. nam)
-        user2 (SaslTransportPlugin$User. nam)
-        user3 (SaslTransportPlugin$User. "Bobby")]
-    (is (-> user1 (.equals user1)))
-    (is (-> user1 (.equals user2)))
-    (is (not (-> user1 (.equals nil))))
-    (is (not (-> user1 (.equals "Potato"))))
-    (is (not (-> user1 (.equals user3))))
-  )
-)

http://git-wip-us.apache.org/repos/asf/storm/blob/fe5d37a3/storm-core/test/jvm/org/apache/storm/security/auth/SaslTransportPluginTest.java
----------------------------------------------------------------------
diff --git a/storm-core/test/jvm/org/apache/storm/security/auth/SaslTransportPluginTest.java b/storm-core/test/jvm/org/apache/storm/security/auth/SaslTransportPluginTest.java
new file mode 100644
index 0000000..005d415
--- /dev/null
+++ b/storm-core/test/jvm/org/apache/storm/security/auth/SaslTransportPluginTest.java
@@ -0,0 +1,49 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.security.auth;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+public class SaslTransportPluginTest {
+
+    @Test
+    public void testUserName() {
+        String name = "Andy";
+        SaslTransportPlugin.User user = new SaslTransportPlugin.User(name);
+        assertEquals(name, user.toString());
+        assertEquals(user.getName(), user.toString());
+        assertEquals(name.hashCode(), user.hashCode());
+    }
+
+    @Test
+    public void testUserEquals() {
+        String name = "Andy";
+        SaslTransportPlugin.User user1 = new SaslTransportPlugin.User(name);
+        SaslTransportPlugin.User user2 = new SaslTransportPlugin.User(name);
+        SaslTransportPlugin.User user3 = new SaslTransportPlugin.User("Bobby");
+        assertTrue(user1.equals(user1));
+        assertTrue(user1.equals(user2));
+        assertFalse(user1.equals(null));
+        assertFalse(user1.equals("Potato"));
+        assertFalse(user1.equals(user3));
+    }
+}


[6/7] storm git commit: Merge branch 'tests' of https://github.com/abhishekagarwal87/storm into STORM-1235-1236-1237-1238-1249

Posted by ka...@apache.org.
Merge branch 'tests' of https://github.com/abhishekagarwal87/storm into STORM-1235-1236-1237-1238-1249


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

Branch: refs/heads/master
Commit: 364b0ea1e25aac9134208d4f243ba888370aeba1
Parents: d1280c2 e05a916
Author: Jungtaek Lim <ka...@gmail.com>
Authored: Thu Jul 7 23:20:25 2016 +0900
Committer: Jungtaek Lim <ka...@gmail.com>
Committed: Thu Jul 7 23:20:25 2016 +0900

----------------------------------------------------------------------
 storm-core/pom.xml                              | 13 +--
 .../storm/security/auth/ReqContext_test.clj     | 73 ----------------
 .../security/auth/SaslTransportPlugin_test.clj  | 43 ----------
 .../storm/security/auth/ThriftClient_test.clj   | 61 --------------
 .../storm/security/auth/ThriftServer_test.clj   | 32 -------
 .../BlowfishTupleSerializer_test.clj            | 77 -----------------
 .../storm/security/auth/ReqContextTest.java     | 87 ++++++++++++++++++++
 .../security/auth/SaslTransportPluginTest.java  | 49 +++++++++++
 .../storm/security/auth/ThriftClientTest.java   | 68 +++++++++++++++
 .../storm/security/auth/ThriftServerTest.java   | 38 +++++++++
 .../BlowfishTupleSerializerTest.java            | 86 +++++++++++++++++++
 .../utils/ThrowableNestedCauseMatcher.java      | 44 ++++++++++
 12 files changed, 380 insertions(+), 291 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/storm/blob/364b0ea1/storm-core/pom.xml
----------------------------------------------------------------------


[7/7] storm git commit: add STORM-1235, 1236, 1237, 1238, 1249 to CHANGELOG

Posted by ka...@apache.org.
add STORM-1235, 1236, 1237, 1238, 1249 to CHANGELOG


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

Branch: refs/heads/master
Commit: 0348624ae4f2eaaabd83f5d9553598cbc0d18f10
Parents: 364b0ea
Author: Jungtaek Lim <ka...@gmail.com>
Authored: Thu Jul 7 23:25:52 2016 +0900
Committer: Jungtaek Lim <ka...@gmail.com>
Committed: Thu Jul 7 23:25:52 2016 +0900

----------------------------------------------------------------------
 CHANGELOG.md | 5 +++++
 1 file changed, 5 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/storm/blob/0348624a/CHANGELOG.md
----------------------------------------------------------------------
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6e08d13..8eac8da 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,4 +1,9 @@
 ## 2.0.0
+ * STORM-1249: port backtype.storm.security.serialization.BlowfishTupleSerializer-test to java
+ * STORM-1238: port backtype.storm.security.auth.ThriftServer-test to java
+ * STORM-1237: port backtype.storm.security.auth.ThriftClient-test to java
+ * STORM-1236: port backtype.storm.security.auth.SaslTransportPlugin-test to java
+ * STORM-1235: port backtype.storm.security.auth.ReqContext-test to java
  * STORM-1229: port backtype.storm.metric.testing to java
  * STORM-1228: port backtype.storm.fields-test to java
  * STORM-1233: Port AuthUtilsTest to java