]> rtime.felk.cvut.cz Git - novaboot.git/commitdiff
tests: Rework server tests to not require external ssh-agent
authorMichal Sojka <michal.sojka@cvut.cz>
Tue, 26 Jan 2021 18:24:56 +0000 (19:24 +0100)
committerMichal Sojka <michal.sojka@cvut.cz>
Tue, 26 Jan 2021 18:32:43 +0000 (19:32 +0100)
tests/server.wv

index 8c8545101c34fefeff1b91a9bab38bbef25202a5..4a4cd2552e5372c954dcb98f39abbbcd25f66546 100755 (executable)
@@ -142,15 +142,21 @@ TFTPROOT="$NBT_HOME/tftproot"
 AUTH="$NBT_HOME/.ssh/authorized_keys"
 sudo_() { sudo -u novaboot-test "$@"; }
 
-WVSTART "Check that ssh-agent needed for following tests is running"
+WVSTART "Create and check ssh keys needed for following tests"
+# Start our custom ssh-agent to not mess up with the user's agent
+eval "$(ssh-agent)"
+trap 'ssh-agent -k' EXIT
 WVPASS test -n "$SSH_AUTH_SOCK" || exit 1
+if [ ! -f id_rsa ]; then
+    ssh-keygen -t rsa -C "generated by $0" -N '' -f ./id_rsa
+fi
+WVPASS ssh-add ./id_rsa
 
 WVSTART "Setup SSH server's admin key"
-WVPASS ssh-add -L > keys
-WVPASS test $(wc -l < keys) -gt 0
 WVPASS sudo_ mkdir -p $(dirname "$AUTH")
 WVPASS sudo_ chmod 700 $(dirname "$AUTH")
-WVPASS sudo_ tee "$AUTH" <<<"command=\"user test admin\" $(tail -n 1 keys)"
+WVPASS sudo_ tee "$AUTH" <<<"command=\"user test admin\" $(cat ./id_rsa.pub)"
+exit
 
 WVSTART "Novaboot --ssh option (connect, rsync, reset)"
 WVPASS sudo_ rm -rf "$TFTPROOT"