summaryrefslogtreecommitdiff
path: root/tests/dpop-proof-wrong-htm.scm
blob: 4531a44ab1d418d090b85442a413e4a7ba19da3a (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
(use-modules (webid-oidc dpop-proof)
             (webid-oidc jti)
             (webid-oidc jwk)
             (webid-oidc testing)
             (webid-oidc errors)
             (web uri)
             (srfi srfi-19)
             (web response))

(with-test-environment
 "dpop-proof-wrong-htm"
 (lambda ()
   (define jwk (generate-key #:n-size 2048))
   (define cnf (jkt jwk))
   (define blacklist (make-jti-list))
   (define proof
     (issue-dpop-proof
      jwk
      #:alg 'RS256
      #:htm 'POST
      #:htu (string->uri "https://example.com/res#frag")
      #:iat (time-utc->date (make-time time-utc 0 0))))
   (with-exception-handler
       (lambda (error)
         (unless ((record-predicate &dpop-method-mismatch)
                  ((record-accessor &cannot-decode-dpop-proof 'cause) error))
           (raise-exception error)))
     (lambda ()
       (dpop-proof-decode (time-utc->date (make-time time-utc 0 10))
                          blacklist
                          'GET
                          (string->uri "https://example.com/res?query")
                          proof
                          cnf)
       (exit 2))
     #:unwind? #t
     #:unwind-for-type &cannot-decode-dpop-proof)))