summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorVivien Kraus <vivien@planete-kraus.eu>2020-01-01 00:00:00 +0100
committerVivien Kraus <vivien@planete-kraus.eu>2021-06-19 15:44:24 +0200
commit0dd0ab17ebf6d8cef93f007582156548aca4c5dd (patch)
treefc7fd2f8695dc2b1924f12a5321048aa67c50214 /tests
parent2fc254c809e42029f28982404870604633b35521 (diff)
Add a function to hash a public key for DPoP.
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am3
-rw-r--r--tests/jkt.scm23
2 files changed, 25 insertions, 1 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 94a8b5b..b889e0b 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -7,7 +7,8 @@ TESTS = %reldir%/load-library.scm \
%reldir%/jwk-kty-rsa-correct.scm \
%reldir%/jwk-kty-rsa-incorrect.scm \
%reldir%/hash-ok.scm \
- %reldir%/hash-unsupported.scm
+ %reldir%/hash-unsupported.scm \
+ %reldir%/jkt.scm
EXTRA_DIST += $(TESTS)
diff --git a/tests/jkt.scm b/tests/jkt.scm
new file mode 100644
index 0000000..ca20f89
--- /dev/null
+++ b/tests/jkt.scm
@@ -0,0 +1,23 @@
+(use-modules (webid-oidc stubs)
+ (webid-oidc testing))
+
+(with-test-environment
+ "jkt"
+ (lambda ()
+ (let* ((key (json-string->scm "{
+ \"kty\":\"EC\",
+ \"x\":\"l8tFrhx-34tV3hRICRDY9zCkDlpBhF42UQUfWVAWBFs\",
+ \"y\":\"9VE4jf_Ok_o64zbTTlcuNJajHmt6v9TDVrU0CdvGRDA\",
+ \"crv\":\"P-256\"
+ }"))
+ (jkt (jkt key))
+ (expected "0ZcOCORZNYy-DWpqq30jZyJGHTN0d2HglBV3uiguA4I"))
+ (unless (string=? jkt expected)
+ (format (current-error-port)
+ "The JKT algorithm is not correct:
+expected: ~a
+obtained: ~a
+"
+ expected
+ jkt)
+ (exit 1)))))