summaryrefslogtreecommitdiff
path: root/tests/services
diff options
context:
space:
mode:
Diffstat (limited to 'tests/services')
-rw-r--r--tests/services/pam-mount.scm83
1 files changed, 83 insertions, 0 deletions
diff --git a/tests/services/pam-mount.scm b/tests/services/pam-mount.scm
new file mode 100644
index 00000000000..bfbd15967f5
--- /dev/null
+++ b/tests/services/pam-mount.scm
@@ -0,0 +1,83 @@
1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2023 Brian Cully <bjc@spork.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 (tests services pam-mount)
20 #:use-module (gnu services pam-mount)
21 #:use-module (gnu system pam)
22 #:use-module (gnu services)
23 #:use-module (gnu services configuration)
24 #:use-module (guix derivations)
25 #:use-module (guix gexp)
26 #:use-module (guix grafts)
27 #:use-module (guix store)
28 #:use-module (guix tests)
29 #:use-module (ice-9 match)
30 #:use-module (srfi srfi-1)
31 #:use-module (srfi srfi-64))
32
33(define pam-mount-volume-fields (@@ (gnu services pam-mount)
34 pam-mount-volume-fields))
35(define field-name->tag (@@ (gnu services pam-mount)
36 field-name->tag))
37
38(define pam-mount-volume->sxml (@@ (gnu services pam-mount)
39 pam-mount-volume->sxml))
40
41(test-begin "services-pam-mount")
42
43(test-group "field-name->tag"
44 (let ((field-map '((user-name user)
45 (user-id uid)
46 (primary-group pgrp)
47 (group-id gid)
48 (secondary-group sgrp)
49 (file-system-type fstype)
50 (no-mount-as-root? noroot)
51 (server server)
52 (file-name path)
53 (mount-point mountpoint)
54 (options options)
55 (ssh? ssh)
56 (cipher cipher)
57 (file-system-key-cipher fskeycipher)
58 (file-system-key-hash fskeyhash)
59 (file-system-key-file-name fskeypath))))
60
61 (test-equal "all fields accounted for"
62 (map car field-map)
63 (map configuration-field-name pam-mount-volume-fields))
64
65 (for-each (match-lambda
66 ((field-name tag-name)
67 (test-eq (format #f "~a -> ~a" field-name tag-name)
68 (field-name->tag field-name) tag-name)))
69 field-map)))
70
71(let ((tmpfs-volume (pam-mount-volume
72 (secondary-group "users")
73 (file-system-type "tmpfs")
74 (mount-point "/run/user/%(USERUID)")
75 (options "someoptions"))))
76 (test-equal "tmpfs"
77 '(volume (@ (sgrp "users")
78 (fstype "tmpfs")
79 (mountpoint "/run/user/%(USERUID)")
80 (options "someoptions")))
81 (pam-mount-volume->sxml tmpfs-volume)))
82
83(test-end "services-pam-mount")