Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Uncomment and fix wrap-requiring-login test and fix the bug reported …

…by Victor Rodriguez.
  • Loading branch information...
commit 2cfe33effd429507e62fb202b330995dcbc61f6e 1 parent 4aab779
@duelinmarkers authored
View
4 src/appengine_clj/users.clj
@@ -23,7 +23,7 @@
(defn wrap-requiring-login
[application]
(fn [request]
- (let [{:keys [user-service]} (:appengine-clj/user-info request)]
+ (let [{:keys [user-service]} (user-info request)]
(if (.isUserLoggedIn user-service)
(application request)
- {:status 302 :headers {"Location" (.createLoginURL user-service)}}))))
+ {:status 302 :headers {"Location" (.createLoginURL user-service "/")}}))))
View
9 test/appengine_clj/users_test.clj
@@ -8,14 +8,13 @@
ring-request {:appengine-clj/user-info user-info-map}]
(is (= (users/user-info ring-request) user-info-map))))
-(comment
(deftest wrap-requiring-login
(testing "redirects to login when user isn't logged in"
(let [fake-user-service (proxy [com.google.appengine.api.users.UserService] []
(isUserLoggedIn [] false)
(createLoginURL [dest] (str "/login?then=" dest)))
- request {:appengine-clj/user-info {:user nil :user-service fake-user-service}}]
- (is (= {:status 302 :headers {"Location" "/login?then=/path"}}
- ((users/wrap-requiring-login #(throw (Exception.)) request)))))))
-)
+ request {:appengine-clj/user-info {:user nil :user-service fake-user-service}}
+ wrapped-app (users/wrap-requiring-login #(throw (Exception.)))]
+ (is (= {:status 302 :headers {"Location" "/login?then=/"}}
+ (wrapped-app request))))))
Please sign in to comment.
Something went wrong with that request. Please try again.