diff --git a/src/notehub/api.clj b/src/notehub/api.clj index 7f0f5b5..7753591 100644 --- a/src/notehub/api.clj +++ b/src/notehub/api.clj @@ -64,7 +64,7 @@ (f (if (and (:noteID params) (< (Double/parseDouble version) 1.3)) (assoc params :noteID (sreplace (params :noteID) #" " "/")) params)) - (create-response false "API version expected"))) + {:status (create-response false "API version expected")})) (defn get-note [{:keys [noteID]}] (if (storage/note-exists? noteID) @@ -76,7 +76,7 @@ :statistics (storage/get-note-statistics noteID) :status (create-response true) :publisher (storage/get-publisher noteID)}) - (create-response false "noteID '%s' unknown" noteID))) + {:status (create-response false "noteID '%s' unknown" noteID)})) (defn post-note [{:keys [note pid signature password] :as params}] diff --git a/test/notehub/test/api.clj b/test/notehub/test/api.clj index 1f6f4cd..0a651e9 100644 --- a/test/notehub/test/api.clj +++ b/test/notehub/test/api.clj @@ -66,6 +66,7 @@ (is (= (:title get-response) (derive-title note))) (is (= "1" (get-in get-response [:statistics :views]))) (isnt (get-in get-response [:statistics :edited])) + (is (= "noteID 'randomString' unknown"(get-in (parse-string (:body (send-request "/api/note" {:version "1.3" :noteID "randomString"}))) ["status" "message"]))) (is (= "3" (get-in (get-note post-response) [:statistics :views]))))) (testing "creation with wrong signature" (let [response (post-note {:note note :pid pid :signature (storage/sign pid2 psk note)})] @@ -121,8 +122,8 @@ (is (get-in body ["status" "success"])) (is (= note ((parse-string (:body (send-request [:get "/api/note"] {:version "1.0" :noteID noteID}))) "note"))) - (is (= "API version expected" ((parse-string - (:body (send-request [:get "/api/note"] {:noteID noteID}))) "message"))) + (is (= "API version expected" (get-in (parse-string + (:body (send-request [:get "/api/note"] {:noteID noteID}))) ["status" "message"]))) (is (= note ((parse-string (:body (send-request [:get "/api/note"] {:version "1.1" :noteID (clojure.string/replace noteID #"/" " ")}))) "note")))