You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@storm.apache.org by bo...@apache.org on 2014/05/28 00:24:27 UTC
git commit: rename test for consistent capitalization
Repository: incubator-storm
Updated Branches:
refs/heads/security fe5f41aa8 -> ce6e5d263
rename test for consistent capitalization
Project: http://git-wip-us.apache.org/repos/asf/incubator-storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-storm/commit/ce6e5d26
Tree: http://git-wip-us.apache.org/repos/asf/incubator-storm/tree/ce6e5d26
Diff: http://git-wip-us.apache.org/repos/asf/incubator-storm/diff/ce6e5d26
Branch: refs/heads/security
Commit: ce6e5d26384d7f5d831b35e4eff126fe214981d1
Parents: fe5f41a
Author: Derek Dagit <de...@yahoo-inc.com>
Authored: Thu May 22 18:34:23 2014 +0000
Committer: Derek Dagit <de...@yahoo-inc.com>
Committed: Thu May 22 18:34:23 2014 +0000
----------------------------------------------------------------------
.../authorizer/DRPCSimpleACLAuthorizer_test.clj | 226 +++++++++++++++++++
.../authorizer/DRPCSimpleAclAuthorizer_test.clj | 226 -------------------
2 files changed, 226 insertions(+), 226 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-storm/blob/ce6e5d26/storm-core/test/clj/backtype/storm/security/auth/authorizer/DRPCSimpleACLAuthorizer_test.clj
----------------------------------------------------------------------
diff --git a/storm-core/test/clj/backtype/storm/security/auth/authorizer/DRPCSimpleACLAuthorizer_test.clj b/storm-core/test/clj/backtype/storm/security/auth/authorizer/DRPCSimpleACLAuthorizer_test.clj
new file mode 100644
index 0000000..c70fa2a
--- /dev/null
+++ b/storm-core/test/clj/backtype/storm/security/auth/authorizer/DRPCSimpleACLAuthorizer_test.clj
@@ -0,0 +1,226 @@
+(ns backtype.storm.security.auth.authorizer.DRPCSimpleACLAuthorizer-test
+ (:use [clojure test])
+ (:import [org.mockito Mockito])
+ (:import [backtype.storm Config])
+ (:import [backtype.storm.security.auth ReqContext SingleUserPrincipal])
+ (:import [backtype.storm.security.auth.authorizer DRPCSimpleACLAuthorizer])
+ (:use [backtype.storm config util])
+ )
+
+(defn- mk-mock-context [user]
+ (let [mock-context (Mockito/mock ReqContext)]
+ (. (Mockito/when (.principal mock-context)) thenReturn
+ (SingleUserPrincipal. user))
+ mock-context))
+
+(let [function "jump"
+ partial-function "partial"
+ alice-context (mk-mock-context "alice")
+ alice-kerb-context (mk-mock-context "alice@SOME.RELM")
+ bob-context (mk-mock-context "bob")
+ charlie-context (mk-mock-context "charlie")
+ acl-file "drpc-simple-acl-test-scenario.yaml"
+ strict-handler (doto (DRPCSimpleACLAuthorizer.)
+ (.prepare {DRPC-AUTHORIZER-ACL-STRICT true
+ DRPC-AUTHORIZER-ACL-FILENAME acl-file
+ STORM-PRINCIPAL-TO-LOCAL-PLUGIN "backtype.storm.security.auth.KerberosPrincipalToLocal"}))
+ permissive-handler (doto (DRPCSimpleACLAuthorizer.)
+ (.prepare {DRPC-AUTHORIZER-ACL-STRICT false
+ DRPC-AUTHORIZER-ACL-FILENAME acl-file
+ STORM-PRINCIPAL-TO-LOCAL-PLUGIN "backtype.storm.security.auth.KerberosPrincipalToLocal"}))]
+
+ (deftest test-partial-authorization
+ (testing "deny execute to unauthorized user"
+ (is (not
+ (.permit strict-handler
+ (ReqContext/context)
+ "execute"
+ {DRPCSimpleACLAuthorizer/FUNCTION_KEY partial-function}))))
+
+ (testing "allow execute to authorized kerb user for correct function"
+ (is
+ (.permit
+ strict-handler
+ alice-kerb-context
+ "execute"
+ {DRPCSimpleACLAuthorizer/FUNCTION_KEY partial-function})))
+
+ (testing "deny fetchRequest to unauthorized user for correct function"
+ (is (not
+ (.permit
+ strict-handler
+ alice-kerb-context
+ "fetchRequest"
+ {DRPCSimpleACLAuthorizer/FUNCTION_KEY partial-function}))))
+ )
+
+ (deftest test-client-authorization-strict
+ (testing "deny execute to unauthorized user"
+ (is (not
+ (.permit strict-handler
+ (ReqContext/context)
+ "execute"
+ {DRPCSimpleACLAuthorizer/FUNCTION_KEY function}))))
+
+ (testing "deny execute to valid user for incorrect function"
+ (is (not
+ (.permit
+ strict-handler
+ alice-context
+ "execute"
+ {DRPCSimpleACLAuthorizer/FUNCTION_KEY "wrongFunction"}))))
+
+ (testing "allow execute to authorized kerb user for correct function"
+ (is
+ (.permit
+ strict-handler
+ alice-kerb-context
+ "execute"
+ {DRPCSimpleACLAuthorizer/FUNCTION_KEY function})))
+
+ (testing "allow execute to authorized user for correct function"
+ (is
+ (.permit
+ strict-handler
+ alice-context
+ "execute"
+ {DRPCSimpleACLAuthorizer/FUNCTION_KEY function}))))
+
+
+ (deftest test-client-authorization-permissive
+ (testing "deny execute to unauthorized user for correct function"
+ (is (not
+ (.permit permissive-handler
+ (ReqContext/context)
+ "execute"
+ {DRPCSimpleACLAuthorizer/FUNCTION_KEY function}))))
+
+ (testing "allow execute for user for incorrect function when permissive"
+ (is
+ (.permit permissive-handler
+ alice-context
+ "execute"
+ {DRPCSimpleACLAuthorizer/FUNCTION_KEY "wrongFunction"})))
+
+ (testing "allow execute for user for incorrect function when permissive"
+ (is
+ (.permit permissive-handler
+ alice-kerb-context
+ "execute"
+ {DRPCSimpleACLAuthorizer/FUNCTION_KEY "wrongFunction"})))
+
+ (testing "allow execute to authorized user for correct function"
+ (is
+ (.permit permissive-handler
+ bob-context
+ "execute"
+ {DRPCSimpleACLAuthorizer/FUNCTION_KEY function}))))
+
+ (deftest test-invocation-authorization-strict
+ (doseq [operation ["fetchRequest" "failRequest" "result"]]
+
+ (testing (str "deny " operation
+ " to unauthorized user for correct function")
+ (is (not
+ (.permit
+ strict-handler
+ alice-context
+ operation
+ {DRPCSimpleACLAuthorizer/FUNCTION_KEY function})))
+
+ (testing (str "deny " operation
+ " to user for incorrect function when strict")
+ (is (not
+ (.permit
+ strict-handler
+ charlie-context
+ operation
+ {DRPCSimpleACLAuthorizer/FUNCTION_KEY "wrongFunction"}))))
+
+ (testing (str "allow " operation
+ " to authorized user for correct function")
+ (is
+ (.permit
+ strict-handler
+ charlie-context
+ operation
+ {DRPCSimpleACLAuthorizer/FUNCTION_KEY function}))))))
+
+ (deftest test-invocation-authorization-permissive
+ (doseq [operation ["fetchRequest" "failRequest" "result"]]
+
+ (testing (str "deny " operation
+ " to unauthorized user for correct function")
+ (is (not
+ (.permit
+ permissive-handler
+ bob-context
+ operation
+ {DRPCSimpleACLAuthorizer/FUNCTION_KEY function}))))
+
+ (testing (str "allow " operation
+ " to user for incorrect function when permissive")
+ (is
+ (.permit
+ permissive-handler
+ charlie-context
+ operation
+ {DRPCSimpleACLAuthorizer/FUNCTION_KEY "wrongFunction"})))
+
+ (testing (str operation " is allowed for authorized user")
+ (is
+ (.permit
+ permissive-handler
+ charlie-context
+ operation
+ {DRPCSimpleACLAuthorizer/FUNCTION_KEY function})))))
+
+ (deftest test-deny-when-no-function-given
+ (is (not
+ (.permit strict-handler alice-context "execute" {})))
+
+ (is (not
+ (.permit
+ strict-handler
+ alice-context
+ "execute"
+ {DRPCSimpleACLAuthorizer/FUNCTION_KEY nil})))
+
+ (is (not
+ (.permit permissive-handler bob-context "execute" {})))
+
+ (is (not
+ (.permit
+ permissive-handler
+ bob-context
+ "execute"
+ {DRPCSimpleACLAuthorizer/FUNCTION_KEY nil}))))
+
+ (deftest test-deny-when-invalid-user-given
+ (is (not
+ (.permit
+ strict-handler
+ (Mockito/mock ReqContext)
+ "execute"
+ {DRPCSimpleACLAuthorizer/FUNCTION_KEY function})))
+
+ (is (not
+ (.permit
+ strict-handler
+ nil
+ "execute"
+ {DRPCSimpleACLAuthorizer/FUNCTION_KEY function})))
+
+ (is (not
+ (.permit
+ permissive-handler
+ (Mockito/mock ReqContext)
+ "execute"
+ {DRPCSimpleACLAuthorizer/FUNCTION_KEY function})))
+
+ (is (not
+ (.permit
+ permissive-handler
+ nil
+ "execute"
+ {DRPCSimpleACLAuthorizer/FUNCTION_KEY function})))))
http://git-wip-us.apache.org/repos/asf/incubator-storm/blob/ce6e5d26/storm-core/test/clj/backtype/storm/security/auth/authorizer/DRPCSimpleAclAuthorizer_test.clj
----------------------------------------------------------------------
diff --git a/storm-core/test/clj/backtype/storm/security/auth/authorizer/DRPCSimpleAclAuthorizer_test.clj b/storm-core/test/clj/backtype/storm/security/auth/authorizer/DRPCSimpleAclAuthorizer_test.clj
deleted file mode 100644
index d592a40..0000000
--- a/storm-core/test/clj/backtype/storm/security/auth/authorizer/DRPCSimpleAclAuthorizer_test.clj
+++ /dev/null
@@ -1,226 +0,0 @@
-(ns backtype.storm.security.auth.authorizer.DRPCSimpleAclAuthorizer-test
- (:use [clojure test])
- (:import [org.mockito Mockito])
- (:import [backtype.storm Config])
- (:import [backtype.storm.security.auth ReqContext SingleUserPrincipal])
- (:import [backtype.storm.security.auth.authorizer DRPCSimpleACLAuthorizer])
- (:use [backtype.storm config util])
- )
-
-(defn- mk-mock-context [user]
- (let [mock-context (Mockito/mock ReqContext)]
- (. (Mockito/when (.principal mock-context)) thenReturn
- (SingleUserPrincipal. user))
- mock-context))
-
-(let [function "jump"
- partial-function "partial"
- alice-context (mk-mock-context "alice")
- alice-kerb-context (mk-mock-context "alice@SOME.RELM")
- bob-context (mk-mock-context "bob")
- charlie-context (mk-mock-context "charlie")
- acl-file "drpc-simple-acl-test-scenario.yaml"
- strict-handler (doto (DRPCSimpleACLAuthorizer.)
- (.prepare {DRPC-AUTHORIZER-ACL-STRICT true
- DRPC-AUTHORIZER-ACL-FILENAME acl-file
- STORM-PRINCIPAL-TO-LOCAL-PLUGIN "backtype.storm.security.auth.KerberosPrincipalToLocal"}))
- permissive-handler (doto (DRPCSimpleACLAuthorizer.)
- (.prepare {DRPC-AUTHORIZER-ACL-STRICT false
- DRPC-AUTHORIZER-ACL-FILENAME acl-file
- STORM-PRINCIPAL-TO-LOCAL-PLUGIN "backtype.storm.security.auth.KerberosPrincipalToLocal"}))]
-
- (deftest test-partial-authorization
- (testing "deny execute to unauthorized user"
- (is (not
- (.permit strict-handler
- (ReqContext/context)
- "execute"
- {DRPCSimpleACLAuthorizer/FUNCTION_KEY partial-function}))))
-
- (testing "allow execute to authorized kerb user for correct function"
- (is
- (.permit
- strict-handler
- alice-kerb-context
- "execute"
- {DRPCSimpleACLAuthorizer/FUNCTION_KEY partial-function})))
-
- (testing "deny fetchRequest to unauthorized user for correct function"
- (is (not
- (.permit
- strict-handler
- alice-kerb-context
- "fetchRequest"
- {DRPCSimpleACLAuthorizer/FUNCTION_KEY partial-function}))))
- )
-
- (deftest test-client-authorization-strict
- (testing "deny execute to unauthorized user"
- (is (not
- (.permit strict-handler
- (ReqContext/context)
- "execute"
- {DRPCSimpleACLAuthorizer/FUNCTION_KEY function}))))
-
- (testing "deny execute to valid user for incorrect function"
- (is (not
- (.permit
- strict-handler
- alice-context
- "execute"
- {DRPCSimpleACLAuthorizer/FUNCTION_KEY "wrongFunction"}))))
-
- (testing "allow execute to authorized kerb user for correct function"
- (is
- (.permit
- strict-handler
- alice-kerb-context
- "execute"
- {DRPCSimpleACLAuthorizer/FUNCTION_KEY function})))
-
- (testing "allow execute to authorized user for correct function"
- (is
- (.permit
- strict-handler
- alice-context
- "execute"
- {DRPCSimpleACLAuthorizer/FUNCTION_KEY function}))))
-
-
- (deftest test-client-authorization-permissive
- (testing "deny execute to unauthorized user for correct function"
- (is (not
- (.permit permissive-handler
- (ReqContext/context)
- "execute"
- {DRPCSimpleACLAuthorizer/FUNCTION_KEY function}))))
-
- (testing "allow execute for user for incorrect function when permissive"
- (is
- (.permit permissive-handler
- alice-context
- "execute"
- {DRPCSimpleACLAuthorizer/FUNCTION_KEY "wrongFunction"})))
-
- (testing "allow execute for user for incorrect function when permissive"
- (is
- (.permit permissive-handler
- alice-kerb-context
- "execute"
- {DRPCSimpleACLAuthorizer/FUNCTION_KEY "wrongFunction"})))
-
- (testing "allow execute to authorized user for correct function"
- (is
- (.permit permissive-handler
- bob-context
- "execute"
- {DRPCSimpleACLAuthorizer/FUNCTION_KEY function}))))
-
- (deftest test-invocation-authorization-strict
- (doseq [operation ["fetchRequest" "failRequest" "result"]]
-
- (testing (str "deny " operation
- " to unauthorized user for correct function")
- (is (not
- (.permit
- strict-handler
- alice-context
- operation
- {DRPCSimpleACLAuthorizer/FUNCTION_KEY function})))
-
- (testing (str "deny " operation
- " to user for incorrect function when strict")
- (is (not
- (.permit
- strict-handler
- charlie-context
- operation
- {DRPCSimpleACLAuthorizer/FUNCTION_KEY "wrongFunction"}))))
-
- (testing (str "allow " operation
- " to authorized user for correct function")
- (is
- (.permit
- strict-handler
- charlie-context
- operation
- {DRPCSimpleACLAuthorizer/FUNCTION_KEY function}))))))
-
- (deftest test-invocation-authorization-permissive
- (doseq [operation ["fetchRequest" "failRequest" "result"]]
-
- (testing (str "deny " operation
- " to unauthorized user for correct function")
- (is (not
- (.permit
- permissive-handler
- bob-context
- operation
- {DRPCSimpleACLAuthorizer/FUNCTION_KEY function}))))
-
- (testing (str "allow " operation
- " to user for incorrect function when permissive")
- (is
- (.permit
- permissive-handler
- charlie-context
- operation
- {DRPCSimpleACLAuthorizer/FUNCTION_KEY "wrongFunction"})))
-
- (testing (str operation " is allowed for authorized user")
- (is
- (.permit
- permissive-handler
- charlie-context
- operation
- {DRPCSimpleACLAuthorizer/FUNCTION_KEY function})))))
-
- (deftest test-deny-when-no-function-given
- (is (not
- (.permit strict-handler alice-context "execute" {})))
-
- (is (not
- (.permit
- strict-handler
- alice-context
- "execute"
- {DRPCSimpleACLAuthorizer/FUNCTION_KEY nil})))
-
- (is (not
- (.permit permissive-handler bob-context "execute" {})))
-
- (is (not
- (.permit
- permissive-handler
- bob-context
- "execute"
- {DRPCSimpleACLAuthorizer/FUNCTION_KEY nil}))))
-
- (deftest test-deny-when-invalid-user-given
- (is (not
- (.permit
- strict-handler
- (Mockito/mock ReqContext)
- "execute"
- {DRPCSimpleACLAuthorizer/FUNCTION_KEY function})))
-
- (is (not
- (.permit
- strict-handler
- nil
- "execute"
- {DRPCSimpleACLAuthorizer/FUNCTION_KEY function})))
-
- (is (not
- (.permit
- permissive-handler
- (Mockito/mock ReqContext)
- "execute"
- {DRPCSimpleACLAuthorizer/FUNCTION_KEY function})))
-
- (is (not
- (.permit
- permissive-handler
- nil
- "execute"
- {DRPCSimpleACLAuthorizer/FUNCTION_KEY function})))))