tests: ssh: Generalize.
* gnu/tests/ssh.scm (%openssh-os): Rename to... (%base-os): ... this. [services]: Remove 'openssh-service-type' instance. (os-with-service): New procedure. (run-openssh-test): Rename to... (run-ssh-test): ... this. Add 'ssh-service' and 'pid-file' parameters. Use 'os-with-service' to add SSH-SERVICE to %BASE-OS. Honor PID-FILE. (%test-openssh): Adjust accordingly.
This commit is contained in:
parent
26cfc415be
commit
0e59885060
|
@ -33,7 +33,7 @@
|
||||||
#:use-module (guix monads)
|
#:use-module (guix monads)
|
||||||
#:export (%test-openssh))
|
#:export (%test-openssh))
|
||||||
|
|
||||||
(define %openssh-os
|
(define %base-os
|
||||||
(operating-system
|
(operating-system
|
||||||
(host-name "komputilo")
|
(host-name "komputilo")
|
||||||
(timezone "Europe/Berlin")
|
(timezone "Europe/Berlin")
|
||||||
|
@ -43,18 +43,22 @@
|
||||||
(file-systems %base-file-systems)
|
(file-systems %base-file-systems)
|
||||||
(firmware '())
|
(firmware '())
|
||||||
(users %base-user-accounts)
|
(users %base-user-accounts)
|
||||||
|
(services (cons (dhcp-client-service)
|
||||||
|
%base-services))))
|
||||||
|
|
||||||
;; Allow root logins with an empty password to simplify testing.
|
(define (os-with-service service)
|
||||||
(services (cons* (service openssh-service-type
|
"Return a test operating system that runs SERVICE."
|
||||||
(openssh-configuration
|
(operating-system
|
||||||
(permit-root-login #t)
|
(inherit %base-os)
|
||||||
(allow-empty-passwords? #t)))
|
(services (cons service
|
||||||
(dhcp-client-service)
|
(operating-system-user-services %base-os)))))
|
||||||
%base-services))))
|
|
||||||
|
|
||||||
(define (run-openssh-test name)
|
(define (run-ssh-test name ssh-service pid-file)
|
||||||
|
"Run a test of an OS running SSH-SERVICE, which writes its PID to PID-FILE.
|
||||||
|
SSH-SERVICE must be configured to listen on port 22 and to allow for root and
|
||||||
|
empty-password logins."
|
||||||
(mlet* %store-monad ((os -> (marionette-operating-system
|
(mlet* %store-monad ((os -> (marionette-operating-system
|
||||||
%openssh-os
|
(os-with-service ssh-service)
|
||||||
#:imported-modules '((gnu services herd)
|
#:imported-modules '((gnu services herd)
|
||||||
(guix combinators))))
|
(guix combinators))))
|
||||||
(command (system-qemu-image/shared-store-script
|
(command (system-qemu-image/shared-store-script
|
||||||
|
@ -98,7 +102,7 @@
|
||||||
(mkdir #$output)
|
(mkdir #$output)
|
||||||
(chdir #$output)
|
(chdir #$output)
|
||||||
|
|
||||||
(test-begin "openssh")
|
(test-begin "ssh-daemon")
|
||||||
|
|
||||||
;; Wait for sshd to be up and running.
|
;; Wait for sshd to be up and running.
|
||||||
(test-eq "service running"
|
(test-eq "service running"
|
||||||
|
@ -112,7 +116,7 @@
|
||||||
|
|
||||||
;; Check sshd's PID file.
|
;; Check sshd's PID file.
|
||||||
(test-equal "sshd PID"
|
(test-equal "sshd PID"
|
||||||
(wait-for-file "/var/run/sshd.pid")
|
(wait-for-file #$pid-file)
|
||||||
(marionette-eval
|
(marionette-eval
|
||||||
'(begin
|
'(begin
|
||||||
(use-modules (gnu services herd)
|
(use-modules (gnu services herd)
|
||||||
|
@ -155,4 +159,11 @@
|
||||||
(system-test
|
(system-test
|
||||||
(name "openssh")
|
(name "openssh")
|
||||||
(description "Connect to a running OpenSSH daemon.")
|
(description "Connect to a running OpenSSH daemon.")
|
||||||
(value (run-openssh-test name))))
|
(value (run-ssh-test name
|
||||||
|
;; Allow root logins with an empty password to
|
||||||
|
;; simplify testing.
|
||||||
|
(service openssh-service-type
|
||||||
|
(openssh-configuration
|
||||||
|
(permit-root-login #t)
|
||||||
|
(allow-empty-passwords? #t)))
|
||||||
|
"/var/run/sshd.pid"))))
|
||||||
|
|
Loading…
Reference in New Issue