Software /
code /
prosody
Diff
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 |
line wrap: on
line diff
--- a/spec/util_stanza_spec.lua Mon Nov 25 20:52:01 2019 +0100 +++ b/spec/util_stanza_spec.lua Mon Nov 25 20:52:03 2019 +0100 @@ -220,6 +220,16 @@ st.error_reply(not "a stanza", "modify", "bad-request"); end, "expected stanza"); end); + + it("should reject stanzas of type error", function () + assert.has.error_match(function () + st.error_reply(st.message({type="error"}), "cancel", "conflict"); + end, "got stanza of type error"); + assert.has.error_match(function () + st.error_reply(st.error_reply(st.message({type="chat"}), "modify", "forbidden"), "cancel", "service-unavailable"); + end, "got stanza of type error"); + end); + end); describe("should reject #invalid", function ()