Skip to content
Browse files

added explicit authentication and requirepass testing

  • Loading branch information...
1 parent 3cdb5e3 commit 65d2b581759cdfc774d0fb8e278004c24767f461 @jeyoor committed Dec 12, 2011
Showing with 15 additions and 5 deletions.
  1. +15 −5 test/redis/command_tests.clj
View
20 test/redis/command_tests.clj
@@ -24,13 +24,14 @@
(redis/hset "hash" "two" "bar")
(redis/hset "hash" "three" "baz")
(f)
- (redis/flushdb))
+ (redis/flushdb)
+ (redis/config "set" "requirepass" "testing"))
(redis/with-server
{:host "127.0.0.1"
:port 6379
:db 15
- :password "testpass"
+ :password "testing"
}
;; String value
(redis/set "foo" "bar")
@@ -47,7 +48,9 @@
(redis/hset "hash" "two" "bar")
(redis/hset "hash" "three" "baz")
(f)
- (redis/flushdb)))
+ (redis/flushdb)
+ (redis/config "set" "requirepass" "")
+ (redis/quit)))
(use-fixtures :each server-fixture)
@@ -683,9 +686,16 @@
(deftest config
(let [response (redis/config "get" "timeout")
- timeout ((Integer/parseInt (second res)))]
+ timeout (Integer/parseInt (second response))]
(is (= "timeout" (first response)))
(is (integer? timeout))
(redis/config "set" "timeout" "0")
(is (= "0" (second (redis/config "get" "timeout"))))
- (redis/config "set" "timeout" timeout)))
+ (redis/config "set" "timeout" timeout)))
+
+ (deftest auth
+ (if-let [password (second (redis/config "get" "requirepass"))]
+ (do
+ (is (thrown? Exception (redis/auth (str password "WRONGPASS"))))
+ (is (= "OK" (redis/auth password))))
+ (is (thrown? Exception (redis/auth "anypassword")))))

0 comments on commit 65d2b58

Please sign in to comment.
Something went wrong with that request. Please try again.