Software /
code /
prosody
Comparison
spec/util_stanza_spec.lua @ 10445:f53c03ab4357
util.stanza: Check that argument to error_reply is NOT a stanza of type error
Replying to an error is Very Bad
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Mon, 25 Nov 2019 20:52:03 +0100 |
parent | 10444:4eab1f5a4f3b |
child | 10446:5c2d1b13537c |
comparison
equal
deleted
inserted
replaced
10444:4eab1f5a4f3b | 10445:f53c03ab4357 |
---|---|
218 it("should reject not-stanzas", function () | 218 it("should reject not-stanzas", function () |
219 assert.has.error_match(function () | 219 assert.has.error_match(function () |
220 st.error_reply(not "a stanza", "modify", "bad-request"); | 220 st.error_reply(not "a stanza", "modify", "bad-request"); |
221 end, "expected stanza"); | 221 end, "expected stanza"); |
222 end); | 222 end); |
223 | |
224 it("should reject stanzas of type error", function () | |
225 assert.has.error_match(function () | |
226 st.error_reply(st.message({type="error"}), "cancel", "conflict"); | |
227 end, "got stanza of type error"); | |
228 assert.has.error_match(function () | |
229 st.error_reply(st.error_reply(st.message({type="chat"}), "modify", "forbidden"), "cancel", "service-unavailable"); | |
230 end, "got stanza of type error"); | |
231 end); | |
232 | |
223 end); | 233 end); |
224 | 234 |
225 describe("should reject #invalid", function () | 235 describe("should reject #invalid", function () |
226 local invalid_names = { | 236 local invalid_names = { |
227 ["empty string"] = "", ["characters"] = "<>"; | 237 ["empty string"] = "", ["characters"] = "<>"; |