Changeset - d752715bb533
[Not reviewed]
0 41 0
Branko Majic (branko) - 4 years ago 2020-05-07 22:38:43
branko@majic.rs
MAR-149: Switch to using File.content_string instead of File.content in tests for all roles:

- The .content variant returns contents as bytes, while the
content_string returns a string (which is what is wanted in
practically all cases).
41 files changed with 194 insertions and 194 deletions:
0 comments (0 inline, 0 general)
roles/backup/molecule/default/tests/test_parameters_mandatory.py
Show inline comments
 
@@ -16,7 +16,7 @@ def test_backup_patterns_content(host):
 

	
 
        backup_pattern = host.file('/etc/duply/main/patterns/test')
 

	
 
        assert backup_pattern.content == ''
 
        assert backup_pattern.content_string == ''
 

	
 

	
 
def test_include_content(host):
 
@@ -29,4 +29,4 @@ def test_include_content(host):
 

	
 
        include = host.file('/etc/duply/main/include')
 

	
 
        assert include.content == ''
 
        assert include.content_string == ''
roles/backup/molecule/default/tests/test_parameters_optional.py
Show inline comments
 
@@ -16,7 +16,7 @@ def test_backup_patterns_content(host):
 

	
 
        backup_pattern = host.file('/etc/duply/main/patterns/test')
 

	
 
        assert backup_pattern.content == "/etc/hosts\n/etc/ethers\n/var/log\n"
 
        assert backup_pattern.content_string == "/etc/hosts\n/etc/ethers\n/var/log\n"
 

	
 

	
 
def test_include_content(host):
 
@@ -29,4 +29,4 @@ def test_include_content(host):
 

	
 
        include = host.file('/etc/duply/main/include')
 

	
 
        assert include.content == "/etc/hosts\n/etc/ethers\n/var/log\n"
 
        assert include.content_string == "/etc/hosts\n/etc/ethers\n/var/log\n"
roles/backup_client/molecule/default/tests/test_default.py
Show inline comments
 
@@ -129,7 +129,7 @@ def test_exclude_file(host):
 
        assert exclude.user == 'root'
 
        assert exclude.group == 'root'
 
        assert exclude.mode == 0o600
 
        assert exclude.content == "- **"
 
        assert exclude.content_string == "- **"
 

	
 

	
 
def test_pre_backup_script_directory(host):
 
@@ -171,7 +171,7 @@ def test_cron_entry(host):
 
    assert cron.user == 'root'
 
    assert cron.group == 'root'
 
    assert cron.mode == 0o644
 
    assert cron.content == "#Ansible: backup\n0 2 * * * root /usr/bin/duply main backup\n"
 
    assert cron.content_string == "#Ansible: backup\n0 2 * * * root /usr/bin/duply main backup\n"
 

	
 

	
 
def test_duply_include_file(host):
roles/backup_client/molecule/default/tests/test_parameters_mandatory.py
Show inline comments
 
@@ -18,7 +18,7 @@ def test_gnupg_private_keys_file_content(host):
 

	
 
        # The rstrip() is added because Ansible strips last newline
 
        # when using the file lookup plugin.
 
        assert gnupg_private_keys.content == open('tests/data/gnupg/parameters-mandatory.asc', 'r').read().rstrip()
 
        assert gnupg_private_keys.content_string == open('tests/data/gnupg/parameters-mandatory.asc', 'r').read().rstrip()
 

	
 

	
 
def test_gnupg_public_keys_file_content(host):
 
@@ -30,7 +30,7 @@ def test_gnupg_public_keys_file_content(host):
 
    with host.sudo():
 
        gnupg_public_keys = host.file('/etc/duply/main/public_keys.asc')
 

	
 
        assert gnupg_public_keys.content == ""
 
        assert gnupg_public_keys.content_string == ""
 

	
 

	
 
def test_backup_ssh_key_file_content(host):
 
@@ -42,7 +42,7 @@ def test_backup_ssh_key_file_content(host):
 

	
 
        ssh_key = host.file('/etc/duply/main/ssh/identity')
 

	
 
        assert ssh_key.content == open('tests/data/ssh/parameters-mandatory', 'r').read()
 
        assert ssh_key.content_string == open('tests/data/ssh/parameters-mandatory', 'r').read()
 

	
 

	
 
def test_known_hosts_content(host):
 
@@ -54,7 +54,7 @@ def test_known_hosts_content(host):
 

	
 
        known_hosts = host.file('/etc/duply/main/ssh/known_hosts')
 

	
 
        assert known_hosts.content == open('tests/data/ssh/parameters-mandatory-known_hosts', 'r').read()
 
        assert known_hosts.content_string == open('tests/data/ssh/parameters-mandatory-known_hosts', 'r').read()
 

	
 

	
 
def test_duply_configuration_content(host):
 
@@ -66,11 +66,11 @@ def test_duply_configuration_content(host):
 

	
 
        duply_configuration = host.file('/etc/duply/main/conf')
 

	
 
        assert "GPG_KEYS_ENC='59C26F031A129C54'" in duply_configuration.content
 
        assert "GPG_KEY_SIGN='59C26F031A129C54'" in duply_configuration.content
 
        assert "TARGET='pexpect+sftp://bak-parameters-mandatory-s64@10.31.127.10:2222//duplicity'" in duply_configuration.content
 
        assert "GPG_KEYS_ENC='59C26F031A129C54'" in duply_configuration.content_string
 
        assert "GPG_KEY_SIGN='59C26F031A129C54'" in duply_configuration.content_string
 
        assert "TARGET='pexpect+sftp://bak-parameters-mandatory-s64@10.31.127.10:2222//duplicity'" in duply_configuration.content_string
 
        assert "DUPL_PARAMS=\"$DUPL_PARAMS --ssh-options='-oLogLevel=ERROR -oUserKnownHostsFile=/dev/null " \
 
            "-oGlobalKnownHostsFile=/etc/duply/main/ssh/known_hosts -oIdentityFile=/etc/duply/main/ssh/identity'\"" in duply_configuration.content
 
            "-oGlobalKnownHostsFile=/etc/duply/main/ssh/known_hosts -oIdentityFile=/etc/duply/main/ssh/identity'\"" in duply_configuration.content_string
 

	
 

	
 
def test_duply_gnupg_keyring_private_keys(host):
roles/backup_client/molecule/default/tests/test_parameters_optional.py
Show inline comments
 
@@ -16,7 +16,7 @@ def test_gnupg_private_keys_file_content(host):
 
    with host.sudo():
 
        gnupg_private_keys = host.file('/etc/duply/main/private_keys.asc')
 

	
 
        assert gnupg_private_keys.content == open('tests/data/gnupg/parameters-optional.asc', 'r').read().strip()
 
        assert gnupg_private_keys.content_string == open('tests/data/gnupg/parameters-optional.asc', 'r').read().strip()
 

	
 

	
 
def test_gnupg_public_keys_file_content(host):
 
@@ -27,9 +27,9 @@ def test_gnupg_public_keys_file_content(host):
 
    with host.sudo():
 
        gnupg_public_keys = host.file('/etc/duply/main/public_keys.asc')
 

	
 
        assert open('tests/data/gnupg/additional_encryption_key_1.asc', 'r').read().strip() in gnupg_public_keys.content
 
        assert open('tests/data/gnupg/additional_encryption_key_2.asc', 'r').read().strip() in gnupg_public_keys.content
 
        assert open('tests/data/gnupg/additional_encryption_key_3.asc', 'r').read().strip() in gnupg_public_keys.content
 
        assert open('tests/data/gnupg/additional_encryption_key_1.asc', 'r').read().strip() in gnupg_public_keys.content_string
 
        assert open('tests/data/gnupg/additional_encryption_key_2.asc', 'r').read().strip() in gnupg_public_keys.content_string
 
        assert open('tests/data/gnupg/additional_encryption_key_3.asc', 'r').read().strip() in gnupg_public_keys.content_string
 

	
 

	
 
def test_backup_ssh_key_file_content(host):
 
@@ -41,7 +41,7 @@ def test_backup_ssh_key_file_content(host):
 

	
 
        ssh_key = host.file('/etc/duply/main/ssh/identity')
 

	
 
        assert ssh_key.content == open('tests/data/ssh/parameters-optional', 'r').read().strip()
 
        assert ssh_key.content_string == open('tests/data/ssh/parameters-optional', 'r').read().strip()
 

	
 

	
 
def test_known_hosts_content(host):
 
@@ -53,7 +53,7 @@ def test_known_hosts_content(host):
 

	
 
        known_hosts = host.file('/etc/duply/main/ssh/known_hosts')
 

	
 
        assert known_hosts.content == open('tests/data/ssh/parameters-optional-known_hosts', 'r').read()
 
        assert known_hosts.content_string == open('tests/data/ssh/parameters-optional-known_hosts', 'r').read()
 

	
 

	
 
def test_duply_configuration_content(host):
 
@@ -65,11 +65,11 @@ def test_duply_configuration_content(host):
 

	
 
        duply_configuration = host.file('/etc/duply/main/conf')
 

	
 
        assert "GPG_KEYS_ENC='C4B2AE9F7A4F400A,3093C91BC3A9444B,86816FD928063B3F,8A14CD6C71223B72'" in duply_configuration.content
 
        assert "GPG_KEY_SIGN='C4B2AE9F7A4F400A'" in duply_configuration.content
 
        assert "TARGET='pexpect+sftp://backupuser@10.31.127.10:3333//duplicity/parameters-optional-s64'" in duply_configuration.content
 
        assert "GPG_KEYS_ENC='C4B2AE9F7A4F400A,3093C91BC3A9444B,86816FD928063B3F,8A14CD6C71223B72'" in duply_configuration.content_string
 
        assert "GPG_KEY_SIGN='C4B2AE9F7A4F400A'" in duply_configuration.content_string
 
        assert "TARGET='pexpect+sftp://backupuser@10.31.127.10:3333//duplicity/parameters-optional-s64'" in duply_configuration.content_string
 
        assert "DUPL_PARAMS=\"$DUPL_PARAMS --ssh-options='-oLogLevel=ERROR -oUserKnownHostsFile=/dev/null " \
 
            "-oGlobalKnownHostsFile=/etc/duply/main/ssh/known_hosts -oIdentityFile=/etc/duply/main/ssh/identity'\"" in duply_configuration.content
 
            "-oGlobalKnownHostsFile=/etc/duply/main/ssh/known_hosts -oIdentityFile=/etc/duply/main/ssh/identity'\"" in duply_configuration.content_string
 

	
 

	
 
