test_svrauth.py 1.3 KB

123456789101112131415161718192021222324252627282930
  1. from test_dropbear import *
  2. import signal
  3. import queue
  4. import socket
  5. import os
  6. from pathlib import Path
  7. # Tests for server side authentication
  8. # Requires keyfile and authorized_keys set up in github action build.yml
  9. @pytest.mark.skipif('DBTEST_IN_ACTION' not in os.environ, reason="DBTEST_IN_ACTION not set")
  10. def test_pubkeyinfo(request, dropbear):
  11. kf = str(Path.home() / ".ssh/id_dropbear_key2")
  12. r = dbclient(request, "-i", kf, "echo -n $SSH_PUBKEYINFO", capture_output=True)
  13. # stop at first space
  14. assert r.stdout.decode() == "key2"
  15. @pytest.mark.skipif('DBTEST_IN_ACTION' not in os.environ, reason="DBTEST_IN_ACTION not set")
  16. def test_pubkeyinfo_special(request, dropbear):
  17. kf = str(Path.home() / ".ssh/id_dropbear_key3")
  18. r = dbclient(request, "-i", kf, "echo -n $SSH_PUBKEYINFO", capture_output=True)
  19. # comment contains special characters so the SSH_PUBKEYINFO should not be set
  20. assert r.stdout.decode() == ""
  21. @pytest.mark.skipif('DBTEST_IN_ACTION' not in os.environ, reason="DBTEST_IN_ACTION not set")
  22. def test_pubkeyinfo_okchar(request, dropbear):
  23. kf = str(Path.home() / ".ssh/id_dropbear_key4")
  24. r = dbclient(request, "-i", kf, "echo -n $SSH_PUBKEYINFO", capture_output=True)
  25. # comment contains special characters so the SSH_PUBKEYINFO should not be set
  26. assert r.stdout.decode() == "key4,char"