Changeset - 2c140fba79b9
[Not reviewed]
2 1 0
Branko Majic (branko) - 3 years ago 2021-01-12 21:26:44
branko@majic.rs
MAR-163: Deduplicate tests in the bootstrap role:

- The two tests are now identical due to ansible_key parameter now
being mandatory.
3 files changed with 26 insertions and 66 deletions:
0 comments (0 inline, 0 general)
roles/bootstrap/molecule/default/tests/test_default.py
Show inline comments
 
@@ -49,3 +49,29 @@ def test_sudo_configuration(host):
 
        assert sudo_config.group == 'root'
 
        assert sudo_config.mode == 0o640
 
        assert sudo_config.content_string == 'ansible ALL=(ALL:ALL) NOPASSWD:ALL\n'
 

	
 

	
 
def test_authorized_keys(host):
 
    """
 
    Tests if Ansible user authorized_keys has been set-up correctly.
 
    """
 

	
 
    with host.sudo():
 

	
 
        ssh_key = open('tests/data/ansible_key.pub', 'r').read().strip()
 
        authorized_keys = host.file('/home/ansible/.ssh/authorized_keys')
 

	
 
        assert authorized_keys.is_file
 
        assert ssh_key in authorized_keys.content_string
 

	
 

	
 
def test_root_authorized_keys(host):
 
    """
 
    Tests if Ansible key been removed from root's authorized keys.
 
    """
 

	
 
    with host.sudo():
 

	
 
        ssh_key = open('tests/data/ansible_key.pub', 'r').read().strip()
 

	
 
        assert ssh_key not in host.file('/root/.ssh/authorized_keys').content_string
roles/bootstrap/molecule/default/tests/test_parameters_mandatory.py
Show inline comments
 
deleted file
roles/bootstrap/molecule/default/tests/test_parameters_optional.py
Show inline comments
 
deleted file
0 comments (0 inline, 0 general)