summaryrefslogtreecommitdiff
path: root/gnu/tests/ssh.scm
diff options
context:
space:
mode:
Diffstat (limited to 'gnu/tests/ssh.scm')
-rw-r--r--gnu/tests/ssh.scm39
1 files changed, 25 insertions, 14 deletions
diff --git a/gnu/tests/ssh.scm b/gnu/tests/ssh.scm
index a9592d9fee0..bcf7c973c41 100644
--- a/gnu/tests/ssh.scm
+++ b/gnu/tests/ssh.scm
@@ -33,7 +33,7 @@
33 #:use-module (guix monads) 33 #:use-module (guix monads)
34 #:export (%test-openssh)) 34 #:export (%test-openssh))
35 35
36(define %openssh-os 36(define %base-os
37 (operating-system 37 (operating-system
38 (host-name "komputilo") 38 (host-name "komputilo")
39 (timezone "Europe/Berlin") 39 (timezone "Europe/Berlin")
@@ -43,18 +43,22 @@
43 (file-systems %base-file-systems) 43 (file-systems %base-file-systems)
44 (firmware '()) 44 (firmware '())
45 (users %base-user-accounts) 45 (users %base-user-accounts)
46 (services (cons (dhcp-client-service)
47 %base-services))))
46 48
47 ;; Allow root logins with an empty password to simplify testing. 49(define (os-with-service service)
48 (services (cons* (service openssh-service-type 50 "Return a test operating system that runs SERVICE."
49 (openssh-configuration 51 (operating-system
50 (permit-root-login #t) 52 (inherit %base-os)
51 (allow-empty-passwords? #t))) 53 (services (cons service
52 (dhcp-client-service) 54 (operating-system-user-services %base-os)))))
53 %base-services)))) 55
54 56(define (run-ssh-test name ssh-service pid-file)
55(define (run-openssh-test name) 57 "Run a test of an OS running SSH-SERVICE, which writes its PID to PID-FILE.
58SSH-SERVICE must be configured to listen on port 22 and to allow for root and
59empty-password logins."
56 (mlet* %store-monad ((os -> (marionette-operating-system 60 (mlet* %store-monad ((os -> (marionette-operating-system
57 %openssh-os 61 (os-with-service ssh-service)
58 #:imported-modules '((gnu services herd) 62 #:imported-modules '((gnu services herd)
59 (guix combinators)))) 63 (guix combinators))))
60 (command (system-qemu-image/shared-store-script 64 (command (system-qemu-image/shared-store-script
@@ -98,7 +102,7 @@
98 (mkdir #$output) 102 (mkdir #$output)
99 (chdir #$output) 103 (chdir #$output)
100 104
101 (test-begin "openssh") 105 (test-begin "ssh-daemon")
102 106
103 ;; Wait for sshd to be up and running. 107 ;; Wait for sshd to be up and running.
104 (test-eq "service running" 108 (test-eq "service running"
@@ -112,7 +116,7 @@
112 116
113 ;; Check sshd's PID file. 117 ;; Check sshd's PID file.
114 (test-equal "sshd PID" 118 (test-equal "sshd PID"
115 (wait-for-file "/var/run/sshd.pid") 119 (wait-for-file #$pid-file)
116 (marionette-eval 120 (marionette-eval
117 '(begin 121 '(begin
118 (use-modules (gnu services herd) 122 (use-modules (gnu services herd)
@@ -155,4 +159,11 @@
155 (system-test 159 (system-test
156 (name "openssh") 160 (name "openssh")
157 (description "Connect to a running OpenSSH daemon.") 161 (description "Connect to a running OpenSSH daemon.")
158 (value (run-openssh-test name)))) 162 (value (run-ssh-test name
163 ;; Allow root logins with an empty password to
164 ;; simplify testing.
165 (service openssh-service-type
166 (openssh-configuration
167 (permit-root-login #t)
168 (allow-empty-passwords? #t)))
169 "/var/run/sshd.pid"))))