Annotate

spec/mod_bosh_spec.lua @ 12705:008a7097fdc5

util.jwt: Provide built-in token expiry support (defaults to 3600s lifetime) To avoid every user of the library needing to add and verify expiry info, this is now handled by util.jwt itself (if not overridden or disabled). Issuing tokens that are valid forever is bad practice and rarely desired, and the default token lifetime is now 3600s (1 hour).
author Matthew Wild <mwild1@gmail.com>
date Mon, 11 Jul 2022 13:28:29 +0100
parent 9374:a1a39d395260
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9374
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2 -- Requires a host 'localhost' with SASL ANONYMOUS
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4 local bosh_url = "http://localhost:5280/http-bind"
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6 local logger = require "util.logger";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8 local debug = false;
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
10 local print = print;
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
11 if debug then
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
12 logger.add_simple_sink(print, {
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
13 --"debug";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
14 "info";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
15 "warn";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
16 "error";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
17 });
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
18 else
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
19 print = function () end
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
20 end
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
21
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
22 describe("#mod_bosh", function ()
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
23 local server = require "net.server_select";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
24 package.loaded["net.server"] = server;
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
25 local async = require "util.async";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
26 local timer = require "util.timer";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
27 local http = require "net.http".new({ suppress_errors = false });
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
28
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
29 local function sleep(n)
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
30 local wait, done = async.waiter();
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
31 timer.add_task(n, function () done() end);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
32 wait();
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
33 end
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
34
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
35 local st = require "util.stanza";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
36 local xml = require "util.xml";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
37
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
38 local function request(url, opt, cb, auto_wait)
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
39 local wait, done = async.waiter();
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
40 local ok, err;
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
41 http:request(url, opt, function (...)
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
42 ok, err = pcall(cb, ...);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
43 if not ok then print("CAUGHT", err) end
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
44 done();
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
45 end);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
46 local function err_wait(throw)
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
47 wait();
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
48 if throw ~= false and not ok then
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
49 error(err);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
50 end
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
51 return ok, err;
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
52 end
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
53 if auto_wait == false then
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
54 return err_wait;
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
55 else
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
56 err_wait();
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
57 end
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
58 end
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
59
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
60 local function run_async(f)
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
61 local err;
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
62 local r = async.runner();
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
63 r:onerror(function (_, err_)
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
64 print("EER", err_)
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
65 err = err_;
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
66 server.setquitting("once");
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
67 end)
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
68 :onwaiting(function ()
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
69 --server.loop();
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
70 end)
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
71 :run(function ()
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
72 f()
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
73 server.setquitting("once");
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
74 end);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
75 server.loop();
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
76 if err then
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
77 error(err);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
78 end
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
79 if r.state ~= "ready" then
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
80 error("Runner in unexpected state: "..r.state);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
81 end
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
82 end
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
83
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
84 it("test endpoint should be reachable", function ()
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
85 -- This is partly just to ensure the other tests have a chance to succeed
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
86 -- (i.e. the BOSH endpoint is up and functioning)
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
87 local function test()
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
88 request(bosh_url, nil, function (resp, code)
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
89 if code ~= 200 then
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
90 error("Unable to reach BOSH endpoint "..bosh_url);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
91 end
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
92 assert.is_string(resp);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
93 end);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
94 end
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
95 run_async(test);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
96 end);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
97
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
98 it("should respond to past rids with past responses", function ()
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
99 local resp_1000_1, resp_1000_2 = "1", "2";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
100
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
101 local function test_bosh()
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
102 local sid;
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
103
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
104 -- Set up BOSH session
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
105 request(bosh_url, {
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
106 body = tostring(st.stanza("body", {
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
107 to = "localhost";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
108 from = "test@localhost";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
109 content = "text/xml; charset=utf-8";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
110 hold = "1";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
111 rid = "998";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
112 wait = "10";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
113 ["xml:lang"] = "en";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
114 ["xmpp:version"] = "1.0";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
115 xmlns = "http://jabber.org/protocol/httpbind";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
116 ["xmlns:xmpp"] = "urn:xmpp:xbosh";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
117 })
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
118 :tag("auth", { xmlns = "urn:ietf:params:xml:ns:xmpp-sasl", mechanism = "ANONYMOUS" }):up()
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
119 :tag("iq", { xmlns = "jabber:client", type = "set", id = "bind1" })
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
120 :tag("bind", { xmlns = "urn:ietf:params:xml:ns:xmpp-bind" })
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
121 :tag("resource"):text("bosh-test1"):up()
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
122 :up()
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
123 :up()
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
124 );
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
125 }, function (response_body)
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
126 local resp = xml.parse(response_body);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
127 if not response_body:find("<jid>", 1, true) then
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
128 print("ERR", resp:pretty_print());
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
129 error("Failed to set up BOSH session");
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
130 end
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
131 sid = assert(resp.attr.sid);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
132 print("SID", sid);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
133 end);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
134
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
135 -- Receive some additional post-login stuff
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
136 request(bosh_url, {
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
137 body = tostring(st.stanza("body", {
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
138 sid = sid;
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
139 rid = "999";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
140 content = "text/xml; charset=utf-8";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
141 ["xml:lang"] = "en";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
142 xmlns = "http://jabber.org/protocol/httpbind";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
143 ["xmlns:xmpp"] = "urn:xmpp:xbosh";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
144 })
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
145 )
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
146 }, function (response_body)
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
147 local resp = xml.parse(response_body);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
148 print("RESP 999", resp:pretty_print());
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
149 end);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
150
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
151 -- Send first long poll
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
152 print "SEND 1000#1"
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
153 local wait1000 = request(bosh_url, {
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
154 body = tostring(st.stanza("body", {
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
155 sid = sid;
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
156 rid = "1000";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
157 content = "text/xml; charset=utf-8";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
158 ["xml:lang"] = "en";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
159 xmlns = "http://jabber.org/protocol/httpbind";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
160 ["xmlns:xmpp"] = "urn:xmpp:xbosh";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
161 }))
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
162 }, function (response_body)
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
163 local resp = xml.parse(response_body);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
164 resp_1000_1 = resp;
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
165 print("RESP 1000#1", resp:pretty_print());
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
166 end, false);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
167
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
168 -- Wait a couple of seconds
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
169 sleep(2)
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
170
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
171 -- Send an early request, causing rid 1000 to return early
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
172 print "SEND 1001"
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
173 local wait1001 = request(bosh_url, {
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
174 body = tostring(st.stanza("body", {
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
175 sid = sid;
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
176 rid = "1001";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
177 content = "text/xml; charset=utf-8";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
178 ["xml:lang"] = "en";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
179 xmlns = "http://jabber.org/protocol/httpbind";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
180 ["xmlns:xmpp"] = "urn:xmpp:xbosh";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
181 }))
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
182 }, function (response_body)
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
183 local resp = xml.parse(response_body);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
184 print("RESP 1001", resp:pretty_print());
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
185 end, false);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
186 -- Ensure we've received the response for rid 1000
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
187 wait1000();
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
188
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
189 -- Sleep a couple of seconds
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
190 print "...pause..."
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
191 sleep(2);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
192
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
193 -- Re-send rid 1000, we should get the same response
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
194 print "SEND 1000#2"
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
195 request(bosh_url, {
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
196 body = tostring(st.stanza("body", {
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
197 sid = sid;
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
198 rid = "1000";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
199 content = "text/xml; charset=utf-8";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
200 ["xml:lang"] = "en";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
201 xmlns = "http://jabber.org/protocol/httpbind";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
202 ["xmlns:xmpp"] = "urn:xmpp:xbosh";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
203 }))
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
204 }, function (response_body)
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
205 local resp = xml.parse(response_body);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
206 resp_1000_2 = resp;
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
207 print("RESP 1000#2", resp:pretty_print());
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
208 end);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
209
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
210 local wait_final = request(bosh_url, {
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
211 body = tostring(st.stanza("body", {
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
212 sid = sid;
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
213 rid = "1002";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
214 type = "terminate";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
215 content = "text/xml; charset=utf-8";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
216 ["xml:lang"] = "en";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
217 xmlns = "http://jabber.org/protocol/httpbind";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
218 ["xmlns:xmpp"] = "urn:xmpp:xbosh";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
219 }))
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
220 }, function ()
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
221 end, false);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
222
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
223 print "WAIT 1001"
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
224 wait1001();
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
225 wait_final();
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
226 print "DONE ALL"
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
227 end
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
228 run_async(test_bosh);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
229 assert.truthy(resp_1000_1);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
230 assert.same(resp_1000_1, resp_1000_2);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
231 end);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
232
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
233 it("should handle out-of-order requests", function ()
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
234 local function test()
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
235 local sid;
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
236 -- Set up BOSH session
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
237 local wait, done = async.waiter();
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
238 http:request(bosh_url, {
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
239 body = tostring(st.stanza("body", {
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
240 to = "localhost";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
241 from = "test@localhost";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
242 content = "text/xml; charset=utf-8";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
243 hold = "1";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
244 rid = "1";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
245 wait = "10";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
246 ["xml:lang"] = "en";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
247 ["xmpp:version"] = "1.0";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
248 xmlns = "http://jabber.org/protocol/httpbind";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
249 ["xmlns:xmpp"] = "urn:xmpp:xbosh";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
250 }));
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
251 }, function (response_body)
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
252 local resp = xml.parse(response_body);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
253 sid = assert(resp.attr.sid, "Failed to set up BOSH session");
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
254 print("SID", sid);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
255 done();
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
256 end);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
257 print "WAIT 1"
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
258 wait();
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
259 print "DONE 1"
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
260
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
261 local rid2_response_received = false;
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
262
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
263 -- Temporarily skip rid 2, to simulate missed request
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
264 local wait3, done3 = async.waiter();
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
265 http:request(bosh_url, {
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
266 body = tostring(st.stanza("body", {
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
267 sid = sid;
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
268 rid = "3";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
269 content = "text/xml; charset=utf-8";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
270 ["xml:lang"] = "en";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
271 xmlns = "http://jabber.org/protocol/httpbind";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
272 ["xmlns:xmpp"] = "urn:xmpp:xbosh";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
273 }):tag("iq", { xmlns = "jabber:client", type = "set", id = "bind" })
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
274 :tag("bind", { xmlns = "urn:ietf:params:xml:ns:xmpp-bind" }):up()
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
275 :up()
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
276 )
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
277 }, function (response_body)
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
278 local resp = xml.parse(response_body);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
279 print("RESP 3", resp:pretty_print());
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
280 done3();
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
281 -- The server should not respond to this request until
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
282 -- it has responded to rid 2
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
283 assert.is_true(rid2_response_received);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
284 end);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
285
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
286 print "SLEEPING"
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
287 sleep(2);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
288 print "SLEPT"
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
289
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
290 -- Send the "missed" rid 2
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
291 local wait2, done2 = async.waiter();
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
292 http:request(bosh_url, {
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
293 body = tostring(st.stanza("body", {
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
294 sid = sid;
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
295 rid = "2";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
296 content = "text/xml; charset=utf-8";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
297 ["xml:lang"] = "en";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
298 xmlns = "http://jabber.org/protocol/httpbind";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
299 ["xmlns:xmpp"] = "urn:xmpp:xbosh";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
300 }):tag("auth", { xmlns = "urn:ietf:params:xml:ns:xmpp-sasl", mechanism = "ANONYMOUS" }):up()
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
301 )
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
302 }, function (response_body)
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
303 local resp = xml.parse(response_body);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
304 print("RESP 2", resp:pretty_print());
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
305 rid2_response_received = true;
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
306 done2();
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
307 end);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
308 print "WAIT 2"
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
309 wait2();
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
310 print "WAIT 3"
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
311 wait3();
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
312 print "QUIT"
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
313 end
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
314 run_async(test);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
315 end);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
316
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
317 it("should work", function ()
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
318 local function test()
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
319 local sid;
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
320 -- Set up BOSH session
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
321 local wait, done = async.waiter();
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
322 http:request(bosh_url, {
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
323 body = tostring(st.stanza("body", {
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
324 to = "localhost";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
325 from = "test@localhost";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
326 content = "text/xml; charset=utf-8";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
327 hold = "1";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
328 rid = "1";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
329 wait = "10";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
330 ["xml:lang"] = "en";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
331 ["xmpp:version"] = "1.0";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
332 xmlns = "http://jabber.org/protocol/httpbind";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
333 ["xmlns:xmpp"] = "urn:xmpp:xbosh";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
334 }));
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
335 }, function (response_body)
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
336 local resp = xml.parse(response_body);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
337 sid = assert(resp.attr.sid, "Failed to set up BOSH session");
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
338 print("SID", sid);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
339 done();
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
340 end);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
341 print "WAIT 1"
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
342 wait();
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
343 print "DONE 1"
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
344
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
345 local rid2_response_received = false;
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
346
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
347 -- Send the "missed" rid 2
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
348 local wait2, done2 = async.waiter();
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
349 http:request(bosh_url, {
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
350 body = tostring(st.stanza("body", {
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
351 sid = sid;
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
352 rid = "2";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
353 content = "text/xml; charset=utf-8";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
354 ["xml:lang"] = "en";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
355 xmlns = "http://jabber.org/protocol/httpbind";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
356 ["xmlns:xmpp"] = "urn:xmpp:xbosh";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
357 }):tag("auth", { xmlns = "urn:ietf:params:xml:ns:xmpp-sasl", mechanism = "ANONYMOUS" }):up()
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
358 )
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
359 }, function (response_body)
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
360 local resp = xml.parse(response_body);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
361 print("RESP 2", resp:pretty_print());
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
362 rid2_response_received = true;
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
363 done2();
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
364 end);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
365
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
366 local wait3, done3 = async.waiter();
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
367 http:request(bosh_url, {
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
368 body = tostring(st.stanza("body", {
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
369 sid = sid;
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
370 rid = "3";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
371 content = "text/xml; charset=utf-8";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
372 ["xml:lang"] = "en";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
373 xmlns = "http://jabber.org/protocol/httpbind";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
374 ["xmlns:xmpp"] = "urn:xmpp:xbosh";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
375 }):tag("iq", { xmlns = "jabber:client", type = "set", id = "bind" })
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
376 :tag("bind", { xmlns = "urn:ietf:params:xml:ns:xmpp-bind" }):up()
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
377 :up()
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
378 )
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
379 }, function (response_body)
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
380 local resp = xml.parse(response_body);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
381 print("RESP 3", resp:pretty_print());
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
382 done3();
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
383 -- The server should not respond to this request until
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
384 -- it has responded to rid 2
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
385 assert.is_true(rid2_response_received);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
386 end);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
387
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
388 print "SLEEPING"
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
389 sleep(2);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
390 print "SLEPT"
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
391
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
392 print "WAIT 2"
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
393 wait2();
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
394 print "WAIT 3"
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
395 wait3();
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
396 print "QUIT"
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
397 end
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
398 run_async(test);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
399 end);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
400
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
401 it("should handle aborted pending requests", function ()
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
402 local resp_1000_1, resp_1000_2 = "1", "2";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
403
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
404 local function test_bosh()
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
405 local sid;
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
406
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
407 -- Set up BOSH session
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
408 request(bosh_url, {
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
409 body = tostring(st.stanza("body", {
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
410 to = "localhost";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
411 from = "test@localhost";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
412 content = "text/xml; charset=utf-8";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
413 hold = "1";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
414 rid = "998";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
415 wait = "10";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
416 ["xml:lang"] = "en";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
417 ["xmpp:version"] = "1.0";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
418 xmlns = "http://jabber.org/protocol/httpbind";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
419 ["xmlns:xmpp"] = "urn:xmpp:xbosh";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
420 })
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
421 :tag("auth", { xmlns = "urn:ietf:params:xml:ns:xmpp-sasl", mechanism = "ANONYMOUS" }):up()
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
422 :tag("iq", { xmlns = "jabber:client", type = "set", id = "bind1" })
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
423 :tag("bind", { xmlns = "urn:ietf:params:xml:ns:xmpp-bind" })
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
424 :tag("resource"):text("bosh-test1"):up()
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
425 :up()
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
426 :up()
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
427 );
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
428 }, function (response_body)
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
429 local resp = xml.parse(response_body);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
430 if not response_body:find("<jid>", 1, true) then
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
431 print("ERR", resp:pretty_print());
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
432 error("Failed to set up BOSH session");
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
433 end
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
434 sid = assert(resp.attr.sid);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
435 print("SID", sid);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
436 end);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
437
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
438 -- Receive some additional post-login stuff
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
439 request(bosh_url, {
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
440 body = tostring(st.stanza("body", {
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
441 sid = sid;
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
442 rid = "999";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
443 content = "text/xml; charset=utf-8";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
444 ["xml:lang"] = "en";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
445 xmlns = "http://jabber.org/protocol/httpbind";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
446 ["xmlns:xmpp"] = "urn:xmpp:xbosh";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
447 })
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
448 )
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
449 }, function (response_body)
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
450 local resp = xml.parse(response_body);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
451 print("RESP 999", resp:pretty_print());
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
452 end);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
453
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
454 -- Send first long poll
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
455 print "SEND 1000#1"
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
456 local wait1000_1 = request(bosh_url, {
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
457 body = tostring(st.stanza("body", {
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
458 sid = sid;
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
459 rid = "1000";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
460 content = "text/xml; charset=utf-8";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
461 ["xml:lang"] = "en";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
462 xmlns = "http://jabber.org/protocol/httpbind";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
463 ["xmlns:xmpp"] = "urn:xmpp:xbosh";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
464 }))
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
465 }, function (response_body)
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
466 local resp = xml.parse(response_body);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
467 resp_1000_1 = resp;
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
468 assert.is_nil(resp.attr.type);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
469 print("RESP 1000#1", resp:pretty_print());
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
470 end, false);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
471
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
472 -- Wait a couple of seconds
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
473 sleep(2)
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
474
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
475 -- Re-send rid 1000, we should eventually get a normal response (with no stanzas)
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
476 print "SEND 1000#2"
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
477 request(bosh_url, {
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
478 body = tostring(st.stanza("body", {
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
479 sid = sid;
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
480 rid = "1000";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
481 content = "text/xml; charset=utf-8";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
482 ["xml:lang"] = "en";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
483 xmlns = "http://jabber.org/protocol/httpbind";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
484 ["xmlns:xmpp"] = "urn:xmpp:xbosh";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
485 }))
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
486 }, function (response_body)
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
487 local resp = xml.parse(response_body);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
488 resp_1000_2 = resp;
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
489 assert.is_nil(resp.attr.type);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
490 print("RESP 1000#2", resp:pretty_print());
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
491 end);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
492
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
493 wait1000_1();
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
494 print "DONE ALL"
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
495 end
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
496 run_async(test_bosh);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
497 assert.truthy(resp_1000_1);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
498 assert.same(resp_1000_1, resp_1000_2);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
499 end);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
500
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
501 it("should fail on requests beyond rid window", function ()
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
502 local function test_bosh()
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
503 local sid;
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
504
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
505 -- Set up BOSH session
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
506 request(bosh_url, {
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
507 body = tostring(st.stanza("body", {
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
508 to = "localhost";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
509 from = "test@localhost";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
510 content = "text/xml; charset=utf-8";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
511 hold = "1";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
512 rid = "998";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
513 wait = "10";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
514 ["xml:lang"] = "en";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
515 ["xmpp:version"] = "1.0";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
516 xmlns = "http://jabber.org/protocol/httpbind";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
517 ["xmlns:xmpp"] = "urn:xmpp:xbosh";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
518 })
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
519 :tag("auth", { xmlns = "urn:ietf:params:xml:ns:xmpp-sasl", mechanism = "ANONYMOUS" }):up()
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
520 :tag("iq", { xmlns = "jabber:client", type = "set", id = "bind1" })
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
521 :tag("bind", { xmlns = "urn:ietf:params:xml:ns:xmpp-bind" })
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
522 :tag("resource"):text("bosh-test1"):up()
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
523 :up()
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
524 :up()
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
525 );
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
526 }, function (response_body)
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
527 local resp = xml.parse(response_body);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
528 if not response_body:find("<jid>", 1, true) then
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
529 print("ERR", resp:pretty_print());
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
530 error("Failed to set up BOSH session");
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
531 end
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
532 sid = assert(resp.attr.sid);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
533 print("SID", sid);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
534 end);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
535
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
536 -- Receive some additional post-login stuff
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
537 request(bosh_url, {
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
538 body = tostring(st.stanza("body", {
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
539 sid = sid;
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
540 rid = "999";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
541 content = "text/xml; charset=utf-8";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
542 ["xml:lang"] = "en";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
543 xmlns = "http://jabber.org/protocol/httpbind";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
544 ["xmlns:xmpp"] = "urn:xmpp:xbosh";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
545 })
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
546 )
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
547 }, function (response_body)
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
548 local resp = xml.parse(response_body);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
549 print("RESP 999", resp:pretty_print());
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
550 end);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
551
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
552 -- Send poll with a rid that's too high (current + 2, where only current + 1 is allowed)
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
553 print "SEND 1002(!)"
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
554 request(bosh_url, {
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
555 body = tostring(st.stanza("body", {
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
556 sid = sid;
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
557 rid = "1002";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
558 content = "text/xml; charset=utf-8";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
559 ["xml:lang"] = "en";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
560 xmlns = "http://jabber.org/protocol/httpbind";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
561 ["xmlns:xmpp"] = "urn:xmpp:xbosh";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
562 }))
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
563 }, function (response_body)
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
564 local resp = xml.parse(response_body);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
565 assert.equal("terminate", resp.attr.type);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
566 print("RESP 1002(!)", resp:pretty_print());
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
567 end);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
568
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
569 print "DONE ALL"
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
570 end
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
571 run_async(test_bosh);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
572 end);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
573
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
574 it("should always succeed for requests within the rid window", function ()
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
575 local function test()
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
576 local sid;
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
577 -- Set up BOSH session
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
578 request(bosh_url, {
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
579 body = tostring(st.stanza("body", {
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
580 to = "localhost";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
581 from = "test@localhost";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
582 content = "text/xml; charset=utf-8";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
583 hold = "1";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
584 rid = "1";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
585 wait = "10";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
586 ["xml:lang"] = "en";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
587 ["xmpp:version"] = "1.0";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
588 xmlns = "http://jabber.org/protocol/httpbind";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
589 ["xmlns:xmpp"] = "urn:xmpp:xbosh";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
590 }));
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
591 }, function (response_body)
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
592 local resp = xml.parse(response_body);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
593 sid = assert(resp.attr.sid, "Failed to set up BOSH session");
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
594 print("SID", sid);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
595 end);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
596 print "DONE 1"
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
597
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
598 request(bosh_url, {
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
599 body = tostring(st.stanza("body", {
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
600 sid = sid;
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
601 rid = "2";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
602 content = "text/xml; charset=utf-8";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
603 ["xml:lang"] = "en";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
604 xmlns = "http://jabber.org/protocol/httpbind";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
605 ["xmlns:xmpp"] = "urn:xmpp:xbosh";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
606 }):tag("auth", { xmlns = "urn:ietf:params:xml:ns:xmpp-sasl", mechanism = "ANONYMOUS" }):up()
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
607 )
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
608 }, function (response_body)
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
609 local resp = xml.parse(response_body);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
610 print("RESP 2", resp:pretty_print());
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
611 end);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
612
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
613 local resp3;
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
614 request(bosh_url, {
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
615 body = tostring(st.stanza("body", {
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
616 sid = sid;
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
617 rid = "3";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
618 content = "text/xml; charset=utf-8";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
619 ["xml:lang"] = "en";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
620 xmlns = "http://jabber.org/protocol/httpbind";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
621 ["xmlns:xmpp"] = "urn:xmpp:xbosh";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
622 }):tag("iq", { xmlns = "jabber:client", type = "set", id = "bind" })
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
623 :tag("bind", { xmlns = "urn:ietf:params:xml:ns:xmpp-bind" }):up()
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
624 :up()
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
625 )
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
626 }, function (response_body)
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
627 local resp = xml.parse(response_body);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
628 print("RESP 3#1", resp:pretty_print());
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
629 resp3 = resp;
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
630 end);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
631
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
632
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
633 request(bosh_url, {
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
634 body = tostring(st.stanza("body", {
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
635 sid = sid;
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
636 rid = "4";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
637 content = "text/xml; charset=utf-8";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
638 ["xml:lang"] = "en";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
639 xmlns = "http://jabber.org/protocol/httpbind";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
640 ["xmlns:xmpp"] = "urn:xmpp:xbosh";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
641 }):tag("iq", { xmlns = "jabber:client", type = "get", id = "ping1" })
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
642 :tag("ping", { xmlns = "urn:xmpp:ping" }):up()
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
643 :up()
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
644 )
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
645 }, function (response_body)
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
646 local resp = xml.parse(response_body);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
647 print("RESP 4", resp:pretty_print());
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
648 end);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
649
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
650 request(bosh_url, {
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
651 body = tostring(st.stanza("body", {
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
652 sid = sid;
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
653 rid = "3";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
654 content = "text/xml; charset=utf-8";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
655 ["xml:lang"] = "en";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
656 xmlns = "http://jabber.org/protocol/httpbind";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
657 ["xmlns:xmpp"] = "urn:xmpp:xbosh";
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
658 }):tag("iq", { xmlns = "jabber:client", type = "set", id = "bind" })
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
659 :tag("bind", { xmlns = "urn:ietf:params:xml:ns:xmpp-bind" }):up()
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
660 :up()
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
661 )
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
662 }, function (response_body)
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
663 local resp = xml.parse(response_body);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
664 print("RESP 3#2", resp:pretty_print());
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
665 assert.not_equal("terminate", resp.attr.type);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
666 assert.same(resp3, resp);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
667 end);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
668
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
669
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
670 print "QUIT"
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
671 end
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
672 run_async(test);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
673 end);
a1a39d395260 mod_bosh: Add tests (run with 'busted -r bosh')
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
674 end);