From 5f94745a1eb4e836199caff8fa372d0a023b8339 Mon Sep 17 00:00:00 2001 From: Vivien Kraus Date: Wed, 1 Jan 2020 00:00:00 +0100 Subject: Add a strip function --- tests/Makefile.am | 6 +++++- tests/jwk-kty-ec-correct.scm | 15 +++++++++++++++ tests/jwk-kty-ec-incorrect.scm | 23 +++++++++++++++++++++++ tests/jwk-kty-rsa-correct.scm | 10 ++++++++++ tests/jwk-kty-rsa-incorrect.scm | 18 ++++++++++++++++++ 5 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 tests/jwk-kty-ec-correct.scm create mode 100644 tests/jwk-kty-ec-incorrect.scm create mode 100644 tests/jwk-kty-rsa-correct.scm create mode 100644 tests/jwk-kty-rsa-incorrect.scm (limited to 'tests') diff --git a/tests/Makefile.am b/tests/Makefile.am index adff911..8713516 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,7 +1,11 @@ TESTS = %reldir%/load-library.scm \ %reldir%/base64-ok.scm \ %reldir%/base64-error.scm \ - %reldir%/random.scm + %reldir%/random.scm \ + %reldir%/jwk-kty-ec-correct.scm \ + %reldir%/jwk-kty-ec-incorrect.scm \ + %reldir%/jwk-kty-rsa-correct.scm \ + %reldir%/jwk-kty-rsa-incorrect.scm EXTRA_DIST += $(TESTS) diff --git a/tests/jwk-kty-ec-correct.scm b/tests/jwk-kty-ec-correct.scm new file mode 100644 index 0000000..04306eb --- /dev/null +++ b/tests/jwk-kty-ec-correct.scm @@ -0,0 +1,15 @@ +(use-modules (webid-oidc stubs) + (webid-oidc testing)) + +(with-test-environment + "jwk-kty-ec-correct" + (lambda () + (let* ((key (json-string->scm "{ + \"kty\":\"EC\", + \"x\":\"l8tFrhx-34tV3hRICRDY9zCkDlpBhF42UQUfWVAWBFs\", + \"y\":\"9VE4jf_Ok_o64zbTTlcuNJajHmt6v9TDVrU0CdvGRDA\", + \"crv\":\"P-256\" + }")) + (kty (kty key))) + (unless (eq? kty 'EC) + (exit 1))))) diff --git a/tests/jwk-kty-ec-incorrect.scm b/tests/jwk-kty-ec-incorrect.scm new file mode 100644 index 0000000..5ada4f2 --- /dev/null +++ b/tests/jwk-kty-ec-incorrect.scm @@ -0,0 +1,23 @@ +(use-modules (webid-oidc stubs) + (webid-oidc testing) + (webid-oidc errors)) + +(with-test-environment + "jwk-kty-ec-incorrect" + (lambda () + (let* ((key (json-string->scm "{ + \"kty\":\"EC\", + \"x\":\"This-point-does-not-exist-on-the-curve_____\", + \"y\":\"9VE4jf_Ok_o64zbTTlcuNJajHmt6v9TDVrU0CdvGRDA\", + \"crv\":\"P-256\" + }")) + (kty + (with-exception-handler + (lambda (exn) + #f) + (lambda () + (kty key)) + #:unwind? #t + #:unwind-for-type ¬-a-jwk))) + (when kty + (exit 1))))) diff --git a/tests/jwk-kty-rsa-correct.scm b/tests/jwk-kty-rsa-correct.scm new file mode 100644 index 0000000..f6d42ad --- /dev/null +++ b/tests/jwk-kty-rsa-correct.scm @@ -0,0 +1,10 @@ +(use-modules (webid-oidc stubs) + (webid-oidc testing)) + +(with-test-environment + "jwk-kty-ec-correct" + (lambda () + (let* ((key (json-string->scm "{\"kty\":\"RSA\",\"e\":\"AQAB\",\"kid\":\"db7cdbbf-0ca3-48da-abf6-8f34002a4651\",\"n\":\"nzyis1ZjfNB0bBgKFMSvvkTtwlvBsaJq7S5wA-kzeVOVpVWwkWdVha4s38XM_pa_yr47av7-z3VTmvDRyAHcaT92whREFpLv9cj5lTeJSibyr_Mrm_YtjCZVWgaOYIhwrXwKLqPr_11inWsAkfIytvHWTxZYEcXLgAXFuUuaS3uF9gEiNQwzGTU1v0FqkqTBr4B8nW3HCN47XUu0t8Y0e-lf4s4OxQawWD79J9_5d3Ry0vbV3Am1FtGJiJvOwRsIfVChDpYStTcHTCMqtvWbV6L11BWkpzGXSW4Hv43qa-GSYOD2QU68Mb59oSk2OB-BtOLpJofmbGEGgvmwyCI9Mw\"}")) + (kty (kty key))) + (unless (eq? kty 'RSA) + (exit 1))))) diff --git a/tests/jwk-kty-rsa-incorrect.scm b/tests/jwk-kty-rsa-incorrect.scm new file mode 100644 index 0000000..11ab368 --- /dev/null +++ b/tests/jwk-kty-rsa-incorrect.scm @@ -0,0 +1,18 @@ +(use-modules (webid-oidc stubs) + (webid-oidc testing) + (webid-oidc errors)) + +(with-test-environment + "jwk-kty-ec-incorrect" + (lambda () + (let* ((key (json-string->scm "{\"kty\":\"RSA\",\"e\":\"AQAB\",\"kid\":\"db7cdbbf-0ca3-48da-abf6-8f34002a4651\",\"n\":\"--\"}")) + (kty + (with-exception-handler + (lambda (exn) + #f) + (lambda () + (kty key)) + #:unwind? #t + #:unwind-for-type ¬-a-jwk))) + (when kty + (exit 1))))) -- cgit v1.2.3