diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Makefile.am | 3 | ||||
-rw-r--r-- | tests/preconditions.scm | 69 |
2 files changed, 71 insertions, 1 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am index 2a4c5b7..1a6242d 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -45,7 +45,8 @@ TESTS = %reldir%/load-library.scm \ %reldir%/server-path.scm \ %reldir%/http-link.scm \ %reldir%/acl.scm \ - %reldir%/crud.scm + %reldir%/crud.scm \ + %reldir%/preconditions.scm EXTRA_DIST += $(TESTS) %reldir%/ChangeLog diff --git a/tests/preconditions.scm b/tests/preconditions.scm new file mode 100644 index 0000000..01cbd1c --- /dev/null +++ b/tests/preconditions.scm @@ -0,0 +1,69 @@ +(use-modules (webid-oidc server precondition) + (webid-oidc errors) + (webid-oidc testing) + (web http) + (web request) + (web response) + (web uri) + (ice-9 receive) + (rnrs bytevectors)) + +(with-test-environment + "preconditions" + (lambda () + (check-precondition "/whatever" #f #f #f) + (check-precondition "/whatever" #f #f "etag") + (check-precondition "/whatever" '* #f "etag") + (check-precondition "/whatever" '* '() "etag") + (check-precondition "/whatever" #f '("other") "etag") + (check-precondition "/whatever" '("one" "etag" "or" "another") '() "etag") + (with-exception-handler + (lambda (error) + (unless (precondition-failed? error) + (exit 1))) + (lambda () + (check-precondition "/whatever" '("etag") '("etag") "etag")) + #:unwind? #t + #:unwind-for-type &precondition-failed) + (with-exception-handler + (lambda (error) + (unless (precondition-failed? error) + (exit 1))) + (lambda () + (check-precondition "/whatever" '("etag") '* "etag")) + #:unwind? #t + #:unwind-for-type &precondition-failed) + (with-exception-handler + (lambda (error) + (unless (precondition-failed? error) + (exit 1))) + (lambda () + (check-precondition "/whatever" '("nope") '() "etag")) + #:unwind? #t + #:unwind-for-type &precondition-failed) + (with-exception-handler + (lambda (error) + (unless (precondition-failed? error) + (exit 1))) + (lambda () + (check-precondition "/whatever" '("nope") '() "etag")) + #:unwind? #t + #:unwind-for-type &precondition-failed) + (with-exception-handler + (lambda (error) + (unless (precondition-failed? error) + (exit 1))) + (lambda () + (check-precondition "/whatever" '* #f #f)) + #:unwind? #t + #:unwind-for-type &precondition-failed) + (with-exception-handler + (lambda (error) + (unless (precondition-failed? error) + (exit 1))) + (lambda () + (check-precondition "/whatever" '() #f #f)) + #:unwind? #t + #:unwind-for-type &precondition-failed) + (check-precondition "/whatever" #f '* #f) + (check-precondition "/whatever" #f '() #f))) |