From 9e2873b126bff9e0d13d2953729def4b0b3cd73e Mon Sep 17 00:00:00 2001 From: Vivien Kraus Date: Thu, 30 Sep 2021 19:51:38 +0200 Subject: Client manifest: use GOOPS --- tests/authorization-endpoint-submit-form.scm | 43 ++++++++++++++++------------ tests/client-manifest-fraudulent.scm | 28 ++++++++++-------- tests/client-manifest-public.scm | 29 ++++++++++--------- tests/client-manifest.scm | 27 +++++++++-------- 4 files changed, 68 insertions(+), 59 deletions(-) (limited to 'tests') diff --git a/tests/authorization-endpoint-submit-form.scm b/tests/authorization-endpoint-submit-form.scm index 3de3e19..4f11db0 100644 --- a/tests/authorization-endpoint-submit-form.scm +++ b/tests/authorization-endpoint-submit-form.scm @@ -1,4 +1,4 @@ -;; webid-oidc, implementation of the Solid specification +;; disfluid, implementation of the Solid specification ;; Copyright (C) 2020, 2021 Vivien Kraus ;; This program is free software: you can redistribute it and/or modify @@ -14,21 +14,25 @@ ;; You should have received a copy of the GNU Affero General Public License ;; along with this program. If not, see . -(use-modules (webid-oidc authorization-endpoint) - (webid-oidc authorization-code) - (webid-oidc client-manifest) - (webid-oidc jwk) - (webid-oidc cache) - (webid-oidc jti) - (webid-oidc testing) - ((webid-oidc parameters) #:prefix p:) - (web uri) - (web request) - (web response) - (srfi srfi-19) - (web response) - (ice-9 optargs) - (ice-9 receive)) +(define-module (tests authorization-endpoint-submit-form) + #:use-module (webid-oidc authorization-endpoint) + #:use-module (webid-oidc authorization-code) + #:use-module (webid-oidc client-manifest) + #:use-module (webid-oidc jwk) + #:use-module (webid-oidc cache) + #:use-module (webid-oidc jti) + #:use-module (webid-oidc testing) + #:use-module ((webid-oidc parameters) #:prefix p:) + #:use-module (web uri) + #:use-module (web request) + #:use-module (web response) + #:use-module (srfi srfi-19) + #:use-module (web response) + #:use-module (ice-9 optargs) + #:use-module (ice-9 receive) + #:use-module (oop goops) + #:declarative? #t + #:duplicates (merge-generics)) (with-test-environment "authorization-endpoint-submit-form" @@ -42,9 +46,10 @@ (define what-uri-to-expect client) (define served (receive (response response-body) - (serve-client-manifest - (time-utc->date (make-time time-utc 0 3600)) - (make-client-manifest client (list redirect))) + (serve (make + #:client-id client + #:redirect-uris (list redirect)) + (time-utc->date (make-time time-utc 0 3600))) (cons response response-body))) (define the-response (car served)) (define the-response-body (cdr served)) diff --git a/tests/client-manifest-fraudulent.scm b/tests/client-manifest-fraudulent.scm index 548f6c1..b1803f4 100644 --- a/tests/client-manifest-fraudulent.scm +++ b/tests/client-manifest-fraudulent.scm @@ -14,16 +14,20 @@ ;; You should have received a copy of the GNU Affero General Public License ;; along with this program. If not, see . -(use-modules (webid-oidc client-manifest) - (webid-oidc cache) - (webid-oidc testing) - ((webid-oidc parameters) #:prefix p:) - (webid-oidc errors) - (web uri) - (srfi srfi-19) - (web response) - (ice-9 optargs) - (ice-9 receive)) +(define-module (tests client-manifest-fraudulent) + #:use-module (webid-oidc client-manifest) + #:use-module (webid-oidc cache) + #:use-module (webid-oidc testing) + #:use-module ((webid-oidc parameters) #:prefix p:) + #:use-module (webid-oidc errors) + #:use-module (web uri) + #:use-module (srfi srfi-19) + #:use-module (web response) + #:use-module (ice-9 optargs) + #:use-module (ice-9 receive) + #:use-module (oop goops) + #:declarative? #t + #:duplicates (merge-generics)) ;; In this example, the client_id of the oidcRegistration does not ;; match the base URI. @@ -68,8 +72,8 @@ (exit 3))) (lambda () (parameterize ((p:current-date 0)) - (get-client-manifest - (string->uri "https://fraudulent-app.example.com/id#app"))) + (make + #:client-id "https://fraudulent-app.example.com/id#app")) (exit 4)) #:unwind? #t #:unwind-for-type &inconsistent-client-manifest)))))) diff --git a/tests/client-manifest-public.scm b/tests/client-manifest-public.scm index f4e0bd5..478679c 100644 --- a/tests/client-manifest-public.scm +++ b/tests/client-manifest-public.scm @@ -14,33 +14,34 @@ ;; You should have received a copy of the GNU Affero General Public License ;; along with this program. If not, see . -(use-modules (webid-oidc client-manifest) - (webid-oidc testing) - (webid-oidc errors) - (web uri) - (srfi srfi-19) - (web response)) +(define-module (tests client-manifest-public) + #:use-module (webid-oidc client-manifest) + #:use-module (webid-oidc testing) + #:use-module (webid-oidc errors) + #:use-module (web uri) + #:use-module (srfi srfi-19) + #:use-module (web response) + #:use-module (oop goops) + #:declarative? #t) (with-test-environment "client-manifest-public" (lambda () (define mf - (get-client-manifest - (string->uri "http://www.w3.org/ns/solid/terms#PublicOidcClient"))) - (define id (client-manifest-client-id mf)) + (make + #:client-id "http://www.w3.org/ns/solid/terms#PublicOidcClient")) + (define id (client-id mf)) (unless (equal? id (string->uri "http://www.w3.org/ns/solid/terms#PublicOidcClient")) (exit 2)) - (unless (client-manifest-check-redirect-uri mf "https://example.com") + (unless (check-redirect-uri mf "https://example.com") (exit 3)) (with-exception-handler (lambda (error) (unless (cannot-serve-public-manifest? error) (exit 4))) (lambda () - (serve-client-manifest - (time-utc->date - (make-time time-utc 0 0)) - mf) + (serve mf (time-utc->date + (make-time time-utc 0 0))) (exit 5)) #:unwind? #t #:unwind-for-type &cannot-serve-public-manifest))) diff --git a/tests/client-manifest.scm b/tests/client-manifest.scm index 7f8e130..9aa32b5 100644 --- a/tests/client-manifest.scm +++ b/tests/client-manifest.scm @@ -24,7 +24,10 @@ #:use-module (srfi srfi-19) #:use-module (web response) #:use-module (ice-9 optargs) - #:use-module (ice-9 receive)) + #:use-module (ice-9 receive) + #:use-module (oop goops) + #:declarative? #t + #:duplicates (merge-generics)) (with-test-environment "client-manifest" @@ -59,38 +62,34 @@ (lambda () (define mf (parameterize ((p:current-date 0)) - (get-client-manifest - (string->uri "https://app.example.com/id#app")))) - (define id (client-manifest-client-id mf)) + (make + #:client-id "https://app.example.com/id#app"))) + (define id (client-id mf)) (unless (equal? id (string->uri "https://app.example.com/id#app")) (exit 3)) - (unless (client-manifest-check-redirect-uri mf "https://app.example.com/callback") + (unless (check-redirect-uri mf "https://app.example.com/callback") (exit 4)) (with-exception-handler (lambda (error) (unless (unauthorized-redirect-uri? error) (exit 5))) (lambda () - (client-manifest-check-redirect-uri mf "https://fraudulent-app.example.com/callback") + (check-redirect-uri mf "https://fraudulent-app.example.com/callback") (exit 55)) #:unwind? #t #:unwind-for-type &unauthorized-redirect-uri) (receive (response response-body) - (serve-client-manifest - (time-utc->date (make-time time-utc 0 3600)) - mf) + (serve mf (time-utc->date (make-time time-utc 0 3600))) (unless (equal? (response-content-type response) '(application/ld+json)) (exit 6)) (set! what-to-respond response) (set! what-to-respond-body response-body) (let ((re-parsed (parameterize ((p:current-date 10)) - (get-client-manifest - (string->uri "https://app.example.com/id#app"))))) + (make + #:client-id "https://app.example.com/id#app")))) (map (lambda (key) (unless (equal? (assq-ref mf key) (assq-ref re-parsed key)) (exit 9))) - '(client_id redirect_uris client_name client_uri - logo_uri tos_uri scope grant_types response_types - default_max_age require_auth_time))))))))) + '(client_id redirect_uris))))))))) -- cgit v1.2.3