summaryrefslogtreecommitdiff
path: root/tests/authorization-endpoint-submit-form.scm
diff options
context:
space:
mode:
authorVivien Kraus <vivien@planete-kraus.eu>2021-08-01 14:51:28 +0200
committerVivien Kraus <vivien@planete-kraus.eu>2021-08-01 18:08:56 +0200
commitbae1843f1a1d644fb3bd4f8c40b1dbb900aa3325 (patch)
tree00f590033af904a6a493e41bdebe9b3ddd73043b /tests/authorization-endpoint-submit-form.scm
parentd8c2ca930673da858d63f2dea9526c259a2dd936 (diff)
Use guile parameters
With parameters, the API does not need to care about the directory where to load files and how to get the time.
Diffstat (limited to 'tests/authorization-endpoint-submit-form.scm')
-rw-r--r--tests/authorization-endpoint-submit-form.scm59
1 files changed, 28 insertions, 31 deletions
diff --git a/tests/authorization-endpoint-submit-form.scm b/tests/authorization-endpoint-submit-form.scm
index f379e38..ef84f40 100644
--- a/tests/authorization-endpoint-submit-form.scm
+++ b/tests/authorization-endpoint-submit-form.scm
@@ -21,6 +21,7 @@
(webid-oidc cache)
(webid-oidc jti)
(webid-oidc testing)
+ ((webid-oidc parameters) #:prefix p:)
(web uri)
(web request)
(web response)
@@ -40,9 +41,6 @@
(define password "p4ssw0rd")
(define encrypted-password (crypt password "$6$this.is.the.salt"))
(define validity 120)
- (define the-time 0)
- (define (current-time)
- (make-time time-utc 0 the-time))
(define what-uri-to-expect client)
(define served
(receive (response response-body)
@@ -57,37 +55,36 @@
(exit 2))
(values the-response the-response-body))
(define cached-http-get
- (with-cache #:http-get http-get
- #:current-time current-time))
- (define jti-list (make-jti-list))
+ (with-cache #:http-get http-get))
(define endpoint
(make-authorization-endpoint
subject encrypted-password alg key validity
- #:http-get cached-http-get
- #:current-time current-time))
+ #:http-get cached-http-get))
(receive (response response-body)
;; The password is fake!
- (endpoint
- (build-request (string->uri
- (format #f "https://authorization-endpoint-submit-form.scm/authorize?client_id=~a&redirect_uri=~a"
- (uri-encode (uri->string client))
- (uri-encode (uri->string redirect))))
- #:headers '((content-type application/x-www-form-urlencoded))
- #:method 'POST
- #:port #t)
- "password=fake")
+ (parameterize ((p:current-date 0))
+ (endpoint
+ (build-request (string->uri
+ (format #f "https://authorization-endpoint-submit-form.scm/authorize?client_id=~a&redirect_uri=~a"
+ (uri-encode (uri->string client))
+ (uri-encode (uri->string redirect))))
+ #:headers '((content-type application/x-www-form-urlencoded))
+ #:method 'POST
+ #:port #t)
+ "password=fake"))
(when (eq? (response-code response) 302)
(exit 3)))
(receive (response response-body)
- (endpoint
- (build-request (string->uri
- (format #f "https://authorization-endpoint-submit-form.scm/authorize?client_id=~a&redirect_uri=~a"
- (uri-encode (uri->string client))
- (uri-encode (uri->string redirect))))
- #:headers '((content-type application/x-www-form-urlencoded))
- #:method 'POST
- #:port #t)
- "password=p4ssw0rd")
+ (parameterize ((p:current-date 0))
+ (endpoint
+ (build-request (string->uri
+ (format #f "https://authorization-endpoint-submit-form.scm/authorize?client_id=~a&redirect_uri=~a"
+ (uri-encode (uri->string client))
+ (uri-encode (uri->string redirect))))
+ #:headers '((content-type application/x-www-form-urlencoded))
+ #:method 'POST
+ #:port #t)
+ "password=p4ssw0rd"))
(unless (eq? (response-code response) 302)
(exit 4))
(let ((loc (response-location response)))
@@ -109,10 +106,10 @@
kv)))
(unless (assoc-ref args "code")
(exit 9))
- (let ((parsed (authorization-code-decode
- 60
- jti-list
- (car (assoc-ref args "code"))
- key)))
+ (let ((parsed
+ (parameterize ((p:current-date 60))
+ (authorization-code-decode
+ (car (assoc-ref args "code"))
+ key))))
(unless parsed
(exit 10)))))))))