diff options
author | Vivien Kraus <vivien@planete-kraus.eu> | 2021-10-14 11:36:14 +0200 |
---|---|---|
committer | Vivien Kraus <vivien@planete-kraus.eu> | 2021-10-20 18:04:30 +0200 |
commit | 34624c72245b483e645efd281a27c9c9e210a19a (patch) | |
tree | afca30257d8a7c842bd80a4121c69be201c5fdca /tests | |
parent | 326f056867bab68ae94408a31af6f4c666dfb191 (diff) |
server: add an identity provider endpoint
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Makefile.am | 2 | ||||
-rw-r--r-- | tests/authorization-endpoint-get-form.scm | 3 | ||||
-rw-r--r-- | tests/authorization-endpoint-no-args.scm | 3 | ||||
-rw-r--r-- | tests/authorization-endpoint-submit-form.scm | 9 | ||||
-rw-r--r-- | tests/token-endpoint-issue.scm | 9 | ||||
-rw-r--r-- | tests/token-endpoint-refresh.scm | 15 |
6 files changed, 28 insertions, 13 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am index a35c853..b24819c 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -83,6 +83,8 @@ clean-local: %canon_reldir%-clean-local %canon_reldir%-clean-local: rm -rf %reldir%/*.cache rm -rf %reldir%/*.home + rm -f key-file.jwk.lock + rm -f key-file.jwk AM_TESTS_ENVIRONMENT = $(top_builddir)/pre-inst-env SCM_LOG_COMPILER = $(GUILE) diff --git a/tests/authorization-endpoint-get-form.scm b/tests/authorization-endpoint-get-form.scm index 27f22f9..25b7128 100644 --- a/tests/authorization-endpoint-get-form.scm +++ b/tests/authorization-endpoint-get-form.scm @@ -29,12 +29,11 @@ (with-test-environment "authorization-endpoint-get-form" (lambda () - (define key (generate-key #:n-size 2048)) (define subject (string->uri "https://authorization-endpoint-get-form.scm/profile/card#me")) (define password "p4ssw0rd") (define endpoint (make-authorization-endpoint - subject password key)) + subject password "key-file.jwk")) (receive (response response-body) (parameterize ((p:current-date 0)) (endpoint diff --git a/tests/authorization-endpoint-no-args.scm b/tests/authorization-endpoint-no-args.scm index 164e345..7976d9d 100644 --- a/tests/authorization-endpoint-no-args.scm +++ b/tests/authorization-endpoint-no-args.scm @@ -29,11 +29,10 @@ (with-test-environment "authorization-endpoint-no-args" (lambda () - (define key (generate-key #:n-size 2048)) (define subject (string->uri "https://authorization-endpoint-get-form.scm/profile/card#me")) (define password "p4ssw0rd") (define endpoint - (make-authorization-endpoint subject password key)) + (make-authorization-endpoint subject password "./key-file.jwk")) (receive (response response-body) (parameterize ((p:current-date 0)) (endpoint diff --git a/tests/authorization-endpoint-submit-form.scm b/tests/authorization-endpoint-submit-form.scm index 4f11db0..78216a9 100644 --- a/tests/authorization-endpoint-submit-form.scm +++ b/tests/authorization-endpoint-submit-form.scm @@ -23,6 +23,7 @@ #:use-module (webid-oidc jti) #:use-module (webid-oidc testing) #:use-module ((webid-oidc parameters) #:prefix p:) + #:use-module ((webid-oidc stubs) #:prefix stubs:) #:use-module (web uri) #:use-module (web request) #:use-module (web response) @@ -37,7 +38,6 @@ (with-test-environment "authorization-endpoint-submit-form" (lambda () - (define key (generate-key #:n-size 2048)) (define subject (string->uri "https://authorization-endpoint-submit-form.scm/profile/card#me")) (define client (string->uri "https://authorization-endpoint-submit-form.scm/client/card#app")) (define redirect (string->uri "https://authorization-endpoint-submit-form.scm/client/redirect")) @@ -55,7 +55,7 @@ (define the-response-body (cdr served)) (define endpoint (make-authorization-endpoint - subject encrypted-password key)) + subject encrypted-password "key-file.jwk")) (parameterize ((p:anonymous-http-request (lambda* (uri #:key (headers '()) #:allow-other-keys) (unless (equal? uri what-uri-to-expect) @@ -113,6 +113,9 @@ (parameterize ((p:current-date 60)) (decode <authorization-code> (car (assoc-ref args "code")) - #:issuer-key key)))) + #:issuer-key + (call-with-input-file "key-file.jwk" + (lambda (port) + (jwk->key (stubs:json->scm port)))))))) (unless parsed (exit 10)))))))))))) diff --git a/tests/token-endpoint-issue.scm b/tests/token-endpoint-issue.scm index 8fdd1ad..f986e8e 100644 --- a/tests/token-endpoint-issue.scm +++ b/tests/token-endpoint-issue.scm @@ -36,6 +36,12 @@ "token-endpoint-issue" (lambda () (define key (generate-key #:n-size 2048)) + (call-with-output-file "key-file.jwk" + (lambda (port) + (stubs:scm->json + (key->jwk key) + port + #:pretty #t))) (define client-key (generate-key #:n-size 2048)) (define subject (string->uri "https://token-endpoint-issue.scm/profile/card#me")) (define client (string->uri "https://token-endpoint-issue.scm/client/card#app")) @@ -49,7 +55,7 @@ (define endpoint (make-token-endpoint (string->uri "https://token-endpoint-issue.scm/token") - issuer key)) + issuer "key-file.jwk")) (receive (response response-body . _) ;; The code is fake! (let ((dpop @@ -90,7 +96,6 @@ #:port #t) (string-append "grant_type=authorization_code&code=" authz)))) (unless (eq? (response-code response) 200) - (write response) (exit 4)) (unless (eq? (car (response-content-type response)) 'application/json) (exit 5)) diff --git a/tests/token-endpoint-refresh.scm b/tests/token-endpoint-refresh.scm index 90e2625..91effe0 100644 --- a/tests/token-endpoint-refresh.scm +++ b/tests/token-endpoint-refresh.scm @@ -37,15 +37,22 @@ "token-endpoint-refresh" (lambda () (define key (generate-key #:n-size 2048)) + (call-with-output-file "key-file.jwk" + (lambda (port) + (stubs:scm->json + (key->jwk key) + port + #:pretty #t))) (define client-key (generate-key #:n-size 2048)) (define subject (string->uri "https://token-endpoint-issue.scm/profile/card#me")) (define client (string->uri "https://token-endpoint-issue.scm/client/card#app")) (define issuer (string->uri "https://issuer.token-endpoint-issue.scm")) (define refresh-code (issue-refresh-token subject client (jkt client-key))) - (define endpoint (make-token-endpoint - (string->uri "https://token-endpoint-issue.scm/token") - issuer key)) + (define endpoint + (make-token-endpoint + (string->uri "https://token-endpoint-issue.scm/token") + issuer "key-file.jwk")) (receive (response response-body . _) ;; The refresh token is fake! (let ((dpop @@ -67,7 +74,7 @@ "refresh_token=fake"))) (unless (eq? (response-code response) 400) (exit 3)) - (receive (response response-body user error) + (receive (response response-body) (let ((dpop (parameterize ((p:current-date 10)) (issue <dpop-proof> |