summaryrefslogtreecommitdiff
path: root/tests/client-manifest.scm
diff options
context:
space:
mode:
authorVivien Kraus <vivien@planete-kraus.eu>2021-09-22 13:11:21 +0200
committerVivien Kraus <vivien@planete-kraus.eu>2021-09-22 18:08:47 +0200
commit555e59deba33284067298ce6130c379c75e3d2a3 (patch)
treec15c823913e917bc474f1cf163caf65a117ee9c3 /tests/client-manifest.scm
parent0d74f8c1ca9c1e9bf9a04b85f598ba7a175d1d86 (diff)
Use anonymous-http-request from (webid-oidc parameters) everywhere
Diffstat (limited to 'tests/client-manifest.scm')
-rw-r--r--tests/client-manifest.scm99
1 files changed, 51 insertions, 48 deletions
diff --git a/tests/client-manifest.scm b/tests/client-manifest.scm
index 8e98091..7f8e130 100644
--- a/tests/client-manifest.scm
+++ b/tests/client-manifest.scm
@@ -14,15 +14,17 @@
;; You should have received a copy of the GNU Affero General Public License
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
-(use-modules (webid-oidc client-manifest)
- (webid-oidc cache)
- (webid-oidc testing)
- (webid-oidc errors)
- (web uri)
- (srfi srfi-19)
- (web response)
- (ice-9 optargs)
- (ice-9 receive))
+(define-module (tests client-manifest)
+ #: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))
(with-test-environment
"client-manifest"
@@ -52,42 +54,43 @@
(string->uri "https://app.example.com/id#app"))
(exit 2))
(values what-to-respond what-to-respond-body))
- (define cache-http-get
- (with-cache
- #:http-get respond))
- (define mf
- (get-client-manifest
- (string->uri "https://app.example.com/id#app")
- #:http-get cache-http-get))
- (define id (client-manifest-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")
- (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")
- (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)
- (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 (get-client-manifest
- (string->uri "https://app.example.com/id#app")
- #:http-get cache-http-get)))
- (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))))))
+ (parameterize ((p:anonymous-http-request respond))
+ (use-cache
+ (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))
+ (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")
+ (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")
+ (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)
+ (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")))))
+ (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)))))))))