]> git.ekhem.eu.org Git - guix.git/commitdiff
[tests] Add SSH and networking test cases.
authorJakub Czajka <jakub@ekhem.eu.org>
Wed, 15 Jul 2026 22:51:20 +0000 (22:51 +0000)
committerJakub Czajka <jakub@ekhem.eu.org>
Fri, 17 Jul 2026 13:47:16 +0000 (13:47 +0000)
Test SSH daemon (service, port 72, authorized_keys, key
auth shell command) and networking (service, eth0).

Co-Authored-By: Claude <noreply@anthropic.com>
tests/networking.scm [new file with mode: 0644]
tests/sshd.scm [new file with mode: 0644]
tests/vps-base.scm

diff --git a/tests/networking.scm b/tests/networking.scm
new file mode 100644 (file)
index 0000000..d08ad5f
--- /dev/null
@@ -0,0 +1,22 @@
+;;; Copyright (c) 2026 Jakub Czajka <jakub@ekhem.eu.org>
+;;; License: GPL-3.0 or later.
+;;;
+;;; Static networking test cases.
+
+(define-module (tests networking)
+  #:use-module (guix gexp)
+  #:export (networking-test-cases))
+
+(define (networking-test-cases marionette)
+  "Return a gexp with static networking test assertions."
+  #~(begin
+      (test-assert "net: service running"
+                   (marionette-eval '(begin
+                                       (use-modules (gnu services herd))
+                                       (start-service 'networking))
+                                    #$marionette))
+
+      (test-assert "net: eth0 is up"
+                   (marionette-eval '(file-exists?
+                                      "/sys/class/net/eth0/operstate")
+                                    #$marionette))))
diff --git a/tests/sshd.scm b/tests/sshd.scm
new file mode 100644 (file)
index 0000000..9ac5023
--- /dev/null
@@ -0,0 +1,31 @@
+;;; Copyright (c) 2026 Jakub Czajka <jakub@ekhem.eu.org>
+;;; License: GPL-3.0 or later.
+;;;
+;;; SSH daemon test cases.
+
+(define-module (tests sshd)
+  #:use-module (guix gexp)
+  #:export (sshd-test-cases))
+
+(define (sshd-test-cases marionette connect-gexp)
+  "Return a gexp with SSH daemon test assertions."
+  #~(begin
+      (test-assert "sshd: service running"
+                   (marionette-eval '(begin
+                                       (use-modules (gnu services herd))
+                                       (start-service 'ssh-daemon))
+                                    #$marionette))
+
+      (test-assert "sshd: port 72 TCP"
+                   (wait-for-tcp-port 72
+                                      #$marionette))
+
+      ;; Diagnostic: verify the authorized keys file is in place.
+      (test-assert "sshd: authorized_keys exists for dak"
+                   (marionette-eval '(file-exists?
+                                      "/etc/ssh/authorized_keys.d/dak")
+                                    #$marionette))
+
+      (test-equal "sshd: shell command via key auth"
+                  'hello
+                  (#$connect-gexp))))
index ca78a839e19f0cd1af064a7f4639f42c1bce3e82..33fa71ac4e78306979293d6c5f53b27fd8a1f8ad 100644 (file)
@@ -24,6 +24,8 @@
   #:use-module (tests claude-code)
   #:use-module (tests dotfiles)
   #:use-module (tests paseo)
+  #:use-module (tests sshd)
+  #:use-module (tests networking)
   #:use-module (guix gexp)
   #:export (%test-vps %vps-test-os run-vps-test))
 
@@ -193,7 +195,16 @@ every function in TEST-CASES.  Each element is a function
   (let ((claude claude-code-test-cases)
         (paseo paseo-test-cases)
         (dots dotfiles-test-cases)
-        (home home-activation-test-cases))
+        (home home-activation-test-cases)
+        (ssh (lambda (m)
+               (sshd-test-cases m
+                                (make-ssh-connect m))))
+        (net networking-test-cases))
     (system-test (name "vps")
                  (description "VPS test suite.")
-                 (value (run-vps-test (list claude paseo dots home))))))
+                 (value (run-vps-test (list claude
+                                            paseo
+                                            dots
+                                            home
+                                            ssh
+                                            net))))))