Changeset - b35918db4b2d
[Not reviewed]
0 11 0
Branko Majic (branko) - 6 years ago 2020-01-06 18:10:31
branko@majic.rs
MAR-148: Fixed tests for the backup_server role:

- Fix some handling of newlines by updating test data keys to include
newline at the end of file.
- Ensure we do not produce exit code 255 when testing the available
authentication mechanisms for the backup SSH server
instance (otherwise we get runtime exception from Testinfra itself).
- Fix some handling of newlines by not doing stripping and including
newline in expected output.
3 files changed with 15 insertions and 7 deletions:
0 comments (0 inline, 0 general)
roles/backup_server/molecule/default/tests/test_default.py
Show inline comments
 
@@ -173,7 +173,15 @@ def test_backup_ssh_server_login_mechanisms(host):
 
    """
 

	
 
    # Try to login with no preferred authentication types to the server.
 
    login_attempt = host.run("ssh -v -o PreferredAuthentications=none -o NoHostAuthenticationForLocalhost=yes localhost")
 

	
 
    assert login_attempt.rc == 255
 
    # Try to login with no preferred authentication types to the
 
    # server.
 
    # @TODO: The /bin/false is used because the ssh command listed
 
    #        below will return error code 255. On the other hand,
 
    #        Testinfra itself treats exit code 255 as special case for
 
    #        detecting when the ssh connection to managed machine
 
    #        fails. It might be a good idea to try to reach out to
 
    #        Testinfra maintainer about this or update this test to
 
    #        use Paramiko in some way.
 
    login_attempt = host.run("ssh -v -o PreferredAuthentications=none -o NoHostAuthenticationForLocalhost=yes localhost || /bin/false")
 

	
 
    assert login_attempt.rc == 1
 
    assert "debug1: Authentications that can continue: publickey" in login_attempt.stderr.split("\r\n")
roles/backup_server/molecule/default/tests/test_parameters_mandatory.py
Show inline comments
 
@@ -21,3 +21,3 @@ def test_firewall_configuration(host):
 
        assert firewall_config.group == 'root'
 
        assert firewall_config.mode == 0o640
 
        assert firewall_config.content == ""
 
        assert firewall_config.content == "\n"
roles/backup_server/molecule/default/tests/test_parameters_optional.py
Show inline comments
 
@@ -111,5 +111,5 @@ def test_backup_client_authorized_keys(host):
 
        assert client1_user_authorized_keys.group == 'bak-client1_backup'
 
        assert client1_user_authorized_keys.mode == 0o640
 
        assert client1_user_authorized_keys.content == open('tests/data/ssh/client1.pub', 'r').read().strip()
 
        assert client1_user_authorized_keys.content == open('tests/data/ssh/client1.pub', 'r').read()
 

	
 
        client2_user = host.user('bak-client2-backup')
 
@@ -120,5 +120,5 @@ def test_backup_client_authorized_keys(host):
 
        assert client2_user_authorized_keys.group == 'bak-client2-backup'
 
        assert client2_user_authorized_keys.mode == 0o640
 
        assert client2_user_authorized_keys.content == open('tests/data/ssh/client2.pub', 'r').read().strip()
 
        assert client2_user_authorized_keys.content == open('tests/data/ssh/client2.pub', 'r').read()
 

	
 

	
0 comments (0 inline, 0 general)