util.x509: Nameprep commonName once
[prosody.git] / spec / muc_util_spec.lua
blobcef68e80d12c92f122b915b50d05a338c6124360
1 local muc_util;
3 local st = require "util.stanza";
5 do
6 local old_pp = package.path;
7 package.path = "./?.lib.lua;"..package.path;
8 muc_util = require "plugins.muc.util";
9 package.path = old_pp;
10 end
12 describe("muc/util", function ()
13 describe("filter_muc_x()", function ()
14 it("correctly filters muc#user", function ()
15 local stanza = st.message({ to = "to", from = "from", id = "foo" })
16 :tag("x", { xmlns = "http://jabber.org/protocol/muc#user" })
17 :tag("invite", { to = "user@example.com" });
19 assert.equal(1, #stanza.tags);
20 assert.equal(stanza, muc_util.filter_muc_x(stanza));
21 assert.equal(0, #stanza.tags);
22 end);
24 it("correctly filters muc#user on a cloned stanza", function ()
25 local stanza = st.message({ to = "to", from = "from", id = "foo" })
26 :tag("x", { xmlns = "http://jabber.org/protocol/muc#user" })
27 :tag("invite", { to = "user@example.com" });
29 assert.equal(1, #stanza.tags);
30 local filtered = muc_util.filter_muc_x(st.clone(stanza));
31 assert.equal(1, #stanza.tags);
32 assert.equal(0, #filtered.tags);
33 end);
34 end);
35 end);