Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for port allocation errors during tests #594

Merged
merged 1 commit into from
Jun 21, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
176 changes: 90 additions & 86 deletions storm-core/test/clj/backtype/storm/security/auth/auth_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -123,101 +123,105 @@
))

(deftest Simple-authentication-test
(with-server [6627 nil nil "backtype.storm.security.auth.SimpleTransportPlugin"]
(let [storm-conf (merge (read-storm-config)
{STORM-THRIFT-TRANSPORT-PLUGIN "backtype.storm.security.auth.SimpleTransportPlugin"})
client (NimbusClient. storm-conf "localhost" 6627 nimbus-timeout)
nimbus_client (.getClient client)]
(.activate nimbus_client "security_auth_test_topology")
(.close client))

(let [storm-conf (merge (read-storm-config)
{STORM-THRIFT-TRANSPORT-PLUGIN "backtype.storm.security.auth.digest.DigestSaslTransportPlugin"
"java.security.auth.login.config" "test/clj/backtype/storm/security/auth/jaas_digest.conf"})]
(testing "(Negative authentication) Server: Simple vs. Client: Digest"
(is (thrown-cause? java.net.SocketTimeoutException
(NimbusClient. storm-conf "localhost" 6627 nimbus-timeout)))))))
(let [a-port (available-port)]
(with-server [a-port nil nil "backtype.storm.security.auth.SimpleTransportPlugin"]
(let [storm-conf (merge (read-storm-config)
{STORM-THRIFT-TRANSPORT-PLUGIN "backtype.storm.security.auth.SimpleTransportPlugin"})
client (NimbusClient. storm-conf "localhost" a-port nimbus-timeout)
nimbus_client (.getClient client)]
(.activate nimbus_client "security_auth_test_topology")
(.close client))

(let [storm-conf (merge (read-storm-config)
{STORM-THRIFT-TRANSPORT-PLUGIN "backtype.storm.security.auth.digest.DigestSaslTransportPlugin"
"java.security.auth.login.config" "test/clj/backtype/storm/security/auth/jaas_digest.conf"})]
(testing "(Negative authentication) Server: Simple vs. Client: Digest"
(is (thrown-cause? java.net.SocketTimeoutException
(NimbusClient. storm-conf "localhost" a-port nimbus-timeout))))))))

(deftest positive-authorization-test
(with-server [6627 nil
"backtype.storm.security.auth.authorizer.NoopAuthorizer"
"backtype.storm.security.auth.SimpleTransportPlugin"]
(let [storm-conf (merge (read-storm-config)
{STORM-THRIFT-TRANSPORT-PLUGIN "backtype.storm.security.auth.SimpleTransportPlugin"})
client (NimbusClient. storm-conf "localhost" 6627 nimbus-timeout)
nimbus_client (.getClient client)]
(testing "(Positive authorization) Authorization plugin should accept client request"
(.activate nimbus_client "security_auth_test_topology"))
(.close client))))
(let [a-port (available-port)]
(with-server [a-port nil
"backtype.storm.security.auth.authorizer.NoopAuthorizer"
"backtype.storm.security.auth.SimpleTransportPlugin"]
(let [storm-conf (merge (read-storm-config)
{STORM-THRIFT-TRANSPORT-PLUGIN "backtype.storm.security.auth.SimpleTransportPlugin"})
client (NimbusClient. storm-conf "localhost" a-port nimbus-timeout)
nimbus_client (.getClient client)]
(testing "(Positive authorization) Authorization plugin should accept client request"
(.activate nimbus_client "security_auth_test_topology"))
(.close client)))))

