summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorVivien Kraus <vivien@planete-kraus.eu>2021-06-02 17:18:12 +0200
committerVivien Kraus <vivien@planete-kraus.eu>2021-06-19 15:44:36 +0200
commit5863e990a70ab01b98540bed49bbe9ca38cba638 (patch)
tree7b2daf5999d5f987e9d20ddb80190d11fd06eed7 /tests
parent109049c6868898630a104c568ff2e7335e838fd9 (diff)
An API to manipulate contents on the server
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am3
-rw-r--r--tests/server-content.scm54
2 files changed, 56 insertions, 1 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 5ec6e49..ce3186d 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -40,7 +40,8 @@ TESTS = %reldir%/load-library.scm \
%reldir%/resource-server.scm \
%reldir%/client-authorization.scm \
%reldir%/client-token.scm \
- %reldir%/client-manifest-not-modified.scm
+ %reldir%/client-manifest-not-modified.scm \
+ %reldir%/server-content.scm
EXTRA_DIST += $(TESTS) %reldir%/ChangeLog
diff --git a/tests/server-content.scm b/tests/server-content.scm
new file mode 100644
index 0000000..c546dea
--- /dev/null
+++ b/tests/server-content.scm
@@ -0,0 +1,54 @@
+(use-modules (webid-oidc server resource content)
+ (webid-oidc fetch)
+ (webid-oidc testing)
+ (webid-oidc errors)
+ (web uri)
+ (web response)
+ (rnrs bytevectors)
+ (ice-9 optargs)
+ (ice-9 receive)
+ (oop goops))
+
+(with-test-environment
+ "server-content"
+ (lambda ()
+ (false-if-exception
+ ;; This is the etag of the root with the seed of the test
+ (delete-file "tests/server-content.home/webid-oidc/server/content/6/8OMG_V5x-KmI6TI"))
+ (false-if-exception
+ ;; This is the etag of /wtf
+ (delete-file "tests/server-content.home/webid-oidc/server/content/X/hqM_2Avn5_egTzs"))
+ (receive (/ /wtf)
+ (with-session
+ (lambda (content-type contained static-content create delete)
+ (let ((/ (create 'text/turtle '("/whatever" "/you" "/want")
+ "# This is the content of the root"))
+ (/wtf (create 'text/plain '() "This is the content of the wtf")))
+ (unless (equal? (static-content /wtf)
+ (string->utf8 "This is the content of the wtf"))
+ (exit 1))
+ (delete /wtf)
+ (unless (eq? (content-type /wtf) 'text/plain)
+ ;; It has survived in the cache
+ (exit 2))
+ (values / /wtf))))
+ (with-session
+ (lambda (content-type contained static-content create delete)
+ (unless
+ (with-exception-handler
+ (lambda (error)
+ ;; Good, we can’t load /wtf
+ #t)
+ (lambda ()
+ (content-type /wtf)
+ #f)
+ #:unwind? #t)
+ ;;We could read /wtf, it has not been deleted
+ (exit 3))
+ (unless (eq? (content-type /) 'text/turtle)
+ (exit 4))
+ (unless (equal? (contained /) '("/whatever" "/you" "/want"))
+ (exit 5))
+ (unless (equal? (static-content /)
+ (string->utf8 "# This is the content of the root"))
+ (exit 6)))))))