Permalink
Browse files

Jetty SSL tests

  • Loading branch information...
1 parent 8454d80 commit e86afb4a0b9eb5d59d1fc63c39012c1be058ab76 @weavejester weavejester committed Feb 25, 2012
View
BIN ring-jetty-adapter/test/keystore.jks
Binary file not shown.
View
25 ring-jetty-adapter/test/ring/adapter/test/jetty.clj
@@ -8,13 +8,26 @@
:headers {"Content-Type" "text/plain"}
:body "Hello World"})
-(deftest jetty-test
- (let [server (run-jetty hello-world {:port 4347, :join? false})]
- (try
- (Thread/sleep 2000)
+(defmacro with-server [options & body]
+ `(let [server# (run-jetty hello-world ~(assoc options :join? false))]
+ (try
+ ~@body
+ (finally (.stop server#)))))
+
+(deftest test-run-jetty
+ (testing "HTTP server"
+ (with-server {:port 4347}
(let [response (http/get "http://localhost:4347")]
(is (= (:status response) 200))
(is (.startsWith (get-in response [:headers "content-type"])
"text/plain"))
- (is (= (:body response) "Hello World")))
- (finally (.stop server)))))
+ (is (= (:body response) "Hello World")))))
+
+ (testing "HTTPS server"
+ (with-server {:port 4347
+ :ssl-port 4348
+ :keystore "test/keystore.jks"
+ :key-password "password"}
+ (let [response (http/get "https://localhost:4348" {:insecure? true})]
+ (is (= (:status response) 200))
+ (is (= (:body response) "Hello World"))))))

0 comments on commit e86afb4

Please sign in to comment.