Software /
code /
prosody
Annotate
tests/test_core_stanza_router.lua @ 434:0d7ba3742f7a
(Basic) IDNA and SRV fallback support
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Wed, 26 Nov 2008 23:44:30 +0000 |
parent | 302:8aedb3766ec7 |
child | 519:cccd610a0ef9 |
rev | line source |
---|---|
273
b4c6b124c06f
Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1 |
b4c6b124c06f
Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2 function core_process_stanza(core_process_stanza) |
b4c6b124c06f
Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3 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
|
4 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
|
5 local local_host_session = { host = "localhost", type = "local" } |
b4c6b124c06f
Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6 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
|
7 local hosts = { |
b4c6b124c06f
Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8 ["localhost"] = local_host_session; |
b4c6b124c06f
Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9 } |
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 -- Test message routing |
b4c6b124c06f
Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
12 local function test_message_full_jid() |
b4c6b124c06f
Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
13 local env = testlib_new_env(); |
b4c6b124c06f
Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
14 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
|
15 |
b4c6b124c06f
Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
16 local target_routed; |
b4c6b124c06f
Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
17 |
b4c6b124c06f
Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
18 function env.core_route_stanza(p_origin, p_stanza) |
b4c6b124c06f
Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
19 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
|
20 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
|
21 target_routed = true; |
b4c6b124c06f
Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
22 end |
b4c6b124c06f
Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
23 env.hosts = hosts; |
b4c6b124c06f
Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
24 setfenv(core_process_stanza, env); |
b4c6b124c06f
Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
25 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
|
26 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
|
27 end |
b4c6b124c06f
Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
28 |
b4c6b124c06f
Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
29 local function test_message_bare_jid() |
b4c6b124c06f
Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
30 local env = testlib_new_env(); |
b4c6b124c06f
Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
31 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
|
32 |
b4c6b124c06f
Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
33 local target_routed; |
b4c6b124c06f
Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
34 |
b4c6b124c06f
Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
35 function env.core_route_stanza(p_origin, p_stanza) |
b4c6b124c06f
Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
36 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
|
37 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
|
38 target_routed = true; |
b4c6b124c06f
Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
39 end |
b4c6b124c06f
Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
40 env.hosts = hosts; |
b4c6b124c06f
Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
41 setfenv(core_process_stanza, env); |
b4c6b124c06f
Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
42 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
|
43 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
|
44 end |
b4c6b124c06f
Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
45 |
b4c6b124c06f
Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
46 local function test_message_no_to() |
b4c6b124c06f
Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
47 local env = testlib_new_env(); |
b4c6b124c06f
Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
48 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
|
49 |
b4c6b124c06f
Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
50 local target_handled; |
b4c6b124c06f
Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
51 |
b4c6b124c06f
Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
52 function env.core_route_stanza(p_origin, p_stanza) |
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 function env.core_handle_stanza(p_origin, p_stanza) |
b4c6b124c06f
Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
56 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
|
57 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
|
58 target_handled = true; |
b4c6b124c06f
Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
59 end |
b4c6b124c06f
Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
60 env.hosts = hosts; |
b4c6b124c06f
Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
61 setfenv(core_process_stanza, env); |
b4c6b124c06f
Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
62 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
|
63 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
|
64 end |
b4c6b124c06f
Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
65 |
b4c6b124c06f
Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
66 local function test_message_to_remote_bare() |
b4c6b124c06f
Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
67 local env = testlib_new_env(); |
b4c6b124c06f
Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
68 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
|
69 |
b4c6b124c06f
Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
70 local target_routed; |
b4c6b124c06f
Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
71 |
b4c6b124c06f
Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
72 function env.core_route_stanza(p_origin, p_stanza) |
b4c6b124c06f
Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
73 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
|
74 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
|
75 target_routed = true; |
b4c6b124c06f
Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
76 end |
b4c6b124c06f
Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
77 |
b4c6b124c06f
Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
78 env.hosts = hosts; |
b4c6b124c06f
Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
79 setfenv(core_process_stanza, env); |
b4c6b124c06f
Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
80 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
|
81 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
|
82 end |
b4c6b124c06f
Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
83 |
b4c6b124c06f
Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
84 local function test_message_to_remote_server() |
b4c6b124c06f
Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
85 local env = testlib_new_env(); |
b4c6b124c06f
Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
86 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
|
87 |
b4c6b124c06f
Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
88 local target_routed; |
b4c6b124c06f
Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
89 |
b4c6b124c06f
Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
90 function env.core_route_stanza(p_origin, p_stanza) |
b4c6b124c06f
Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
91 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
|
92 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
|
93 target_routed = true; |
b4c6b124c06f
Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
94 end |
b4c6b124c06f
Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
95 |
b4c6b124c06f
Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
96 env.hosts = hosts; |
b4c6b124c06f
Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
97 setfenv(core_process_stanza, env); |
b4c6b124c06f
Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
98 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
|
99 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
|
100 end |
b4c6b124c06f
Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
101 |
b4c6b124c06f
Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
102 --IQ tests |
b4c6b124c06f
Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
103 |
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 local function test_iq_to_remote_server() |
b4c6b124c06f
Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
106 local env = testlib_new_env(); |
b4c6b124c06f
Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
107 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
|
108 |
b4c6b124c06f
Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
109 local target_routed; |
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 function env.core_route_stanza(p_origin, p_stanza) |
b4c6b124c06f
Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
112 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
|
113 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
|
114 target_routed = true; |
b4c6b124c06f
Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
115 end |
b4c6b124c06f
Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
116 |
b4c6b124c06f
Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
117 function env.core_handle_stanza(p_origin, p_stanza) |
b4c6b124c06f
Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
118 |
b4c6b124c06f
Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
119 end |
b4c6b124c06f
Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
120 |
b4c6b124c06f
Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
121 env.hosts = hosts; |
b4c6b124c06f
Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
122 setfenv(core_process_stanza, env); |
b4c6b124c06f
Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
123 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
|
124 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
|
125 end |
b4c6b124c06f
Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
126 |
302
8aedb3766ec7
You can never have too many tests
Matthew Wild <mwild1@gmail.com>
parents:
273
diff
changeset
|
127 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
|
128 local env = testlib_new_env(); |
8aedb3766ec7
You can never have too many tests
Matthew Wild <mwild1@gmail.com>
parents:
273
diff
changeset
|
129 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
|
130 |
8aedb3766ec7
You can never have too many tests
Matthew Wild <mwild1@gmail.com>
parents:
273
diff
changeset
|
131 local target_routed; |
8aedb3766ec7
You can never have too many tests
Matthew Wild <mwild1@gmail.com>
parents:
273
diff
changeset
|
132 |
8aedb3766ec7
You can never have too many tests
Matthew Wild <mwild1@gmail.com>
parents:
273
diff
changeset
|
133 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
|
134 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
|
135 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
|
136 target_routed = true; |
8aedb3766ec7
You can never have too many tests
Matthew Wild <mwild1@gmail.com>
parents:
273
diff
changeset
|
137 end |
8aedb3766ec7
You can never have too many tests
Matthew Wild <mwild1@gmail.com>
parents:
273
diff
changeset
|
138 |
8aedb3766ec7
You can never have too many tests
Matthew Wild <mwild1@gmail.com>
parents:
273
diff
changeset
|
139 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
|
140 |
8aedb3766ec7
You can never have too many tests
Matthew Wild <mwild1@gmail.com>
parents:
273
diff
changeset
|
141 end |
8aedb3766ec7
You can never have too many tests
Matthew Wild <mwild1@gmail.com>
parents:
273
diff
changeset
|
142 |
8aedb3766ec7
You can never have too many tests
Matthew Wild <mwild1@gmail.com>
parents:
273
diff
changeset
|
143 env.hosts = hosts; |
8aedb3766ec7
You can never have too many tests
Matthew Wild <mwild1@gmail.com>
parents:
273
diff
changeset
|
144 setfenv(core_process_stanza, env); |
8aedb3766ec7
You can never have too many tests
Matthew Wild <mwild1@gmail.com>
parents:
273
diff
changeset
|
145 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
|
146 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
|
147 end |
8aedb3766ec7
You can never have too many tests
Matthew Wild <mwild1@gmail.com>
parents:
273
diff
changeset
|
148 |
273
b4c6b124c06f
Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
149 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
|
150 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
|
151 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
|
152 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
|
153 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
|
154 |
b4c6b124c06f
Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
155 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
|
156 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
|
157 |
b4c6b124c06f
Add tests for core.stanza_router
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
158 end |