Annotate

tests/test_core_stanza_router.lua @ 758:b1885732e979

GPL->MIT!
author Matthew Wild <mwild1@gmail.com>
date Fri, 30 Jan 2009 17:22:56 +0000
parent 615:4ae3e81513f3
child 759:5cccfb5da6cb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
615
4ae3e81513f3 0.1 -> 0.2
Matthew Wild <mwild1@gmail.com>
parents: 519
diff changeset
1 -- Prosody IM v0.2
519
cccd610a0ef9 Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents: 302
diff changeset
2 -- Copyright (C) 2008 Matthew Wild
cccd610a0ef9 Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents: 302
diff changeset
3 -- Copyright (C) 2008 Waqas Hussain
cccd610a0ef9 Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents: 302
diff changeset
4 --
758
b1885732e979 GPL->MIT!
Matthew Wild <mwild1@gmail.com>
parents: 615
diff changeset
5 -- This project is MIT/X11 licensed. Please see the
b1885732e979 GPL->MIT!
Matthew Wild <mwild1@gmail.com>
parents: 615
diff changeset
6 -- COPYING file in the source package for more information.
519
cccd610a0ef9 Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents: 302
diff changeset
7 --
cccd610a0ef9 Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents: 302
diff changeset
8
cccd610a0ef9 Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents: 302
diff changeset
9
273
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
10
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
11 function core_process_stanza(core_process_stanza)
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
12 local s2sout_session = { to_host = "remotehost", from_host = "localhost", type = "s2sout" }
302
8aedb3766ec7 You can never have too many tests
Matthew Wild <mwild1@gmail.com>
parents: 273
diff changeset
13 local s2sin_session = { from_host = "remotehost", to_host = "localhost", type = "s2sin" }
273
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
14 local local_host_session = { host = "localhost", type = "local" }
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
15 local local_user_session = { username = "user", host = "localhost", resource = "resource", full_jid = "user@localhost/resource", type = "c2s" }
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
16 local hosts = {
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
17 ["localhost"] = local_host_session;
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
18 }
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
19
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
20 -- Test message routing
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
21 local function test_message_full_jid()
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
22 local env = testlib_new_env();
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
23 local msg = stanza.stanza("message", { to = "user@localhost/resource", type = "chat" }):tag("body"):text("Hello world");
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
24
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
25 local target_routed;
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
26
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
27 function env.core_route_stanza(p_origin, p_stanza)
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
28 assert_equal(p_origin, local_user_session, "origin of routed stanza is not correct");
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
29 assert_equal(p_stanza, msg, "routed stanza is not correct one: "..p_stanza:pretty_print());
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
30 target_routed = true;
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
31 end
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
32 env.hosts = hosts;
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
33 setfenv(core_process_stanza, env);
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
34 assert_equal(core_process_stanza(local_user_session, msg), nil, "core_process_stanza returned incorrect value");
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
35 assert_equal(target_routed, true, "stanza was not routed successfully");
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
36 end
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
37
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
38 local function test_message_bare_jid()
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
39 local env = testlib_new_env();
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
40 local msg = stanza.stanza("message", { to = "user@localhost", type = "chat" }):tag("body"):text("Hello world");
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
41
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
42 local target_routed;
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
43
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
44 function env.core_route_stanza(p_origin, p_stanza)
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
45 assert_equal(p_origin, local_user_session, "origin of routed stanza is not correct");
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
46 assert_equal(p_stanza, msg, "routed stanza is not correct one: "..p_stanza:pretty_print());
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
47 target_routed = true;
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
48 end
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
49 env.hosts = hosts;
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
50 setfenv(core_process_stanza, env);
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
51 assert_equal(core_process_stanza(local_user_session, msg), nil, "core_process_stanza returned incorrect value");
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
52 assert_equal(target_routed, true, "stanza was not routed successfully");
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
53 end
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
54
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
55 local function test_message_no_to()
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
56 local env = testlib_new_env();
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
57 local msg = stanza.stanza("message", { type = "chat" }):tag("body"):text("Hello world");
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
58
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
59 local target_handled;
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
60
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
61 function env.core_route_stanza(p_origin, p_stanza)
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
62 end
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
63
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
64 function env.core_handle_stanza(p_origin, p_stanza)
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
65 assert_equal(p_origin, local_user_session, "origin of handled stanza is not correct");
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
66 assert_equal(p_stanza, msg, "handled stanza is not correct one: "..p_stanza:pretty_print());
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
67 target_handled = true;
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
68 end
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
69 env.hosts = hosts;
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
70 setfenv(core_process_stanza, env);
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
71 assert_equal(core_process_stanza(local_user_session, msg), nil, "core_process_stanza returned incorrect value");
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
72 assert_equal(target_handled, true, "stanza was not handled successfully");
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
73 end
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
74
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
75 local function test_message_to_remote_bare()
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
76 local env = testlib_new_env();
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
77 local msg = stanza.stanza("message", { to = "user@remotehost", type = "chat" }):tag("body"):text("Hello world");
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
78
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
79 local target_routed;
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
80
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
81 function env.core_route_stanza(p_origin, p_stanza)
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
82 assert_equal(p_origin, local_user_session, "origin of handled stanza is not correct");
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
83 assert_equal(p_stanza, msg, "handled stanza is not correct one: "..p_stanza:pretty_print());
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
84 target_routed = true;
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
85 end
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
86
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
87 env.hosts = hosts;
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
88 setfenv(core_process_stanza, env);
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
89 assert_equal(core_process_stanza(local_user_session, msg), nil, "core_process_stanza returned incorrect value");
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
90 assert_equal(target_routed, true, "stanza was not routed successfully");
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
91 end
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
92
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
93 local function test_message_to_remote_server()
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
94 local env = testlib_new_env();
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
95 local msg = stanza.stanza("message", { to = "remotehost", type = "chat" }):tag("body"):text("Hello world");
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
96
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
97 local target_routed;
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
98
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
99 function env.core_route_stanza(p_origin, p_stanza)
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
100 assert_equal(p_origin, local_user_session, "origin of handled stanza is not correct");
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
101 assert_equal(p_stanza, msg, "handled stanza is not correct one: "..p_stanza:pretty_print());
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
102 target_routed = true;
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
103 end
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
104
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
105 env.hosts = hosts;
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
106 setfenv(core_process_stanza, env);
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
107 assert_equal(core_process_stanza(local_user_session, msg), nil, "core_process_stanza returned incorrect value");
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
108 assert_equal(target_routed, true, "stanza was not routed successfully");
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
109 end
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
110
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
111 --IQ tests
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
112
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
113
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
114 local function test_iq_to_remote_server()
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
115 local env = testlib_new_env();
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
116 local msg = stanza.stanza("iq", { to = "remotehost", type = "chat" }):tag("body"):text("Hello world");
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
117
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
118 local target_routed;
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
119
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
120 function env.core_route_stanza(p_origin, p_stanza)
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
121 assert_equal(p_origin, local_user_session, "origin of handled stanza is not correct");
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
122 assert_equal(p_stanza, msg, "handled stanza is not correct one: "..p_stanza:pretty_print());
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
123 target_routed = true;
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
124 end
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
125
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
126 function env.core_handle_stanza(p_origin, p_stanza)
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
127
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
128 end
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
129
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
130 env.hosts = hosts;
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
131 setfenv(core_process_stanza, env);
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
132 assert_equal(core_process_stanza(local_user_session, msg), nil, "core_process_stanza returned incorrect value");
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
133 assert_equal(target_routed, true, "stanza was not routed successfully");
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
134 end
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
135
302
8aedb3766ec7 You can never have too many tests
Matthew Wild <mwild1@gmail.com>
parents: 273
diff changeset
136 local function test_iq_error_to_local_user()
8aedb3766ec7 You can never have too many tests
Matthew Wild <mwild1@gmail.com>
parents: 273
diff changeset
137 local env = testlib_new_env();
8aedb3766ec7 You can never have too many tests
Matthew Wild <mwild1@gmail.com>
parents: 273
diff changeset
138 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' });
8aedb3766ec7 You can never have too many tests
Matthew Wild <mwild1@gmail.com>
parents: 273
diff changeset
139
8aedb3766ec7 You can never have too many tests
Matthew Wild <mwild1@gmail.com>
parents: 273
diff changeset
140 local target_routed;
8aedb3766ec7 You can never have too many tests
Matthew Wild <mwild1@gmail.com>
parents: 273
diff changeset
141
8aedb3766ec7 You can never have too many tests
Matthew Wild <mwild1@gmail.com>
parents: 273
diff changeset
142 function env.core_route_stanza(p_origin, p_stanza)
8aedb3766ec7 You can never have too many tests
Matthew Wild <mwild1@gmail.com>
parents: 273
diff changeset
143 assert_equal(p_origin, s2sin_session, "origin of handled stanza is not correct");
8aedb3766ec7 You can never have too many tests
Matthew Wild <mwild1@gmail.com>
parents: 273
diff changeset
144 assert_equal(p_stanza, msg, "handled stanza is not correct one: "..p_stanza:pretty_print());
8aedb3766ec7 You can never have too many tests
Matthew Wild <mwild1@gmail.com>
parents: 273
diff changeset
145 target_routed = true;
8aedb3766ec7 You can never have too many tests
Matthew Wild <mwild1@gmail.com>
parents: 273
diff changeset
146 end
8aedb3766ec7 You can never have too many tests
Matthew Wild <mwild1@gmail.com>
parents: 273
diff changeset
147
8aedb3766ec7 You can never have too many tests
Matthew Wild <mwild1@gmail.com>
parents: 273
diff changeset
148 function env.core_handle_stanza(p_origin, p_stanza)
8aedb3766ec7 You can never have too many tests
Matthew Wild <mwild1@gmail.com>
parents: 273
diff changeset
149
8aedb3766ec7 You can never have too many tests
Matthew Wild <mwild1@gmail.com>
parents: 273
diff changeset
150 end
8aedb3766ec7 You can never have too many tests
Matthew Wild <mwild1@gmail.com>
parents: 273
diff changeset
151
8aedb3766ec7 You can never have too many tests
Matthew Wild <mwild1@gmail.com>
parents: 273
diff changeset
152 env.hosts = hosts;
8aedb3766ec7 You can never have too many tests
Matthew Wild <mwild1@gmail.com>
parents: 273
diff changeset
153 setfenv(core_process_stanza, env);
8aedb3766ec7 You can never have too many tests
Matthew Wild <mwild1@gmail.com>
parents: 273
diff changeset
154 assert_equal(core_process_stanza(s2sin_session, msg), nil, "core_process_stanza returned incorrect value");
8aedb3766ec7 You can never have too many tests
Matthew Wild <mwild1@gmail.com>
parents: 273
diff changeset
155 assert_equal(target_routed, true, "stanza was not routed successfully");
8aedb3766ec7 You can never have too many tests
Matthew Wild <mwild1@gmail.com>
parents: 273
diff changeset
156 end
8aedb3766ec7 You can never have too many tests
Matthew Wild <mwild1@gmail.com>
parents: 273
diff changeset
157
273
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
158 runtest(test_message_full_jid, "Messages with full JID destinations get routed");
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
159 runtest(test_message_bare_jid, "Messages with bare JID destinations get routed");
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
160 runtest(test_message_no_to, "Messages with no destination are handled by the server");
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
161 runtest(test_message_to_remote_bare, "Messages to a remote user are routed by the server");
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
162 runtest(test_message_to_remote_server, "Messages to a remote server's JID are routed");
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
163
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
164 runtest(test_iq_to_remote_server, "iq to a remote server's JID are routed");
302
8aedb3766ec7 You can never have too many tests
Matthew Wild <mwild1@gmail.com>
parents: 273
diff changeset
165 runtest(test_iq_error_to_local_user, "iq type=error to a local user's JID are routed");
273
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
166
b4c6b124c06f Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
167 end