blob: 4584c8dbbb020d48fe967bb7f9b77a01eb690e9b (
about) (
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
|
(use-modules (webid-oidc jwk)
(webid-oidc testing)
(webid-oidc cache)
(web uri)
(srfi srfi-19)
(web response))
(with-test-environment
"jwks-get"
(lambda ()
(define* (respond uri #:key (headers '()))
(unless (null? headers)
(exit 1))
(when (string? uri)
(set! uri (string->uri uri)))
(if (string=? (uri->string uri) "https://example.com/keys")
(values
(build-response #:headers `((expires . ,(time-utc->date (make-time time-utc 0 10)))
(content-type application/json (charset . "utf-8"))))
"{
\"keys\": [
{
\"e\": \"AQAB\",
\"use\": \"sig\",
\"kid\": \"dedc012d07f52aedfd5f97784e1bcbe23c19724d\",
\"n\": \"sV158-MQ-5-sP2iTJibiMap1ug8tNY97laOud3Se_3jd4INq36NwhLpgU3FC5SCfJOs9wehTLzv_hBuo-sW0JNjAEtMEE-SDtx5486gjymDR-5Iwv7bgt25tD0cDgiboZLt1RLn-nP-V3zgYHZa_s9zLjpNyArsWWcSh6tWe2R8yW6BqS8l4_9z8jkKeyAwWmdpkY8BtKS0zZ9yljiCxKvs8CKjfHmrayg45sZ8V1-aRcjtR2ECxATHjE8L96_oNddZ-rj2axf2vTmnkx3OvIMgx0tZ0ycMG6Wy8wxxaR5ir2LV3Gkyfh72U7tI8Q1sokPmH6G62JcduNY66jEQlvQ\",
\"alg\": \"RS256\",
\"kty\": \"RSA\"
},
{
\"alg\": \"RS256\",
\"kid\": \"2e3025f26b595f96eac907cc2b9471422bcaeb93\",
\"e\": \"AQAB\",
\"use\": \"sig\",
\"kty\": \"RSA\",
\"n\": \"syWuIlYmoWSl5rBQGOtYGwO5OCCZnhoWBCyl-x5gby5ofc4HNhBoVVMUggk-f_MH-pyMI5yRYsS_aPQ2bmSox2s4i9cPhxqtSAYMhTPwSwQ2BROC7xxi_N0ovp5Ivut5q8TwAn5kQZa_jR9d7JO20BUB7UqbMkBsqg2J8QTtMJ9YtA5BmUn4Y6vhIjTFtvrA6iM4i1cKoUD5Rirt5CYpcKwsLxBZbVk4E4rqgv7G0UlWt6NAs-z7XDkchlNBVpMUuiUBzxHl4LChc7dsWXRaO5vhu3j_2WnxuWCQZPlGoB51jD_ynZ027hhIcoa_tXg28_qb5Al78ZttiRCQDKueAQ\"
}
]
}
")
(exit 2)))
(define current-time 0)
(define cache-http-get
(with-cache
#:current-time
(lambda ()
(make-time time-utc 0 current-time))
#:http-get respond))
(define jwks (get-jwks "https://example.com/keys"
#:http-get cache-http-get))
(define keys (jwks-keys jwks))
(unless (eq? (length keys) 2)
(exit 3))
(map (lambda (k)
(unless (jwk-public? k)
(exit 4)))
keys)))
|