diff options
Diffstat (limited to 'tests/preconditions.scm')
-rw-r--r-- | tests/preconditions.scm | 69 |
1 files changed, 69 insertions, 0 deletions
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))) |