Skip to content

Commit

Permalink
fix proxied server tests
Browse files Browse the repository at this point in the history
  • Loading branch information
d-t-w committed Jan 17, 2025
1 parent 12622ca commit 729b339
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions slipway-jetty12/test/slipway/proxied_server_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,15 @@

;; requires authentication
(is (= {:protocol-version {:name "HTTP" :major 1 :minor 1}
:status 303
:reason-phrase "See Other"
:status 302
:reason-phrase "Found"
:orig-content-encoding nil
:body ""}
(-> (client/do-get "http" "localhost" 3000 "")
(select-keys of-interest))))

(is (= 303 (:status (client/do-get "http" "localhost" 3000 "/"))))
(is (= 303 (:status (client/do-get "http" "localhost" 3000 "/user"))))
(is (= 302 (:status (client/do-get "http" "localhost" 3000 "/"))))
(is (= 302 (:status (client/do-get "http" "localhost" 3000 "/user"))))

;; auth redirect goes to expected login page
(is (= "http://localhost:3000/login" (get-in (client/do-get "http" "localhost" 3000 "")
Expand All @@ -149,7 +149,7 @@
(is (= 200 (:status (client/do-get "http" "localhost" 3000 "/login-retry"))))

;; jetty nukes session and redirects to /login regardless
(is (= 303 (:status (client/do-get "http" "localhost" 3000 "/logout")))))
(is (= 302 (:status (client/do-get "http" "localhost" 3000 "/logout")))))

(testing "constraints https"

Expand All @@ -168,15 +168,15 @@

;; requires authentication
(is (= {:protocol-version {:name "HTTP" :major 1 :minor 1}
:status 303
:reason-phrase "See Other"
:status 302
:reason-phrase "Found"
:orig-content-encoding nil
:body ""}
(-> (client/do-get "https" "localhost" 3443 "" {:insecure? true})
(select-keys of-interest))))

(is (= 303 (:status (client/do-get "https" "localhost" 3443 "/" {:insecure? true}))))
(is (= 303 (:status (client/do-get "https" "localhost" 3443 "/user" {:insecure? true}))))
(is (= 302 (:status (client/do-get "https" "localhost" 3443 "/" {:insecure? true}))))
(is (= 302 (:status (client/do-get "https" "localhost" 3443 "/user" {:insecure? true}))))

;; auth redirect goes to expected login page
(is (= "https://localhost:3443/login" (get-in (client/do-get "https" "localhost" 3443 "" {:insecure? true})
Expand All @@ -194,7 +194,7 @@
(is (= 200 (:status (client/do-get "https" "localhost" 3443 "/login-retry" {:insecure? true}))))

;; jetty nukes session and redirects to /login regardless
(is (= 303 (:status (client/do-get "https" "localhost" 3443 "/logout" {:insecure? true})))))
(is (= 302 (:status (client/do-get "https" "localhost" 3443 "/logout" {:insecure? true})))))

(testing "login http"

Expand Down Expand Up @@ -315,17 +315,17 @@
(testing "logout"

(is (= {:protocol-version {:name "HTTP" :major 1 :minor 1}
:reason-phrase "See Other"
:status 303}
:reason-phrase "Found"
:status 302}
(let [session (-> (client/do-login "http" "localhost" 3000 "" "admin" "admin")
(select-keys [:cookies]))]
(client/do-get "http" "localhost" 3000 "/logout" session)
(-> (client/do-get "http" "localhost" 3000 "/" session)
(select-keys [:protocol-version :status :reason-phrase])))))

(is (= {:protocol-version {:name "HTTP" :major 1 :minor 1}
:reason-phrase "See Other"
:status 303}
:reason-phrase "Found"
:status 302}
(let [session (-> (client/do-login "https" "localhost" 3443 "" "admin" "admin" {:insecure? true})
(select-keys [:cookies])
(merge {:insecure? true}))]
Expand Down

0 comments on commit 729b339

Please sign in to comment.