Add (guix pki).
[jackhill/guix/guix.git] / tests / pki.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2013 Ludovic Courtès <ludo@gnu.org>
3 ;;;
4 ;;; This file is part of GNU Guix.
5 ;;;
6 ;;; GNU Guix is free software; you can redistribute it and/or modify it
7 ;;; under the terms of the GNU General Public License as published by
8 ;;; the Free Software Foundation; either version 3 of the License, or (at
9 ;;; your option) any later version.
10 ;;;
11 ;;; GNU Guix is distributed in the hope that it will be useful, but
12 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;;; GNU General Public License for more details.
15 ;;;
16 ;;; You should have received a copy of the GNU General Public License
17 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
18
19 (define-module (test-pki)
20 #:use-module (guix pki)
21 #:use-module (guix pk-crypto)
22 #:use-module (rnrs io ports)
23 #:use-module (srfi srfi-64))
24
25 ;; Test the (guix pki) module.
26
27 (define %public-key
28 (call-with-input-file %public-key-file
29 (compose string->canonical-sexp
30 get-string-all)))
31
32 (test-begin "pki")
33
34 (test-assert "current-acl"
35 (not (not (member (canonical-sexp->sexp %public-key)
36 (map canonical-sexp->sexp
37 (acl->public-keys (current-acl)))))))
38
39 (test-assert "authorized-key? public-key current-acl"
40 (authorized-key? %public-key))
41
42 (test-assert "authorized-key? public-key empty-acl"
43 (not (authorized-key? %public-key (public-keys->acl '()))))
44
45 (test-assert "authorized-key? public-key singleton"
46 (authorized-key? %public-key (public-keys->acl (list %public-key))))
47
48 (test-end)
49
50 \f
51 (exit (= (test-runner-fail-count (test-runner-current)) 0))