|
39 | 39 | user-id "alice"
|
40 | 40 | another-user "alice_smith"
|
41 | 41 | catid 2]
|
42 |
| - (let [response (-> (request :put (str "/api/applications/save")) |
| 42 | + (let [response (-> (request :post (str "/api/applications/save")) |
43 | 43 | (authenticate api-key user-id)
|
44 | 44 | (json-body {:command "save"
|
45 | 45 | :catalogue-items [catid]
|
|
86 | 86 | application (read-body response)]
|
87 | 87 | (is (= 401 (:status response)))))
|
88 | 88 | (testing "saving as other user"
|
89 |
| - (let [response (-> (request :put (str "/api/applications/save")) |
| 89 | + (let [response (-> (request :post (str "/api/applications/save")) |
90 | 90 | (authenticate api-key another-user)
|
91 | 91 | (json-body {:command "save"
|
92 | 92 | :application-id application-id
|
93 | 93 | :items {1 "REST-Test"}})
|
94 | 94 | app)]
|
95 | 95 | (is (= 401 (:status response)))))
|
96 | 96 | (testing "submitting"
|
97 |
| - (let [response (-> (request :put (str "/api/applications/save")) |
| 97 | + (let [response (-> (request :post (str "/api/applications/save")) |
98 | 98 | (authenticate api-key user-id)
|
99 | 99 | (json-body {:command "submit"
|
100 | 100 | :application-id application-id
|
|
111 | 111 | (is (:valid cmd-response))
|
112 | 112 | (is (empty? (:validation cmd-response)))))
|
113 | 113 | (testing "approving"
|
114 |
| - (let [response (-> (request :put (str "/api/applications/judge")) |
| 114 | + (let [response (-> (request :post (str "/api/applications/judge")) |
115 | 115 | (authenticate api-key "developer")
|
116 | 116 | (json-body {:command "approve"
|
117 | 117 | :application-id application-id
|
|
131 | 131 | (let [api-key "42"
|
132 | 132 | user-id "alice"
|
133 | 133 | catid 2]
|
134 |
| - (let [response (-> (request :put (str "/api/applications/save")) |
| 134 | + (let [response (-> (request :post (str "/api/applications/save")) |
135 | 135 | (authenticate api-key user-id)
|
136 | 136 | (json-body {:command "save"
|
137 | 137 | :catalogue-items [catid]
|
|
150 | 150 | (is (some #(.contains (:text %) "non-localized link license") validations))
|
151 | 151 | (is (some #(.contains (:text %) "non-localized text license") validations)))
|
152 | 152 | (testing "add one field"
|
153 |
| - (let [response (-> (request :put (str "/api/applications/save")) |
| 153 | + (let [response (-> (request :post (str "/api/applications/save")) |
154 | 154 | (authenticate api-key user-id)
|
155 | 155 | (json-body {:command "save"
|
156 | 156 | :application-id application-id
|
|
162 | 162 | (is (not (:valid cmd-response)))
|
163 | 163 | (is (= 3 (count validations)))))
|
164 | 164 | (testing "add one license"
|
165 |
| - (let [response (-> (request :put (str "/api/applications/save")) |
| 165 | + (let [response (-> (request :post (str "/api/applications/save")) |
166 | 166 | (authenticate api-key user-id)
|
167 | 167 | (json-body {:command "save"
|
168 | 168 | :application-id application-id
|
|
175 | 175 | (is (not (:valid cmd-response)))
|
176 | 176 | (is (= 2 (count validations)))))
|
177 | 177 | (testing "submit partial form"
|
178 |
| - (let [response (-> (request :put (str "/api/applications/save")) |
| 178 | + (let [response (-> (request :post (str "/api/applications/save")) |
179 | 179 | (authenticate api-key user-id)
|
180 | 180 | (json-body {:command "submit"
|
181 | 181 | :application-id application-id
|
|
188 | 188 | (is (not (:valid cmd-response)))
|
189 | 189 | (is (= 2 (count validations)))))
|
190 | 190 | (testing "save full form"
|
191 |
| - (let [response (-> (request :put (str "/api/applications/save")) |
| 191 | + (let [response (-> (request :post (str "/api/applications/save")) |
192 | 192 | (authenticate api-key user-id)
|
193 | 193 | (json-body {:command "save"
|
194 | 194 | :application-id application-id
|
|
201 | 201 | (is (:valid cmd-response))
|
202 | 202 | (is (empty? validations))))
|
203 | 203 | (testing "submit full form"
|
204 |
| - (let [response (-> (request :put (str "/api/applications/save")) |
| 204 | + (let [response (-> (request :post (str "/api/applications/save")) |
205 | 205 | (authenticate api-key user-id)
|
206 | 206 | (json-body {:command "submit"
|
207 | 207 | :application-id application-id
|
|
219 | 219 | user-id "developer"
|
220 | 220 | catid 6]
|
221 | 221 | (testing "save draft for disabled item"
|
222 |
| - (let [response (-> (request :put (str "/api/applications/save")) |
| 222 | + (let [response (-> (request :post (str "/api/applications/save")) |
223 | 223 | (authenticate api-key user-id)
|
224 | 224 | (json-body {:command "save"
|
225 | 225 | :catalogue-items [catid]
|
|
229 | 229 | ;; TODO should we actually return a nice error message here?
|
230 | 230 | (is (= 400 (:status response)) "should not be able to save draft with disbled item")))
|
231 | 231 | (testing "submit for application with disabled item"
|
232 |
| - (let [response (-> (request :put (str "/api/applications/save")) |
| 232 | + (let [response (-> (request :post (str "/api/applications/save")) |
233 | 233 | (authenticate api-key user-id)
|
234 | 234 | (json-body {:application-id 6 ;; application-id 6 is already created, but catalogue-item was disabled later
|
235 | 235 | :command "submit"
|
|
245 | 245 | applicant "alice"
|
246 | 246 | approver "developer"
|
247 | 247 | catid 2]
|
248 |
| - (let [response (-> (request :put (str "/api/applications/save")) |
| 248 | + (let [response (-> (request :post (str "/api/applications/save")) |
249 | 249 | (authenticate api-key applicant)
|
250 | 250 | (json-body {:command "submit"
|
251 | 251 | :catalogue-items [catid]
|
|
275 | 275 | (is (:can-approve? application))))
|
276 | 276 | ;; TODO tests for :review-type
|
277 | 277 | (testing "approve application"
|
278 |
| - (is (= 200 (-> (request :put (str "/api/applications/judge")) |
| 278 | + (is (= 200 (-> (request :post (str "/api/applications/judge")) |
279 | 279 | (authenticate api-key approver)
|
280 | 280 | (json-body {:command "approve"
|
281 | 281 | :application-id app-id
|
|
305 | 305 | (let [api-key "42"
|
306 | 306 | user "developer"
|
307 | 307 | catid 2
|
308 |
| - app-id (-> (request :put (str "/api/applications/save")) |
| 308 | + app-id (-> (request :post (str "/api/applications/save")) |
309 | 309 | (authenticate api-key user)
|
310 | 310 | (json-body {:command "save"
|
311 | 311 | :catalogue-items [catid]
|
|
316 | 316 | :id)
|
317 | 317 | submit (fn []
|
318 | 318 | (is (= 200
|
319 |
| - (-> (request :put (str "/api/applications/save")) |
| 319 | + (-> (request :post (str "/api/applications/save")) |
320 | 320 | (authenticate api-key user)
|
321 | 321 | (json-body {:command "submit"
|
322 | 322 | :application-id app-id
|
|
326 | 326 | :status))))
|
327 | 327 | action (fn [body]
|
328 | 328 | (is (= 200
|
329 |
| - (-> (request :put (str "/api/applications/judge")) |
| 329 | + (-> (request :post (str "/api/applications/judge")) |
330 | 330 | (authenticate api-key user)
|
331 | 331 | (json-body (merge {:application-id app-id
|
332 | 332 | :round 0}
|
|
367 | 367 | approver "developer"
|
368 | 368 | reviewer "carl"
|
369 | 369 | catid 2
|
370 |
| - app-id (-> (request :put (str "/api/applications/save")) |
| 370 | + app-id (-> (request :post (str "/api/applications/save")) |
371 | 371 | (authenticate api-key applicant)
|
372 | 372 | (json-body {:command "submit"
|
373 | 373 | :catalogue-items [catid]
|
|
385 | 385 | (is (not (contains? (set (map :userid reviewers)) "invalid")))))
|
386 | 386 | (testing "send review request"
|
387 | 387 | (is (= 200
|
388 |
| - (-> (request :put (str "/api/applications/review_request")) |
| 388 | + (-> (request :post (str "/api/applications/review_request")) |
389 | 389 | (authenticate api-key approver)
|
390 | 390 | (json-body {:application-id app-id
|
391 | 391 | :round 0
|
|
405 | 405 | (map #(select-keys % [:userid :comment :event]) events)))))
|
406 | 406 | (testing "send review"
|
407 | 407 | (is (= 200
|
408 |
| - (-> (request :put (str "/api/applications/judge")) |
| 408 | + (-> (request :post (str "/api/applications/judge")) |
409 | 409 | (authenticate api-key reviewer)
|
410 | 410 | (json-body {:command "third-party-review"
|
411 | 411 | :application-id app-id
|
|
415 | 415 | :status))))
|
416 | 416 | (testing "approve"
|
417 | 417 | (is (= 200
|
418 |
| - (-> (request :put (str "/api/applications/judge")) |
| 418 | + (-> (request :post (str "/api/applications/judge")) |
419 | 419 | (authenticate api-key approver)
|
420 | 420 | (json-body {:command "approve"
|
421 | 421 | :application-id app-id
|
|
487 | 487 | (is cookie)
|
488 | 488 | (is csrf)
|
489 | 489 | (testing "submit with session"
|
490 |
| - (let [response (-> (request :put (str "/api/applications/save")) |
| 490 | + (let [response (-> (request :post (str "/api/applications/save")) |
491 | 491 | (header "Cookie" cookie)
|
492 | 492 | (header "x-csrf-token" csrf)
|
493 | 493 | (json-body {:command "submit"
|
|
499 | 499 | (is (= 200 (:status response)))
|
500 | 500 | (is (:success body))))
|
501 | 501 | (testing "submit with session but without csrf"
|
502 |
| - (let [response (-> (request :put (str "/api/applications/save")) |
| 502 | + (let [response (-> (request :post (str "/api/applications/save")) |
503 | 503 | (header "Cookie" cookie)
|
504 | 504 | (json-body {:command "submit"
|
505 | 505 | :catalogue-items [2]
|
|
508 | 508 | app)]
|
509 | 509 | (is (= 403 (:status response)))))
|
510 | 510 | (testing "submit with session and csrf and wrong api-key"
|
511 |
| - (let [response (-> (request :put (str "/api/applications/save")) |
| 511 | + (let [response (-> (request :post (str "/api/applications/save")) |
512 | 512 | (header "Cookie" cookie)
|
513 | 513 | (header "x-csrf-token" csrf)
|
514 | 514 | (header "x-rems-api-key" "WRONG")
|
|
539 | 539 | body (read-body response)]
|
540 | 540 | (is (= body "unauthorized"))))
|
541 | 541 | (testing "save without authentication"
|
542 |
| - (let [response (-> (request :put (str "/api/applications/save")) |
| 542 | + (let [response (-> (request :post (str "/api/applications/save")) |
543 | 543 | (json-body {:command "save"
|
544 | 544 | :catalogue-items [2]
|
545 | 545 | :items {1 "REST-Test"}})
|
546 | 546 | app)
|
547 | 547 | body (read-body response)]
|
548 | 548 | (is (str/includes? body "Invalid anti-forgery token"))))
|
549 | 549 | (testing "save with wrong API-Key"
|
550 |
| - (let [response (-> (request :put (str "/api/applications/save")) |
| 550 | + (let [response (-> (request :post (str "/api/applications/save")) |
551 | 551 | (assoc-in [:headers "x-rems-api-key"] "invalid-api-key")
|
552 | 552 | (json-body {:command "save"
|
553 | 553 | :catalogue-items [2]
|
|
556 | 556 | body (read-body response)]
|
557 | 557 | (is (= "invalid api key" body))))
|
558 | 558 | (testing "judge without authentication"
|
559 |
| - (let [body (-> (request :put (str "/api/applications/judge")) |
| 559 | + (let [body (-> (request :post (str "/api/applications/judge")) |
560 | 560 | (json-body {:command "approve"
|
561 | 561 | :application-id 2
|
562 | 562 | :round 0
|
|
565 | 565 | read-body)]
|
566 | 566 | (is (str/includes? body "Invalid anti-forgery token"))))
|
567 | 567 | (testing "judge with wrong API-Key"
|
568 |
| - (let [body (-> (request :put (str "/api/applications/judge")) |
| 568 | + (let [body (-> (request :post (str "/api/applications/judge")) |
569 | 569 | (authenticate "invalid-api-key" "developer")
|
570 | 570 | (json-body {:command "approve"
|
571 | 571 | :application-id 2
|
|
0 commit comments