|
1 | 1 | (ns backtype.storm.nimbus-test
|
2 | 2 | (:use [clojure test])
|
| 3 | + (:require [backtype.storm [util :as util]]) |
3 | 4 | (:require [backtype.storm.daemon [nimbus :as nimbus]])
|
4 |
| - |
5 | 5 | (:import [backtype.storm.testing TestWordCounter TestWordSpout TestGlobalCount TestAggregatesCounter])
|
6 | 6 | (:import [backtype.storm.scheduler INimbus])
|
7 | 7 | (:use [backtype.storm bootstrap testing])
|
|
875 | 875 | )
|
876 | 876 | )
|
877 | 877 |
|
| 878 | +(deftest test-nimbus-check-authorization-params |
| 879 | + (with-local-cluster [cluster |
| 880 | + :daemon-conf {NIMBUS-AUTHORIZER "backtype.storm.security.auth.authorizer.NoopAuthorizer"}] |
| 881 | + (let [nimbus (:nimbus cluster) |
| 882 | + topology-name "test-nimbus-check-autho-params" |
| 883 | + topology (thrift/mk-topology {} {})] |
| 884 | + ; Fake good authorization as part of setup. |
| 885 | + (mocking [nimbus/check-authorization!] |
| 886 | + (submit-local-topology-with-opts nimbus topology-name {} topology |
| 887 | + (SubmitOptions. TopologyInitialStatus/INACTIVE))) |
| 888 | + (let [expected-name topology-name |
| 889 | + expected-conf {TOPOLOGY-NAME expected-name |
| 890 | + :foo :bar}] |
| 891 | + |
| 892 | + (testing "getTopologyConf calls check-authorization! with the correct parameters." |
| 893 | + (let [expected-operation "getTopologyConf"] |
| 894 | + (stubbing [nimbus/check-authorization! nil |
| 895 | + nimbus/try-read-storm-conf expected-conf |
| 896 | + util/to-json nil] |
| 897 | + (try |
| 898 | + (.getTopologyConf nimbus "fake-id") |
| 899 | + (catch NotAliveException e) |
| 900 | + (finally |
| 901 | + (verify-first-call-args-for-indices |
| 902 | + nimbus/check-authorization! |
| 903 | + [1 2 3] expected-name expected-conf expected-operation) |
| 904 | + (verify-first-call-args-for util/to-json expected-conf)))))) |
| 905 | + |
| 906 | + (testing "getTopology calls check-authorization! with the correct parameters." |
| 907 | + (let [expected-operation "getTopology"] |
| 908 | + (stubbing [nimbus/check-authorization! nil |
| 909 | + nimbus/try-read-storm-conf expected-conf |
| 910 | + nimbus/try-read-storm-topology nil |
| 911 | + system-topology! nil] |
| 912 | + (try |
| 913 | + (.getTopology nimbus "fake-id") |
| 914 | + (catch NotAliveException e) |
| 915 | + (finally |
| 916 | + (verify-first-call-args-for-indices |
| 917 | + nimbus/check-authorization! |
| 918 | + [1 2 3] expected-name expected-conf expected-operation) |
| 919 | + (verify-first-call-args-for-indices |
| 920 | + system-topology! [0] expected-conf)))))) |
| 921 | + |
| 922 | + (testing "getUserTopology calls check-authorization with the correct parameters." |
| 923 | + (let [expected-operation "getUserTopology"] |
| 924 | + (stubbing [nimbus/check-authorization! nil |
| 925 | + nimbus/try-read-storm-conf expected-conf |
| 926 | + nimbus/try-read-storm-topology nil] |
| 927 | + (try |
| 928 | + (.getUserTopology nimbus "fake-id") |
| 929 | + (catch NotAliveException e) |
| 930 | + (finally |
| 931 | + (verify-first-call-args-for-indices |
| 932 | + nimbus/check-authorization! |
| 933 | + [1 2 3] expected-name expected-conf expected-operation) |
| 934 | + (verify-first-call-args-for-indices |
| 935 | + nimbus/try-read-storm-topology [0] expected-conf)))))))))) |
| 936 | + |
878 | 937 | (deftest test-nimbus-iface-getTopology-methods-throw-correctly
|
879 | 938 | (with-local-cluster [cluster]
|
880 | 939 | (let [
|
|
0 commit comments