tests/test_core_stanza_router.lua

changeset 788
b85b1dee4f4b
parent 786
f2dc6118b3f4
child 858
dddc63818c3d
equal deleted inserted replaced
787:c4a4d5604549 788:b85b1dee4f4b
153 setfenv(core_process_stanza, env); 153 setfenv(core_process_stanza, env);
154 assert_equal(core_process_stanza(s2sin_session, msg), nil, "core_process_stanza returned incorrect value"); 154 assert_equal(core_process_stanza(s2sin_session, msg), nil, "core_process_stanza returned incorrect value");
155 assert_equal(target_routed, true, "stanza was not routed successfully"); 155 assert_equal(target_routed, true, "stanza was not routed successfully");
156 end 156 end
157 157
158 local function test_iq_to_local_bare()
159 local env = testlib_new_env();
160 local msg = stanza.stanza("iq", { to = "user@localhost", from = "user@localhost", type = "get" }):tag("ping", { xmlns = "urn:xmpp:ping:0" });
161
162 local target_handled;
163
164 function env.core_handle_stanza(p_origin, p_stanza)
165 assert_equal(p_origin, local_user_session, "origin of handled stanza is not correct");
166 assert_equal(p_stanza, msg, "handled stanza is not correct one: "..p_stanza:pretty_print());
167 target_handled = true;
168 end
169
170 function env.core_route_stanza(p_origin, p_stanza)
171
172 end
173
174 env.hosts = hosts;
175 setfenv(core_process_stanza, env);
176 assert_equal(core_process_stanza(local_user_session, msg), nil, "core_process_stanza returned incorrect value");
177 assert_equal(target_handled, true, "stanza was not handled successfully");
178 end
179
158 runtest(test_message_full_jid, "Messages with full JID destinations get routed"); 180 runtest(test_message_full_jid, "Messages with full JID destinations get routed");
159 runtest(test_message_bare_jid, "Messages with bare JID destinations get routed"); 181 runtest(test_message_bare_jid, "Messages with bare JID destinations get routed");
160 runtest(test_message_no_to, "Messages with no destination are handled by the server"); 182 runtest(test_message_no_to, "Messages with no destination are handled by the server");
161 runtest(test_message_to_remote_bare, "Messages to a remote user are routed by the server"); 183 runtest(test_message_to_remote_bare, "Messages to a remote user are routed by the server");
162 runtest(test_message_to_remote_server, "Messages to a remote server's JID are routed"); 184 runtest(test_message_to_remote_server, "Messages to a remote server's JID are routed");
163 185
164 runtest(test_iq_to_remote_server, "iq to a remote server's JID are routed"); 186 runtest(test_iq_to_remote_server, "iq to a remote server's JID are routed");
187 runtest(test_iq_to_local_bare, "iq from a local user to a local user's bare JID are handled");
165 runtest(test_iq_error_to_local_user, "iq type=error to a local user's JID are routed"); 188 runtest(test_iq_error_to_local_user, "iq type=error to a local user's JID are routed");
166 189
167 end 190 end

mercurial