Changeset - 44d578f5e1f3
[Not reviewed]
0 3 0
Branko Majic (branko) - 7 years ago 2017-07-05 10:27:00
branko@majic.rs
MAR-28: Minor fixes for mail_server tests:

- Take into account different extension for ClamAV database (cvd or cld) that
could happen in cases where the test VM has been running for a long time.
- Before checking Dovecot directory permissions, make sure to send out at least
two mails so the directory structure will get created.
- Fixed incorrect directory path for testing Dovecot directory permissions.
3 files changed with 24 insertions and 9 deletions:
0 comments (0 inline, 0 general)
roles/mail_server/tests/test_default.py
Show inline comments
 
@@ -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):
roles/mail_server/tests/test_mandatory.py
Show inline comments
 
@@ -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)
 

	
roles/mail_server/tests/test_optional.py
Show inline comments
 
@@ -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)
 

	
0 comments (0 inline, 0 general)