Mercurial > prosody-hg
annotate spec/muc_util_spec.lua @ 11545:7b8a482f4efd 0.11
MUC: Add support for advertising muc#roomconfig_allowinvites in room disco#info
The de-facto interpretation of this (undocumented) option is to indicate to
the client whether it is allowed to invite other users to the MUC.
This is differs from the existing option in our config form, which only
controls the behaviour of sending of invites in a members-only MUC (we always
allow invites in open rooms).
Conversations is one client known to use this disco#info item to determine
whether it may send invites.
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Mon, 10 May 2021 17:01:38 +0100 |
| parents | 172f93f752b8 |
| children | ad86b93093a3 |
| rev | line source |
|---|---|
|
9213
172f93f752b8
tests: Add muc/util tests for filtering MUC elements
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1 local muc_util; |
|
172f93f752b8
tests: Add muc/util tests for filtering MUC elements
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2 |
|
172f93f752b8
tests: Add muc/util tests for filtering MUC elements
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3 local st = require "util.stanza"; |
|
172f93f752b8
tests: Add muc/util tests for filtering MUC elements
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4 |
|
172f93f752b8
tests: Add muc/util tests for filtering MUC elements
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5 do |
|
172f93f752b8
tests: Add muc/util tests for filtering MUC elements
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6 local old_pp = package.path; |
|
172f93f752b8
tests: Add muc/util tests for filtering MUC elements
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7 package.path = "./?.lib.lua;"..package.path; |
|
172f93f752b8
tests: Add muc/util tests for filtering MUC elements
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8 muc_util = require "plugins.muc.util"; |
|
172f93f752b8
tests: Add muc/util tests for filtering MUC elements
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9 package.path = old_pp; |
|
172f93f752b8
tests: Add muc/util tests for filtering MUC elements
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
10 end |
|
172f93f752b8
tests: Add muc/util tests for filtering MUC elements
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
11 |
|
172f93f752b8
tests: Add muc/util tests for filtering MUC elements
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
12 describe("muc/util", function () |
|
172f93f752b8
tests: Add muc/util tests for filtering MUC elements
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
13 describe("filter_muc_x()", function () |
|
172f93f752b8
tests: Add muc/util tests for filtering MUC elements
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
14 it("correctly filters muc#user", function () |
|
172f93f752b8
tests: Add muc/util tests for filtering MUC elements
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
15 local stanza = st.message({ to = "to", from = "from", id = "foo" }) |
|
172f93f752b8
tests: Add muc/util tests for filtering MUC elements
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
16 :tag("x", { xmlns = "http://jabber.org/protocol/muc#user" }) |
|
172f93f752b8
tests: Add muc/util tests for filtering MUC elements
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
17 :tag("invite", { to = "user@example.com" }); |
|
172f93f752b8
tests: Add muc/util tests for filtering MUC elements
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
18 |
|
172f93f752b8
tests: Add muc/util tests for filtering MUC elements
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
19 assert.equal(1, #stanza.tags); |
|
172f93f752b8
tests: Add muc/util tests for filtering MUC elements
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
20 assert.equal(stanza, muc_util.filter_muc_x(stanza)); |
|
172f93f752b8
tests: Add muc/util tests for filtering MUC elements
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
21 assert.equal(0, #stanza.tags); |
|
172f93f752b8
tests: Add muc/util tests for filtering MUC elements
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
22 end); |
|
172f93f752b8
tests: Add muc/util tests for filtering MUC elements
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
23 |
|
172f93f752b8
tests: Add muc/util tests for filtering MUC elements
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
24 it("correctly filters muc#user on a cloned stanza", function () |
|
172f93f752b8
tests: Add muc/util tests for filtering MUC elements
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
25 local stanza = st.message({ to = "to", from = "from", id = "foo" }) |
|
172f93f752b8
tests: Add muc/util tests for filtering MUC elements
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
26 :tag("x", { xmlns = "http://jabber.org/protocol/muc#user" }) |
|
172f93f752b8
tests: Add muc/util tests for filtering MUC elements
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
27 :tag("invite", { to = "user@example.com" }); |
|
172f93f752b8
tests: Add muc/util tests for filtering MUC elements
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
28 |
|
172f93f752b8
tests: Add muc/util tests for filtering MUC elements
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
29 assert.equal(1, #stanza.tags); |
|
172f93f752b8
tests: Add muc/util tests for filtering MUC elements
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
30 local filtered = muc_util.filter_muc_x(st.clone(stanza)); |
|
172f93f752b8
tests: Add muc/util tests for filtering MUC elements
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
31 assert.equal(1, #stanza.tags); |
|
172f93f752b8
tests: Add muc/util tests for filtering MUC elements
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
32 assert.equal(0, #filtered.tags); |
|
172f93f752b8
tests: Add muc/util tests for filtering MUC elements
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
33 end); |
|
172f93f752b8
tests: Add muc/util tests for filtering MUC elements
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
34 end); |
|
172f93f752b8
tests: Add muc/util tests for filtering MUC elements
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
35 end); |