(deftest deny-authorization-test
(with-server [6627 nil
"backtype.storm.security.auth.authorizer.DenyAuthorizer"
"backtype.storm.security.auth.SimpleTransportPlugin"]
(let [storm-conf (merge (read-storm-config)
{STORM-THRIFT-TRANSPORT-PLUGIN "backtype.storm.security.auth.SimpleTransportPlugin"
Config/NIMBUS_HOST "localhost"
Config/NIMBUS_THRIFT_PORT 6627
Config/NIMBUS_TASK_TIMEOUT_SECS nimbus-timeout})
client (NimbusClient/getConfiguredClient storm-conf)
nimbus_client (.getClient client)]
(testing "(Negative authorization) Authorization plugin should reject client request"
(is (thrown? TTransportException
(.activate nimbus_client "security_auth_test_topology"))))
(.close client))))
(let [a-port (available-port)]
(with-server [a-port nil
"backtype.storm.security.auth.authorizer.DenyAuthorizer"
"backtype.storm.security.auth.SimpleTransportPlugin"]
(let [storm-conf (merge (read-storm-config)
{STORM-THRIFT-TRANSPORT-PLUGIN "backtype.storm.security.auth.SimpleTransportPlugin"
Config/NIMBUS_HOST "localhost"
Config/NIMBUS_THRIFT_PORT a-port
Config/NIMBUS_TASK_TIMEOUT_SECS nimbus-timeout})
client (NimbusClient/getConfiguredClient storm-conf)
nimbus_client (.getClient client)]
(testing "(Negative authorization) Authorization plugin should reject client request"
(is (thrown? TTransportException
(.activate nimbus_client "security_auth_test_topology"))))
(.close client)))))

