diff --git a/roles/xmpp_server/molecule/default/molecule.yml b/roles/xmpp_server/molecule/default/molecule.yml index b800f059efef57644141854c4884723ffd9a4093..058d724fa79b3d451f36d54f211fe8beaf44eea2 100644 --- a/roles/xmpp_server/molecule/default/molecule.yml +++ b/roles/xmpp_server/molecule/default/molecule.yml @@ -38,7 +38,11 @@ platforms: groups: - clients - bullseye - box: debian/bullseye64 + # Use Bookworm client box for testing Bullseye servers to avoid + # duplication of test code in test_client.py due to missing + # functional build of go-sendxmpp for the Bullseye release (glibc + # mismatch in prebuilt package). + box: debian/bookworm64 memory: 256 cpus: 1 provider_raw_config_args: diff --git a/roles/xmpp_server/molecule/default/prepare.yml b/roles/xmpp_server/molecule/default/prepare.yml index cddfe31b7ecbbd8f820eba30cee0bd60a8f4996a..62187af3f9d3e10025beb642832b9b024a2bb50f 100644 --- a/roles/xmpp_server/molecule/default/prepare.yml +++ b/roles/xmpp_server/molecule/default/prepare.yml @@ -183,7 +183,7 @@ - name: Install console-based XMPP tool (for non-interactive testing) apt: - name: sendxmpp + name: go-sendxmpp state: present - name: Create dedicated group for testing @@ -308,8 +308,10 @@ - name: Install console-based XMPP tool (for non-interactive testing) apt: - name: sendxmpp + name: "{{ sendxmpp_package }}" state: present + vars: + sendxmpp_package: "{% if ansible_distribution_release == 'bullseye' %}sendxmpp{% else %}go-sendxmpp{% endif %}" - name: Deploy small Lua script for listing the enabled modules in Prosody copy: diff --git a/roles/xmpp_server/molecule/default/tests/test_backup.py b/roles/xmpp_server/molecule/default/tests/test_backup.py index 3c314f7b84133a18558d4770e2217b40bda5494d..1b27ff1455c629e956d212ce860611b18a0335bf 100644 --- a/roles/xmpp_server/molecule/default/tests/test_backup.py +++ b/roles/xmpp_server/molecule/default/tests/test_backup.py @@ -12,15 +12,30 @@ def test_backup(host): Tests if Prosody data directory is correctly backed-up. """ - # Deliver a couple of messages in order to make sure the directory structure - # is created. - send = host.run("echo 'Hello' | sendxmpp --tls-ca-path /usr/local/share/ca-certificates/testca.crt " - "-t -u jane.doe -p janepassword -j domain2:5222 jane.doe@domain2") - assert send.rc == 0 - - send = host.run("echo 'Hello' | sendxmpp --tls-ca-path /usr/local/share/ca-certificates/testca.crt " - "-t -u mick.doe -p mickpassword -j domain3:5222 mick.doe@domain3") - assert send.rc == 0 + distribution_release = host.ansible("setup")["ansible_facts"]["ansible_distribution_release"] + + # Ugly, but functional for now. + if distribution_release == "bullseye": + # Deliver a couple of messages in order to make sure the directory structure + # is created. + send = host.run("echo 'Hello' | sendxmpp --tls-ca-path /usr/local/share/ca-certificates/testca.crt " + "-t -u jane.doe -p janepassword -j domain2:5222 jane.doe@domain2") + assert send.rc == 0 + + send = host.run("echo 'Hello' | sendxmpp --tls-ca-path /usr/local/share/ca-certificates/testca.crt " + "-t -u mick.doe -p mickpassword -j domain3:5222 mick.doe@domain3") + assert send.rc == 0 + else: + send = host.run(f"echo 'Hello' | go-sendxmpp --debug " + f"--username jane.doe@domain2 --password janepassword --jserver domain2:5222 " + f"jane.doe@domain2") + assert send.rc == 0 + + send = host.run(f"echo 'Hello' | go-sendxmpp --debug " + f"--username mick.doe@domain3 --password mickpassword --jserver domain3:5222 " + f"mick.doe@domain3") + assert send.rc == 0 + with host.sudo(): diff --git a/roles/xmpp_server/molecule/default/tests/test_client.py b/roles/xmpp_server/molecule/default/tests/test_client.py index c2b8cc3151d5b2edcd19c498d56bceeee790f0d0..372d5fd364ce7ba00e0436a7a7dd804f140298d3 100644 --- a/roles/xmpp_server/molecule/default/tests/test_client.py +++ b/roles/xmpp_server/molecule/default/tests/test_client.py @@ -34,13 +34,17 @@ def test_tls(host, username, password, domain): Tests if TLS works as expected. """ - send = host.run(f"echo 'Hello' | sendxmpp --tls-ca-path /usr/local/share/ca-certificates/testca.crt " - f"-t -u {username} -p {password} -j {domain}:5222 {username}@{domain}") + send = host.run(f"echo 'Hello' | go-sendxmpp --debug " + f"--username {username}@{domain} --password {password} --jserver {domain}:5222 " + f"{username}@{domain}") assert send.rc == 0 + assert "Hello" in send.stderr - send = host.run(f"echo 'Hello' | sendxmpp --tls-ca-path /usr/local/share/ca-certificates/testca.crt " - f"-e -u {username} -p {password} -j {domain}:5223 {username}@{domain}") + send = host.run(f"echo 'Hello' | go-sendxmpp --debug --tls " + f"--username {username}@{domain} --password {password} --jserver {domain}:5223 " + f"{username}@{domain}") assert send.rc == 0 + assert "Hello" in send.stderr @pytest.mark.parametrize("username, password, domain", [ @@ -49,12 +53,15 @@ def test_tls(host, username, password, domain): ]) def test_authentication_requires_tls(host, username, password, domain): """ - Tests if authentication must be done over TLS. + Tests if STARTTLS is required. """ - command = host.run(f"echo 'Hello' | sendxmpp --tls-ca-path /usr/local/share/ca-certificates/testca.crt " - f"-u {username} -p {password} -j {domain}:5222 {username}@{domain} -d") - assert "" in command.stderr + send = host.run(f"echo 'Hello' | go-sendxmpp --debug " + f"--username {username}@{domain} --password {password} --jserver {domain}:5222 " + f"{username}@{domain}") + + assert send.rc == 0 + assert "" in send.stderr @pytest.mark.parametrize("username, password, domain", [ @@ -67,12 +74,14 @@ def test_authentication(host, username, password, domain): Tests if authentication works correctly. """ - send = host.run(f"echo 'Hello' | sendxmpp --tls-ca-path /usr/local/share/ca-certificates/testca.crt " - f"-t -u {username} -p {password} -j {domain}:5222 {username}@{domain}") + send = host.run(f"echo 'Hello' | go-sendxmpp --debug " + f"--username {username}@{domain} --password {password} --jserver {domain}:5222 " + f"{username}@{domain}") assert send.rc == 0 - send = host.run(f"echo 'Hello' | sendxmpp --tls-ca-path /usr/local/share/ca-certificates/testca.crt " - f"-e -u {username} -p {password} -j {domain}:5223 {username}@{domain}") + send = host.run(f"echo 'Hello' | go-sendxmpp --debug --tls " + f"--username {username}@{domain} --password {password} --jserver {domain}:5223 " + f"{username}@{domain}") assert send.rc == 0 @@ -86,7 +95,8 @@ def test_unauthorized_users_rejected(host, target_username, target_domain): group) are rejected from accessing the XMPP server. """ - send = host.run(f"echo 'Hello' | sendxmpp --tls-ca-path /usr/local/share/ca-certificates/testca.crt " - f"-t -u noxmpp -p noxmpppassword -j {target_domain}:5222 {target_username}@{target_domain}") + send = host.run(f"echo 'Hello' | go-sendxmpp --debug " + f"--username noxmpp@{target_domain} --password noxmpppassword --jserver {target_domain}:5222 " + f"{target_username}@{target_domain}") assert send.rc != 0 - assert "Error 'AuthSend': error: not-authorized[?]" in send.stderr + assert "Unable to authorize you with the authentication credentials you've sent" in send.stderr