From 2fc254c809e42029f28982404870604633b35521 Mon Sep 17 00:00:00 2001 From: Vivien Kraus Date: Wed, 1 Jan 2020 00:00:00 +0100 Subject: Add a hash function --- tests/Makefile.am | 4 +++- tests/hash-ok.scm | 11 +++++++++++ tests/hash-unsupported.scm | 21 +++++++++++++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 tests/hash-ok.scm create mode 100644 tests/hash-unsupported.scm (limited to 'tests') diff --git a/tests/Makefile.am b/tests/Makefile.am index 8713516..94a8b5b 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -5,7 +5,9 @@ TESTS = %reldir%/load-library.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 + %reldir%/jwk-kty-rsa-incorrect.scm \ + %reldir%/hash-ok.scm \ + %reldir%/hash-unsupported.scm EXTRA_DIST += $(TESTS) diff --git a/tests/hash-ok.scm b/tests/hash-ok.scm new file mode 100644 index 0000000..26384f8 --- /dev/null +++ b/tests/hash-ok.scm @@ -0,0 +1,11 @@ +(use-modules + (webid-oidc testing) + ((webid-oidc stubs) #:prefix stubs:) + (rnrs bytevectors)) + +(with-test-environment + "hash-ok" + (lambda () + (let ((hashed (stubs:hash 'SHA-256 "hello :)"))) + (unless (string? hashed) + (exit 1))))) diff --git a/tests/hash-unsupported.scm b/tests/hash-unsupported.scm new file mode 100644 index 0000000..c52959a --- /dev/null +++ b/tests/hash-unsupported.scm @@ -0,0 +1,21 @@ +(use-modules + (webid-oidc testing) + (webid-oidc errors) + ((webid-oidc stubs) #:prefix stubs:) + (rnrs bytevectors)) + +(with-test-environment + "hash-unsupported" + (lambda () + (with-exception-handler + (lambda (error) + (unless ((record-predicate &unsupported-alg) error) + (exit 1)) + (let ((value ((record-accessor &unsupported-alg 'value) error))) + (unless (eq? value 'SHA-1024) + (exit 2)))) + (lambda () + (stubs:hash 'SHA-1024 "hello :)") + (exit 3)) + #:unwind? #t + #:unwind-for-type &unsupported-alg))) -- cgit v1.2.3