Created
December 23, 2012 16:24
-
-
Save boxxxie/4364133 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;this fn doesn't work. couchdb is still being called even though with-redef is replacing the authenticator. | |
(with-redefs [ | |
api.routes.login/conn (db.datomic.seeding/connection-to-seeded-db) | |
api.db.couch/authenticator (constantly {:basic-authentication {:ok true :name nil :roles ["_admin"] } :couchdb-id "sharedadmin"}) | |
] | |
;;use mem DB for this | |
(deftest login-route | |
(testing "testing logging in as sharedadmin" | |
(is (= (-> (session api.core/app) ;Use your ring app | |
(request ,,, "/login" :request-method :post | |
:headers { :authorization (str "Basic " (encode-str "sharedadmin:ujJWj5jM"))})) | |
{:username "sharedadmin" :admin true :firstname "En" :lastname "Ginuity"}))))) | |
;;this works. | |
;;api.routes.login/couch-auth-proxy called api.db.couch/authenticator through another fn (testing if i could redef more than 1 level deep) | |
(with-redefs [ | |
api.db.couch/authenticator | |
(fn [username pass] | |
;(if (= username "sharedadmin") | |
{:basic-authentication {:ok true :name nil :roles ["_admin"] } :couchdb-id "sharedadmin"} | |
; nil) | |
)] | |
(println (api.routes.login/couch-auth-proxy))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment