summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorVivien Kraus <vivien@planete-kraus.eu>2020-12-06 19:43:34 +0100
committerVivien Kraus <vivien@planete-kraus.eu>2021-06-19 15:44:36 +0200
commit02a3091aa2ff9d32cad4ffe6eeffabee5e78ca15 (patch)
tree9214ecb995e4271fe1d27eb38d0898b91765c69c /tests
parent25ef58cf81a08ab5f8273fd0480ca96c9d3158b5 (diff)
Implement Solid oidc provider confirmation
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am3
-rw-r--r--tests/provider-confirmation.scm40
2 files changed, 42 insertions, 1 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 3d5e46d..1d6cf14 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -35,7 +35,8 @@ TESTS = %reldir%/load-library.scm \
%reldir%/authorization-endpoint-get-form.scm \
%reldir%/authorization-endpoint-submit-form.scm \
%reldir%/token-endpoint-issue.scm \
- %reldir%/token-endpoint-refresh.scm
+ %reldir%/token-endpoint-refresh.scm \
+ %reldir%/provider-confirmation.scm
EXTRA_DIST += $(TESTS) %reldir%/ChangeLog
diff --git a/tests/provider-confirmation.scm b/tests/provider-confirmation.scm
new file mode 100644
index 0000000..44825e3
--- /dev/null
+++ b/tests/provider-confirmation.scm
@@ -0,0 +1,40 @@
+(use-modules (webid-oidc provider-confirmation)
+ (webid-oidc testing)
+ (web uri)
+ (srfi srfi-19)
+ (web response)
+ (ice-9 optargs)
+ (ice-9 receive))
+
+(with-test-environment
+ "provider-confirmation"
+ (lambda ()
+ (define what-uri-to-expect
+ (string->uri "https://provider-confirmation.scm/id#webid"))
+ (define what-headers-to-expect
+ '((accept (text/turtle))))
+ (define what-to-respond
+ (build-response #:headers '((content-type text/turtle))))
+ (define what-to-respond-body
+ "@prefix solid: <http://www.w3.org/ns/solid/terms#> .
+
+<#webid> solid:oidcIssuer <https://other-provider.provider-confirmation.scm>, <http://unsecure.provider> .
+")
+ (define* (http-get uri #:key (headers '()))
+ (unless (equal? uri what-uri-to-expect)
+ (exit 1))
+ (unless (equal? headers what-headers-to-expect)
+ (exit 2))
+ (values what-to-respond what-to-respond-body))
+ (define cnf (get-provider-confirmations
+ (string->uri "https://provider-confirmation.scm/id#webid")
+ #:http-get http-get))
+ (unless (eq? (length cnf) 2)
+ (format (current-error-port) "~s\n" cnf)
+ (exit 3))
+ (unless (string=? (uri->string (car cnf))
+ "https://provider-confirmation.scm")
+ (exit 4))
+ (unless (string=? (uri->string (cadr cnf))
+ "https://other-provider.provider-confirmation.scm")
+ (exit 5))))