Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

test(prosody): split test config into extensible fragments (#17622)

bgrozevf6b24aac606e
diff --git a/resources/prosody-plugins/mod_muc_meeting_id.lua b/resources/prosody-plugins/mod_muc_meeting_id.lua
index 9e5a62e8e9..49a102a0b8 100644
--- a/resources/prosody-plugins/mod_muc_meeting_id.lua
+++ b/resources/prosody-plugins/mod_muc_meeting_id.lua
@@ -12,6 +12,7 @@ local uuid_gen = require "util.uuid".generate;
local main_util = module:require "util";
local is_admin = main_util.is_admin;
local is_focus = main_util.is_focus;
+local is_focus_jid = main_util.is_focus_jid;
local get_room_from_jid = main_util.get_room_from_jid;
local is_healthcheck_room = main_util.is_healthcheck_room;
local internal_room_jid_match_rewrite = main_util.internal_room_jid_match_rewrite;
@@ -206,25 +207,18 @@ local function filter_admin_set(event)
end
for item in query:childtags('item') do
- local target_nick;
-
- if item.attr.nick then
- -- role changes target the occupant nick
- target_nick = room.jid .. '/' .. item.attr.nick;
- elseif item.attr.jid then
- -- affiliation changes target the real jid, resolve the occupant
- local target_bare_jid = jid.bare(item.attr.jid);
- for _, occupant in room:each_occupant() do
- if occupant.bare_jid == target_bare_jid then
- target_nick = occupant.nick;
- break;
- end
- end
+ -- An item may carry a nick (role changes) and/or a jid (affiliation
+ -- changes). Prosody's own handler applies a role change by nick and an
+ -- affiliation change by jid, so both must be checked independently: a
+ -- decoy nick must not mask a jid that targets focus (and vice versa).
+ if item.attr.nick and is_focus(room.jid .. '/' .. item.attr.nick) then
+ module:log('warn', 'Blocking attempt to modify %s in room %s', item.attr.nick, room.jid);
+ origin.send(st.error_reply(stanza, 'cancel', 'not-allowed'));
+ return true;
end
- -- block any admin operation on that target
- if target_nick and is_focus(target_nick) then
- module:log('warn', 'Blocking attempt to modify %s in room %s', target_nick,room.jid);
+ if item.attr.jid and is_focus_jid(item.attr.jid) then
+ module:log('warn', 'Blocking attempt to modify %s in room %s', item.attr.jid, room.jid);
origin.send(st.error_reply(stanza, 'cancel', 'not-allowed'));
return true;
end
diff --git a/tests/prosody/README.md b/tests/prosody/README.md
index 316b5f1663..39a020ce60 100644
--- a/tests/prosody/README.md
+++ b/tests/prosody/README.md
@@ -109,7 +109,12 @@ tests/prosody/
├── docker/
│ ├── Dockerfile Prosody 13 image with lua-cjson + Jitsi plugins
│ ├── docker-compose.yml Exposes :5222 (XMPP) and :5280 (HTTP)
-│ └── prosody.cfg.lua Minimal config: anonymous auth, no TLS, MUC at conference.localhost
+│ ├── prosody.cfg.lua Top-level config: Includes the cfg/ fragments below
+│ └── cfg/ Config fragments (see prosody.cfg.lua header)
+│ ├── global.cfg.lua Global settings: no TLS, anonymous auth, HTTP on :5280
+│ ├── virtualhosts.cfg.lua All VirtualHost blocks
+│ ├── components.cfg.lua All Component blocks except conference.localhost
+│ └── conference.cfg.lua conference.localhost (separate so extending images can re-declare it)
│
├── helpers/
│ ├── container.js Holds the testcontainers container reference (set in setup.js)
@@ -163,3 +168,22 @@ export DOCKER_HOST=unix:///Users/$(whoami)/.colima/default/docker.sock
export TESTCONTAINERS_RYUK_DISABLED=true # Ryuk reaper fails under Colima
npm test
```
+
+## Extending from another repo
+
+Repos with private Prosody plugins (e.g. jitsi-meet-branding) can reuse this
+setup by building on top of the test image:
+
+```bash
+npm run build:test-image # builds jitsi-meet-prosody-test:latest
+```
+
+The extending image starts `FROM jitsi-meet-prosody-test:latest`, copies its
+plugins into an additional plugin path, and replaces
+`/etc/prosody/prosody.cfg.lua` with a config that Includes the baked-in
+`/etc/prosody/cfg/global.cfg.lua`, `virtualhosts.cfg.lua` and
+`components.cfg.lua` fragments, then re-declares `conference.localhost`
+(based on `cfg/conference.cfg.lua`) with the extra modules appended.
+Prosody Component blocks cannot be extended in place, which is why
+`conference.localhost` lives in its own fragment that extending configs
+replace wholesale.
diff --git a/tests/prosody/docker/Dockerfile b/tests/prosody/docker/Dockerfile
index ae5035da8c..6c38d61afb 100644
--- a/tests/prosody/docker/Dockerfile
+++ b/tests/prosody/docker/Dockerfile
@@ -38,6 +38,7 @@ COPY --chown=prosody:prosody resources/prosody-plugins/ /opt/prosody-jitsi-plugi
COPY --chown=prosody:prosody tests/prosody/docker/inspect.lua /opt/prosody-jitsi-plugins/inspect.lua
COPY --chown=prosody:prosody tests/prosody/docker/prosody.cfg.lua /etc/prosody/prosody.cfg.lua
+COPY --chown=prosody:prosody tests/prosody/docker/cfg/ /etc/prosody/cfg/
# Test ASAP public keys — served by mod_test_observer_http for RS256 token verification tests.
# Two separate key pairs are used: one for login tokens (mod_auth_token) and one for system
diff --git a/tests/prosody/docker/cfg/components.cfg.lua b/tests/prosody/docker/cfg/components.cfg.lua
new file mode 100644
index 0000000000..c4f7f22d1d
--- /dev/null
+++ b/tests/prosody/docker/cfg/components.cfg.lua
@@ -0,0 +1,113 @@
+-- Component blocks fragment (all Components except conference.localhost).
+-- See prosody.cfg.lua for the fragment layout.
+
+Component "lobby.conference.localhost" "muc"
+ storage = "memory"
+ muc_room_cache_size = 1000
+ restrict_room_creation = true
+ muc_room_locking = false
+ muc_room_default_public_jids = true
+
+-- Internal MUC used by mod_muc_jigasi_invite: the module resolves the Jigasi
+-- brewery room from this component via process_host_module. Without this
+-- component main_muc_service would remain nil and requests that reach the
+-- invite_jigasi() path would crash instead of returning 404.
+Component "internal.auth.localhost" "muc"
+
+-- Minimal MUC component used to test mod_muc_filter_access in isolation.
+-- Only clients from whitelist.localhost are permitted to join rooms here.
+Component "conference-internal.localhost" "muc"
+ modules_enabled = {
+ "muc_filter_access";
+ }
+ muc_filter_whitelist = { "whitelist.localhost" }
+
+-- Component for mod_end_conference tests. Clients send a message stanza with
+-- an <end_conference/> child to this component; the module looks up the room
+-- from the sender's jitsi_web_query_room session field (set by mod_jitsi_session
+-- from the ?room= WebSocket URL param) and destroys it if the sender is a
+-- moderator occupant.
+Component "endconference.localhost" "end_conference"
+ muc_component = "conference.localhost"
+ muc_mapper_domain_base = "localhost"
+ muc_mapper_domain_prefix = "conference"
+
+-- MUC component for mod_muc_rate_limit integration tests.
+-- Intentionally low join/leave rates (1/s) so that 5 simultaneous clients
+-- exercise the queuing and timer logic without long waits.
+Component "rate-limited.localhost" "muc"
+ modules_enabled = { "muc_rate_limit" }
+ muc_rate_joins = 1
+ muc_rate_leaves = 1
+
+-- Metadata component for mod_room_metadata_component tests.
+Component "metadata.localhost" "room_metadata_component"
+ muc_component = "conference.localhost"
+ muc_mapper_domain_base = "localhost"
+ muc_mapper_domain_prefix = "conference"
+
+-- Component for mod_filesharing_component tests. Clients send file-sharing
+-- messages here; the component looks up the room from jitsi_web_query_room
+-- (set by mod_jitsi_session) and broadcasts add/remove notifications.
+Component "filesharing.localhost" "filesharing_component"
+ muc_component = "conference.localhost"
+ muc_mapper_domain_base = "localhost"
+ muc_mapper_domain_prefix = "conference"
+
+-- Component for mod_audio_translation_component tests. Receivers send
+-- <audio-translation> messages here; the component aggregates per-receiver
+-- subscriptions and exposes the map to jicofo via room._data.audioTranslationRequests
+-- (forwarded by mod_room_metadata_component on the metadata.localhost component).
+Component "audiotranslation.localhost" "audio_translation_component"
+ muc_component = "conference.localhost"
+ muc_mapper_domain_base = "localhost"
+ muc_mapper_domain_prefix = "conference"
+ -- Short debounce so tests don't wait long for the aggregate broadcast.
+ audio_translation_debounce_interval = 0.1
+ -- Low limit so the per-receiver cap is exercised without many subscriptions.
+ audio_translation_max_subscriptions = 3
+
+-- Component for mod_polls_component tests. The module hooks message/host for
+-- new-poll / answer-poll json-messages, keeps per-room poll state (installed on
+-- conference.localhost via process_host_module) and re-broadcasts poll updates
+-- to all occupants. The sender must be an occupant of the room, located from
+-- jitsi_web_query_room (set by mod_jitsi_session from the ?room= param).
+Component "polls.localhost" "polls_component"
+ muc_mapper_domain_base = "localhost"
+ muc_mapper_domain_prefix = "conference"
+
+-- Plain MUC for mod_presence_identity tests. No token verification and no
+-- muc_meeting_id lock so any client can join freely without focus.
+Component "conference-identity.localhost" "muc"
+
+-- Isolated MUC component for mod_muc_wait_for_host tests.
+-- No muc_meeting_id, so no jicofo lock — a JWT-authenticated client can join
+-- directly as host without focus unlocking the room first.
+-- muc_mapper_domain_base is set to "conference.localhost" so that:
+-- lobby_muc_component_config = "lobby." .. "conference.localhost"
+-- = "lobby.conference.localhost" (already configured above)
+-- This means the existing lobby component is reused for the lobby rooms created
+-- by this component, and no additional lobby MUC component is needed.
+Component "conference-waitforhost.localhost" "muc"
+ storage = "memory"
+ modules_enabled = {
+ "muc_wait_for_host";
+ }
+ muc_mapper_domain_base = "conference.localhost"
+ muc_mapper_domain_prefix = "conference"
+
+-- Isolated MUC component for mod_muc_allowners tests.
+-- No muc_meeting_id (no jicofo lock) and no token_verification, so anonymous
+-- clients can join freely. In non-moderated rooms every occupant is promoted
+-- to owner on join and muc#admin set stanzas revoking affiliations are
+-- rejected. Room names listed in allowners_moderated_rooms are moderated:
+-- only JWT-authenticated users with a matching room claim are promoted and
+-- the revoke filtering is skipped.
+Component "conference-allowners.localhost" "muc"
+ storage = "memory"
+ modules_enabled = {
+ "muc_allowners";
+ }
+ muc_mapper_domain_base = "localhost"
+ muc_mapper_domain_prefix = "conference"
+ allowners_moderated_rooms = { "moderated-room-1"; "moderated-room-2" }
diff --git a/tests/prosody/docker/cfg/conference.cfg.lua b/tests/prosody/docker/cfg/conference.cfg.lua
new file mode 100644
index 0000000000..f9dd1bb37e
--- /dev/null
+++ b/tests/prosody/docker/cfg/conference.cfg.lua
@@ -0,0 +1,72 @@
+-- conference.localhost fragment. See prosody.cfg.lua for the fragment layout.
+--
+-- Kept in its own fragment so that extending environments (e.g. the
+-- jitsi-meet-branding private plugins) can skip this Include and re-declare
+-- the component with extra modules appended. Keep this block self-contained:
+-- everything conference.localhost needs must live in this file.
+
+Component "conference.localhost" "muc"
+ -- Module order follows prod (conference.8x8.vc) so that same-priority hook
+ -- execution order matches production. Test-only modules are inserted at
+ -- sensible positions relative to the shared modules they interact with.
+ modules_enabled = {
+ "muc_hide_all";
+ "token_verification"; -- prod pos 2: gate check runs before meeting-id / password logic
+ "muc_max_occupants";
+ "muc_resource_validate"; -- test-only: occupant gate, alongside muc_max_occupants
+ "muc_password_whitelist";
+ "token_affiliation"; -- test-only: reads auth_token set by token_verification above
+ "muc_meeting_id"; -- prod pos 9: after gate checks
+ "muc_flip";
+ "test_observer"; -- test-only
+ "filter_messages";
+ "muc_displayname"; -- prod pos 21: after filter_messages
+ -- mod_muc_limit_messages registers its message/bare hook at priority -1
+ -- (below the default 0 used by filter_messages), so filter_messages
+ -- always fires first. Messages it blocks (return true) never reach
+ -- muc_limit_messages and do not count toward the per-room cap.
+ "muc_limit_messages";
+ -- Destroys a room after a short timeout when only Jibri/transcriber remain.
+ "muc_cleanup_backend_services";
+ }
+
+ anonymous_strict = true
+
+ -- Same as prod: only Prosody admins (jicofo, i.e. [email protected]) may
+ -- create a room. Regular clients (anonymous or JWT) can only join a room
+ -- that focus has already created.
+ restrict_room_creation = true
+
+ -- Used by mod_muc_max_occupants tests (2 occupants max).
+ muc_max_occupants = 2
+
+ -- Clients on whitelist.localhost bypass the occupant limit.
+ -- Clients on auth.localhost are the focus (jicofo) admin; they also bypass
+ -- the limit and are not counted against it.
+ -- Clients on recorder.localhost are Jibri/transcriber accounts; they bypass
+ -- token_verification (is_jibri / is_transcriber JID prefix checks still apply).
+ muc_access_whitelist = { "whitelist.localhost", "auth.localhost", "recorder.localhost" }
+
+ -- Used by mod_muc_password_whitelist tests: clients from whitelist.localhost
+ -- are injected with the room password and bypass the password check.
+ muc_password_whitelist = { "whitelist.localhost" }
+
+ -- Required by util.lib.lua domain-mapping helpers and mod_jitsi_permissions.
+ muc_mapper_domain_base = "localhost"
+ muc_mapper_domain_prefix = "conference"
+
+ -- [email protected] is a Prosody admin and is therefore exempt from
+ -- token_verification on both muc-room-pre-create and muc-occupant-pre-join,
+ -- mirroring production where jicofo is a Prosody admin.
+
+ -- mod_muc_cleanup_backend_services: short timeout so tests don't wait 20 s.
+ services_empty_meeting_timeout = 1
+
+ -- mod_muc_limit_messages: cap per room and honour auth tokens.
+ muc_limit_messages_count = 3
+ muc_limit_messages_check_token = true
+
+ -- Blocks unauthenticated users from sending room-owner config IQs
+ -- (muc#owner queries), which is how moderator status is granted to other
+ -- participants and how room configuration is changed.
+ token_verification_require_token_for_moderation = true
diff --git a/tests/prosody/docker/cfg/global.cfg.lua b/tests/prosody/docker/cfg/global.cfg.lua
new file mode 100644
index 0000000000..25710f180a
--- /dev/null
+++ b/tests/prosody/docker/cfg/global.cfg.lua
@@ -0,0 +1,58 @@
+-- Global settings fragment. See prosody.cfg.lua for the fragment layout.
+--
+-- Minimal Prosody config for integration testing.
+-- No TLS: tests connect plaintext over loopback.
+
+data_path = "/var/lib/prosody"
+pid_file = "/var/run/prosody/prosody.pid"
+
+plugin_paths = { "/usr/lib/prosody/modules", "/opt/prosody-jitsi-plugins" }
+
+log = {
+ { levels = { min = "debug" }, to = "console" };
+}
+
+-- No TLS module means no STARTTLS offered, so clients connect plaintext.
+modules_enabled = {
+ "saslauth";
+ "disco";
+ "ping";
+ "admin_shell";
+ "http";
+ "websocket";
+ "smacks";
+ -- Global HTTP API modules.
+ "muc_end_meeting";
+ -- Sets jitsi_web_query_room on sessions from the ?room= WebSocket URL param;
+ -- required by mod_end_conference to locate the target MUC room.
+ "jitsi_session";
+}
+
+-- Required by mod_muc_end_meeting (global module) to locate the MUC component
+-- and to attach its HTTP handler to the correct VirtualHost.
+muc_mapper_domain_base = "localhost"
+muc_mapper_domain_prefix = "conference"
+
+-- System token key server for mod_muc_end_meeting and similar HTTP API modules.
+-- These tokens are signed with a separate key pair from login tokens, providing
+-- key-level separation between user-facing and system-facing authentication.
+-- The endpoint is served by mod_test_observer_http at /test-observer/system-asap-keys/.
+prosody_password_public_key_repo_url = "http://localhost:5280/test-observer/system-asap-keys"
+
+-- Allow WebSocket connections without TLS (tests run over loopback).
+consider_websocket_secure = true
+
+c2s_require_encryption = false
+s2s_require_encryption = false
+allow_unencrypted_plain_auth = true
+
+-- HTTP server for mod_test_observer_http endpoints.
+-- Disable HTTPS so all HTTP routes land on port 5280 (not 5281).
+http_ports = { 5280 }
+http_interfaces = { "*" }
+https_ports = {}
+
+-- The focus (jicofo) test helper authenticates as [email protected].
+-- Prosody admins are exempt from token_verification checks and are used as
+-- room owners, mirroring production where jicofo is a Prosody admin.
+admins = { "[email protected]" }
diff --git a/tests/prosody/docker/cfg/virtualhosts.cfg.lua b/tests/prosody/docker/cfg/virtualhosts.cfg.lua
new file mode 100644
index 0000000000..47d7e49187
--- /dev/null
+++ b/tests/prosody/docker/cfg/virtualhosts.cfg.lua
@@ -0,0 +1,125 @@
+-- VirtualHost blocks fragment. See prosody.cfg.lua for the fragment layout.
+
+VirtualHost "localhost"
+ authentication = "token"
+ app_id = "jitsi"
+ asap_key_server = "http://localhost:5280/test-observer/asap-keys"
+ signature_algorithm = "RS256"
+ allow_empty_token = true
+
+ -- Serve test_observer HTTP endpoints here so plain HTTP on port 5280 is
+ -- reachable. Component HTTP routes end up on HTTPS 5281 due to Prosody's
+ -- virtual-host routing, which does not match Host: localhost on port 5280.
+ modules_enabled = {
+ -- test-only: HTTP endpoints and census helpers
+ "test_observer_http";
+ "muc_size";
+ "muc_census";
+ -- Module order below follows prod (conference.8x8.vc VirtualHost) so that
+ -- same-priority hook execution order matches production.
+ -- Handles 'jitsi-add-identity' so components (room_metadata,
+ -- audio_translation, ...) can advertise a disco identity on this host.
+ "features_identity";
+ "conference_duration";
+ "filter_iq_rayo"; -- priority 1 on pre-iq/full; listed before filter_iq_jibri (matches prod)
+ "filter_iq_jibri";
+ "muc_lobby_rooms";
+ "jiconop";
+ "muc_kick_participant";
+ "muc_jigasi_invite";
+ -- Loaded here so that the global jitsi-access-ban-check event handler
+ -- is registered and mod_auth_token can fire it for token-authenticated
+ -- sessions. muc_prosody_jitsi_access_manager_url points at the mock
+ -- access manager served by mod_test_observer_http on the same host.
+ "muc_auth_ban";
+ -- test-only
+ "turncredentials_http";
+ -- Rewrites MUC JIDs between external subdomain form
+ -- ([email protected]) and internal bracket form
+ -- ([sub][email protected]) for all sessions on all hosts.
+ "muc_domain_mapper";
+ "persistent_lobby";
+ "system_chat_message";
+ -- test-only
+ "muc_password_check";
+ }
+
+ -- mod_muc_password_check: verify Bearer tokens with the login ASAP key server.
+ enable_password_token_verification = true
+
+ shard_name = "test-shard"
+ region_name = "test-region"
+ release_number = "test-release"
+
+ -- mod_turncredentials_http (HTTP via external_services): port 3479.
+ external_services = {
+ { type = "stun", host = "127.0.0.1", port = 3479 };
+ { type = "turn", host = "127.0.0.1", port = 3479, secret = "http-turn-secret" };
+ }
+
+ -- Required by mod_muc_auth_ban: URL of the access manager to call.
+ -- Points at the mock endpoint served by mod_test_observer_http.
+ muc_prosody_jitsi_access_manager_url = "http://localhost:5280/test-observer/access-manager"
+
+ -- Required by mod_test_observer_http to locate the shared MUC data.
+ muc_mapper_domain_base = "localhost"
+ muc_mapper_domain_prefix = "conference"
+
+ -- Required by mod_conference_duration to find the MUC component.
+ -- Required by mod_muc_lobby_rooms.
+ main_muc = "conference.localhost"
+ lobby_muc = "lobby.conference.localhost"
+
+ -- Clients on whitelist.localhost bypass the lobby.
+ muc_lobby_whitelist = { "whitelist.localhost" }
+
+-- VirtualHost for the focus (jicofo) test helper.
+-- Clients authenticate with username "focus" and password "focussecret".
+-- The account is pre-created in the Docker image (see Dockerfile).
+-- [email protected] is listed in the global admins table, so it is exempt
+-- from token_verification and can act as room owner on all MUC components.
+VirtualHost "auth.localhost"
+ authentication = "internal_hashed"
+ -- @xmpp/sasl (v0.13) does not await async SASL responses; the SCRAM-SHA-1
+ -- mechanism in sasl-scram-sha-1 1.4+ is async, so the client sends an
+ -- empty client-final message which Prosody rejects as malformed-request.
+ -- Disable SCRAM and force PLAIN (safe on loopback in the test environment).
+ disable_sasl_mechanisms = { "SCRAM-SHA-1", "SCRAM-SHA-1-PLUS", "SCRAM-SHA-256", "SCRAM-SHA-256-PLUS" }
+
+-- VirtualHost for Jibri (recorder) and transcriber accounts used by
+-- mod_muc_cleanup_backend_services tests. Accounts on this domain get JIDs whose
+-- bare form starts with 'recorder@recorder.' or 'transcriber@recorder.', satisfying
+-- is_jibri() and is_transcriber() respectively.
+-- recorder.localhost is added to muc_access_whitelist on the MUC component so
+-- these clients bypass token_verification without needing JWT tokens.
+VirtualHost "recorder.localhost"
+ authentication = "internal_hashed"
+ disable_sasl_mechanisms = { "SCRAM-SHA-1", "SCRAM-SHA-1-PLUS", "SCRAM-SHA-256", "SCRAM-SHA-256-PLUS" }
+
+-- VirtualHost for HS256 (shared-secret) token auth tests and mod_presence_identity tests.
+VirtualHost "hs256.localhost"
+ authentication = "token"
+ app_id = "jitsi"
+ app_secret = "testsecret"
+ signature_algorithm = "HS256"
+ allow_empty_token = false
+ modules_enabled = { "presence_identity" }
+
+-- Second VirtualHost whose domain is listed in muc_access_whitelist on the
+-- MUC component below. Clients connecting here get JIDs like
+-- <random>@whitelist.localhost and are treated as whitelisted.
+-- VirtualHost used by mod_auth_jitsi-anonymous tests.
+VirtualHost "jitsi-anonymous.localhost"
+ authentication = "jitsi-anonymous"
+
+-- VirtualHost used by mod_auth_jitsi-shared-secret tests.
+VirtualHost "shared-secret.localhost"
+ authentication = "jitsi-shared-secret"
+ shared_secret = "topsecret"
+ shared_secret_prev = "oldsecret"
+ -- Disable SCRAM so Prosody only offers PLAIN. SCRAM requires per-user key
+ -- derivation which is incompatible with a shared-secret auth provider.
+ disable_sasl_mechanisms = { "SCRAM-SHA-1", "SCRAM-SHA-1-PLUS" }
+
+VirtualHost "whitelist.localhost"
+ authentication = "anonymous"
diff --git a/tests/prosody/docker/prosody.cfg.lua b/tests/prosody/docker/prosody.cfg.lua
index 63bc6564a7..ebe6896efc 100644
--- a/tests/prosody/docker/prosody.cfg.lua
+++ b/tests/prosody/docker/prosody.cfg.lua
@@ -1,357 +1,20 @@
--- Minimal Prosody config for integration testing.
--- No TLS: tests connect plaintext over loopback.
-
-data_path = "/var/lib/prosody"
-pid_file = "/var/run/prosody/prosody.pid"
-
-plugin_paths = { "/usr/lib/prosody/modules", "/opt/prosody-jitsi-plugins" }
-
-log = {
- { levels = { min = "debug" }, to = "console" };
-}
-
--- No TLS module means no STARTTLS offered, so clients connect plaintext.
-modules_enabled = {
- "saslauth";
- "disco";
- "ping";
- "admin_shell";
- "http";
- "websocket";
- "smacks";
- -- Global HTTP API modules.
- "muc_end_meeting";
- -- Sets jitsi_web_query_room on sessions from the ?room= WebSocket URL param;
- -- required by mod_end_conference to locate the target MUC room.
- "jitsi_session";
-}
-
--- Required by mod_muc_end_meeting (global module) to locate the MUC component
--- and to attach its HTTP handler to the correct VirtualHost.
-muc_mapper_domain_base = "localhost"
-muc_mapper_domain_prefix = "conference"
-
--- System token key server for mod_muc_end_meeting and similar HTTP API modules.
--- These tokens are signed with a separate key pair from login tokens, providing
--- key-level separation between user-facing and system-facing authentication.
--- The endpoint is served by mod_test_observer_http at /test-observer/system-asap-keys/.
-prosody_password_public_key_repo_url = "http://localhost:5280/test-observer/system-asap-keys"
-
--- Allow WebSocket connections without TLS (tests run over loopback).
-consider_websocket_secure = true
-
-c2s_require_encryption = false
-s2s_require_encryption = false
-allow_unencrypted_plain_auth = true
-
--- HTTP server for mod_test_observer_http endpoints.
--- Disable HTTPS so all HTTP routes land on port 5280 (not 5281).
-http_ports = { 5280 }
-http_interfaces = { "*" }
-https_ports = {}
-
--- The focus (jicofo) test helper authenticates as [email protected].
--- Prosody admins are exempt from token_verification checks and are used as
--- room owners, mirroring production where jicofo is a Prosody admin.
-admins = { "[email protected]" }
-
-VirtualHost "localhost"
- authentication = "token"
- app_id = "jitsi"
- asap_key_server = "http://localhost:5280/test-observer/asap-keys"
- signature_algorithm = "RS256"
- allow_empty_token = true
-
- -- Serve test_observer HTTP endpoints here so plain HTTP on port 5280 is
- -- reachable. Component HTTP routes end up on HTTPS 5281 due to Prosody's
- -- virtual-host routing, which does not match Host: localhost on port 5280.
- modules_enabled = {
- -- test-only: HTTP endpoints and census helpers
- "test_observer_http";
- "muc_size";
- "muc_census";
- -- Module order below follows prod (conference.8x8.vc VirtualHost) so that
- -- same-priority hook execution order matches production.
- -- Handles 'jitsi-add-identity' so components (room_metadata,
- -- audio_translation, ...) can advertise a disco identity on this host.
- "features_identity";
- "conference_duration";
- "filter_iq_rayo"; -- priority 1 on pre-iq/full; listed before filter_iq_jibri (matches prod)
- "filter_iq_jibri";
- "muc_lobby_rooms";
- "jiconop";
- "muc_kick_participant";
- "muc_jigasi_invite";
- -- Loaded here so that the global jitsi-access-ban-check event handler
- -- is registered and mod_auth_token can fire it for token-authenticated
- -- sessions. muc_prosody_jitsi_access_manager_url points at the mock
- -- access manager served by mod_test_observer_http on the same host.
- "muc_auth_ban";
- -- test-only
- "turncredentials_http";
- -- Rewrites MUC JIDs between external subdomain form
- -- ([email protected]) and internal bracket form
- -- ([sub][email protected]) for all sessions on all hosts.
- "muc_domain_mapper";
- "persistent_lobby";
- "system_chat_message";
- -- test-only
- "muc_password_check";
- }
-
- -- mod_muc_password_check: verify Bearer tokens with the login ASAP key server.
- enable_password_token_verification = true
-
- shard_name = "test-shard"
- region_name = "test-region"
- release_number = "test-release"
-
- -- mod_turncredentials_http (HTTP via external_services): port 3479.
- external_services = {
- { type = "stun", host = "127.0.0.1", port = 3479 };
- { type = "turn", host = "127.0.0.1", port = 3479, secret = "http-turn-secret" };
- }
-
- -- Required by mod_muc_auth_ban: URL of the access manager to call.
- -- Points at the mock endpoint served by mod_test_observer_http.
- muc_prosody_jitsi_access_manager_url = "http://localhost:5280/test-observer/access-manager"
-
- -- Required by mod_test_observer_http to locate the shared MUC data.
- muc_mapper_domain_base = "localhost"
- muc_mapper_domain_prefix = "conference"
-
- -- Required by mod_conference_duration to find the MUC component.
- -- Required by mod_muc_lobby_rooms.
- main_muc = "conference.localhost"
- lobby_muc = "lobby.conference.localhost"
-
- -- Clients on whitelist.localhost bypass the lobby.
- muc_lobby_whitelist = { "whitelist.localhost" }
-
--- VirtualHost for the focus (jicofo) test helper.
--- Clients authenticate with username "focus" and password "focussecret".
--- The account is pre-created in the Docker image (see Dockerfile).
--- [email protected] is listed in the global admins table, so it is exempt
--- from token_verification and can act as room owner on all MUC components.
-VirtualHost "auth.localhost"
- authentication = "internal_hashed"
- -- @xmpp/sasl (v0.13) does not await async SASL responses; the SCRAM-SHA-1
- -- mechanism in sasl-scram-sha-1 1.4+ is async, so the client sends an
- -- empty client-final message which Prosody rejects as malformed-request.
- -- Disable SCRAM and force PLAIN (safe on loopback in the test environment).
- disable_sasl_mechanisms = { "SCRAM-SHA-1", "SCRAM-SHA-1-PLUS", "SCRAM-SHA-256", "SCRAM-SHA-256-PLUS" }
-
--- VirtualHost for Jibri (recorder) and transcriber accounts used by
--- mod_muc_cleanup_backend_services tests. Accounts on this domain get JIDs whose
--- bare form starts with 'recorder@recorder.' or 'transcriber@recorder.', satisfying
--- is_jibri() and is_transcriber() respectively.
--- recorder.localhost is added to muc_access_whitelist on the MUC component so
--- these clients bypass token_verification without needing JWT tokens.
-VirtualHost "recorder.localhost"
- authentication = "internal_hashed"
- disable_sasl_mechanisms = { "SCRAM-SHA-1", "SCRAM-SHA-1-PLUS", "SCRAM-SHA-256", "SCRAM-SHA-256-PLUS" }
-
--- VirtualHost for HS256 (shared-secret) token auth tests and mod_presence_identity tests.
-VirtualHost "hs256.localhost"
- authentication = "token"
- app_id = "jitsi"
- app_secret = "testsecret"
- signature_algorithm = "HS256"
- allow_empty_token = false
- modules_enabled = { "presence_identity" }
-
--- Second VirtualHost whose domain is listed in muc_access_whitelist on the
--- MUC component below. Clients connecting here get JIDs like
--- <random>@whitelist.localhost and are treated as whitelisted.
--- VirtualHost used by mod_auth_jitsi-anonymous tests.
-VirtualHost "jitsi-anonymous.localhost"
- authentication = "jitsi-anonymous"
-
--- VirtualHost used by mod_auth_jitsi-shared-secret tests.
-VirtualHost "shared-secret.localhost"
- authentication = "jitsi-shared-secret"
- shared_secret = "topsecret"
- shared_secret_prev = "oldsecret"
- -- Disable SCRAM so Prosody only offers PLAIN. SCRAM requires per-user key
- -- derivation which is incompatible with a shared-secret auth provider.
- disable_sasl_mechanisms = { "SCRAM-SHA-1", "SCRAM-SHA-1-PLUS" }
-
-VirtualHost "whitelist.localhost"
- authentication = "anonymous"
-
-Component "lobby.conference.localhost" "muc"
- storage = "memory"
- muc_room_cache_size = 1000
- restrict_room_creation = true
- muc_room_locking = false
- muc_room_default_public_jids = true
-
-Component "conference.localhost" "muc"
- -- Module order follows prod (conference.8x8.vc) so that same-priority hook
- -- execution order matches production. Test-only modules are inserted at
- -- sensible positions relative to the shared modules they interact with.
- modules_enabled = {
- "muc_hide_all";
- "token_verification"; -- prod pos 2: gate check runs before meeting-id / password logic
- "muc_max_occupants";
- "muc_resource_validate"; -- test-only: occupant gate, alongside muc_max_occupants
- "muc_password_whitelist";
- "token_affiliation"; -- test-only: reads auth_token set by token_verification above
- "muc_meeting_id"; -- prod pos 9: after gate checks
- "muc_flip";
- "test_observer"; -- test-only
- "filter_messages";
- "muc_displayname"; -- prod pos 21: after filter_messages
- -- mod_muc_limit_messages registers its message/bare hook at priority -1
- -- (below the default 0 used by filter_messages), so filter_messages
- -- always fires first. Messages it blocks (return true) never reach
- -- muc_limit_messages and do not count toward the per-room cap.
- "muc_limit_messages";
- -- Destroys a room after a short timeout when only Jibri/transcriber remain.
- "muc_cleanup_backend_services";
- }
-
- anonymous_strict = true
-
- -- Same as prod: only Prosody admins (jicofo, i.e. [email protected]) may
- -- create a room. Regular clients (anonymous or JWT) can only join a room
- -- that focus has already created.
- restrict_room_creation = true
-
- -- Used by mod_muc_max_occupants tests (2 occupants max).
- muc_max_occupants = 2
-
- -- Clients on whitelist.localhost bypass the occupant limit.
- -- Clients on auth.localhost are the focus (jicofo) admin; they also bypass
- -- the limit and are not counted against it.
- -- Clients on recorder.localhost are Jibri/transcriber accounts; they bypass
- -- token_verification (is_jibri / is_transcriber JID prefix checks still apply).
- muc_access_whitelist = { "whitelist.localhost", "auth.localhost", "recorder.localhost" }
-
- -- Used by mod_muc_password_whitelist tests: clients from whitelist.localhost
- -- are injected with the room password and bypass the password check.
- muc_password_whitelist = { "whitelist.localhost" }
-
- -- Required by util.lib.lua domain-mapping helpers and mod_jitsi_permissions.
- muc_mapper_domain_base = "localhost"
- muc_mapper_domain_prefix = "conference"
-
- -- [email protected] is a Prosody admin and is therefore exempt from
- -- token_verification on both muc-room-pre-create and muc-occupant-pre-join,
- -- mirroring production where jicofo is a Prosody admin.
-
- -- mod_muc_cleanup_backend_services: short timeout so tests don't wait 20 s.
- services_empty_meeting_timeout = 1
-
- -- mod_muc_limit_messages: cap per room and honour auth tokens.
- muc_limit_messages_count = 3
- muc_limit_messages_check_token = true
-
- -- Blocks unauthenticated users from sending room-owner config IQs
- -- (muc#owner queries), which is how moderator status is granted to other
- -- participants and how room configuration is changed.
- token_verification_require_token_for_moderation = true
-
--- Internal MUC used by mod_muc_jigasi_invite: the module resolves the Jigasi
--- brewery room from this component via process_host_module. Without this
--- component main_muc_service would remain nil and requests that reach the
--- invite_jigasi() path would crash instead of returning 404.
-Component "internal.auth.localhost" "muc"
-
--- Minimal MUC component used to test mod_muc_filter_access in isolation.
--- Only clients from whitelist.localhost are permitted to join rooms here.
-Component "conference-internal.localhost" "muc"
- modules_enabled = {
- "muc_filter_access";
- }
- muc_filter_whitelist = { "whitelist.localhost" }
-
--- Component for mod_end_conference tests. Clients send a message stanza with
--- an <end_conference/> child to this component; the module looks up the room
--- from the sender's jitsi_web_query_room session field (set by mod_jitsi_session
--- from the ?room= WebSocket URL param) and destroys it if the sender is a
--- moderator occupant.
-Component "endconference.localhost" "end_conference"
- muc_component = "conference.localhost"
- muc_mapper_domain_base = "localhost"
- muc_mapper_domain_prefix = "conference"
-
--- MUC component for mod_muc_rate_limit integration tests.
--- Intentionally low join/leave rates (1/s) so that 5 simultaneous clients
--- exercise the queuing and timer logic without long waits.
-Component "rate-limited.localhost" "muc"
- modules_enabled = { "muc_rate_limit" }
- muc_rate_joins = 1
- muc_rate_leaves = 1
-
--- Metadata component for mod_room_metadata_component tests.
-Component "metadata.localhost" "room_metadata_component"
- muc_component = "conference.localhost"
- muc_mapper_domain_base = "localhost"
- muc_mapper_domain_prefix = "conference"
-
--- Component for mod_filesharing_component tests. Clients send file-sharing
--- messages here; the component looks up the room from jitsi_web_query_room
--- (set by mod_jitsi_session) and broadcasts add/remove notifications.
-Component "filesharing.localhost" "filesharing_component"
- muc_component = "conference.localhost"
- muc_mapper_domain_base = "localhost"
- muc_mapper_domain_prefix = "conference"
-
--- Component for mod_audio_translation_component tests. Receivers send
--- <audio-translation> messages here; the component aggregates per-receiver
--- subscriptions and exposes the map to jicofo via room._data.audioTranslationRequests
--- (forwarded by mod_room_metadata_component on the metadata.localhost component).
-Component "audiotranslation.localhost" "audio_translation_component"
- muc_component = "conference.localhost"
- muc_mapper_domain_base = "localhost"
- muc_mapper_domain_prefix = "conference"
- -- Short debounce so tests don't wait long for the aggregate broadcast.
- audio_translation_debounce_interval = 0.1
- -- Low limit so the per-receiver cap is exercised without many subscriptions.
- audio_translation_max_subscriptions = 3
-
--- Component for mod_polls_component tests. The module hooks message/host for
--- new-poll / answer-poll json-messages, keeps per-room poll state (installed on
--- conference.localhost via process_host_module) and re-broadcasts poll updates
--- to all occupants. The sender must be an occupant of the room, located from
--- jitsi_web_query_room (set by mod_jitsi_session from the ?room= param).
-Component "polls.localhost" "polls_component"
- muc_mapper_domain_base = "localhost"
- muc_mapper_domain_prefix = "conference"
-
--- Plain MUC for mod_presence_identity tests. No token verification and no
--- muc_meeting_id lock so any client can join freely without focus.
-Component "conference-identity.localhost" "muc"
-
--- Isolated MUC component for mod_muc_wait_for_host tests.
--- No muc_meeting_id, so no jicofo lock — a JWT-authenticated client can join
--- directly as host without focus unlocking the room first.
--- muc_mapper_domain_base is set to "conference.localhost" so that:
--- lobby_muc_component_config = "lobby." .. "conference.localhost"
--- = "lobby.conference.localhost" (already configured above)
--- This means the existing lobby component is reused for the lobby rooms created
--- by this component, and no additional lobby MUC component is needed.
-Component "conference-waitforhost.localhost" "muc"
- storage = "memory"
- modules_enabled = {
- "muc_wait_for_host";
- }
- muc_mapper_domain_base = "conference.localhost"
- muc_mapper_domain_prefix = "conference"
-
--- Isolated MUC component for mod_muc_allowners tests.
--- No muc_meeting_id (no jicofo lock) and no token_verification, so anonymous
--- clients can join freely. In non-moderated rooms every occupant is promoted
--- to owner on join and muc#admin set stanzas revoking affiliations are
--- rejected. Room names listed in allowners_moderated_rooms are moderated:
--- only JWT-authenticated users with a matching room claim are promoted and
--- the revoke filtering is skipped.
-Component "conference-allowners.localhost" "muc"
- storage = "memory"
- modules_enabled = {
- "muc_allowners";
- }
- muc_mapper_domain_base = "localhost"
- muc_mapper_domain_prefix = "conference"
- allowners_moderated_rooms = { "moderated-room-1"; "moderated-room-2" }
+-- Prosody config for integration testing.
+-- Assembled from fragment files so that other environments (e.g. private
+-- plugin repos) can extend specific sections without duplicating the entire
+-- config.
+--
+-- Fragment layout:
+-- cfg/global.cfg.lua — global settings (data_path, plugin_paths, modules_enabled, …)
+-- cfg/virtualhosts.cfg.lua — all VirtualHost blocks
+-- cfg/components.cfg.lua — all Component blocks except conference.localhost
+-- cfg/conference.cfg.lua — conference.localhost (separate so it can be re-declared)
+--
+-- An extending image keeps the fragments and replaces this file with one that
+-- Includes cfg/global + cfg/virtualhosts + cfg/components, then declares its
+-- own conference.localhost block (based on cfg/conference.cfg.lua) with extra
+-- modules appended.
+
+Include "/etc/prosody/cfg/global.cfg.lua"
+Include "/etc/prosody/cfg/virtualhosts.cfg.lua"
+Include "/etc/prosody/cfg/components.cfg.lua"
+Include "/etc/prosody/cfg/conference.cfg.lua"
diff --git a/tests/prosody/helpers/test_context.js b/tests/prosody/helpers/test_context.js
index 125d6ccd2d..60267f18e3 100644
--- a/tests/prosody/helpers/test_context.js
+++ b/tests/prosody/helpers/test_context.js
@@ -14,10 +14,12 @@ export function createTestContext() {
/**
* Creates a regular XMPP client and registers it for cleanup.
*
+ * @param {object} [opts] Options forwarded to createXmppClient (e.g.
+ * { params: { token } } to authenticate with a JWT).
* @returns {Promise<XmppTestClient>}
*/
- async connect() {
- const c = await createXmppClient();
+ async connect(opts) {
+ const c = await createXmppClient(opts);
clients.push(c);
diff --git a/tests/prosody/helpers/xmpp_client.js b/tests/prosody/helpers/xmpp_client.js
index a096fcbff5..25c0a16513 100644
--- a/tests/prosody/helpers/xmpp_client.js
+++ b/tests/prosody/helpers/xmpp_client.js
@@ -210,7 +210,11 @@ export async function createXmppClient({ host = 'localhost', domain, params, use
* @param {string} [opts.password] room password to include in the join stanza
* @param {string} [opts.displayName] if set, includes a <nick> element in the presence
*/
- async joinRoom(roomJid, nick, { timeout = 5000, password: roomPassword, extensions = [], displayName } = {}) {
+ async joinRoom(roomJid, nick, { timeout = 5000,
+ password: roomPassword,
+ extensions = [],
+ mucContent = [],
+ displayName } = {}) {
// Default to the first 8 characters of the local part of the
// server-assigned JID. Prosody's anonymous_strict mode requires MUC
// resources to match this prefix, so callers that do not pass an
@@ -223,6 +227,12 @@ export async function createXmppClient({ host = 'localhost', domain, params, use
mucX.c('password').t(roomPassword);
}
+ // Children placed INSIDE the muc <x> (e.g. a <billingid> element),
+ // as opposed to `extensions`, which are siblings of <x>.
+ for (const child of mucContent) {
+ mucX.cnode(child).up();
+ }
+
const nickEl = displayName
? xml('nick', { xmlns: 'http://jabber.org/protocol/nick' }, displayName)
: undefined;
@@ -582,6 +592,24 @@ export async function createXmppClient({ host = 'localhost', domain, params, use
return this.waitForMessage(s => s.attrs.id === id);
},
+ /**
+ * Sets the room subject by sending a groupchat message carrying only a
+ * <subject> element (XEP-0045 §8.1). Fire-and-forget — does NOT wait for
+ * the room's subject broadcast.
+ *
+ * @param {string} roomJid e.g. '[email protected]'
+ * @param {string} subject the new subject text
+ */
+ sendRoomSubject(roomJid, subject) {
+ return xmpp.send(
+ xml('message', { to: roomJid,
+ type: 'groupchat',
+ id: `subj-${++_counter}` },
+ xml('subject', {}, subject)
+ )
+ );
+ },
+
/**
* Sends a groupchat message with a <json-message> child to the room.
* Fire-and-forget — does NOT wait for the MUC reflection stanza.
@@ -650,6 +678,54 @@ export async function createXmppClient({ host = 'localhost', domain, params, use
);
},
+ /**
+ * Sends a Jingle IQ (XEP-0166/XEP-0339) to an occupant's full JID in a
+ * MUC room. Fire-and-forget — does NOT wait for a response.
+ *
+ * The pre-iq/full hook fires on the MUC component before routing, so any
+ * module that hooks that event will see the stanza synchronously.
+ *
+ * For session-accept, a <content name="video"> child is included when
+ * videoType is non-null. For source-add, a content/description/source
+ * chain with a videoType attribute is included.
+ *
+ * @param {string} toFullJid Occupant full JID, e.g. '[email protected]/focus'
+ * @param {string} action 'session-accept' | 'source-add'
+ * @param {string|null} videoType 'camera' | 'desktop' | null (audio-only: no video content)
+ */
+ sendJingleIq(toFullJid, action, videoType = null) {
+ let contentEl;
+
+ if (videoType === null) {
+ // Audio-only: a content element with name='audio' and no description.
+ // session-accept: no content with name='video' → no flags set.
+ // source-add: no description/source path → no flags set.
+ contentEl = xml('content', { name: 'audio' });
+ } else {
+ const sourceEl = xml('source', {
+ xmlns: 'urn:xmpp:jingle:apps:rtp:ssma:0',
+ videoType
+ });
+ const descEl = xml('description', {
+ xmlns: 'urn:xmpp:jingle:apps:rtp:1',
+ media: 'video'
+ }, sourceEl);
+
+ contentEl = xml('content', { name: 'video' }, descEl);
+ }
+
+ return xmpp.send(
+ xml('iq', { type: 'set',
+ to: toFullJid,
+ id: `jingle-${++_counter}` },
+ xml('jingle', {
+ xmlns: 'urn:xmpp:jingle:1',
+ action
+ }, contentEl)
+ )
+ );
+ },
+
/**
* Sends a muc#admin set IQ carrying multiple <item> children and
* resolves with the server's IQ response. XEP-0045 allows batching
diff --git a/tests/prosody/mod_auth_jitsi_shared_secret_spec.js b/tests/prosody/mod_auth_jitsi_shared_secret_spec.js
index 698756a6cf..643c33d164 100644
--- a/tests/prosody/mod_auth_jitsi_shared_secret_spec.js
+++ b/tests/prosody/mod_auth_jitsi_shared_secret_spec.js
@@ -5,7 +5,7 @@ import { prosodyShell } from './helpers/prosody_shell.js';
import { createXmppClient } from './helpers/xmpp_client.js';
const DOMAIN = 'shared-secret.localhost';
-const PROSODY_CFG = '/etc/prosody/prosody.cfg.lua';
+const PROSODY_CFG = '/etc/prosody/cfg/virtualhosts.cfg.lua';
const SECRET = 'topsecret';
const PREV_SECRET = 'oldsecret';
diff --git a/tests/prosody/mod_muc_lobby_rooms_spec.js b/tests/prosody/mod_muc_lobby_rooms_spec.js
index 025c5a8e89..064c9f446c 100644
--- a/tests/prosody/mod_muc_lobby_rooms_spec.js
+++ b/tests/prosody/mod_muc_lobby_rooms_spec.js
@@ -377,4 +377,70 @@ describe('mod_muc_lobby_rooms', () => {
'moderator token user who bypassed lobby via password must get moderator role');
});
});
+
+ // -------------------------------------------------------------------------
+ // muc#admin set — nick reservation must not act before authorization
+ // -------------------------------------------------------------------------
+ //
+ // handle_admin_query_set_command_item's "nickname is reserved" branch kicks
+ // whoever currently holds the requested nick when the item's jid doesn't
+ // match. That kick must only happen once set_affiliation has confirmed the
+ // sender is allowed to act — otherwise an unauthorized sender can remove an
+ // occupant just by naming their nick, before the affiliation check ever
+ // gets a chance to reject the request.
+ describe('admin-set nick reservation', () => {
+
+ it('does not remove an occupant before authorizing the affiliation change', async () => {
+ const r = room();
+
+ await focusJoin(r);
+
+ const occupant = await connect();
+
+ await occupant.joinRoom(r, 'participant', { displayName: 'Participant' });
+
+ // Never joins the room — permission is checked from the sender's own
+ // bare jid, which has no affiliation record here regardless.
+ const sender = await connect();
+
+ const resp = await sender.sendMucAdmin(r, {
+ nick: 'participant',
+ affiliation: 'member'
+ });
+
+ // The real proof: a successful kick sends the occupant an unavailable
+ // self-presence. Its absence means the kick never happened.
+ const kicked = await occupant.waitForPresenceFrom(`${r}/participant`, { type: 'unavailable',
+ timeout: 500 })
+ .then(() => true, () => false);
+
+ assert.strictEqual(kicked, false, 'occupant must not be removed by an unauthorized sender');
+ assert.equal(resp.attrs.type, 'error', 'IQ must be rejected');
+ });
+
+ it('does not remove focus before authorizing the affiliation change', async () => {
+ const r = room();
+
+ const focus = await focusJoin(r);
+
+ // Also rejected outright by mod_muc_meeting_id's filter_admin_set,
+ // which runs at a higher priority for any item naming focus's nick.
+ // Kept here so a regression in either guard is still caught.
+ const sender = await connect();
+
+ const resp = await sender.sendMucAdmin(r, {
+ nick: 'focus',
+ affiliation: 'member'
+ });
+
+ const kicked = await focus.waitForPresenceFrom(`${r}/focus`, { type: 'unavailable',
+ timeout: 500 })
+ .then(() => true, () => false);
+
+ assert.strictEqual(kicked, false, 'focus must not be removed by an unauthorized sender');
+ assert.equal(resp.attrs.type, 'error', 'IQ must be rejected');
+ });
+ });
});
diff --git a/tests/prosody/mod_muc_meeting_id_spec.js b/tests/prosody/mod_muc_meeting_id_spec.js
index 4bce5dbb51..ff3aee1bad 100644
--- a/tests/prosody/mod_muc_meeting_id_spec.js
+++ b/tests/prosody/mod_muc_meeting_id_spec.js
@@ -1,5 +1,6 @@
import assert from 'assert';
+import { mintAsapToken } from './helpers/jwt.js';
import { createTestContext } from './helpers/test_context.js';
import { getRoomState } from './helpers/test_observer.js';
import { joinWithTranscriber } from './helpers/xmpp_client.js';
@@ -136,6 +137,44 @@ describe('mod_muc_meeting_id', () => {
assert.strictEqual(state.occupant_count, 2, 'must remain in the room after a blocked ban');
});
+ it('a ban by jid is rejected even when a mismatched nick is also present', async () => {
+ const r = room();
+
+ const focus = await ctx.connectFocus(r);
+ const focusBareJid = focus.jid.split('/')[0];
+
+ // An owner (moderator token) is the only actor Prosody would let
+ // change another occupant's affiliation, so the item has to be
+ // filtered by this hook rather than by Prosody's permission check.
+ const token = mintAsapToken({ room: r.split('@')[0],
+ context: { user: { moderator: true } } });
+ const attacker = await ctx.connect({ params: { token } });
+
+ await attacker.joinRoom(r);
+
+ // The affiliation change acts on the real jid; a nick that resolves
+ // to no occupant must not cause the jid to be skipped when deciding
+ // whether the item targets focus.
+ const resp = await attacker.sendMucAdmin(r, { jid: focusBareJid,
+ nick: 'decoy',
+ affiliation: 'outcast' });
+
+ // The real proof is on focus's own connection: a successful ban
+ // makes the room send focus an unavailable self-presence. If the
+ // item is filtered, none arrives.
+ const kicked = await focus.waitForPresenceFrom(`${r}/focus`, { type: 'unavailable',
+ timeout: 500 })
+ .then(() => true, () => false);
+
+ assert.strictEqual(kicked, false, 'focus must not be kicked/banned from the room');
+
+ assertNotAllowed(resp);
+
+ const state = await getRoomState(r);
+
+ assert.strictEqual(state.occupant_count, 2, 'must remain in the room after a blocked ban');
+ });
+
it('a role demotion (role=participant) targeting certain participant is rejected', async () => {
const r = room();
diff --git a/tests/prosody/mod_muc_resource_validate_spec.js b/tests/prosody/mod_muc_resource_validate_spec.js
index 4eaa6b0b27..52ade03648 100644
--- a/tests/prosody/mod_muc_resource_validate_spec.js
+++ b/tests/prosody/mod_muc_resource_validate_spec.js
@@ -5,7 +5,7 @@ import { createTestContext } from './helpers/test_context.js';
import { isAvailablePresence } from './helpers/xmpp_utils.js';
const MUC = 'conference.localhost';
-const PROSODY_CFG = '/etc/prosody/prosody.cfg.lua';
+const PROSODY_CFG = '/etc/prosody/cfg/conference.cfg.lua';
let _roomCounter = 0;
const room = () => `validate-${++_roomCounter}@${MUC}`;
diff --git a/tests/prosody/package.json b/tests/prosody/package.json
index 3c93f5a4a6..467fdc7c45 100644
--- a/tests/prosody/package.json
+++ b/tests/prosody/package.json
@@ -8,7 +8,8 @@
"test:integration": "DEBUG=testcontainers,testcontainers:containers,testcontainers:build mocha",
"test:report": "npx allure generate allure-results --clean -o allure-report && node fix-allure-report.cjs",
"test": "npm run test:lua; LRC=$?; npm run test:integration; IRC=$?; npm run test:report; exit $(( LRC != 0 || IRC != 0 ))",
- "test:one": "mocha --no-config --require ./setup.js --timeout 120000"
+ "test:one": "mocha --no-config --require ./setup.js --timeout 120000",
+ "build:test-image": "cd ../.. && docker build -t jitsi-meet-prosody-test:latest -f tests/prosody/docker/Dockerfile ."
},
"dependencies": {
"@xmpp/client": "^0.13.1",