diff --git a/roles/xmpp_server/molecule/default/files/list_prosody_modules.lua b/roles/xmpp_server/molecule/default/files/list_prosody_modules.lua new file mode 100644 index 0000000000000000000000000000000000000000..f5134b2fc6b2ce5810fe2bbb541a8034b533ca05 --- /dev/null +++ b/roles/xmpp_server/molecule/default/files/list_prosody_modules.lua @@ -0,0 +1,25 @@ +#!/usr/bin/env lua + +-- Override deault package path to include the Prosody configuration +-- files. +package.path = '/etc/prosody/?.cfg.lua;' .. package.path + +-- Declare a couple of dummy functions to deal with function +-- invocations in Prosody configuration file. Dirty hack to avoid +-- errors about undefined functions. +function VirtualHost(...) +end + +function Component(...) + return function() end +end + +-- Read the configuration file (essentially running it as Lua code). +require "prosody" + +-- Sort the modules and output them, one per line. +table.sort(modules_enabled) + +for _, module in ipairs(modules_enabled) do + print(module) +end diff --git a/roles/xmpp_server/molecule/default/prepare.yml b/roles/xmpp_server/molecule/default/prepare.yml index a3ba13b58393df2d5305e500bec1f0520c8f5952..684bfa9dcb79cb6d9562fe1d1622214a29ce0edf 100644 --- a/roles/xmpp_server/molecule/default/prepare.yml +++ b/roles/xmpp_server/molecule/default/prepare.yml @@ -232,7 +232,7 @@ - uid=jane,ou=people,dc=local - uid=mick,ou=people,dc=local -- hosts: parameters-optional +- hosts: parameters-mandatory,parameters-optional become: true tasks: @@ -240,3 +240,11 @@ apt: name: sendxmpp state: present + + - name: Deploy small Lua script for listing the enabled modules in Prosody + copy: + src: list_prosody_modules.lua + dest: "/usr/local/bin/list_prosody_modules.lua" + owner: root + group: root + mode: 0755 diff --git a/roles/xmpp_server/molecule/default/tests/test_default.py b/roles/xmpp_server/molecule/default/tests/test_default.py index d2c12d490cd3f4ef1d6cb2705d7df39f88bbbc75..4223b36f22982762ce29c6f20a14086b5b379821 100644 --- a/roles/xmpp_server/molecule/default/tests/test_default.py +++ b/roles/xmpp_server/molecule/default/tests/test_default.py @@ -284,6 +284,39 @@ def test_prosody_configuration_validity(host): assert check_config.rc == 0, check_config.stdout +def test_enabled_modules(host): + """ + Tests if correct modules have been enabled. + """ + + expected_modules = [ + "admin_adhoc", + "announce", + "dialback", + "disco", + "legacyauth", + "pep", + "ping", + "posix", + "private", + "register", + "roster", + "saslauth", + "time", + "tls", + "uptime", + "vcard", + "version", + ] + + with host.sudo(): + module_list_command = host.run("/usr/local/bin/list_prosody_modules.lua") + + enabled_modules = sorted(module_list_command.stdout.strip().splitlines()) + + assert enabled_modules == expected_modules + + # @TODO: Tests which were not implemented due to lack of out-of-box tools: # # - Proxy capability.