diff options
Diffstat (limited to 'compojure-3.2/test/compojure/crypto_test.clj')
| -rwxr-xr-x | compojure-3.2/test/compojure/crypto_test.clj | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/compojure-3.2/test/compojure/crypto_test.clj b/compojure-3.2/test/compojure/crypto_test.clj new file mode 100755 index 0000000..ee309e6 --- /dev/null +++ b/compojure-3.2/test/compojure/crypto_test.clj @@ -0,0 +1,35 @@ +(ns compojure.crypto-test + (:use compojure.crypto + clojure.contrib.test-is)) + +(deftest secret-key-length + (are (= (count (gen-secret-key {:key-size _1})) _2) + 256 32 + 128 16)) + +(deftest secret-key-uniqueness + (let [a (gen-secret-key {:key-size 128}) + b (gen-secret-key {:key-size 128})] + (is (not= a b)))) + +(def secret-key + (.getBytes "0123456789ABCDEF")) + +(deftest seal-string + (is (not= (seal secret-key "Foobar") "Foobar"))) + +(deftest seal-uniqueness + (let [a (seal secret-key "Foobar") + b (seal secret-key "Foobar")] + (is (not= a b)))) + +(deftest seal-then-unseal + (are (= (unseal secret-key (seal secret-key _1)) _1) + "Foobar" + [1 2 3] + {:a 10})) + +(deftest seal-then-tamper + (let [data (seal secret-key "Foobar") + data (apply str "A" (rest data))] + (is (nil? (unseal secret-key "Foobar"))))) |
