tests/integration/register.lua

1
local harness = require "harness";
2
 
3
return {
4
	{ "registers a new account in-band and logs in with it", function (t)
5
		local user = "reg"..os.time();
6
		local c = t.client(user, nil, { plugins = { "register" }, expect_disconnect = true });
7
		c:hook("registration-failure", function (err)
8
			t.fail("registration failed: "..tostring(err.condition));
9
		end);
10
		c:hook("registration-success", t.cb(function ()
11
			c:close();
12
			t.client(user, function (c2)
13
				assert(c2.jid:match("^"..user.."@"), "logged in as "..tostring(c2.jid));
14
				t.done();
15
			end);
16
		end));
17
	end };
18
};