(deftest digest-authentication-test
(with-server [6630
"test/clj/backtype/storm/security/auth/jaas_digest.conf"
nil
"backtype.storm.security.auth.digest.DigestSaslTransportPlugin"]
(let [storm-conf (merge (read-storm-config)
{STORM-THRIFT-TRANSPORT-PLUGIN "backtype.storm.security.auth.digest.DigestSaslTransportPlugin"
"java.security.auth.login.config" "test/clj/backtype/storm/security/auth/jaas_digest.conf"})
client (NimbusClient. storm-conf "localhost" 6630 nimbus-timeout)
nimbus_client (.getClient client)]
(testing "(Positive authentication) valid digest authentication"
(.activate nimbus_client "security_auth_test_topology"))
(.close client))

(let [storm-conf (merge (read-storm-config)
{STORM-THRIFT-TRANSPORT-PLUGIN "backtype.storm.security.auth.SimpleTransportPlugin"})
client (NimbusClient. storm-conf "localhost" 6630 nimbus-timeout)
nimbus_client (.getClient client)]
(testing "(Negative authentication) Server: Digest vs. Client: Simple"
(is (thrown-cause? java.net.SocketTimeoutException
(.activate nimbus_client "security_auth_test_topology"))))
(.close client))
(let [a-port (available-port)]
(with-server [a-port
"test/clj/backtype/storm/security/auth/jaas_digest.conf"
nil
"backtype.storm.security.auth.digest.DigestSaslTransportPlugin"]
(let [storm-conf (merge (read-storm-config)
{STORM-THRIFT-TRANSPORT-PLUGIN "backtype.storm.security.auth.digest.DigestSaslTransportPlugin"
"java.security.auth.login.config" "test/clj/backtype/storm/security/auth/jaas_digest.conf"})
client (NimbusClient. storm-conf "localhost" a-port nimbus-timeout)
nimbus_client (.getClient client)]
(testing "(Positive authentication) valid digest authentication"
(.activate nimbus_client "security_auth_test_topology"))
(.close client))

(let [storm-conf (merge (read-storm-config)
{STORM-THRIFT-TRANSPORT-PLUGIN "backtype.storm.security.auth.digest.DigestSaslTransportPlugin"
(let [storm-conf (merge (read-storm-config)
{STORM-THRIFT-TRANSPORT-PLUGIN "backtype.storm.security.auth.SimpleTransportPlugin"})
client (NimbusClient. storm-conf "localhost" a-port nimbus-timeout)
nimbus_client (.getClient client)]
(testing "(Negative authentication) Server: Digest vs. Client: Simple"
(is (thrown-cause? java.net.SocketTimeoutException
(.activate nimbus_client "security_auth_test_topology"))))
(.close client))

(let [storm-conf (merge (read-storm-config)
{STORM-THRIFT-TRANSPORT-PLUGIN "backtype.storm.security.auth.digest.DigestSaslTransportPlugin"
"java.security.auth.login.config" "test/clj/backtype/storm/security/auth/jaas_digest_bad_password.conf"})]
(testing "(Negative authentication) Invalid password"
(is (thrown? TTransportException
(NimbusClient. storm-conf "localhost" 6630 nimbus-timeout)))))
(testing "(Negative authentication) Invalid password"
(is (thrown? TTransportException
(NimbusClient. storm-conf "localhost" a-port nimbus-timeout)))))

(let [storm-conf (merge (read-storm-config)
{STORM-THRIFT-TRANSPORT-PLUGIN "backtype.storm.security.auth.digest.DigestSaslTransportPlugin"
"java.security.auth.login.config" "test/clj/backtype/storm/security/auth/jaas_digest_unknown_user.conf"})]
(testing "(Negative authentication) Unknown user"
(is (thrown? TTransportException
(NimbusClient. storm-conf "localhost" a-port nimbus-timeout)))))

(let [storm-conf (merge (read-storm-config)
{STORM-THRIFT-TRANSPORT-PLUGIN "backtype.storm.security.auth.digest.DigestSaslTransportPlugin"
"java.security.auth.login.config" "test/clj/backtype/storm/security/auth/nonexistent.conf"})]
(testing "(Negative authentication) nonexistent configuration file"
(is (thrown? RuntimeException
(NimbusClient. storm-conf "localhost" a-port nimbus-timeout)))))

(let [storm-conf (merge (read-storm-config)
{STORM-THRIFT-TRANSPORT-PLUGIN "backtype.storm.security.auth.digest.DigestSaslTransportPlugin"
"java.security.auth.login.config" "test/clj/backtype/storm/security/auth/jaas_digest_unknown_user.conf"})]
(testing "(Negative authentication) Unknown user"
(is (thrown? TTransportException
(NimbusClient. storm-conf "localhost" 6630 nimbus-timeout)))))

(let [storm-conf (merge (read-storm-config)
{STORM-THRIFT-TRANSPORT-PLUGIN "backtype.storm.security.auth.digest.DigestSaslTransportPlugin"
"java.security.auth.login.config" "test/clj/backtype/storm/security/auth/nonexistent.conf"})]
(testing "(Negative authentication) nonexistent configuration file"
(is (thrown? RuntimeException
(NimbusClient. storm-conf "localhost" 6630 nimbus-timeout)))))

(let [storm-conf (merge (read-storm-config)
{STORM-THRIFT-TRANSPORT-PLUGIN "backtype.storm.security.auth.digest.DigestSaslTransportPlugin"
"java.security.auth.login.config" "test/clj/backtype/storm/security/auth/jaas_digest_missing_client.conf"})]
(testing "(Negative authentication) Missing client"
(is (thrown-cause? java.io.IOException
(NimbusClient. storm-conf "localhost" 6630 nimbus-timeout)))))))


(let [storm-conf (merge (read-storm-config)
{STORM-THRIFT-TRANSPORT-PLUGIN "backtype.storm.security.auth.digest.DigestSaslTransportPlugin"
"java.security.auth.login.config" "test/clj/backtype/storm/security/auth/jaas_digest_missing_client.conf"})]
(testing "(Negative authentication) Missing client"
(is (thrown-cause? java.io.IOException
(NimbusClient. storm-conf "localhost" a-port nimbus-timeout))))))))


(deftest test-GetTransportPlugin-throws-RuntimeException
(let [conf (merge (read-storm-config)
{Config/STORM_THRIFT_TRANSPORT_PLUGIN "null.invalid"})]
Expand Down