webfinger.scm
| 1 | ;;;; Copyright (C) 2020 Julien Lepiller <julien@lepiller.eu> |
| 2 | ;;;; |
| 3 | ;;;; This library is free software; you can redistribute it and/or |
| 4 | ;;;; modify it under the terms of the GNU Lesser General Public |
| 5 | ;;;; License as published by the Free Software Foundation; either |
| 6 | ;;;; version 3 of the License, or (at your option) any later version. |
| 7 | ;;;; |
| 8 | ;;;; This library is distributed in the hope that it will be useful, |
| 9 | ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 11 | ;;;; Lesser General Public License for more details. |
| 12 | ;;;; |
| 13 | ;;;; You should have received a copy of the GNU Lesser General Public |
| 14 | ;;;; License along with this library; if not, write to the Free Software |
| 15 | ;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 16 | ;;;; |
| 17 | |
| 18 | (define-module (tests webfinger) |
| 19 | #:use-module (ice-9 format) |
| 20 | #:use-module (json) |
| 21 | #:use-module (rnrs bytevectors) |
| 22 | #:use-module (srfi srfi-64) |
| 23 | #:use-module (webfinger webfinger)) |
| 24 | |
| 25 | (test-begin "webfinger") |
| 26 | |
| 27 | (define simple-record-scm |
| 28 | '(("subject" . "acct:carol@example.com") |
| 29 | ("links" . #((("rel" . "http://openid.net/specs/connect/1.0/issuer") |
| 30 | ("href" . "https://openid.example.com")))))) |
| 31 | (define simple-record |
| 32 | (make-jrd-record |
| 33 | "acct:carol@example.com" |
| 34 | '() |
| 35 | #f |
| 36 | (list |
| 37 | (make-link-record |
| 38 | "http://openid.net/specs/connect/1.0/issuer" |
| 39 | #f |
| 40 | "https://openid.example.com" |
| 41 | #f |
| 42 | #f)))) |
| 43 | |
| 44 | (test-assert "simple example decode" |
| 45 | (let ((converted-simple-record (json->jrd-record simple-record-scm))) |
| 46 | (if (equal? converted-simple-record simple-record) |
| 47 | #t |
| 48 | (pk 'fail converted-simple-record #f)))) |
| 49 | |
| 50 | (test-assert "simple example encode" |
| 51 | (let ((converted-simple-record-scm (jrd->string simple-record))) |
| 52 | (if (equal? (scm->json-string simple-record-scm) |
| 53 | converted-simple-record-scm) |
| 54 | #t |
| 55 | (pk 'fail converted-simple-record-scm #f)))) |
| 56 | |
| 57 | (test-end "webfinger") |
| 58 |