diff options
| author | Ludovic Courtès <ludo@gnu.org> | 2016-10-03 15:18:51 +0200 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2016-10-03 15:18:51 +0200 |
| commit | 2b4363891c70bbf641bff8ff0a6fb7526babd5b9 (patch) | |
| tree | 1de9f651bd6b771e16db586354bb8c760f00ddb9 /gnu/tests/ssh.scm | |
| parent | 0e59885060df92bcfb1ee765dfbfdcf26dd67e08 (diff) | |
tests: ssh: Add Dropbear test.
* gnu/tests/ssh.scm (run-ssh-test): Try authenticating with
'userauth-none!' when 'userauth-password!' fails.
(%test-dropbear): New variable.
Diffstat (limited to 'gnu/tests/ssh.scm')
| -rw-r--r-- | gnu/tests/ssh.scm | 46 |
1 files changed, 35 insertions, 11 deletions
diff --git a/gnu/tests/ssh.scm b/gnu/tests/ssh.scm index bcf7c973c41..456476e69d4 100644 --- a/gnu/tests/ssh.scm +++ b/gnu/tests/ssh.scm | |||
| @@ -31,7 +31,8 @@ | |||
| 31 | #:use-module (guix gexp) | 31 | #:use-module (guix gexp) |
| 32 | #:use-module (guix store) | 32 | #:use-module (guix store) |
| 33 | #:use-module (guix monads) | 33 | #:use-module (guix monads) |
| 34 | #:export (%test-openssh)) | 34 | #:export (%test-openssh |
| 35 | %test-dropbear)) | ||
| 35 | 36 | ||
| 36 | (define %base-os | 37 | (define %base-os |
| 37 | (operating-system | 38 | (operating-system |
| @@ -74,6 +75,7 @@ empty-password logins." | |||
| 74 | %load-path))) | 75 | %load-path))) |
| 75 | 76 | ||
| 76 | (use-modules (gnu build marionette) | 77 | (use-modules (gnu build marionette) |
| 78 | (srfi srfi-26) | ||
| 77 | (srfi srfi-64) | 79 | (srfi srfi-64) |
| 78 | (ice-9 match) | 80 | (ice-9 match) |
| 79 | (ssh session) | 81 | (ssh session) |
| @@ -139,16 +141,27 @@ empty-password logins." | |||
| 139 | #:log-verbosity 'protocol))) | 141 | #:log-verbosity 'protocol))) |
| 140 | (match (connect! session) | 142 | (match (connect! session) |
| 141 | ('ok | 143 | ('ok |
| 142 | (match (pk 'auth (userauth-password! session "")) | 144 | ;; Try the simple authentication methods. Dropbear |
| 143 | ('success | 145 | ;; requires 'none' when there are no passwords, whereas |
| 144 | ;; FIXME: 'get-server-public-key' segfaults. | 146 | ;; OpenSSH accepts 'password' with an empty password. |
| 145 | ;; (get-server-public-key session) | 147 | (let loop ((methods (list (cut userauth-password! <> "") |
| 146 | (let ((channel (make-channel session))) | 148 | (cut userauth-none! <>)))) |
| 147 | (channel-open-session channel) | 149 | (match methods |
| 148 | (channel-request-exec channel | 150 | (() |
| 149 | "echo hello > /root/witness") | 151 | (error "all the authentication methods failed")) |
| 150 | (and (zero? (channel-get-exit-status channel)) | 152 | ((auth rest ...) |
| 151 | (wait-for-file "/root/witness"))))))))) | 153 | (match (pk 'auth (auth session)) |
| 154 | ('success | ||
| 155 | ;; FIXME: 'get-server-public-key' segfaults. | ||
| 156 | ;; (get-server-public-key session) | ||
| 157 | (let ((channel (make-channel session))) | ||
| 158 | (channel-open-session channel) | ||
| 159 | (channel-request-exec channel | ||
| 160 | "echo hello > /root/witness") | ||
| 161 | (and (zero? (channel-get-exit-status channel)) | ||
| 162 | (wait-for-file "/root/witness")))) | ||
| 163 | ('denied | ||
| 164 | (loop rest)))))))))) | ||
| 152 | 165 | ||
| 153 | (test-end) | 166 | (test-end) |
| 154 | (exit (= (test-runner-fail-count (test-runner-current)) 0))))) | 167 | (exit (= (test-runner-fail-count (test-runner-current)) 0))))) |
| @@ -167,3 +180,14 @@ empty-password logins." | |||
| 167 | (permit-root-login #t) | 180 | (permit-root-login #t) |
| 168 | (allow-empty-passwords? #t))) | 181 | (allow-empty-passwords? #t))) |
| 169 | "/var/run/sshd.pid")))) | 182 | "/var/run/sshd.pid")))) |
| 183 | |||
| 184 | (define %test-dropbear | ||
| 185 | (system-test | ||
| 186 | (name "dropbear") | ||
| 187 | (description "Connect to a running Dropbear SSH daemon.") | ||
| 188 | (value (run-ssh-test name | ||
| 189 | (service dropbear-service-type | ||
| 190 | (dropbear-configuration | ||
| 191 | (root-login? #t) | ||
| 192 | (allow-empty-passwords? #t))) | ||
| 193 | "/var/run/dropbear.pid")))) | ||