def test_duply_gnupg_keyring_private_keys(host):
roles/backup_server/molecule/default/tests/test_default.py
Show inline comments
 
@@ -39,7 +39,7 @@ def test_regular_ssh_server_configuration(host):
 

	
 
    with host.sudo():
 

	
 
        assert "DenyGroups backup" in host.file('/etc/ssh/sshd_config').content
 
        assert "DenyGroups backup" in host.file('/etc/ssh/sshd_config').content_string
 

	
 

	
 
def test_backup_ssh_server_configuration_directory(host):
 
@@ -70,7 +70,7 @@ def test_backup_ssh_server_service_configuration(host):
 
    assert config_file.user == 'root'
 
    assert config_file.group == 'root'
 
    assert config_file.mode == 0o644
 
    assert 'SSHD_OPTS="-f /etc/ssh-backup/sshd_config"' in config_file.content
 
    assert 'SSHD_OPTS="-f /etc/ssh-backup/sshd_config"' in config_file.content_string
 

	
 

	
 
def test_backup_ssh_server_configuration(host):
 
@@ -86,16 +86,16 @@ def test_backup_ssh_server_configuration(host):
 
        assert config_file.user == 'root'
 
        assert config_file.group == 'root'
 
        assert config_file.mode == 0o600
 
        assert "AllowGroups backup" in config_file.content
 
        assert "ChrootDirectory %h" in config_file.content
 
        assert "ForceCommand internal-sftp" in config_file.content
 
        assert "Subsystem sftp internal-sftp" in config_file.content
 
        assert "PasswordAuthentication no" in config_file.content
 
        assert "PubkeyAuthentication yes" in config_file.content
 
        assert "PermitRootLogin no" in config_file.content
 
        assert "HostKey /etc/ssh-backup/ssh_host_rsa_key" in config_file.content
 
        assert "HostKey /etc/ssh-backup/ssh_host_ecdsa_key" in config_file.content
 
        assert "HostKey /etc/ssh-backup/ssh_host_ed25519_key" in config_file.content
 
        assert "AllowGroups backup" in config_file.content_string
 
        assert "ChrootDirectory %h" in config_file.content_string
 
        assert "ForceCommand internal-sftp" in config_file.content_string
 
        assert "Subsystem sftp internal-sftp" in config_file.content_string
 
        assert "PasswordAuthentication no" in config_file.content_string
 
        assert "PubkeyAuthentication yes" in config_file.content_string
 
        assert "PermitRootLogin no" in config_file.content_string
 
        assert "HostKey /etc/ssh-backup/ssh_host_rsa_key" in config_file.content_string
 
        assert "HostKey /etc/ssh-backup/ssh_host_ecdsa_key" in config_file.content_string
 
        assert "HostKey /etc/ssh-backup/ssh_host_ed25519_key" in config_file.content_string
 

	
 

	
 
def test_backup_ssh_server_keys(host):
 
@@ -110,28 +110,28 @@ def test_backup_ssh_server_keys(host):
 
        assert dsa.user == 'root'
 
        assert dsa.group == 'root'
 
        assert dsa.mode == 0o600
 
        assert dsa.content == open('tests/data/ssh/server_dsa', 'r').read()
 
        assert dsa.content_string == open('tests/data/ssh/server_dsa', 'r').read()
 

	
 
        rsa = host.file('/etc/ssh-backup/ssh_host_rsa_key')
 
        assert rsa.is_file
 
        assert rsa.user == 'root'
 
        assert rsa.group == 'root'
 
        assert rsa.mode == 0o600
 
        assert rsa.content == open('tests/data/ssh/server_rsa', 'r').read()
 
        assert rsa.content_string == open('tests/data/ssh/server_rsa', 'r').read()
 

	
 
        ed25519 = host.file('/etc/ssh-backup/ssh_host_ed25519_key')
 
        assert ed25519.is_file
 
        assert ed25519.user == 'root'
 
        assert ed25519.group == 'root'
 
        assert ed25519.mode == 0o600
 
        assert ed25519.content == open('tests/data/ssh/server_ed25519', 'r').read()
 
        assert ed25519.content_string == open('tests/data/ssh/server_ed25519', 'r').read()
 

	
 
        ecdsa = host.file('/etc/ssh-backup/ssh_host_ecdsa_key')
 
        assert ecdsa.is_file
 
        assert ecdsa.user == 'root'
 
        assert ecdsa.group == 'root'
 
        assert ecdsa.mode == 0o600
 
        assert ecdsa.content == open('tests/data/ssh/server_ecdsa', 'r').read()
 
        assert ecdsa.content_string == open('tests/data/ssh/server_ecdsa', 'r').read()
 

	
 

	
 
def test_backup_ssh_server_systemd_service(host):
 
@@ -146,7 +146,7 @@ def test_backup_ssh_server_systemd_service(host):
 
    assert service_file.user == 'root'
 
    assert service_file.group == 'root'
 
    assert service_file.mode == 0o644
 
    assert "EnvironmentFile=-/etc/default/ssh-backup" in service_file.content
 
    assert "EnvironmentFile=-/etc/default/ssh-backup" in service_file.content_string
 

	
 

	
 
def test_backup_ssh_server_service(host):
roles/backup_server/molecule/default/tests/test_parameters_mandatory.py
Show inline comments
 
@@ -20,4 +20,4 @@ def test_firewall_configuration(host):
 
        assert firewall_config.user == 'root'
 
        assert firewall_config.group == 'root'
 
        assert firewall_config.mode == 0o640
 
        assert firewall_config.content == "\n"
 
        assert firewall_config.content_string == "\n"
roles/backup_server/molecule/default/tests/test_parameters_optional.py
Show inline comments
 
@@ -111,7 +111,7 @@ def test_backup_client_authorized_keys(host):
 
        assert client1_user_authorized_keys.user == 'root'
 
        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()
 
        assert client1_user_authorized_keys.content_string == open('tests/data/ssh/client1.pub', 'r').read()
 

	
 
        client2_user = host.user('bak-client2-backup')
 

	
 
@@ -120,7 +120,7 @@ def test_backup_client_authorized_keys(host):
 
        assert client2_user_authorized_keys.user == 'root'
 
        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()
 
        assert client2_user_authorized_keys.content_string == open('tests/data/ssh/client2.pub', 'r').read()
 

	
 

	
 
def test_firewall_configuration(host):
 
@@ -136,7 +136,7 @@ def test_firewall_configuration(host):
 
        assert firewall_config.user == 'root'
 
        assert firewall_config.group == 'root'
 
        assert firewall_config.mode == 0o640
 
        assert 'saddr ( 10.31.127.1 10.31.127.3) @subchain "backup_in" {' in firewall_config.content
 
        assert 'saddr ( 10.31.127.1 10.31.127.3) @subchain "backup_in" {' in firewall_config.content_string
 

	
 

	
 
@pytest.mark.usefixtures("prepare_ssh_client_private_key_permissions")
roles/bootstrap/molecule/default/tests/test_default.py
Show inline comments
 
@@ -48,4 +48,4 @@ def test_sudo_configuration(host):
 
        assert sudo_config.user == 'root'
 
        assert sudo_config.group == 'root'
 
        assert sudo_config.mode == 0o640
 
        assert sudo_config.content == 'ansible ALL=(ALL:ALL) NOPASSWD:ALL\n'
 
        assert sudo_config.content_string == 'ansible ALL=(ALL:ALL) NOPASSWD:ALL\n'
roles/bootstrap/molecule/default/tests/test_parameters_mandatory.py
Show inline comments
 
@@ -18,7 +18,7 @@ def test_authorized_keys(host):
 
        authorized_keys = host.file('/home/ansible/.ssh/authorized_keys')
 

	
 
        assert authorized_keys.is_file
 
        assert ssh_key in authorized_keys.content
 
        assert ssh_key in authorized_keys.content_string
 

	
 

	
 
def test_root_authorized_keys(host):
 
@@ -30,4 +30,4 @@ def test_root_authorized_keys(host):
 

	
 
        ssh_key = open(os.path.expanduser('~/.ssh/id_rsa.pub'), 'read').read().strip()
 

	
 
        assert ssh_key not in host.file('/root/.ssh/authorized_keys').content
 
        assert ssh_key not in host.file('/root/.ssh/authorized_keys').content_string
roles/bootstrap/molecule/default/tests/test_parameters_optional.py
Show inline comments
 
@@ -18,7 +18,7 @@ def test_authorized_keys(host):
 
        authorized_keys = host.file('/home/ansible/.ssh/authorized_keys')
 

	
 
        assert authorized_keys.is_file
 
        assert ssh_key in authorized_keys.content
 
        assert ssh_key in authorized_keys.content_string
 

	
 

	
 
def test_root_authorised_keys(host):
 
@@ -30,4 +30,4 @@ def test_root_authorised_keys(host):
 

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

	
 
        assert ssh_key not in host.file('/root/.ssh/authorized_keys').content
 
        assert ssh_key not in host.file('/root/.ssh/authorized_keys').content_string
roles/common/molecule/default/tests/test_default.py
Show inline comments
 
