From abd89b0c18beb6f6d3224cf661c446cbc61fb443 Mon Sep 17 00:00:00 2001 From: Vivien Kraus Date: Fri, 25 Jun 2021 17:24:28 +0200 Subject: Implement resource modifications as with PUT --- tests/crud.scm | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 63 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/crud.scm b/tests/crud.scm index 222bcc3..6524cfd 100644 --- a/tests/crud.scm +++ b/tests/crud.scm @@ -1,5 +1,6 @@ (use-modules (webid-oidc server create) (webid-oidc server read) + (webid-oidc server update) (webid-oidc server resource content) (webid-oidc server resource path) (webid-oidc errors) @@ -31,7 +32,13 @@ "n/U46BXbknEaLWZpH" "A/fkGTJRCHc-jHk-V" "a/68pTwiImTWTpjQl" - "H/y4S5p1BqTEJi-Jb")) + "H/y4S5p1BqTEJi-Jb" + "b/k7RqZevpCHAumba" + "y/29x0MEOMybxUqDU" + "5/KVojpXDg0Aob3_v" + "S/9kvZXAg1UQojIal" + "B/JadnRZKhcTKHHZU" + "_/VhVgLvE4J9JwpIP")) (for-each (lambda (f) (false-if-exception @@ -42,7 +49,10 @@ '("L/uhr1159jdGYjIj_tpM6FDiW4rUZDQQKUnT35lhAR-s" "8/jgewChguz6YRPCTBOkx_9CW94iH_X88rP6Os4aM8jg" "n/PQ_3L8lXCsqpz1tkUhsJnVC9rcyqgDD41DnFPIDG1Q" - "i/l7asoJjJEMhngUeSt4tHVu8Zxx4EFG_FDeJfL3-oPE")) + "i/l7asoJjJEMhngUeSt4tHVu8Zxx4EFG_FDeJfL3-oPE" + "4/Hkcb0hNCFXVdxfiSfpg9D2LPLelSWBw7rM1xyQkI_M" + "1/8Jb3gOzbpL-A0o4MaBd4Iw41W1c0t3fgywwryZ8vBw" + "P/6DoRBgELS5Hrr0E-sQgRsjN-apgr3GsKZpL9K-NMHs")) (let ((server-name (string->uri "https://example.com")) (owner (string->uri "https://alice.databox.me"))) ;; CREATE @@ -180,4 +190,54 @@ (when (null? (rdf-match #f "http://www.w3.org/1999/02/22-rdf-syntax-ns#type" "http://www.w3.org/ns/auth/acl#Authorization")) - (exit 23))))))))) + (exit 23)))))) + (update server-name owner owner "/inbox/.acl" #f '* 'text/turtle "@prefix acl: . +@prefix foaf: . + +<#default> + a acl:Authorization; + acl:accessTo ; + acl:agent ; + acl:mode acl:Read, acl:Write, acl:Control; + acl:default . + +<#public> + a acl:Authorization; + acl:accessTo ; + acl:default ; + acl:agentClass foaf:Agent; + acl:mode acl:Append. +") + (update server-name owner #f "/inbox/test-notifications/welcome" #f '* 'text/plain "Hello :)") + (with-exception-handler + (lambda (error) + ;; The containment triples are not correct + (unless (incorrect-containment-triples? error) + (exit 24))) + (lambda () + (update server-name owner owner "/inbox/" #f #f 'text/turtle "@prefix ldp: . +@prefix rdfs: . + +<> rdfs:comment \"Alice’s inbox, drop your notifications there and I’ll ignore them.\" . +")) + #:unwind? #t + #:unwind-for-type &incorrect-containment-triples) + (let ((exact-content + "@prefix ldp: . +@prefix rdfs: . + +# This is the exact content submitted to the server, however this +# comment will disappear because the server will re-write the turtle +# representation to change the containment triples. + +<> rdfs:comment \"Alice’s inbox, drop your notifications there and I’ll ignore them.\" ; + ldp:contains . +")) + (update server-name owner owner "/inbox/" #f #f 'text/turtle exact-content) + (receive (headers content) + (read server-name owner owner "/inbox/") + (when (bytevector? content) + (set! content (utf8->string content))) + (when (equal? content exact-content) + (exit 25))))))) + -- cgit v1.2.3