From d752715bb533ee7ddc8d5c7f0849b6455a7b0045 2020-05-07 22:38:43 From: Branko Majic Date: 2020-05-07 22:38:43 Subject: [PATCH] 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). --- diff --git a/roles/backup/molecule/default/tests/test_parameters_mandatory.py b/roles/backup/molecule/default/tests/test_parameters_mandatory.py index 1d7fdfe2d1b16acf9bfc1a2546c891e061a513d8..61b62b63b8bd48607b1378f40dd0ca267ded4a37 100644 --- a/roles/backup/molecule/default/tests/test_parameters_mandatory.py +++ b/roles/backup/molecule/default/tests/test_parameters_mandatory.py @@ -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 == '' diff --git a/roles/backup/molecule/default/tests/test_parameters_optional.py b/roles/backup/molecule/default/tests/test_parameters_optional.py index 2735ebc8edd01e50a1660b5a7ab03d0345d1aba3..38fe330dd54c717c5a7c4f4074ea9886aa7c9751 100644 --- a/roles/backup/molecule/default/tests/test_parameters_optional.py +++ b/roles/backup/molecule/default/tests/test_parameters_optional.py @@ -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" diff --git a/roles/backup_client/molecule/default/tests/test_default.py b/roles/backup_client/molecule/default/tests/test_default.py index 711706ec462290f78954155da4d54562e1d05fee..28e2e8d79c6b640ec290a54eedb0c26128f1b670 100644 --- a/roles/backup_client/molecule/default/tests/test_default.py +++ b/roles/backup_client/molecule/default/tests/test_default.py @@ -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): diff --git a/roles/backup_client/molecule/default/tests/test_parameters_mandatory.py b/roles/backup_client/molecule/default/tests/test_parameters_mandatory.py index 5f0c0d804629d65f74ea594703df034c816763bd..3629d88ee7feb6739ef2107e20bc98453cced8b7 100644 --- a/roles/backup_client/molecule/default/tests/test_parameters_mandatory.py +++ b/roles/backup_client/molecule/default/tests/test_parameters_mandatory.py @@ -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): diff --git a/roles/backup_client/molecule/default/tests/test_parameters_optional.py b/roles/backup_client/molecule/default/tests/test_parameters_optional.py index ff1f54f7418d5faa66a02eb48894ff5a0c59965e..478d845b80c12b708870ba97a6dc24b816b6ec89 100644 --- a/roles/backup_client/molecule/default/tests/test_parameters_optional.py +++ b/roles/backup_client/molecule/default/tests/test_parameters_optional.py @@ -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): diff --git a/roles/backup_server/molecule/default/tests/test_default.py b/roles/backup_server/molecule/default/tests/test_default.py index eaca91ed06efbae0b6a1e0e521f535411cceccd3..72cac4603998a6895dddd9c3440de39d1660efb7 100644 --- a/roles/backup_server/molecule/default/tests/test_default.py +++ b/roles/backup_server/molecule/default/tests/test_default.py @@ -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): diff --git a/roles/backup_server/molecule/default/tests/test_parameters_mandatory.py b/roles/backup_server/molecule/default/tests/test_parameters_mandatory.py index 2d551f19a6f9b968d0a29e0fc39b7a4d3e1bb82f..13ef853dd75c5eb555b74ad990bd251a9f5662ae 100644 --- a/roles/backup_server/molecule/default/tests/test_parameters_mandatory.py +++ b/roles/backup_server/molecule/default/tests/test_parameters_mandatory.py @@ -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" diff --git a/roles/backup_server/molecule/default/tests/test_parameters_optional.py b/roles/backup_server/molecule/default/tests/test_parameters_optional.py index 9eeee279aa7521d64036f679c32f792be5a4825f..33cb10498ba21f0fba7e5413c0b7b2c25322ef0a 100644 --- a/roles/backup_server/molecule/default/tests/test_parameters_optional.py +++ b/roles/backup_server/molecule/default/tests/test_parameters_optional.py @@ -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") diff --git a/roles/bootstrap/molecule/default/tests/test_default.py b/roles/bootstrap/molecule/default/tests/test_default.py index 03b96b6149d2452d90b9582005a919fd13ebb0c5..f5fb4117f9b073bf23c9803a7a8fd90d9af1c05f 100644 --- a/roles/bootstrap/molecule/default/tests/test_default.py +++ b/roles/bootstrap/molecule/default/tests/test_default.py @@ -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' diff --git a/roles/bootstrap/molecule/default/tests/test_parameters_mandatory.py b/roles/bootstrap/molecule/default/tests/test_parameters_mandatory.py index 5365ff7bc29bb002b57fa7291d5bf00a6ca0994d..f62b306a52a5d47d7dd3941686a30744becdc33e 100644 --- a/roles/bootstrap/molecule/default/tests/test_parameters_mandatory.py +++ b/roles/bootstrap/molecule/default/tests/test_parameters_mandatory.py @@ -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 diff --git a/roles/bootstrap/molecule/default/tests/test_parameters_optional.py b/roles/bootstrap/molecule/default/tests/test_parameters_optional.py index d9792e7c684a7bef085bc8edd595a543b5aaa22b..041d5e687f2393cde4418cf637c5d3b251664952 100644 --- a/roles/bootstrap/molecule/default/tests/test_parameters_optional.py +++ b/roles/bootstrap/molecule/default/tests/test_parameters_optional.py @@ -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 diff --git a/roles/common/molecule/default/tests/test_default.py b/roles/common/molecule/default/tests/test_default.py index fa58eb04c55e5f3c6ffa4d6a35f48fcb54f0c4f3..acaa5a0d43af09fb57035b7b62de26b49551e5b1 100644 --- a/roles/common/molecule/default/tests/test_default.py +++ b/roles/common/molecule/default/tests/test_default.py @@ -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', [ diff --git a/roles/common/molecule/default/tests/test_parameters_mandatory.py b/roles/common/molecule/default/tests/test_parameters_mandatory.py index 325e454aa2a79ccf6a38204088c1255c25724216..6379f00f509a5a4c0c1c7dbeb04be77c2728dff1 100644 --- a/roles/common/molecule/default/tests/test_parameters_mandatory.py +++ b/roles/common/molecule/default/tests/test_parameters_mandatory.py @@ -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') diff --git a/roles/common/molecule/default/tests/test_parameters_optional.py b/roles/common/molecule/default/tests/test_parameters_optional.py index 6b730003f8bcf320a56a42e381f027be9d7ee728..985cf012cc2be17825917301f23a723ec1846476 100644 --- a/roles/common/molecule/default/tests/test_parameters_optional.py +++ b/roles/common/molecule/default/tests/test_parameters_optional.py @@ -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). diff --git a/roles/database/molecule/default/tests/test_backup.py b/roles/database/molecule/default/tests/test_backup.py index a8d55b05dd97dce85e0c91cadcc8cc0e646a2ce1..11a59ceb481d548378b6d8d7d82304e40ad2fe54 100644 --- a/roles/database/molecule/default/tests/test_backup.py +++ b/roles/database/molecule/default/tests/test_backup.py @@ -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 diff --git a/roles/database_server/molecule/default/tests/test_default.py b/roles/database_server/molecule/default/tests/test_default.py index 34e72d2b57a789d93ea12b2f7b7caee2a3dacd84..cc339bce4968a3e457400f70e996b7bd218fc88f 100644 --- a/roles/database_server/molecule/default/tests/test_default.py +++ b/roles/database_server/molecule/default/tests/test_default.py @@ -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): diff --git a/roles/ldap_client/molecule/default/tests/test_mandatory.py b/roles/ldap_client/molecule/default/tests/test_mandatory.py index 611a036078fabb69ccdf11efb0c066b2c3fb9a6d..af1b57ba791736b0e4037bce87b7f010051a7ae7 100644 --- a/roles/ldap_client/molecule/default/tests/test_mandatory.py +++ b/roles/ldap_client/molecule/default/tests/test_mandatory.py @@ -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 == "" diff --git a/roles/ldap_client/molecule/default/tests/test_optional.py b/roles/ldap_client/molecule/default/tests/test_optional.py index 12a32dbd8317ff6ebfe7046e30c28275c98fed4f..a3253635f0449679b3d291fcaad8f3fb5ab81381 100644 --- a/roles/ldap_client/molecule/default/tests/test_optional.py +++ b/roles/ldap_client/molecule/default/tests/test_optional.py @@ -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 diff --git a/roles/ldap_server/molecule/default/tests/test_backup.py b/roles/ldap_server/molecule/default/tests/test_backup.py index 6f84d1d004fe8e1631d7ca761edd56dbd109e28b..9a5b60bd956282c82465327c937b4f6e7d8d0fe0 100644 --- a/roles/ldap_server/molecule/default/tests/test_backup.py +++ b/roles/ldap_server/molecule/default/tests/test_backup.py @@ -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 diff --git a/roles/ldap_server/molecule/default/tests/test_default.py b/roles/ldap_server/molecule/default/tests/test_default.py index 47c79b221b76b01b291058f7346506b944350567..daee18588aeaa2412ab8962af2bea20764ad8bc6 100644 --- a/roles/ldap_server/molecule/default/tests/test_default.py +++ b/roles/ldap_server/molecule/default/tests/test_default.py @@ -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): diff --git a/roles/ldap_server/molecule/default/tests/test_mandatory.py b/roles/ldap_server/molecule/default/tests/test_mandatory.py index b1cbae5ca068770e47120beb27ce61e51fb6d692..8bfdc2abeb1277b5313c3486372905d9b934ea5d 100644 --- a/roles/ldap_server/molecule/default/tests/test_mandatory.py +++ b/roles/ldap_server/molecule/default/tests/test_mandatory.py @@ -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): diff --git a/roles/ldap_server/molecule/default/tests/test_optional.py b/roles/ldap_server/molecule/default/tests/test_optional.py index dcacdfcaffa50c3122460e60fd866e7be9d59e00..a2d7b8b2e281a0d4e6197010e62ca3277408d476 100644 --- a/roles/ldap_server/molecule/default/tests/test_optional.py +++ b/roles/ldap_server/molecule/default/tests/test_optional.py @@ -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): diff --git a/roles/mail_forwarder/molecule/default/tests/test_mandatory.py b/roles/mail_forwarder/molecule/default/tests/test_mandatory.py index 403ba9e866f7ea2ff8199fbc38d77bf74b37b114..622504e2b7fafbfb388ebefd7861da3f09241d50 100644 --- a/roles/mail_forwarder/molecule/default/tests/test_mandatory.py +++ b/roles/mail_forwarder/molecule/default/tests/test_mandatory.py @@ -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=, 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 diff --git a/roles/mail_forwarder/molecule/default/tests/test_optional.py b/roles/mail_forwarder/molecule/default/tests/test_optional.py index 84316c572afda63c688bb98eb524eadcb27581e7..d0375369d89ca382de7f772b4fd57381708d061b 100644 --- a/roles/mail_forwarder/molecule/default/tests/test_optional.py +++ b/roles/mail_forwarder/molecule/default/tests/test_optional.py @@ -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=, orig_to=.*status=sent" % (message_id, hostname) pattern2 = "%s: to=, orig_to=.*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=, 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=, 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 diff --git a/roles/mail_forwarder/molecule/default/tests/test_smtp_relay_host_port.py b/roles/mail_forwarder/molecule/default/tests/test_smtp_relay_host_port.py index 5a132758f7bdbc0d4356350573440fed5e20dd6a..7760405f5a3f2c33e4954c5abcccfeac8a28ebf0 100644 --- a/roles/mail_forwarder/molecule/default/tests/test_smtp_relay_host_port.py +++ b/roles/mail_forwarder/molecule/default/tests/test_smtp_relay_host_port.py @@ -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=, 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 diff --git a/roles/mail_server/molecule/default/tests/test_default.py b/roles/mail_server/molecule/default/tests/test_default.py index ce8e4b055da0abd4e59e470ae3cd279d5d7f0d6f..c7774ed477724fe5f8f291a5d4a869539ebc9488 100644 --- a/roles/mail_server/molecule/default/tests/test_default.py +++ b/roles/mail_server/molecule/default/tests/test_default.py @@ -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): diff --git a/roles/mail_server/molecule/default/tests/test_mandatory.py b/roles/mail_server/molecule/default/tests/test_mandatory.py index 048fba86a4fef7305ca352d4bdff2201983ecdde..6feec89f0aa58111c94f6565cd7e699f3f4f1335 100644 --- a/roles/mail_server/molecule/default/tests/test_mandatory.py +++ b/roles/mail_server/molecule/default/tests/test_mandatory.py @@ -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 diff --git a/roles/mail_server/molecule/default/tests/test_optional.py b/roles/mail_server/molecule/default/tests/test_optional.py index 8bae2d776333810bd2559ebedddc32829cf7ea54..c8079027080cd50e5b6c11e5f44a1836093679b8 100644 --- a/roles/mail_server/molecule/default/tests/test_optional.py +++ b/roles/mail_server/molecule/default/tests/test_optional.py @@ -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): diff --git a/roles/php_website/molecule/default/tests/test_parameters_mandatory.py b/roles/php_website/molecule/default/tests/test_parameters_mandatory.py index 2f18afce6283023114a87af108aff890a2c2cd82..0d1637b93221d56f2fbc5f977e79b4b2a6060be3 100644 --- a/roles/php_website/molecule/default/tests/test_parameters_mandatory.py +++ b/roles/php_website/molecule/default/tests/test_parameters_mandatory.py @@ -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=.*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=, orig_to=.*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): diff --git a/roles/php_website/molecule/default/tests/test_parameters_optional.py b/roles/php_website/molecule/default/tests/test_parameters_optional.py index a8e622338ba2dae17b09ae758be2915c957b4d43..aca89c8220004a58e992ed279ebec48ef6bc366d 100644 --- a/roles/php_website/molecule/default/tests/test_parameters_optional.py +++ b/roles/php_website/molecule/default/tests/test_parameters_optional.py @@ -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=.*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=, orig_to=.*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): diff --git a/roles/preseed/molecule/default/tests/test_parameters_mandatory.py b/roles/preseed/molecule/default/tests/test_parameters_mandatory.py index 7c77d8482c8090bd23e857a325ea53af95269829..d0060801453de2a70c8ae685ebab2296d8c54a28 100644 --- a/roles/preseed/molecule/default/tests/test_parameters_mandatory.py +++ b/roles/preseed/molecule/default/tests/test_parameters_mandatory.py @@ -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 diff --git a/roles/preseed/molecule/default/tests/test_parameters_optional.py b/roles/preseed/molecule/default/tests/test_parameters_optional.py index 0506f6387f6728b0ea5f8375217f1b1719969ce6..a781302ad539983bf2b2e39d16e52cc3696287d8 100644 --- a/roles/preseed/molecule/default/tests/test_parameters_optional.py +++ b/roles/preseed/molecule/default/tests/test_parameters_optional.py @@ -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 diff --git a/roles/preseed/molecule/default/tests/test_parameters_optional_with_overrides.py b/roles/preseed/molecule/default/tests/test_parameters_optional_with_overrides.py index c8ceb22951ac474063ee726892c395c883b2ccdf..2038e662a0e9e69b552dd1dffb19ae5e1fbfacd0 100644 --- a/roles/preseed/molecule/default/tests/test_parameters_optional_with_overrides.py +++ b/roles/preseed/molecule/default/tests/test_parameters_optional_with_overrides.py @@ -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 diff --git a/roles/web_server/molecule/default/tests/test_default.py b/roles/web_server/molecule/default/tests/test_default.py index 66f2444fee7301eeacd95b866da3af9a51b3d89f..74be94bc9e4dbd460ffcb3f83dc645524e8d3c73 100644 --- a/roles/web_server/molecule/default/tests/test_default.py +++ b/roles/web_server/molecule/default/tests/test_default.py @@ -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 diff --git a/roles/web_server/molecule/default/tests/test_mandatory.py b/roles/web_server/molecule/default/tests/test_mandatory.py index 0b5ae7aff90a952b35cadea0f0c1c7ef40e60f13..6dd360378612801db81d5bf5edaf035d433b8c58 100644 --- a/roles/web_server/molecule/default/tests/test_mandatory.py +++ b/roles/web_server/molecule/default/tests/test_mandatory.py @@ -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): diff --git a/roles/web_server/molecule/default/tests/test_optional.py b/roles/web_server/molecule/default/tests/test_optional.py index 12808f9fa8e0a00a8d1a6465a653dc978fca0ea5..476c289bb464e64fce6044c063b61b7b9554f433 100644 --- a/roles/web_server/molecule/default/tests/test_optional.py +++ b/roles/web_server/molecule/default/tests/test_optional.py @@ -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): diff --git a/roles/wsgi_website/molecule/default/tests/test_default.py b/roles/wsgi_website/molecule/default/tests/test_default.py index 7eb82d3f26592055f45fb7cb5fe4a87dd31050f1..8ee813ee6eca141c64fd1d10fcbb92b4ac8e67b1 100644 --- a/roles/wsgi_website/molecule/default/tests/test_default.py +++ b/roles/wsgi_website/molecule/default/tests/test_default.py @@ -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", [ diff --git a/roles/wsgi_website/molecule/default/tests/test_parameters_paste_req.py b/roles/wsgi_website/molecule/default/tests/test_parameters_paste_req.py index b5a411a21ec754dbb791513b04d82f70bef7d57e..0fbfce9d8c07ee93bdb0eb99569081e8511749bc 100644 --- a/roles/wsgi_website/molecule/default/tests/test_parameters_paste_req.py +++ b/roles/wsgi_website/molecule/default/tests/test_parameters_paste_req.py @@ -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): diff --git a/roles/xmpp_server/molecule/default/tests/test_default.py b/roles/xmpp_server/molecule/default/tests/test_default.py index b7f45eefe72a49f45f31046e768bb7894397ffba..ddb8e6ebd0efcdc6c9aaea31626438e1fd6c8d2f 100644 --- a/roles/xmpp_server/molecule/default/tests/test_default.py +++ b/roles/xmpp_server/molecule/default/tests/test_default.py @@ -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): diff --git a/roles/xmpp_server/molecule/default/tests/test_mandatory.py b/roles/xmpp_server/molecule/default/tests/test_mandatory.py index 5eafca54935d747d685c8befd9b82f9deb5a6d5f..6557d53c49a613cb460a05418502dcac1e3b0563 100644 --- a/roles/xmpp_server/molecule/default/tests/test_mandatory.py +++ b/roles/xmpp_server/molecule/default/tests/test_mandatory.py @@ -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): diff --git a/roles/xmpp_server/molecule/default/tests/test_optional.py b/roles/xmpp_server/molecule/default/tests/test_optional.py index 9b4012eaf7f6ed84f21b506921a09abe7825daec..abfd7c6d423c58d3f7cb4f454cb6992c6d76a401 100644 --- a/roles/xmpp_server/molecule/default/tests/test_optional.py +++ b/roles/xmpp_server/molecule/default/tests/test_optional.py @@ -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):