Permalink
Browse files

Add test for user already logged in.

  • Loading branch information...
1 parent 241b8fc commit afd5e7ed8a8c806d2b50f0704f20679b69f587e1 @duelinmarkers committed Aug 17, 2009
Showing with 8 additions and 1 deletion.
  1. +8 −1 test/appengine_clj/users_test.clj
@@ -19,5 +19,12 @@
(wrapped-app-with-url request))))
(let [wrapped-app-with-no-url (users/wrap-requiring-login #(throw (Exception.)))]
(is (= {:status 302 :headers {"Location" "/login?then=/"}}
- (wrapped-app-with-no-url request)))))))
+ (wrapped-app-with-no-url request))))))
+ (testing "allows request to pass when user is logged in"
+ (let [fake-user-service (proxy [com.google.appengine.api.users.UserService] []
+ (isUserLoggedIn [] true))
+ request {:appengine-clj/user-info {:user nil :user-service fake-user-service}}]
+ (let [wrapped-app (users/wrap-requiring-login (fn [request] {:status 200 :body "Hello"}))]
+ (is (= {:status 200 :body "Hello"}
+ (wrapped-app request)))))))

0 comments on commit afd5e7e

Please sign in to comment.