@@ -129,7 +129,7 @@ def test_root_remote_login_disabled(host):
 
    Tests if SSH server has been configured to prevent remote root logins.
 
    """
 

	
 
    assert 'PermitRootLogin no' in host.file('/etc/ssh/sshd_config').content
 
    assert 'PermitRootLogin no' in host.file('/etc/ssh/sshd_config').content_string
 

	
 

	
 
def test_remote_login_via_password_disabled(host):
 
@@ -138,7 +138,7 @@ def test_remote_login_via_password_disabled(host):
 
    authentication.
 
    """
 

	
 
    assert 'PasswordAuthentication no' in host.file('/etc/ssh/sshd_config').content
 
    assert 'PasswordAuthentication no' in host.file('/etc/ssh/sshd_config').content_string
 

	
 

	
 
def test_ferm_service_configuration(host):
 
@@ -149,9 +149,9 @@ def test_ferm_service_configuration(host):
 
    assert ferm_service_config.user == 'root'
 
    assert ferm_service_config.group == 'root'
 
    assert ferm_service_config.mode == 0o644
 
    assert 'FAST=yes' in ferm_service_config.content
 
    assert 'CACHE=no' in ferm_service_config.content
 
    assert 'ENABLED="yes"' in ferm_service_config.content
 
    assert 'FAST=yes' in ferm_service_config.content_string
 
    assert 'CACHE=no' in ferm_service_config.content_string
 
    assert 'ENABLED="yes"' in ferm_service_config.content_string
 

	
 

	
 
def test_ferm_configuration_directory(host):
 
@@ -180,7 +180,7 @@ def test_ferm_configuration(host):
 
        assert ferm_configuration.user == 'root'
 
        assert ferm_configuration.group == 'root'
 
        assert ferm_configuration.mode == 0o640
 
        assert "@include '/etc/ferm/conf.d/';" in ferm_configuration.content
 
        assert "@include '/etc/ferm/conf.d/';" in ferm_configuration.content_string
 

	
 
        ferm_base = host.file('/etc/ferm/conf.d/00-base.conf')
 
        assert ferm_base.is_file
 
@@ -231,7 +231,7 @@ def test_check_certificate_crontab(host):
 
    assert check_certificate_crontab.user == 'root'
 
    assert check_certificate_crontab.group == 'root'
 
    assert check_certificate_crontab.mode == 0o644
 
    assert "0 0 * * * nobody /usr/local/bin/check_certificate.sh -q expiration" in check_certificate_crontab.content
 
    assert "0 0 * * * nobody /usr/local/bin/check_certificate.sh -q expiration" in check_certificate_crontab.content_string
 

	
 

	
 
