aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2008-11-15 23:22:27 +0000
committerMatthew Wild <mwild1@gmail.com>2008-11-15 23:22:27 +0000
commit669f7ac76a808c91bad5b6b144e459f9144954e8 (patch)
tree54cd29d831ddf750976c9fcedae8308bf687adbb /tests
parent60292ade15292d2398d91a1af6a578d6a20c9f34 (diff)
parentfa063a029970ee01ce8307643e334fb1d33a8a74 (diff)
downloadprosody-669f7ac76a808c91bad5b6b144e459f9144954e8.tar.gz
prosody-669f7ac76a808c91bad5b6b144e459f9144954e8.zip
Merge with myself (!)
Diffstat (limited to 'tests')
-rw-r--r--tests/test.lua1
-rw-r--r--tests/test_core_stanza_router.lua24
2 files changed, 25 insertions, 0 deletions
diff --git a/tests/test.lua b/tests/test.lua
index c0a27abd..c028e859 100644
--- a/tests/test.lua
+++ b/tests/test.lua
@@ -71,6 +71,7 @@ function dotest(unitname)
end
function runtest(f, msg)
+ if not f then print("SUBTEST NOT FOUND: "..(msg or "(no description)")); return; end
local success, ret = pcall(f);
if success and verbosity >= 2 then
print("SUBTEST PASSED: "..(msg or "(no description)"));
diff --git a/tests/test_core_stanza_router.lua b/tests/test_core_stanza_router.lua
index 49c1f90f..a5185c29 100644
--- a/tests/test_core_stanza_router.lua
+++ b/tests/test_core_stanza_router.lua
@@ -1,6 +1,7 @@
function core_process_stanza(core_process_stanza)
local s2sout_session = { to_host = "remotehost", from_host = "localhost", type = "s2sout" }
+ local s2sin_session = { from_host = "remotehost", to_host = "localhost", type = "s2sin" }
local local_host_session = { host = "localhost", type = "local" }
local local_user_session = { username = "user", host = "localhost", resource = "resource", full_jid = "user@localhost/resource", type = "c2s" }
local hosts = {
@@ -123,6 +124,28 @@ function core_process_stanza(core_process_stanza)
assert_equal(target_routed, true, "stanza was not routed successfully");
end
+ local function test_iq_error_to_local_user()
+ local env = testlib_new_env();
+ local msg = stanza.stanza("iq", { to = "user@localhost/resource", from = "user@remotehost", type = "error" }):tag("error", { type = 'cancel' }):tag("item-not-found", { xmlns='urn:ietf:params:xml:ns:xmpp-stanzas' });
+
+ local target_routed;
+
+ function env.core_route_stanza(p_origin, p_stanza)
+ assert_equal(p_origin, s2sin_session, "origin of handled stanza is not correct");
+ assert_equal(p_stanza, msg, "handled stanza is not correct one: "..p_stanza:pretty_print());
+ target_routed = true;
+ end
+
+ function env.core_handle_stanza(p_origin, p_stanza)
+
+ end
+
+ env.hosts = hosts;
+ setfenv(core_process_stanza, env);
+ assert_equal(core_process_stanza(s2sin_session, msg), nil, "core_process_stanza returned incorrect value");
+ assert_equal(target_routed, true, "stanza was not routed successfully");
+ end
+
runtest(test_message_full_jid, "Messages with full JID destinations get routed");
runtest(test_message_bare_jid, "Messages with bare JID destinations get routed");
runtest(test_message_no_to, "Messages with no destination are handled by the server");
@@ -130,5 +153,6 @@ function core_process_stanza(core_process_stanza)
runtest(test_message_to_remote_server, "Messages to a remote server's JID are routed");
runtest(test_iq_to_remote_server, "iq to a remote server's JID are routed");
+ runtest(test_iq_error_to_local_user, "iq type=error to a local user's JID are routed");
end