note editing via passwords enabled

This commit is contained in:
Christian Mueller
2012-07-14 22:34:11 +02:00
parent e53fad2319
commit 9203913886
9 changed files with 178 additions and 59 deletions
+13
View File
@@ -33,6 +33,19 @@
(get-note date test-title)
(get-note-views date test-title))
"2")))
(testing "of note update"
(is (= (do
(set-note date test-title test-note "12345qwert")
(get-note date test-title))
test-note))
(is (= (do
(update-note (build-key date test-title) "update" "12345qwert")
(get-note date test-title))
"update"))
(is (= (do
(update-note (build-key date test-title) "not authorized" "44444")
(get-note date test-title))
"update")))
(testing "of the note access"
(is (not= (get-note date test-title) "any text")))
(testing "session management"
+37 -1
View File
@@ -36,7 +36,6 @@
(deftest note-creation
(let [session-key (create-session)
date (get-date)
; TODO: replace note generation by a function from pages.clj
title "this-is-a-test-note"
[year month day] date]
(testing "Note creation"
@@ -54,6 +53,43 @@
(delete-note date title)
(not (note-exists? date title)))))))
(deftest note-update
(let [session-key (create-session)
date (get-date)
title "test-note"
[year month day] date]
(testing "Note update"
(is (has-status
(send-request
[:post "/post-note"]
{:session-key session-key
:draft "test note"
:password "qwerty"
:session-value (str (lib/hash #(.codePointAt % 0)
(str "test note" session-key)))}) 302))
(is (note-exists? date title))
(is (substring? "test note"
((send-request (url year month day title)) :body)))
(is (has-status
(send-request
[:post "/update-note"]
{:key (build-key [year month day] title)
:draft "WRONG pass"
:password "qwerty1" }) 403))
(is (substring? "test note"
((send-request (url year month day title)) :body)))
(is (has-status
(send-request
[:post "/update-note"]
{:key (build-key [year month day] title)
:draft "UPDATED CONTENT"
:password "qwerty" }) 302))
(is (substring? "UPDATED CONTENT"
((send-request (url year month day title)) :body)))
(is (do
(delete-note date title)
(not (note-exists? date title)))))))
(deftest requests
(testing "HTTP Status"
(testing "of a wrong access"