diff --git a/roles/mail_server/tests/test_default.py b/roles/mail_server/tests/test_default.py index f9ea63cbe30847bc029d0ca1370f26338949b8c2..eb0709dd01a57b25ffeb95b22daaddcf8bf13035 100644 --- a/roles/mail_server/tests/test_default.py +++ b/roles/mail_server/tests/test_default.py @@ -327,13 +327,14 @@ def test_clamav_database_presence(File): Tests if ClamAV database is present. """ - for database_file in ["/var/lib/clamav/bytecode.cvd", - "/var/lib/clamav/daily.cld", - "/var/lib/clamav/main.cvd"]: + for database_file in ["/var/lib/clamav/bytecode", + "/var/lib/clamav/daily", + "/var/lib/clamav/main"]: - database = File(database_file) + database_cvd = File(database_file + '.cvd') + database_cld = File(database_file + '.cld') - assert database.is_file + assert database_cvd.is_file or database_cld.is_file def test_firewall_configuration_file(File, Sudo): diff --git a/roles/mail_server/tests/test_mandatory.py b/roles/mail_server/tests/test_mandatory.py index 01eff428f55973503d33e8f8e196a2793d1317bd..315c5cc6a1cc6835719d163183f9c84b2778cf39 100644 --- a/roles/mail_server/tests/test_mandatory.py +++ b/roles/mail_server/tests/test_mandatory.py @@ -87,11 +87,18 @@ def test_postfix_main_cf_file_content(File): assert "reject_rbl" not in config_lines -def test_dovecot_mailbox_directories(File, Sudo): +def test_dovecot_mailbox_directories(Command, File, Sudo): """ Tests if mailbox directories are created correctly. """ + # Deliver two mails in order to make sure the directory structure is + # created. + send = Command('swaks --suppress-data --to john.doe@domain1 --server localhost') + assert send.rc == 0 + send = Command('swaks --suppress-data --to jane.doe@domain2 --server localhost') + assert send.rc == 0 + with Sudo(): for directory_path in ["/var/vmail/domain1", @@ -99,7 +106,7 @@ def test_dovecot_mailbox_directories(File, Sudo): "/var/vmail/domain1/john.doe/Maildir", "/var/vmail/domain2", "/var/vmail/domain2/jane.doe", - "/var/vmail/domain1/john.doe/Maildir"]: + "/var/vmail/domain2/jane.doe/Maildir"]: directory = File(directory_path) diff --git a/roles/mail_server/tests/test_optional.py b/roles/mail_server/tests/test_optional.py index abe076746d7f5af29e57fe0d17d3abcf89c00757..d6954ab278efb07f4b50b2205df65315cf72e17e 100644 --- a/roles/mail_server/tests/test_optional.py +++ b/roles/mail_server/tests/test_optional.py @@ -106,11 +106,18 @@ def test_local_aliases(Command, File, Sudo): assert re.search(pattern, mail_log.content) is not None -def test_dovecot_mailbox_directories(File, Sudo): +def test_dovecot_mailbox_directories(File, Command, Sudo): """ Tests if mailbox directories are created correctly. """ + # Deliver two mails in order to make sure the directory structure is + # created. + send = Command('swaks --suppress-data --to john.doe@domain1 --server localhost') + assert send.rc == 0 + send = Command('swaks --suppress-data --to jane.doe@domain2 --server localhost') + assert send.rc == 0 + with Sudo(): for directory_path in ["/var/virtmail/domain1", @@ -118,7 +125,7 @@ def test_dovecot_mailbox_directories(File, Sudo): "/var/virtmail/domain1/john.doe/Maildir", "/var/virtmail/domain2", "/var/virtmail/domain2/jane.doe", - "/var/virtmail/domain1/john.doe/Maildir"]: + "/var/virtmail/domain2/jane.doe/Maildir"]: directory = File(directory_path)