Files
@ b68d19ad38a3
Branch filter:
Location: majic-ansible-roles/roles/mail_forwarder/tests/test_mandatory.py - annotation
b68d19ad38a3
2.0 KiB
text/x-python
MAR-33: Added initial scaffolding for wsgi_website tests:
- Added Molecule configuration file.
- Implemented test playbook that sets-up three separate instances of WSGI
website in order to test all variations of parameters.
- Added name for the set_fact task.
- Fixed linting errors related to mode that lacks leading zero.
- Added skip_ansible_lint tag for command that creates the Python virtual
environment.
- Added missing become keyword wherever become_user is specified.
- Fixed invalid parameter name for specifying if HTTPS should be enforced or
not.
- Added small initial sample WSGI apps that get deployed.
- Added static/media sample files.
- Added TLS material.
- Added initial dummy test file.
- Added Molecule configuration file.
- Implemented test playbook that sets-up three separate instances of WSGI
website in order to test all variations of parameters.
- Added name for the set_fact task.
- Fixed linting errors related to mode that lacks leading zero.
- Added skip_ansible_lint tag for command that creates the Python virtual
environment.
- Added missing become keyword wherever become_user is specified.
- Fixed invalid parameter name for specifying if HTTPS should be enforced or
not.
- Added small initial sample WSGI apps that get deployed.
- Added static/media sample files.
- Added TLS material.
- Added initial dummy test file.
f774e938a4ed 01f4b619cfa6 f774e938a4ed f774e938a4ed f774e938a4ed f774e938a4ed f774e938a4ed f774e938a4ed f774e938a4ed f774e938a4ed f774e938a4ed f774e938a4ed f774e938a4ed f774e938a4ed f774e938a4ed f774e938a4ed f774e938a4ed f774e938a4ed f774e938a4ed f774e938a4ed f774e938a4ed f774e938a4ed f774e938a4ed f774e938a4ed f774e938a4ed f774e938a4ed f774e938a4ed f774e938a4ed f774e938a4ed f774e938a4ed f774e938a4ed f774e938a4ed f774e938a4ed f774e938a4ed f774e938a4ed f774e938a4ed f774e938a4ed f774e938a4ed f774e938a4ed f774e938a4ed f774e938a4ed f774e938a4ed f774e938a4ed f774e938a4ed f774e938a4ed f774e938a4ed f774e938a4ed f774e938a4ed f774e938a4ed f774e938a4ed f774e938a4ed f774e938a4ed f774e938a4ed f774e938a4ed f774e938a4ed f774e938a4ed f774e938a4ed f774e938a4ed 01f4b619cfa6 01f4b619cfa6 01f4b619cfa6 f774e938a4ed f774e938a4ed f774e938a4ed f774e938a4ed f774e938a4ed | import re
import time
import testinfra.utils.ansible_runner
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
'.molecule/ansible_inventory').get_hosts('parameters-mandatory')
def test_smtp_relay_truststore_file(File):
"""
Tests if SMTP relay truststore has correct content.
"""
truststore = File('/etc/ssl/certs/smtp_relay_truststore.pem')
assert truststore.content == open("tests/data/x509/truststore.pem", "r").read().rstrip()
def test_smtp_mailname(File):
"""
Tests if SMTP mailname configuration file has correct content.
"""
mailname = File('/etc/mailname')
assert mailname.content == "parameters-mandatory"
def test_postfix_main_cf_file_content(File):
"""
Tests if the Postfix main configuration file content is correct.
"""
config = File('/etc/postfix/main.cf')
config_lines = config.content.split("\n")
assert "myhostname = parameters-mandatory" in config_lines
assert "mydestination = parameters-mandatory, parameters-mandatory, localhost.localdomain, localhost" 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_host_lookup = dns, native" in config_lines
def test_direct_mail_sending(Command, File, Sudo):
"""
Tests if mails are sent correctly directly without relay if relay has not
been configured.
"""
send = Command('swaks --suppress-data --to root@domain1 --server localhost')
assert send.rc == 0
message_id = re.search('Ok: queued as (.*)', send.stdout).group(1)
# Wait for a little while for message to be processed.
time.sleep(5)
with Sudo():
mail_log = File('/var/log/mail.log')
pattern = "%s: to=<root@domain1>, relay=domain1.*status=sent" % message_id
assert re.search(pattern, mail_log.content) is not None
|