summaryrefslogtreecommitdiff
path: root/tests/crud.scm
blob: 422b1daf24727bd8b070eaa8e46a0d8b3098e7a2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
(use-modules (webid-oidc server create)
             (webid-oidc server resource content)
             (webid-oidc server resource path)
             (webid-oidc errors)
             (webid-oidc testing)
             (web http)
             (web request)
             (web response)
             (web uri))

(with-test-environment
 "crud"
 (lambda ()
   (for-each
    (lambda (f)
      (false-if-exception
       (delete-file
        (string-append
         "tests/crud.home/webid-oidc/server/content/"
         f))))
    '("6/8OMG_V5x-KmI6TI"
      "X/hqM_2Avn5_egTzs"
      "5/n1KPgAd3ng4wSqn"
      "D/wxU0ogx5rzRrvu2"
      "F/BQKBGrtq6U_M0L7"
      "n/U46BXbknEaLWZpH"
      "A/fkGTJRCHc-jHk-V"
      "a/68pTwiImTWTpjQl"
      "H/y4S5p1BqTEJi-Jb"))
   (for-each
    (lambda (f)
      (false-if-exception
       (delete-file
        (string-append
         "tests/crud.home/webid-oidc/server/path/"
         f))))  
    '("L/uhr1159jdGYjIj_tpM6FDiW4rUZDQQKUnT35lhAR-s"
      "8/jgewChguz6YRPCTBOkx_9CW94iH_X88rP6Os4aM8jg"
      "n/PQ_3L8lXCsqpz1tkUhsJnVC9rcyqgDD41DnFPIDG1Q"
      "i/l7asoJjJEMhngUeSt4tHVu8Zxx4EFG_FDeJfL3-oPE"))
   (let ((server-name (string->uri "https://example.com"))
         (owner (string->uri "https://alice.databox.me")))
     (unless
         (create-root server-name owner)
       (exit 1))
     (let ((inbox (create server-name owner owner "/"
                          (list (string->uri "http://www.w3.org/ns/ldp#BasicContainer"))
                          "inbox"
                          'text/turtle
                          "")))
       (unless (equal? inbox (string->uri "https://example.com/inbox/"))
         (exit 2))
       (let ((inbox-2 (create server-name owner owner "/"
                              (list (string->uri "http://www.w3.org/ns/ldp#BasicContainer"))
                              "inbox"
                              'text/turtle
                              "")))
         (when (equal? inbox-2 (string->uri "https://example.com/inbox/"))
           (exit 3)))
       (let ((notif-1 (create server-name owner owner "/inbox"
                              '()
                              #f
                              'text/turtle
                              "")))
         (unless (equal? notif-1
                         (string->uri "https://example.com/inbox/NgnO8RAS9FpPiO5j"))
           (format (current-error-port) "Notif 1: ~s\n" notif-1)
           (exit 4))))
     (for-each
      (lambda (slug)
        (with-exception-handler
            (lambda (error)
              (unless (path-is-auxiliary? error)
                (raise-exception error)))
          (lambda ()
            (create server-name owner owner "/" '() slug 'text/turtle "")
            (exit 5))
          #:unwind? #t
          #:unwind-for-type &path-is-auxiliary))
      '(".acl" ".meta")))))