diff options
author | Vivien Kraus <vivien@planete-kraus.eu> | 2021-09-17 22:21:05 +0200 |
---|---|---|
committer | Vivien Kraus <vivien@planete-kraus.eu> | 2021-09-21 22:25:03 +0200 |
commit | 76c90440b7a65d1ec43685a3b6c25facd11030b1 (patch) | |
tree | 8c28d31d700cdbe9ec32a8d65b12489ffd9a5203 /tests | |
parent | 55195e4659339f56036c2f98d06cfd59a0141514 (diff) |
JWK: serialize and deserialize to and from SXML
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Makefile.am | 3 | ||||
-rw-r--r-- | tests/xml-keys.scm | 53 |
2 files changed, 55 insertions, 1 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am index 02512d8..251b6b0 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -63,7 +63,8 @@ TESTS = %reldir%/load-library.scm \ %reldir%/http-link.scm \ %reldir%/acl.scm \ %reldir%/crud.scm \ - %reldir%/preconditions.scm + %reldir%/preconditions.scm \ + %reldir%/xml-keys.scm EXTRA_DIST += $(TESTS) %reldir%/ChangeLog diff --git a/tests/xml-keys.scm b/tests/xml-keys.scm new file mode 100644 index 0000000..0e2baeb --- /dev/null +++ b/tests/xml-keys.scm @@ -0,0 +1,53 @@ +;; disfluid, implementation of the Solid specification +;; Copyright (C) 2021 Vivien Kraus + +;; This program is free software: you can redistribute it and/or modify +;; it under the terms of the GNU Affero General Public License as +;; published by the Free Software Foundation, either version 3 of the +;; License, or (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU Affero General Public License for more details. + +;; 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 jwk) + (sxml simple) + (webid-oidc testing) + (oop goops)) + +(with-test-environment + "xml-keys" + (lambda () + (let ((key-xml + "<?xml version=\"1.0\" encoding=\"utf-8\"?> +<jwk xmlns=\"https://disfluid.planete-kraus.eu/Public_002dkey-cryptography.html#Public_002dkey-cryptography\" + kty=\"EC\" + x=\"l8tFrhx-34tV3hRICRDY9zCkDlpBhF42UQUfWVAWBFs\" + y=\"9VE4jf_Ok_o64zbTTlcuNJajHmt6v9TDVrU0CdvGRDA\" + crv=\"P-256\" />") + (key (make <ec-point> + #:crv 'P-256 + #:x "l8tFrhx-34tV3hRICRDY9zCkDlpBhF42UQUfWVAWBFs" + #:y "9VE4jf_Ok_o64zbTTlcuNJajHmt6v9TDVrU0CdvGRDA"))) + (let ((parsed-once (sxml->key (xml->sxml key-xml))) + (printed-once (call-with-output-string + (lambda (port) + (sxml->xml (->sxml key) port))))) + (let ((parsed-twice (sxml->key (xml->sxml printed-once))) + (printed-twice (call-with-output-string + (lambda (port) + (sxml->xml (->sxml parsed-once) port))))) + (let ((parsed-thrice (sxml->key (xml->sxml printed-twice))) + (printed-thrice (call-with-output-string + (lambda (port) + (sxml->xml (->sxml parsed-twice) port))))) + (unless (and (equal? parsed-once key) + (equal? parsed-twice parsed-once) + (equal? parsed-thrice parsed-twice) + (equal? printed-twice printed-once) + (equal? printed-thrice printed-twice)) + (exit 1)))))))) |