Changeset - 24033bb8b1a5
[Not reviewed]
0 2 1
Branko Majic (branko) - 3 years ago 2020-11-22 15:19:43
branko@majic.rs
MAR-173: Added test for validating the list of enabled modules in Prosody.
3 files changed with 67 insertions and 1 deletions:
0 comments (0 inline, 0 general)
roles/xmpp_server/molecule/default/files/list_prosody_modules.lua
Show inline comments
 
new file 100644
 
#!/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
roles/xmpp_server/molecule/default/prepare.yml
Show inline comments
 
@@ -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
roles/xmpp_server/molecule/default/tests/test_default.py
Show inline comments
 
@@ -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.
0 comments (0 inline, 0 general)