summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorVivien Kraus <vivien@planete-kraus.eu>2021-06-24 20:24:40 +0200
committerVivien Kraus <vivien@planete-kraus.eu>2021-06-27 00:19:33 +0200
commit636476eb01d93e222a22b55152a5eef1bb3329d3 (patch)
tree93bb1bec3e28ab6324af158d5c281b05c9d4c43e /tests
parentd4ba8350e1c821e8a262ab3e84e440069069e34a (diff)
Check client conditional request
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am3
-rw-r--r--tests/preconditions.scm69
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)))