@pytest.mark.parametrize('virtualenv_activate_path', [
 
@@ -369,8 +369,8 @@ def test_pipreqcheck_crontab(host, crontab_path, virtualenv_path):
 
    assert crontab.user == 'root'
 
    assert crontab.group == 'root'
 
    assert crontab.mode == 0o644
 
    assert "MAILTO=root" in crontab.content
 
    assert virtualenv_path in crontab.content.split(" ")
 
    assert "MAILTO=root" in crontab.content_string
 
    assert virtualenv_path in crontab.content_string.split(" ")
 

	
 

	
 
@pytest.mark.parametrize('python_path, expected_major_version', [
roles/common/molecule/default/tests/test_parameters_mandatory.py
Show inline comments
 
@@ -26,8 +26,8 @@ def test_bash_prompt_content(host):
 

	
 
    bash_prompt = host.file('/etc/profile.d/bash_prompt.sh')
 

	
 
    assert "export PS1='\\[\\e]0;\\u@\\h: \\w\\a\\]${debian_chroot:+($debian_chroot)}\\[\\033[0m\\]\\u@\\h:\\w\\$ \\[\\033[0m\\]'" in bash_prompt.content
 
    assert "export PS1='\\[\\e]0;\\u@\\h: \\w\\a\\]${debian_chroot:+($debian_chroot)}\\u@\\h:\\w\\$ '" in bash_prompt.content
 
    assert "export PS1='\\[\\e]0;\\u@\\h: \\w\\a\\]${debian_chroot:+($debian_chroot)}\\[\\033[0m\\]\\u@\\h:\\w\\$ \\[\\033[0m\\]'" in bash_prompt.content_string
 
    assert "export PS1='\\[\\e]0;\\u@\\h: \\w\\a\\]${debian_chroot:+($debian_chroot)}\\u@\\h:\\w\\$ '" in bash_prompt.content_string
 

	
 

	
 
def test_ssh_login_mechanisms(host):
 
@@ -70,7 +70,7 @@ def test_ferm_base_rules(host):
 
    with host.sudo():
 
        ferm_base = host.file('/etc/ferm/conf.d/00-base.conf')
 

	
 
        assert "mod hashlimit hashlimit 3/second hashlimit-burst 9" in ferm_base.content
 
        assert "mod hashlimit hashlimit 3/second hashlimit-burst 9" in ferm_base.content_string
 

	
 
        iptables = host.command('iptables-save')
 

	
roles/common/molecule/default/tests/test_parameters_optional.py
Show inline comments
 
@@ -32,8 +32,8 @@ def test_bash_prompt_content(host):
 

	
 
    config = host.file('/etc/profile.d/bash_prompt.sh')
 

	
 
    assert "export PS1='\\[\\e]0;\\u@\\h: \\w\\a\\]${debian_chroot:+($debian_chroot)}\\[\\033[0;36m\\]\\u@\\h[test]:\\w\\$ \\[\\033[0m\\]'" in config.content
 
    assert "export PS1='\\[\\e]0;\\u@\\h: \\w\\a\\]${debian_chroot:+($debian_chroot)}\\u@\\h[test]:\\w\\$ '" in config.content
 
    assert "export PS1='\\[\\e]0;\\u@\\h: \\w\\a\\]${debian_chroot:+($debian_chroot)}\\[\\033[0;36m\\]\\u@\\h[test]:\\w\\$ \\[\\033[0m\\]'" in config.content_string
 
    assert "export PS1='\\[\\e]0;\\u@\\h: \\w\\a\\]${debian_chroot:+($debian_chroot)}\\u@\\h[test]:\\w\\$ '" in config.content_string
 

	
 

	
 
def test_common_installed_packages_common(host):
 
@@ -78,7 +78,7 @@ def test_emacs_electric_indent_mode(host):
 
    assert emacs_config.user == 'root'
 
    assert emacs_config.group == 'root'
 
    assert emacs_config.mode == 0o644
 
    assert "(electric-indent-mode -1)" in emacs_config.content
 
    assert "(electric-indent-mode -1)" in emacs_config.content_string
 

	
 

	
 
def test_os_groups(host):
 
@@ -129,8 +129,8 @@ def test_os_users(host):
 
        assert user2.password == '$6$wdXOQiMe09ugh0$VRIph2XA2QQyEYlAlH7zT4TPACDUalf/4FKpqG9JRHfKxANTcTug2ANCt450htcs0LikJfHLWofLP54jraFU61'
 

	
 
        user2_authorized_keys = host.file(os.path.join(user2.home, '.ssh', 'authorized_keys'))
 
        assert open('tests/data/ssh/clientkey1.pub', 'r').read().strip() in user2_authorized_keys.content
 
        assert open('tests/data/ssh/clientkey2.pub', 'r').read().strip() in user2_authorized_keys.content
 
        assert open('tests/data/ssh/clientkey1.pub', 'r').read().strip() in user2_authorized_keys.content_string
 
        assert open('tests/data/ssh/clientkey2.pub', 'r').read().strip() in user2_authorized_keys.content_string
 

	
 
        user3 = host.user('user3')
 
        assert user3.uid == 2002
 
@@ -140,7 +140,7 @@ def test_os_users(host):
 
        assert user3.password == '$6$nmx.21uLqT$9LrUqNUgUwIM.l0KFKgr2.kDEwe2lo7IbBIhnG70AGW7GTFdWBUFnGAxH15YxikTXhDJD/uxd.NNgojEOjRvx1'
 

	
 
        user3_authorized_keys = host.file(os.path.join(user3.home, '.ssh', 'authorized_keys'))
 
        assert open('tests/data/ssh/clientkey3.pub', 'r').read().strip() in user3_authorized_keys.content
 
        assert open('tests/data/ssh/clientkey3.pub', 'r').read().strip() in user3_authorized_keys.content_string
 

	
 

	
 
def test_authorized_keys_login(host):
 
@@ -217,7 +217,7 @@ def test_ferm_base_rules(host):
 
    with host.sudo():
 
        ferm_base = host.file('/etc/ferm/conf.d/00-base.conf')
 

	
 
        assert "mod hashlimit hashlimit 5/second hashlimit-burst 5" in ferm_base.content
 
        assert "mod hashlimit hashlimit 5/second hashlimit-burst 5" in ferm_base.content_string
 

	
 
        iptables = host.command('iptables-save')
 

	
 
@@ -262,15 +262,15 @@ def test_backup_configuration(host):
 

	
 
        common = host.file('/etc/duply/main/patterns/common')
 
        assert common.is_file
 
        assert "/var/log" in common.content.split("\n")
 
        assert "/etc/shadow" in common.content.split("\n")
 
        assert "/var/mail" in common.content.split("\n")
 
        assert "/var/spool/cron" in common.content.split("\n")
 
        assert "/var/log" in common.content_string.split("\n")
 
        assert "/etc/shadow" in common.content_string.split("\n")
 
        assert "/var/mail" in common.content_string.split("\n")
 
        assert "/var/spool/cron" in common.content_string.split("\n")
 

	
 
        common_extra = host.file('/etc/duply/main/patterns/common_extra')
 
        assert common_extra.is_file
 
        assert "/home/user1" in common_extra.content.split("\n")
 
        assert "/home/user2" in common_extra.content.split("\n")
 
        assert "/home/user1" in common_extra.content_string.split("\n")
 
        assert "/home/user2" in common_extra.content_string.split("\n")
 

	
 

	
 
def test_ntp_software_installed(host):
 
@@ -290,7 +290,7 @@ def test_ntp_server_configuration(host):
 
    with host.sudo():
 

	
 
        # Read the configuration file.
 
        configuration = host.file("/etc/ntp.conf").content.split("\n")
 
        configuration = host.file("/etc/ntp.conf").content_string.split("\n")
 

	
 
        # Extract only the relevant sections of files (exculde empty
 
        # lines and comments).
roles/database/molecule/default/tests/test_backup.py
Show inline comments
 
@@ -37,7 +37,7 @@ def test_backup_script_file(host):
 
        assert script.user == 'root'
 
        assert script.group == 'root'
 
        assert script.mode == 0o700
 
        assert "/usr/bin/mysqldump \"testdb\" > \"/srv/backup/mariadb/testdb.sql\"" in script.content
 
        assert "/usr/bin/mysqldump \"testdb\" > \"/srv/backup/mariadb/testdb.sql\"" in script.content_string
 

	
 

	
 
def test_backup_run(host):
 
@@ -57,11 +57,11 @@ def test_backup_run(host):
 

	
 
        database_dump = host.file('/srv/backup/mariadb/testdb.sql')
 
        assert database_dump.is_file
 
        assert 'Database: testdb' in database_dump.content
 
        assert 'Database: testdb' in database_dump.content_string
 

	
 
        restore_run = host.run('duply main restore /root/restore')
 
        assert restore_run.rc == 0
 

	
 
        restored_database_dump = host.file('/root/restore/srv/backup/mariadb/testdb.sql')
 
        assert restored_database_dump.is_file
 
        assert restored_database_dump.content == database_dump.content
 
        assert restored_database_dump.content_string == database_dump.content_string
roles/database_server/molecule/default/tests/test_default.py
Show inline comments
 
@@ -55,8 +55,8 @@ def test_root_my_cnf(host):
 
        assert my_cnf.user == 'root'
 
        assert my_cnf.group == 'root'
 
        assert my_cnf.mode == 0o400
 
        assert "user=root" in my_cnf.content
 
        assert "password=root_password" in my_cnf.content
 
        assert "user=root" in my_cnf.content_string
 
        assert "password=root_password" in my_cnf.content_string
 

	
 

	
 
def test_root_my_cnf_login(host):
roles/ldap_client/molecule/default/tests/test_mandatory.py
Show inline comments
 
@@ -14,4 +14,4 @@ def test_ldap_configuration_file_content(host):
 

	
 
    config = host.file('/etc/ldap/ldap.conf')
 

	
 
    assert config.content == ""
 
    assert config.content_string == ""
roles/ldap_client/molecule/default/tests/test_optional.py
Show inline comments
 
@@ -24,4 +24,4 @@ BASE dc=local
 

	
 
    config = host.file('/etc/ldap/ldap.conf')
 

	
 
    assert config.content == expected_content
 
    assert config.content_string == expected_content
roles/ldap_server/molecule/default/tests/test_backup.py
Show inline comments
 
@@ -54,11 +54,11 @@ def test_backup(host):
 

	
 
        database_dump = host.file('/srv/backup/slapd.bak')
 
        assert database_dump.is_file
 
        assert 'dn: dc=local' in database_dump.content
 
        assert 'dn: dc=local' in database_dump.content_string
 

	
 
        restore_run = host.run('duply main restore /root/restore')
 
        assert restore_run.rc == 0
 

	
 
        restored_database_dump = host.file('/root/restore/srv/backup/slapd.bak')
 
        assert restored_database_dump.is_file
 
        assert restored_database_dump.content == database_dump.content
 
        assert restored_database_dump.content_string == database_dump.content_string
roles/ldap_server/molecule/default/tests/test_default.py
Show inline comments
 
@@ -61,7 +61,7 @@ def test_syslog_configuration(host):
 
    with host.sudo():
 
        log = host.file('/var/log/slapd.log')
 
        assert log.is_file
 
        assert 'slapd' in log.content
 
        assert 'slapd' in log.content_string
 

	
 

	
 
def test_log_rotation_configuration(host):
roles/ldap_server/molecule/default/tests/test_mandatory.py
Show inline comments
 
@@ -49,7 +49,7 @@ def test_ldap_tls_private_key_file(host):
 
        assert key.user == 'root'
 
        assert key.group == 'openldap'
 
        assert key.mode == 0o640
 
        assert key.content == open('tests/data/x509/%s_ldap.key' % inventory_hostname).read()
 
        assert key.content_string == open('tests/data/x509/%s_ldap.key' % inventory_hostname).read()
 

	
 

	
 
def test_ldap_tls_certificate_file(host):
 
@@ -67,7 +67,7 @@ def test_ldap_tls_certificate_file(host):
 
        assert cert.user == 'root'
 
        assert cert.group == 'root'
 
        assert cert.mode == 0o644
 
        assert cert.content == open('tests/data/x509/%s_ldap.pem' % inventory_hostname).read()
 
        assert cert.content_string == open('tests/data/x509/%s_ldap.pem' % inventory_hostname).read()
 

	
 

	
 
def test_certificate_validity_check_configuration(host):
 
@@ -84,7 +84,7 @@ def test_certificate_validity_check_configuration(host):
 
    assert config.user == 'root'
 
    assert config.group == 'root'
 
    assert config.mode == 0o644
 
    assert config.content == "/etc/ssl/certs/%s_ldap.pem" % inventory_hostname
 
    assert config.content_string == "/etc/ssl/certs/%s_ldap.pem" % inventory_hostname
 

	
 

	
 
def test_tls_configuration(host):
roles/ldap_server/molecule/default/tests/test_optional.py
Show inline comments
 
@@ -49,7 +49,7 @@ def test_ldap_tls_private_key_file(host):
 
        assert key.user == 'root'
 
        assert key.group == 'openldap'
 
        assert key.mode == 0o640
 
        assert key.content == open('tests/data/x509/parameters-optional.key.pem').read()
 
        assert key.content_string == open('tests/data/x509/parameters-optional.key.pem').read()
 

	
 

	
 
def test_ldap_tls_certificate_file(host):
 
@@ -67,7 +67,7 @@ def test_ldap_tls_certificate_file(host):
 
        assert cert.user == 'root'
 
        assert cert.group == 'root'
 
        assert cert.mode == 0o644
 
        assert cert.content == open('tests/data/x509/parameters-optional.cert.pem').read()
 
        assert cert.content_string == open('tests/data/x509/parameters-optional.cert.pem').read()
 

	
 

	
 
def test_certificate_validity_check_configuration(host):
 
@@ -84,7 +84,7 @@ def test_certificate_validity_check_configuration(host):
 
    assert config.user == 'root'
 
    assert config.group == 'root'
 
    assert config.mode == 0o644
 
    assert config.content == "/etc/ssl/certs/%s_ldap.pem" % inventory_hostname
 
    assert config.content_string == "/etc/ssl/certs/%s_ldap.pem" % inventory_hostname
 

	
 

	
 
def test_tls_configuration(host):
roles/mail_forwarder/molecule/default/tests/test_mandatory.py
Show inline comments
 
@@ -16,7 +16,7 @@ def test_smtp_relay_truststore_file(host):
 

	
 
    truststore = host.file('/etc/ssl/certs/smtp_relay_truststore.pem')
 

	
 
    assert truststore.content == open("tests/data/x509/truststore.pem", "r").read().rstrip()
 
    assert truststore.content_string == open("tests/data/x509/truststore.pem", "r").read().rstrip()
 

	
 

	
 
def test_smtp_mailname(host):
 
@@ -28,7 +28,7 @@ def test_smtp_mailname(host):
 

	
 
    mailname = host.file('/etc/mailname')
 

	
 
    assert mailname.content == hostname
 
    assert mailname.content_string == hostname
 

	
 

	
 
def test_postfix_main_cf_file_content(host):
 
@@ -38,14 +38,14 @@ def test_postfix_main_cf_file_content(host):
 

	
 
    hostname = host.run('hostname').stdout.strip()
 
    config = host.file('/etc/postfix/main.cf')
 
    config_lines = config.content.split("\n")
 
    config_lines = config.content_string.split("\n")
 

	
 
    assert "myhostname = %s" % hostname in config_lines
 
    assert "mydestination = %s, %s, localhost.localdomain, localhost" % (hostname, hostname) in config_lines
 
    assert "relayhost = " in config_lines
 
    assert "mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128" in config_lines
 
    assert "smtp_tls_security_level" not in config.content
 
    assert "smtp_tls_CAfile" not in config.content
 
    assert "smtp_tls_security_level" not in config.content_string
 
    assert "smtp_tls_CAfile" not in config.content_string
 
    assert "smtp_host_lookup = dns, native" in config_lines
 

	
 

	
 
@@ -67,4 +67,4 @@ def test_direct_mail_sending(host):
 
        # Pattern used to verify the mail was sent directly on default port.
 
        pattern = r"%s: to=<root@domain1>, relay=domain1\[[^]]*\]:25.*status=sent" % message_id
 

	
 
        assert re.search(pattern, mail_log.content) is not None
 
        assert re.search(pattern, mail_log.content_string) is not None
roles/mail_forwarder/molecule/default/tests/test_optional.py
Show inline comments
 
@@ -16,7 +16,7 @@ def test_smtp_relay_truststore_file(host):
 

	
 
    truststore = host.file('/etc/ssl/certs/smtp_relay_truststore.pem')
 

	
 
    assert truststore.content == open("tests/data/x509/ca.cert.pem", "r").read().rstrip()
 
    assert truststore.content_string == open("tests/data/x509/ca.cert.pem", "r").read().rstrip()
 

	
 

	
 
def test_smtp_mailname(host):
 
@@ -28,7 +28,7 @@ def test_smtp_mailname(host):
 

	
 
    mailname = host.file('/etc/mailname')
 

	
 
    assert mailname.content == "%s" % hostname
 
    assert mailname.content_string == "%s" % hostname
 

	
 

	
 
def test_postfix_main_cf_file_content(host):
 
@@ -38,7 +38,7 @@ def test_postfix_main_cf_file_content(host):
 

	
 
    hostname = host.run('hostname').stdout.strip()
 
    config = host.file('/etc/postfix/main.cf')
 
    config_lines = config.content.split("\n")
 
    config_lines = config.content_string.split("\n")
 

	
 
    assert "myhostname = %s" % hostname in config_lines
 
    assert "mydestination = %s, %s, localhost.localdomain, localhost" % (hostname, hostname) in config_lines
 
@@ -67,8 +67,8 @@ def test_local_aliases(host):
 
        pattern1 = "%s: to=<root@%s>, orig_to=<root@localhost>.*status=sent" % (message_id, hostname)
 
        pattern2 = "%s: to=<testuser@%s>, orig_to=<root@localhost>.*status=sent" % (message_id, hostname)
 

	
 
        assert re.search(pattern1, mail_log.content) is not None
 
        assert re.search(pattern2, mail_log.content) is not None
 
        assert re.search(pattern1, mail_log.content_string) is not None
 
        assert re.search(pattern2, mail_log.content_string) is not None
 

	
 

	
 
def test_relay_mail_sending(host):
 
@@ -89,7 +89,7 @@ def test_relay_mail_sending(host):
 
        # port.
 
        pattern = r"%s: to=<root@domain1>, relay=mail-server\[[^]]*\]:27.*status=sent" % message_id
 

	
 
        assert re.search(pattern, mail_log.content) is not None
 
        assert re.search(pattern, mail_log.content_string) is not None
 

	
 

	
 
def test_tls_enforced_towards_relay_mail_server(host):
 
@@ -125,4 +125,4 @@ def test_tls_enforced_towards_relay_mail_server(host):
 
            mail_log = host.file('/var/log/mail.log')
 
            pattern = r"%s: to=<root@domain1>, relay=domain1.*status=deferred \(Server certificate not verified\)" % message_id
 

	
 
            assert re.search(pattern, mail_log.content) is not None
 
            assert re.search(pattern, mail_log.content_string) is not None
roles/mail_forwarder/molecule/default/tests/test_smtp_relay_host_port.py
Show inline comments
 
@@ -17,7 +17,7 @@ def test_postfix_main_cf_file_content(host):
 

	
 
    hostname = host.run('hostname').stdout.strip()
 
    config = host.file('/etc/postfix/main.cf')
 
    config_lines = config.content.split("\n")
 
    config_lines = config.content_string.split("\n")
 

	
 
    assert "myhostname = %s" % hostname in config_lines
 
    assert "mydestination = %s, %s, localhost.localdomain, localhost" % (hostname, hostname) in config_lines
 
@@ -45,4 +45,4 @@ def test_relay_mail_sending(host):
 
        # Pattern used to verify the mail was sent over relay on default port.
 
        pattern = r"%s: to=<root@domain1>, relay=mail-server\[[^]]*\]:25.*status=sent" % message_id
 

	
 
        assert re.search(pattern, mail_log.content) is not None
 
        assert re.search(pattern, mail_log.content_string) is not None
roles/mail_server/molecule/default/tests/test_default.py
Show inline comments
 
@@ -113,14 +113,14 @@ def test_ldap_tls_truststore_file(host):
 
    assert tls_file.user == 'root'
 
    assert tls_file.group == 'root'
 
    assert tls_file.mode == 0o644
 
    assert tls_file.content == open("tests/data/x509/ca.cert.pem", "r").read().rstrip()
 
    assert tls_file.content_string == open("tests/data/x509/ca.cert.pem", "r").read().rstrip()
 

	
 
    tls_file = host.file('/var/spool/postfix/etc/ssl/certs/mail_ldap_tls_truststore.pem')
 
    assert tls_file.is_file
 
    assert tls_file.user == 'root'
 
    assert tls_file.group == 'root'
 
    assert tls_file.mode == 0o644
 
    assert tls_file.content == open("tests/data/x509/ca.cert.pem", "r").read().rstrip()
 
    assert tls_file.content_string == open("tests/data/x509/ca.cert.pem", "r").read().rstrip()
 

	
 

	
 
def test_mailname_file(host):
 
@@ -243,7 +243,7 @@ def test_postfix_delivery_to_dovecot(host):
 
    with host.sudo():
 
        mail_log = host.file('/var/log/mail.log')
 
        pattern = r"dovecot: lda\(john.doe@domain1\): msgid=<%s>: saved mail to INBOX" % message_id
 
        assert re.search(pattern, mail_log.content) is not None
 
        assert re.search(pattern, mail_log.content_string) is not None
 

	
 

	
 
def test_dovecot_system_authentication_is_disabled(host):
 
@@ -253,7 +253,7 @@ def test_dovecot_system_authentication_is_disabled(host):
 

	
 
    config = host.file("/etc/dovecot/conf.d/10-auth.conf")
 

	
 
    assert "!include auth-system.conf.ext" not in config.content
 
    assert "!include auth-system.conf.ext" not in config.content_string
 

	
 

	
 
def test_dovecot_overrides_configuration_file(host):
roles/mail_server/molecule/default/tests/test_mandatory.py
Show inline comments
 
@@ -21,28 +21,28 @@ def test_smtp_tls_files(host):
 
        assert tls_file.user == 'root'
 
        assert tls_file.group == 'root'
 
        assert tls_file.mode == 0o640
 
        assert tls_file.content == open("tests/data/x509/%s_smtp.key" % hostname, "r").read().rstrip()
 
        assert tls_file.content_string == open("tests/data/x509/%s_smtp.key" % hostname, "r").read().rstrip()
 

	
 
        tls_file = host.file('/etc/ssl/certs/%s_smtp.pem' % hostname)
 
        assert tls_file.is_file
 
        assert tls_file.user == 'root'
 
        assert tls_file.group == 'root'
 
        assert tls_file.mode == 0o644
 
        assert tls_file.content == open("tests/data/x509/%s_smtp.pem" % hostname, "r").read().rstrip()
 
        assert tls_file.content_string == open("tests/data/x509/%s_smtp.pem" % hostname, "r").read().rstrip()
 

	
 
        tls_file = host.file('/etc/ssl/private/%s_imap.key' % hostname)
 
        assert tls_file.is_file
 
        assert tls_file.user == 'root'
 
        assert tls_file.group == 'root'
 
        assert tls_file.mode == 0o640
 
        assert tls_file.content == open("tests/data/x509/%s_imap.key" % hostname, "r").read().rstrip()
 
        assert tls_file.content_string == open("tests/data/x509/%s_imap.key" % hostname, "r").read().rstrip()
 

	
 
        tls_file = host.file('/etc/ssl/certs/%s_imap.pem' % hostname)
 
        assert tls_file.is_file
 
        assert tls_file.user == 'root'
 
        assert tls_file.group == 'root'
 
        assert tls_file.mode == 0o644
 
        assert tls_file.content == open("tests/data/x509/%s_imap.pem" % hostname, "r").read().rstrip()
 
        assert tls_file.content_string == open("tests/data/x509/%s_imap.pem" % hostname, "r").read().rstrip()
 

	
 

	
 
def test_certificate_validity_check_configuration(host):
 
@@ -58,14 +58,14 @@ def test_certificate_validity_check_configuration(host):
 
    assert config.user == 'root'
 
    assert config.group == 'root'
 
    assert config.mode == 0o644
 
    assert config.content == "/etc/ssl/certs/%s_smtp.pem" % hostname
 
    assert config.content_string == "/etc/ssl/certs/%s_smtp.pem" % hostname
 

	
 
    config = host.file('/etc/check_certificate/%s_imap.conf' % hostname)
 
    assert config.is_file
 
    assert config.user == 'root'
 
    assert config.group == 'root'
 
    assert config.mode == 0o644
 
    assert config.content == "/etc/ssl/certs/%s_imap.pem" % hostname
 
    assert config.content_string == "/etc/ssl/certs/%s_imap.pem" % hostname
 

	
 

	
 
def test_mailname_file_content(host):
 
@@ -76,7 +76,7 @@ def test_mailname_file_content(host):
 
    mailname = host.file('/etc/mailname')
 
    hostname = host.run('hostname').stdout.strip()
 

	
 
    assert mailname.content == hostname
 
    assert mailname.content_string == hostname
 

	
 

	
 
def test_postfix_main_cf_file_content(host):
 
@@ -87,7 +87,7 @@ def test_postfix_main_cf_file_content(host):
 
    hostname = host.run('hostname').stdout.strip()
 

	
 
    config = host.file('/etc/postfix/main.cf')
 
    config_lines = config.content.split("\n")
 
    config_lines = config.content_string.split("\n")
 

	
 
    assert "myhostname = %s" % hostname in config_lines
 
    assert "mydestination = %s, %s, localhost.localdomain, localhost" % (hostname, hostname) in config_lines
roles/mail_server/molecule/default/tests/test_optional.py
Show inline comments
 
@@ -24,28 +24,28 @@ def test_smtp_tls_files(host):
 
        assert tls_file.user == 'root'
 
        assert tls_file.group == 'root'
 
        assert tls_file.mode == 0o640
 
        assert tls_file.content == open("tests/data/x509/parameters-optional_smtp.key.pem", "r").read().rstrip()
 
        assert tls_file.content_string == open("tests/data/x509/parameters-optional_smtp.key.pem", "r").read().rstrip()
 

	
 
        tls_file = host.file('/etc/ssl/certs/%s_smtp.pem' % hostname)
 
        assert tls_file.is_file
 
        assert tls_file.user == 'root'
 
        assert tls_file.group == 'root'
 
        assert tls_file.mode == 0o644
 
        assert tls_file.content == open("tests/data/x509/parameters-optional_smtp.cert.pem", "r").read().rstrip()
 
        assert tls_file.content_string == open("tests/data/x509/parameters-optional_smtp.cert.pem", "r").read().rstrip()
 

	
 
        tls_file = host.file('/etc/ssl/private/%s_imap.key' % hostname)
 
        assert tls_file.is_file
 
        assert tls_file.user == 'root'
 
        assert tls_file.group == 'root'
 
        assert tls_file.mode == 0o640
 
        assert tls_file.content == open("tests/data/x509/parameters-optional_imap.key.pem", "r").read().rstrip()
 
        assert tls_file.content_string == open("tests/data/x509/parameters-optional_imap.key.pem", "r").read().rstrip()
 

	
 
        tls_file = host.file('/etc/ssl/certs/%s_imap.pem' % hostname)
 
        assert tls_file.is_file
 
        assert tls_file.user == 'root'
 
        assert tls_file.group == 'root'
 
        assert tls_file.mode == 0o644
 
        assert tls_file.content == open("tests/data/x509/parameters-optional_imap.cert.pem", "r").read().rstrip()
 
        assert tls_file.content_string == open("tests/data/x509/parameters-optional_imap.cert.pem", "r").read().rstrip()
 

	
 

	
 
def test_certificate_validity_check_configuration(host):
 
@@ -61,14 +61,14 @@ def test_certificate_validity_check_configuration(host):
 
    assert config.user == 'root'
 
    assert config.group == 'root'
 
    assert config.mode == 0o644
 
    assert config.content == "/etc/ssl/certs/%s_smtp.pem" % hostname
 
    assert config.content_string == "/etc/ssl/certs/%s_smtp.pem" % hostname
 

	
 
    config = host.file('/etc/check_certificate/%s_imap.conf' % hostname)
 
    assert config.is_file
 
    assert config.user == 'root'
 
    assert config.group == 'root'
 
    assert config.mode == 0o644
 
    assert config.content == "/etc/ssl/certs/%s_imap.pem" % hostname
 
    assert config.content_string == "/etc/ssl/certs/%s_imap.pem" % hostname
 

	
 

	
 
def test_mailname_file_content(host):
 
@@ -79,7 +79,7 @@ def test_mailname_file_content(host):
 
    mailname = host.file('/etc/mailname')
 
    hostname = host.run('hostname').stdout.strip()
 

	
 
    assert mailname.content == hostname
 
    assert mailname.content_string == hostname
 

	
 

	
 
def test_postfix_main_cf_file_content(host):
 
@@ -92,7 +92,7 @@ def test_postfix_main_cf_file_content(host):
 
    hostname = host.run('hostname').stdout.strip()
 

	
 
    config = host.file('/etc/postfix/main.cf')
 
    config_lines = config.content.split("\n")
 
    config_lines = config.content_string.split("\n")
 

	
 
    assert "myhostname = %s" % hostname in config_lines
 
    assert "mydestination = %s, %s, localhost.localdomain, localhost" % (hostname, hostname) in config_lines
 
@@ -118,7 +118,7 @@ def test_local_aliases(host):
 
    with host.sudo():
 
        mail_log = host.file('/var/log/mail.log')
 
        pattern = r"dovecot: lda\(john.doe@domain1\): msgid=<%s>: saved mail to INBOX" % message_id
 
        assert re.search(pattern, mail_log.content) is not None
 
        assert re.search(pattern, mail_log.content_string) is not None
 

	
 

	
 
def test_dovecot_mailbox_directories(host):
roles/php_website/molecule/default/tests/test_parameters_mandatory.py
Show inline comments
 
@@ -103,7 +103,7 @@ def test_forward_file(host):
 
        assert config.user == 'root'
 
        assert config.group == 'web-parameters-mandatory'
 
        assert config.mode == 0o640
 
        assert config.content == "root\n"
 
        assert config.content_string == "root\n"
 

	
 

	
 
def test_mail_forwarding(host):
 
@@ -125,11 +125,11 @@ def test_mail_forwarding(host):
 

	
 
        # First extract message ID of forwarded mail.
 
        pattern = r"%s: to=<web-parameters-mandatory@localhost>.*status=sent \(forwarded as ([^)]*)\)" % original_queue_id
 
        forward_queue_id = re.search(pattern, mail_log.content).group(1)
 
        forward_queue_id = re.search(pattern, mail_log.content_string).group(1)
 

	
 
        # Now try to determine where the forward ended-up at.
 
        pattern = "%s: to=<vagrant@%s>, orig_to=<web-parameters-mandatory@localhost>.*status=sent" % (forward_queue_id, hostname)
 
        assert re.search(pattern, mail_log.content) is not None
 
        assert re.search(pattern, mail_log.content_string) is not None
 

	
 

	
 
def test_php_fpm_configuration_file(host):
 
@@ -160,14 +160,14 @@ def test_nginx_tls_files(host):
 
        assert tls_file.user == 'root'
 
        assert tls_file.group == 'root'
 
        assert tls_file.mode == 0o640
 
        assert tls_file.content == open("tests/data/x509/parameters-mandatory_https.key", "r").read().rstrip()
 
        assert tls_file.content_string == open("tests/data/x509/parameters-mandatory_https.key", "r").read().rstrip()
 

	
 
        tls_file = host.file('/etc/ssl/certs/parameters-mandatory_https.pem')
 
        assert tls_file.is_file
 
        assert tls_file.user == 'root'
 
        assert tls_file.group == 'root'
 
        assert tls_file.mode == 0o644
 
        assert tls_file.content == open("tests/data/x509/parameters-mandatory_https.pem", "r").read().rstrip()
 
        assert tls_file.content_string == open("tests/data/x509/parameters-mandatory_https.pem", "r").read().rstrip()
 

	
 

	
 
def test_certificate_validity_check_configuration(host):
 
@@ -181,7 +181,7 @@ def test_certificate_validity_check_configuration(host):
 
    assert config.user == 'root'
 
    assert config.group == 'root'
 
    assert config.mode == 0o644
 
    assert config.content == "/etc/ssl/certs/parameters-mandatory_https.pem"
 
    assert config.content_string == "/etc/ssl/certs/parameters-mandatory_https.pem"
 

	
 

	
 
def test_vhost_file(host):
roles/php_website/molecule/default/tests/test_parameters_optional.py
Show inline comments
 
@@ -103,7 +103,7 @@ def test_forward_file(host):
 
        assert config.user == 'root'
 
        assert config.group == 'web-parameters-optional_local'
 
        assert config.mode == 0o640
 
        assert config.content == "user\n"
 
        assert config.content_string == "user\n"
 

	
 

	
 
def test_mail_forwarding(host):
 
@@ -125,11 +125,11 @@ def test_mail_forwarding(host):
 

	
 
        # First extract message ID of forwarded mail.
 
        pattern = r"%s: to=<web-parameters-optional_local@localhost>.*status=sent \(forwarded as ([^)]*)\)" % message_id
 
        message_id = re.search(pattern, mail_log.content).group(1)
 
        message_id = re.search(pattern, mail_log.content_string).group(1)
 

	
 
        # Now try to determine where the forward ended-up at.
 
        pattern = "%s: to=<user@%s>, orig_to=<web-parameters-optional_local@localhost>.*status=sent" % (message_id, hostname)
 
        assert re.search(pattern, mail_log.content) is not None
 
        assert re.search(pattern, mail_log.content_string) is not None
 

	
 

	
 
def test_installed_packages(host):
 
@@ -154,14 +154,14 @@ def test_nginx_tls_files(host):
 
        assert tls_file.user == 'root'
 
        assert tls_file.group == 'root'
 
        assert tls_file.mode == 0o640
 
        assert tls_file.content == open("tests/data/x509/parameters-optional.local_https.key.pem", "r").read().rstrip()
 
        assert tls_file.content_string == open("tests/data/x509/parameters-optional.local_https.key.pem", "r").read().rstrip()
 

	
 
        tls_file = host.file('/etc/ssl/certs/parameters-optional.local_https.pem')
 
        assert tls_file.is_file
 
        assert tls_file.user == 'root'
 
        assert tls_file.group == 'root'
 
        assert tls_file.mode == 0o644
 
        assert tls_file.content == open("tests/data/x509/parameters-optional.local_https.cert.pem", "r").read().rstrip()
 
        assert tls_file.content_string == open("tests/data/x509/parameters-optional.local_https.cert.pem", "r").read().rstrip()
 

	
 

	
 
def test_certificate_validity_check_configuration(host):
 
@@ -175,7 +175,7 @@ def test_certificate_validity_check_configuration(host):
 
    assert config.user == 'root'
 
    assert config.group == 'root'
 
    assert config.mode == 0o644
 
    assert config.content == "/etc/ssl/certs/parameters-optional.local_https.pem"
 
    assert config.content_string == "/etc/ssl/certs/parameters-optional.local_https.pem"
 

	
 

	
 
def test_vhost_file(host):
roles/preseed/molecule/default/tests/test_parameters_mandatory.py
Show inline comments
 
@@ -53,7 +53,7 @@ def test_preseed_configuration_file_content(host):
 

	
 
    with host.sudo():
 
        preseed_file = host.file(os.path.join("/tmp/molecule/preseed/default/inventory", "preseed_files", "%s.cfg" % hostname))
 
        preseed_file_content = preseed_file.content_string
 
        preseed_file_content = preseed_file.content_string_string
 
        ssh_public_key = open(os.path.join(os.path.expanduser("~"), ".ssh", "id_rsa.pub")).read().strip()
 

	
 
    assert "d-i debian-installer/language string en" in preseed_file_content
roles/preseed/molecule/default/tests/test_parameters_optional.py
Show inline comments
 
@@ -48,7 +48,7 @@ def test_preseed_configuration_file_content(host):
 

	
 
    with host.sudo():
 
        preseed_file = host.file(os.path.join(PRESEED_DIRECTORY, "%s.cfg" % hostname))
 
        preseed_file_content = preseed_file.content_string
 
        preseed_file_content = preseed_file.content_string_string
 
        ssh_public_key = "CUSTOMKEY"
 

	
 
    assert "d-i debian-installer/language string sr" in preseed_file_content
roles/preseed/molecule/default/tests/test_parameters_optional_with_overrides.py
Show inline comments
 
@@ -32,7 +32,7 @@ def test_preseed_configuration_file_content_host_without_overrides(host):
 

	
 
    with host.sudo():
 
        preseed_file = host.file(os.path.join(PRESEED_DIRECTORY, "%s.cfg" % hostname))
 
        preseed_file_content = preseed_file.content_string
 
        preseed_file_content = preseed_file.content_string_string
 
        ssh_public_key = "CUSTOMKEY"
 

	
 
    assert "d-i debian-installer/language string en" in preseed_file_content
 
@@ -64,7 +64,7 @@ def test_preseed_configuration_file_content_host_with_overrides(host):
 

	
 
    with host.sudo():
 
        preseed_file = host.file(os.path.join(PRESEED_DIRECTORY, "%s.cfg" % hostname))
 
        preseed_file_content = preseed_file.content_string
 
        preseed_file_content = preseed_file.content_string_string
 
        ssh_public_key = "CUSTOMKEY"
 

	
 
    assert "d-i debian-installer/language string sr" in preseed_file_content
roles/web_server/molecule/default/tests/test_default.py
Show inline comments
 
@@ -35,7 +35,7 @@ def test_default_tls_configuration_removed(host):
 
    configuration file.
 
    """
 

	
 
    assert 'ssl_protocols' not in host.file('/etc/nginx/nginx.conf').content
 
    assert 'ssl_protocols' not in host.file('/etc/nginx/nginx.conf').content_string
 

	
 

	
 
def test_nginx_configuration_verification_script(host):
 
@@ -187,7 +187,7 @@ def test_socket_directories(host, application_type, tmpfiles_d_path):
 
    assert config.user == 'root'
 
    assert config.group == 'root'
 
    assert config.mode == 0o644
 
    assert config.content == tmpfiles_d_content
 
    assert config.content_string == tmpfiles_d_content
 

	
 

	
 
def test_php_fpm_service_overrides(host, php_info):
 
@@ -213,7 +213,7 @@ def test_php_timezone_configuration(host, php_info):
 
    Tests if PHP timezone configuration has been set correctly.
 
    """
 

	
 
    server_timezone = host.file("/etc/timezone").content.strip()
 
    server_timezone = host.file("/etc/timezone").content_string.strip()
 

	
 
    config = host.file('%s/cli/conf.d/30-timezone.ini' % php_info.base_config_dir)
 
    assert config.is_file
roles/web_server/molecule/default/tests/test_mandatory.py
Show inline comments
 
@@ -21,14 +21,14 @@ def test_nginx_tls_files(host):
 
        assert tls_file.user == 'root'
 
        assert tls_file.group == 'root'
 
        assert tls_file.mode == 0o640
 
        assert tls_file.content == open("tests/data/x509/%s_https.key" % hostname, "r").read().rstrip()
 
        assert tls_file.content_string == open("tests/data/x509/%s_https.key" % hostname, "r").read().rstrip()
 

	
 
        tls_file = host.file('/etc/ssl/certs/%s_https.pem' % hostname)
 
        assert tls_file.is_file
 
        assert tls_file.user == 'root'
 
        assert tls_file.group == 'root'
 
        assert tls_file.mode == 0o644
 
        assert tls_file.content == open("tests/data/x509/%s_https.pem" % hostname, "r").read().rstrip()
 
        assert tls_file.content_string == open("tests/data/x509/%s_https.pem" % hostname, "r").read().rstrip()
 

	
 

	
 
def test_certificate_validity_check_configuration(host):
 
@@ -44,7 +44,7 @@ def test_certificate_validity_check_configuration(host):
 
    assert config.user == 'root'
 
    assert config.group == 'root'
 
    assert config.mode == 0o644
 
    assert config.content == "/etc/ssl/certs/%s_https.pem" % hostname
 
    assert config.content_string == "/etc/ssl/certs/%s_https.pem" % hostname
 

	
 

	
 
def test_tls_configuration(host):
roles/web_server/molecule/default/tests/test_optional.py
Show inline comments
 
@@ -21,14 +21,14 @@ def test_nginx_tls_files(host):
 
        assert tls_file.user == 'root'
 
        assert tls_file.group == 'root'
 
        assert tls_file.mode == 0o640
 
        assert tls_file.content == open("tests/data/x509/parameters-optional_https.key.pem", "r").read().rstrip()
 
        assert tls_file.content_string == open("tests/data/x509/parameters-optional_https.key.pem", "r").read().rstrip()
 

	
 
        tls_file = host.file('/etc/ssl/certs/%s_https.pem' % hostname)
 
        assert tls_file.is_file
 
        assert tls_file.user == 'root'
 
        assert tls_file.group == 'root'
 
        assert tls_file.mode == 0o644
 
        assert tls_file.content == open("tests/data/x509/parameters-optional_https.cert.pem", "r").read().rstrip()
 
        assert tls_file.content_string == open("tests/data/x509/parameters-optional_https.cert.pem", "r").read().rstrip()
 

	
 

	
 
def test_certificate_validity_check_configuration(host):
 
@@ -44,7 +44,7 @@ def test_certificate_validity_check_configuration(host):
 
    assert config.user == 'root'
 
    assert config.group == 'root'
 
    assert config.mode == 0o644
 
    assert config.content == "/etc/ssl/certs/%s_https.pem" % hostname
 
    assert config.content_string == "/etc/ssl/certs/%s_https.pem" % hostname
 

	
 

	
 
def test_tls_configuration(host):
roles/wsgi_website/molecule/default/tests/test_default.py
Show inline comments
 
@@ -119,7 +119,7 @@ def test_environment_profile_configuration(host, profile_file, expected_group, e
 
        assert config.user == 'root'
 
        assert config.group == expected_group
 
        assert config.mode == 0o640
 
        assert config.content == expected_content
 
        assert config.content_string == expected_content
 

	
 

	
 
@pytest.mark.parametrize("admin_user, expected_virtualenv_path", [
 
@@ -193,7 +193,7 @@ def test_forward_file(host, forward_file, expected_group, expected_content):
 
        assert config.user == 'root'
 
        assert config.group == expected_group
 
        assert config.mode == 0o640
 
        assert config.content == expected_content
 
        assert config.content_string == expected_content
 

	
 

	
 
@pytest.mark.parametrize("original_destination, expected_destination_user", [
 
@@ -220,11 +220,11 @@ def test_mail_forwarding(host, original_destination, expected_destination_user):
 

	
 
        # First extract message ID of forwarded mail.
 
        pattern = r"%s: to=<%s>.*status=sent \(forwarded as ([^)]*)\)" % (original_queue_id, original_destination)
 
        forward_queue_id = re.search(pattern, mail_log.content).group(1)
 
        forward_queue_id = re.search(pattern, mail_log.content_string).group(1)
 

	
 
        # Now try to determine where the forward ended-up at.
 
        pattern = "%s: to=<%s@%s>, orig_to=<%s>.*status=sent" % (forward_queue_id, expected_destination_user, hostname, original_destination)
 
        assert re.search(pattern, mail_log.content) is not None
 
        assert re.search(pattern, mail_log.content_string) is not None
 

	
 

	
 
@pytest.mark.parametrize("virtualenv_dir, expected_owner, expected_group", [
 
@@ -372,8 +372,8 @@ def test_systemd_socket_configuration_file(host, config_file, expected_website_n
 
    assert config.user == 'root'
 
    assert config.group == 'root'
 
    assert config.mode == 0o644
 
    assert "Socket for website %s" % expected_website_name in config.content
 
    assert "ListenStream=%s" % expected_socket_file_path in config.content
 
    assert "Socket for website %s" % expected_website_name in config.content_string
 
    assert "ListenStream=%s" % expected_socket_file_path in config.content_string
 

	
 

	
 
@pytest.mark.parametrize("socket_file_path", [
 
@@ -413,7 +413,7 @@ def test_systemd_service_configuration_file(host, service_file, expected_fqdn):
 
    assert config.user == 'root'
 
    assert config.group == 'root'
 
    assert config.mode == 0o644
 
    assert expected_fqdn in config.content
 
    assert expected_fqdn in config.content_string
 

	
 

	
 
@pytest.mark.parametrize("service_name", [
 
@@ -471,14 +471,14 @@ def test_nginx_tls_files(host, private_key_path, certificate_path, expected_priv
 
        assert tls_file.user == 'root'
 
        assert tls_file.group == 'root'
 
        assert tls_file.mode == 0o640
 
        assert tls_file.content == open(expected_private_key, "r").read().rstrip()
 
        assert tls_file.content_string == open(expected_private_key, "r").read().rstrip()
 

	
 
        tls_file = host.file(certificate_path)
 
        assert tls_file.is_file
 
        assert tls_file.user == 'root'
 
        assert tls_file.group == 'root'
 
        assert tls_file.mode == 0o644
 
        assert tls_file.content == open(expected_certificate, "r").read().rstrip()
 
        assert tls_file.content_string == open(expected_certificate, "r").read().rstrip()
 

	
 

	
 
@pytest.mark.parametrize("config_file_path, expected_content", [
 
@@ -497,7 +497,7 @@ def test_certificate_validity_check_configuration(host, config_file_path, expect
 
    assert config.user == 'root'
 
    assert config.group == 'root'
 
    assert config.mode == 0o644
 
    assert config.content == expected_content
 
    assert config.content_string == expected_content
 

	
 

	
 
@pytest.mark.parametrize("config_file", [
roles/wsgi_website/molecule/default/tests/test_parameters_paste_req.py
Show inline comments
 
@@ -24,14 +24,14 @@ def test_wsgi_requirements_upgrade_checks(host):
 
        assert config.user == 'root'
 
        assert config.group == 'pipreqcheck'
 
        assert config.mode == 0o640
 
        assert config.content == "gunicorn\nfutures\n"
 
        assert config.content_string == "gunicorn\nfutures\n"
 

	
 
        config = host.file('/etc/pip_check_requirements_upgrades/parameters-paste-req/wsgi_requirements.txt')
 
        assert config.is_file
 
        assert config.user == 'root'
 
        assert config.group == 'pipreqcheck'
 
        assert config.mode == 0o640
 
        assert config.content == "futures==3.1.0\ngunicorn==19.7.0\n"
 
        assert config.content_string == "futures==3.1.0\ngunicorn==19.7.0\n"
 

	
 

	
 
def test_gunicorn_requirements_installation_file(host):
 
@@ -47,7 +47,7 @@ def test_gunicorn_requirements_installation_file(host):
 
        assert requirements.user == 'admin-parameters-paste-req'
 
        assert requirements.group == 'web-parameters-paste-req'
 
        assert requirements.mode == 0o640
 
        assert requirements.content == "futures==3.1.0\ngunicorn==19.7.0\n"
 
        assert requirements.content_string == "futures==3.1.0\ngunicorn==19.7.0\n"
 

	
 

	
 
def test_index_page(host):
roles/xmpp_server/molecule/default/tests/test_default.py
Show inline comments
 
@@ -43,7 +43,7 @@ def test_prosody_repository(host):
 
    assert repository.user == 'root'
 
    assert repository.group == 'root'
 
    assert repository.mode == 0o644
 
    assert repository.content == expected_content
 
    assert repository.content_string == expected_content
 

	
 

	
 
def test_prosody_user(host):
 
@@ -79,8 +79,8 @@ def test_prosody_mod_auth_ldap(host):
 
    assert module.user == 'root'
 
    assert module.group == 'root'
 
    assert module.mode == 0o644
 
    assert 'module:provides("auth", provider);' in module.content
 
    assert 'mod_auth_ldap' in module.content
 
    assert 'module:provides("auth", provider);' in module.content_string
 
    assert 'mod_auth_ldap' in module.content_string
 

	
 

	
 
def test_prosody_configuration_file(host):
roles/xmpp_server/molecule/default/tests/test_mandatory.py
Show inline comments
 
@@ -22,14 +22,14 @@ def test_prosody_tls_files(host):
 
        assert tls_file.user == 'root'
 
        assert tls_file.group == 'prosody'
 
        assert tls_file.mode == 0o640
 
        assert tls_file.content == open("tests/data/x509/%s.domain1_xmpp.key" % hostname, "r").read().rstrip()
 
        assert tls_file.content_string == open("tests/data/x509/%s.domain1_xmpp.key" % hostname, "r").read().rstrip()
 

	
 
        tls_file = host.file('/etc/ssl/certs/%s.domain1_xmpp.pem' % hostname)
 
        assert tls_file.is_file
 
        assert tls_file.user == 'root'
 
        assert tls_file.group == 'root'
 
        assert tls_file.mode == 0o644
 
        assert tls_file.content == open("tests/data/x509/%s.domain1_xmpp.pem" % hostname, "r").read().rstrip()
 
        assert tls_file.content_string == open("tests/data/x509/%s.domain1_xmpp.pem" % hostname, "r").read().rstrip()
 

	
 

	
 
def test_certificate_validity_check_configuration(host):
 
@@ -45,7 +45,7 @@ def test_certificate_validity_check_configuration(host):
 
    assert config.user == 'root'
 
    assert config.group == 'root'
 
    assert config.mode == 0o644
 
    assert config.content == "/etc/ssl/certs/%s.domain1_xmpp.pem" % hostname
 
    assert config.content_string == "/etc/ssl/certs/%s.domain1_xmpp.pem" % hostname
 

	
 

	
 
def test_prosody_configuration_file_content(host):
 
@@ -59,20 +59,20 @@ def test_prosody_configuration_file_content(host):
 

	
 
        config = host.file('/etc/prosody/prosody.cfg.lua')
 

	
 
        assert "admins = { \"john.doe@domain1\",  }" in config.content
 
        assert "key = \"/etc/ssl/private/%s.domain1_xmpp.key\";" % hostname in config.content
 
        assert "certificate = \"/etc/ssl/certs/%s.domain1_xmpp.pem\";" % hostname in config.content
 
        assert "ldap_server = \"ldap-server\"" in config.content
 
        assert "ldap_rootdn = \"cn=prosody,ou=services,dc=local\"" in config.content
 
        assert "ldap_password = \"prosodypassword\"" in config.content
 
        assert "ldap_filter = \"(&(mail=$user@$host)(memberOf=cn=xmpp,ou=groups,dc=local))\"" in config.content
 
        assert "ldap_base = \"ou=people,dc=local\"" in config.content
 
        assert "admins = { \"john.doe@domain1\",  }" in config.content_string
 
        assert "key = \"/etc/ssl/private/%s.domain1_xmpp.key\";" % hostname in config.content_string
 
        assert "certificate = \"/etc/ssl/certs/%s.domain1_xmpp.pem\";" % hostname in config.content_string
 
        assert "ldap_server = \"ldap-server\"" in config.content_string
 
        assert "ldap_rootdn = \"cn=prosody,ou=services,dc=local\"" in config.content_string
 
        assert "ldap_password = \"prosodypassword\"" in config.content_string
 
        assert "ldap_filter = \"(&(mail=$user@$host)(memberOf=cn=xmpp,ou=groups,dc=local))\"" in config.content_string
 
        assert "ldap_base = \"ou=people,dc=local\"" in config.content_string
 

	
 
        assert """VirtualHost "domain1"
 
Component "conference.domain1" "muc"
 
  restrict_room_creation = "local"
 
Component "proxy.domain1" "proxy65"
 
  proxy65_acl = { "domain1" }""" in config.content
 
  proxy65_acl = { "domain1" }""" in config.content_string
 

	
 

	
 
def test_correct_prosody_package_installed(host):
roles/xmpp_server/molecule/default/tests/test_optional.py
Show inline comments
 
@@ -22,14 +22,14 @@ def test_prosody_tls_files(host):
 
        assert tls_file.user == 'root'
 
        assert tls_file.group == 'prosody'
 
        assert tls_file.mode == 0o640
 
        assert tls_file.content == open("tests/data/x509/parameters-optional_xmpp.key.pem", "r").read().rstrip()
 
        assert tls_file.content_string == open("tests/data/x509/parameters-optional_xmpp.key.pem", "r").read().rstrip()
 

	
 
        tls_file = host.file('/etc/ssl/certs/%s_xmpp.pem' % hostname)
 
        assert tls_file.is_file
 
        assert tls_file.user == 'root'
 
        assert tls_file.group == 'root'
 
        assert tls_file.mode == 0o644
 
        assert tls_file.content == open("tests/data/x509/parameters-optional_xmpp.cert.pem", "r").read().rstrip()
 
        assert tls_file.content_string == open("tests/data/x509/parameters-optional_xmpp.cert.pem", "r").read().rstrip()
 

	
 

	
 
def test_certificate_validity_check_configuration(host):
 
@@ -45,7 +45,7 @@ def test_certificate_validity_check_configuration(host):
 
    assert config.user == 'root'
 
    assert config.group == 'root'
 
    assert config.mode == 0o644
 
    assert config.content == "/etc/ssl/certs/%s_xmpp.pem" % hostname
 
    assert config.content_string == "/etc/ssl/certs/%s_xmpp.pem" % hostname
 

	
 

	
 
def test_prosody_configuration_file_content(host):
 
@@ -59,26 +59,26 @@ def test_prosody_configuration_file_content(host):
 

	
 
        config = host.file('/etc/prosody/prosody.cfg.lua')
 

	
 
        assert "admins = { \"jane.doe@domain2\", \"mick.doe@domain3\",  }" in config.content
 
        assert "key = \"/etc/ssl/private/%s_xmpp.key\";" % hostname in config.content
 
        assert "certificate = \"/etc/ssl/certs/%s_xmpp.pem\";" % hostname in config.content
 
        assert "ldap_server = \"ldap-server\"" in config.content
 
        assert "ldap_rootdn = \"cn=prosody,ou=services,dc=local\"" in config.content
 
        assert "ldap_password = \"prosodypassword\"" in config.content
 
        assert "ldap_filter = \"(&(mail=$user@$host)(memberOf=cn=xmpp,ou=groups,dc=local))\"" in config.content
 
        assert "ldap_base = \"ou=people,dc=local\"" in config.content
 
        assert "admins = { \"jane.doe@domain2\", \"mick.doe@domain3\",  }" in config.content_string
 
        assert "key = \"/etc/ssl/private/%s_xmpp.key\";" % hostname in config.content_string
 
        assert "certificate = \"/etc/ssl/certs/%s_xmpp.pem\";" % hostname in config.content_string
 
        assert "ldap_server = \"ldap-server\"" in config.content_string
 
        assert "ldap_rootdn = \"cn=prosody,ou=services,dc=local\"" in config.content_string
 
        assert "ldap_password = \"prosodypassword\"" in config.content_string
 
        assert "ldap_filter = \"(&(mail=$user@$host)(memberOf=cn=xmpp,ou=groups,dc=local))\"" in config.content_string
 
        assert "ldap_base = \"ou=people,dc=local\"" in config.content_string
 

	
 
        assert """VirtualHost "domain2"
 
Component "conference.domain2" "muc"
 
  restrict_room_creation = "local"
 
Component "proxy.domain2" "proxy65"
 
  proxy65_acl = { "domain2" }""" in config.content
 
  proxy65_acl = { "domain2" }""" in config.content_string
 

	
 
        assert """VirtualHost "domain3"
 
Component "conference.domain3" "muc"
 
  restrict_room_creation = "local"
 
Component "proxy.domain3" "proxy65"
 
  proxy65_acl = { "domain3" }""" in config.content
 
  proxy65_acl = { "domain3" }""" in config.content_string
 

	
 

	
 
def test_correct_prosody_package_installed(host):
0 comments (0 inline, 0 general)