Comparison

spec/util_stanza_spec.lua @ 9307:feaef6215bb8

util.stanza: Don't automatically generate ids for iq stanzas Users of this API should provide their own id attribute that meets their uniqueness requirements. The current implementation leaks information (i.e. how many iq stanzas have been sent by the server to other JIDs). Providing any strong guarantees of randomness here would need to pull in additional dependencies that we don't want in this simple library.
author Matthew Wild <mwild1@gmail.com>
date Thu, 13 Sep 2018 16:35:48 +0100
parent 9302:57f8e41255fb
child 9308:21c2f3331c59
comparison
equal deleted inserted replaced
9306:35c128b42509 9307:feaef6215bb8
82 assert.are.equal(m.name, "message"); 82 assert.are.equal(m.name, "message");
83 end); 83 end);
84 end); 84 end);
85 85
86 describe("#iq()", function() 86 describe("#iq()", function()
87 it("should work", function() 87 it("should create an iq stanza", function()
88 local i = st.iq(); 88 local i = st.iq({ id = "foo" });
89 assert.are.equal(i.name, "iq"); 89 assert.are.equal("iq", i.name);
90 assert.are.equal("foo", i.attr.id);
91 end);
92
93 it("should reject stanzas with no id", function ()
94 assert.has.error_match(function ()
95 local i = st.iq();
96 end, "id attribute");
97
98 assert.has.error_match(function ()
99 local i = st.iq({ foo = "bar" });
100 end, "id attribute");
90 end); 101 end);
91 end); 102 end);
92 103
93 describe("#presence()", function () 104 describe("#presence()", function ()
94 it("should work", function() 105 it("should work", function()