test_08_ssh_key_merge.py 736 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import pytest
  2. import rostest.util as u
  3. from rostest.util import SSH
  4. @pytest.fixture(scope="module")
  5. def qemu(request):
  6. q = u.run_qemu(request)
  7. u.flush_out(q.stdout)
  8. return q
  9. def test_ssh_key_merging(qemu):
  10. SSH(qemu).check_call('''cat > test-merge << "SCRIPT"
  11. set -x -e
  12. rm /var/lib/rancher/conf/cloud-config.yml
  13. EXISTING=$(ros config get ssh_authorized_keys | head -1)
  14. cat > /var/lib/rancher/conf/metadata << EOF
  15. SSHPublicKeys:
  16. "0": zero
  17. "1": one
  18. "2": two
  19. EOF
  20. ros config set hostname one
  21. ros config set hostname two
  22. ros config set hostname three
  23. cat > expected << EOF
  24. $EXISTING
  25. - zero
  26. - one
  27. - two
  28. EOF
  29. ros config get ssh_authorized_keys > got
  30. diff got expected
  31. SCRIPT
  32. sudo bash test-merge
  33. '''.strip())