Files
@ b68d19ad38a3
Branch filter:
Location: majic-ansible-roles/roles/xmpp_server/tests/test_client.py - annotation
b68d19ad38a3
2.7 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.
da031f975c67 da031f975c67 da031f975c67 da031f975c67 da031f975c67 da031f975c67 da031f975c67 da031f975c67 da031f975c67 da031f975c67 da031f975c67 da031f975c67 da031f975c67 da031f975c67 da031f975c67 da031f975c67 da031f975c67 da031f975c67 da031f975c67 da031f975c67 da031f975c67 da031f975c67 da031f975c67 da031f975c67 da031f975c67 da031f975c67 da031f975c67 da031f975c67 da031f975c67 da031f975c67 da031f975c67 da031f975c67 da031f975c67 da031f975c67 da031f975c67 da031f975c67 da031f975c67 da031f975c67 da031f975c67 da031f975c67 da031f975c67 da031f975c67 da031f975c67 da031f975c67 da031f975c67 da031f975c67 da031f975c67 da031f975c67 da031f975c67 da031f975c67 da031f975c67 da031f975c67 da031f975c67 da031f975c67 da031f975c67 da031f975c67 da031f975c67 da031f975c67 da031f975c67 da031f975c67 da031f975c67 da031f975c67 da031f975c67 da031f975c67 da031f975c67 da031f975c67 da031f975c67 da031f975c67 da031f975c67 da031f975c67 da031f975c67 da031f975c67 da031f975c67 da031f975c67 da031f975c67 da031f975c67 da031f975c67 da031f975c67 da031f975c67 da031f975c67 | import testinfra.utils.ansible_runner
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
'.molecule/ansible_inventory').get_hosts('client1')
def test_connectivity(Command, Sudo):
"""
Tests connectivity to the XMPP server (ports that should be reachable).
"""
with Sudo():
for server in ["parameters-mandatory",
"parameters-optional"]:
# c2s plaintext, c2s TLS, file proxy, s2s.
for port in [5222, 5223, 5000, 5269]:
ping = Command('hping3 -S -p %d -c 1 %s' % (port, server))
assert ping.rc == 0
def test_tls(Command):
"""
Tests if TLS works as expected.
"""
send = Command("echo 'Hello' | sendxmpp -t -u john.doe -p johnpassword -j domain1:5222 john.doe@domain1")
assert send.rc == 0
send = Command("echo 'Hello' | sendxmpp -e -u john.doe -p johnpassword -j domain1:5223 john.doe@domain1")
assert send.rc == 0
send = Command("echo 'Hello' | sendxmpp -t -u jane.doe -p janepassword -j domain2:5222 jane.doe@domain2")
assert send.rc == 0
send = Command("echo 'Hello' | sendxmpp -e -u jane.doe -p janepassword -j domain2:5223 jane.doe@domain2")
assert send.rc == 0
def test_authentication_requires_tls(Command):
"""
Tests if authentication must be done over TLS.
"""
command = Command("echo 'Hello' | sendxmpp -u bogus -p bogus -j domain1:5222 john.doe@domain1 -d")
assert "<starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'><required/></starttls>" in command.stderr
command = Command("echo 'Hello' | sendxmpp -u bogus -p bogus -j domain2:5222 jane.doe@domain2 -d")
assert "<starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'><required/></starttls>" in command.stderr
def test_authentication(Command):
"""
Tests if authentication works correctly.
"""
send = Command("echo 'Hello' | sendxmpp -t -u john.doe -p johnpassword -j domain1:5222 john.doe@domain1")
assert send.rc == 0
send = Command("echo 'Hello' | sendxmpp -e -u john.doe -p johnpassword -j domain1:5223 john.doe@domain1")
assert send.rc == 0
send = Command("echo 'Hello' | sendxmpp -t -u jane.doe -p janepassword -j domain2:5222 jane.doe@domain2")
assert send.rc == 0
send = Command("echo 'Hello' | sendxmpp -e -u mick.doe -p mickpassword -j domain3:5223 mick.doe@domain3")
assert send.rc == 0
def test_unauthorized_users_rejected(Command):
"""
Tests if unauthorized users (present in LDAP, but not member of correct
group) are rejected from accessing the XMPP server.
"""
send = Command("echo 'Hello' | sendxmpp -t -u noxmpp -p noxmpppassword -j domain1:5222 john.doe@domain1")
assert send.rc != 0
assert "Error 'AuthSend': error: not-authorized[?]" in send.stderr
|