bugfix
This commit is contained in:
+2
-2
@@ -64,7 +64,7 @@
|
|||||||
(f (if (and (:noteID params) (< (Double/parseDouble version) 1.3))
|
(f (if (and (:noteID params) (< (Double/parseDouble version) 1.3))
|
||||||
(assoc params :noteID (sreplace (params :noteID) #" " "/"))
|
(assoc params :noteID (sreplace (params :noteID) #" " "/"))
|
||||||
params))
|
params))
|
||||||
(create-response false "API version expected")))
|
{:status (create-response false "API version expected")}))
|
||||||
|
|
||||||
(defn get-note [{:keys [noteID]}]
|
(defn get-note [{:keys [noteID]}]
|
||||||
(if (storage/note-exists? noteID)
|
(if (storage/note-exists? noteID)
|
||||||
@@ -76,7 +76,7 @@
|
|||||||
:statistics (storage/get-note-statistics noteID)
|
:statistics (storage/get-note-statistics noteID)
|
||||||
:status (create-response true)
|
:status (create-response true)
|
||||||
:publisher (storage/get-publisher noteID)})
|
:publisher (storage/get-publisher noteID)})
|
||||||
(create-response false "noteID '%s' unknown" noteID)))
|
{:status (create-response false "noteID '%s' unknown" noteID)}))
|
||||||
|
|
||||||
(defn post-note
|
(defn post-note
|
||||||
[{:keys [note pid signature password] :as params}]
|
[{:keys [note pid signature password] :as params}]
|
||||||
|
|||||||
@@ -66,6 +66,7 @@
|
|||||||
(is (= (:title get-response) (derive-title note)))
|
(is (= (:title get-response) (derive-title note)))
|
||||||
(is (= "1" (get-in get-response [:statistics :views])))
|
(is (= "1" (get-in get-response [:statistics :views])))
|
||||||
(isnt (get-in get-response [:statistics :edited]))
|
(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])))))
|
(is (= "3" (get-in (get-note post-response) [:statistics :views])))))
|
||||||
(testing "creation with wrong signature"
|
(testing "creation with wrong signature"
|
||||||
(let [response (post-note {:note note :pid pid :signature (storage/sign pid2 psk note)})]
|
(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 (get-in body ["status" "success"]))
|
||||||
(is (= note ((parse-string
|
(is (= note ((parse-string
|
||||||
(:body (send-request [:get "/api/note"] {:version "1.0" :noteID noteID}))) "note")))
|
(:body (send-request [:get "/api/note"] {:version "1.0" :noteID noteID}))) "note")))
|
||||||
(is (= "API version expected" ((parse-string
|
(is (= "API version expected" (get-in (parse-string
|
||||||
(:body (send-request [:get "/api/note"] {:noteID noteID}))) "message")))
|
(:body (send-request [:get "/api/note"] {:noteID noteID}))) ["status" "message"])))
|
||||||
(is (= note ((parse-string
|
(is (= note ((parse-string
|
||||||
(:body (send-request [:get "/api/note"] {:version "1.1"
|
(:body (send-request [:get "/api/note"] {:version "1.1"
|
||||||
:noteID (clojure.string/replace noteID #"/" " ")}))) "note")))
|
:noteID (clojure.string/replace noteID #"/" " ")}))) "note")))
|
||||||
|
|||||||
Reference in New Issue
Block a user