|
36 | 36 | (def stmt-1 |
37 | 37 | (assoc stmt-0 "id" "00000000-0000-4000-8000-000000000001")) |
38 | 38 |
|
| 39 | +(def stmt-2 |
| 40 | + (assoc stmt-0 "id" "00000000-0000-4000-8000-000000000002")) |
| 41 | + |
39 | 42 | (def stmt-id-0 |
40 | 43 | (get stmt-0 "id")) |
41 | 44 |
|
42 | 45 | (def stmt-id-1 |
43 | 46 | (get stmt-1 "id")) |
44 | 47 |
|
| 48 | +(def stmt-id-2 |
| 49 | + (get stmt-2 "id")) |
| 50 | + |
45 | 51 | (def stmt-body-0 |
46 | 52 | (u/write-json-str stmt-0)) |
47 | 53 |
|
48 | 54 | (def stmt-body-1 |
49 | 55 | (u/write-json-str stmt-1)) |
50 | 56 |
|
| 57 | +;; These test constants are to test when statement arrays are POST'd to the LRS. |
| 58 | +;; For some reason, these are not test cases in the ADL conformance tests, and |
| 59 | +;; adding a new namespace just for a couple POST requests would be overkill, |
| 60 | +;; so we just put them here. |
| 61 | +(def stmt-body-empty-array |
| 62 | + (u/write-json-str [])) |
| 63 | + |
| 64 | +(def stmt-body-array |
| 65 | + (u/write-json-str [stmt-2])) |
| 66 | + |
51 | 67 | ;; /agents |
52 | 68 |
|
53 | 69 | (def agent-endpoint |
|
228 | 244 | (is (= ~(if statement-write? 200 403) |
229 | 245 | (try-post ~stmt-endpoint |
230 | 246 | ~'creds |
231 | | - {:body ~stmt-body-0})))) |
| 247 | + {:body ~stmt-body-0}))) |
| 248 | + (is (= ~(if statement-write? 200 403) |
| 249 | + (try-post ~stmt-endpoint |
| 250 | + ~'creds |
| 251 | + {:body ~stmt-body-empty-array}))) |
| 252 | + (is (= ~(if statement-write? 200 403) |
| 253 | + (try-post ~stmt-endpoint |
| 254 | + ~'creds |
| 255 | + {:body ~stmt-body-array})))) |
232 | 256 | (testing "PUT" |
233 | 257 | (is (= ~(if statement-write? 204 403) |
234 | 258 | (try-put ~stmt-endpoint |
|
489 | 513 | (is (= 200 |
490 | 514 | (try-post stmt-endpoint creds-1 {:body stmt-body-0}))) |
491 | 515 | (is (= 200 |
492 | | - (try-post stmt-endpoint creds-2 {:body stmt-body-1})))) |
| 516 | + (try-post stmt-endpoint creds-2 {:body stmt-body-1}))) |
| 517 | + (is (= 200 |
| 518 | + (try-post stmt-endpoint creds-1 {:body stmt-body-empty-array}))) |
| 519 | + (is (= 200 |
| 520 | + (try-post stmt-endpoint creds-2 {:body stmt-body-array})))) |
493 | 521 | (testing "/statements GET with correct authority" |
494 | 522 | (is (= 200 |
495 | 523 | (try-get stmt-endpoint |
|
498 | 526 | (is (= 200 |
499 | 527 | (try-get stmt-endpoint |
500 | 528 | creds-2 |
501 | | - {:params {:statementId stmt-id-1}})))) |
| 529 | + {:params {:statementId stmt-id-1}}))) |
| 530 | + (is (= 200 |
| 531 | + (try-get stmt-endpoint |
| 532 | + creds-2 |
| 533 | + {:params {:statementId stmt-id-2}})))) |
502 | 534 | (testing "/statements HEAD with correct authority" |
503 | 535 | (is (= 200 |
504 | 536 | (try-head stmt-endpoint |
|
507 | 539 | (is (= 200 |
508 | 540 | (try-head stmt-endpoint |
509 | 541 | creds-2 |
510 | | - {:params {:statementId stmt-id-1}})))) |
| 542 | + {:params {:statementId stmt-id-1}}))) |
| 543 | + (is (= 200 |
| 544 | + (try-head stmt-endpoint |
| 545 | + creds-2 |
| 546 | + {:params {:statementId stmt-id-2}})))) |
511 | 547 | ;; Treated as 404 Not Found as the statement does not exist within the |
512 | 548 | ;; scope of the authority, rather than a blanket 403 Forbidden. |
513 | 549 | (testing "/statements GET with wrong authority" |
514 | 550 | (is (= 404 |
515 | 551 | (try-get stmt-endpoint |
516 | 552 | creds-1 |
517 | 553 | {:params {:statementId stmt-id-1}}))) |
| 554 | + (is (= 404 |
| 555 | + (try-get stmt-endpoint |
| 556 | + creds-1 |
| 557 | + {:params {:statementId stmt-id-2}}))) |
518 | 558 | (is (= 404 |
519 | 559 | (try-get stmt-endpoint |
520 | 560 | creds-2 |
|
524 | 564 | (try-head stmt-endpoint |
525 | 565 | creds-1 |
526 | 566 | {:params {:statementId stmt-id-1}}))) |
| 567 | + (is (= 404 |
| 568 | + (try-head stmt-endpoint |
| 569 | + creds-1 |
| 570 | + {:params {:statementId stmt-id-2}}))) |
527 | 571 | (is (= 404 |
528 | 572 | (try-head stmt-endpoint |
529 | 573 | creds-2 |
|
0 commit comments