Annotate

spec/util_sasl_spec.lua @ 12212:bc6fc1cb04ae

mod_pubsub: Use the 'pubsub#type' setting to pick summary generator Allows using different ones even if multiple semantically different formats share the same root element xmlns, e.g. generic Atom and XEP-0277 entries.
author Kim Alvefur <zash@zash.se>
date Mon, 24 Jan 2022 23:05:26 +0100
parent 10502:f1c0aa521dd5
child 13113:191fe4866e3e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10502
f1c0aa521dd5 util.sasl: Add stub tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
1 local sasl = require "util.sasl";
f1c0aa521dd5 util.sasl: Add stub tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
2
f1c0aa521dd5 util.sasl: Add stub tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
3 -- profile * mechanism
f1c0aa521dd5 util.sasl: Add stub tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
4 -- callbacks could use spies instead
f1c0aa521dd5 util.sasl: Add stub tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
5
f1c0aa521dd5 util.sasl: Add stub tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
6 describe("util.sasl", function ()
f1c0aa521dd5 util.sasl: Add stub tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
7 describe("plain_test profile", function ()
f1c0aa521dd5 util.sasl: Add stub tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
8 local profile = {
f1c0aa521dd5 util.sasl: Add stub tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
9 plain_test = function (_, username, password, realm)
f1c0aa521dd5 util.sasl: Add stub tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
10 assert.equals("user", username)
f1c0aa521dd5 util.sasl: Add stub tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
11 assert.equals("pencil", password)
f1c0aa521dd5 util.sasl: Add stub tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
12 assert.equals("sasl.test", realm)
f1c0aa521dd5 util.sasl: Add stub tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
13 return true, true;
f1c0aa521dd5 util.sasl: Add stub tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
14 end;
f1c0aa521dd5 util.sasl: Add stub tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
15 };
f1c0aa521dd5 util.sasl: Add stub tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
16 it("works with PLAIN", function ()
f1c0aa521dd5 util.sasl: Add stub tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
17 local plain = sasl.new("sasl.test", profile);
f1c0aa521dd5 util.sasl: Add stub tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
18 assert.truthy(plain:select("PLAIN"));
f1c0aa521dd5 util.sasl: Add stub tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
19 assert.truthy(plain:process("\000user\000pencil"));
f1c0aa521dd5 util.sasl: Add stub tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
20 assert.equals("user", plain.username);
f1c0aa521dd5 util.sasl: Add stub tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
21 end);
f1c0aa521dd5 util.sasl: Add stub tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
22 end);
f1c0aa521dd5 util.sasl: Add stub tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
23
f1c0aa521dd5 util.sasl: Add stub tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
24 describe("plain profile", function ()
f1c0aa521dd5 util.sasl: Add stub tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
25 local profile = {
f1c0aa521dd5 util.sasl: Add stub tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
26 plain = function (_, username, realm)
f1c0aa521dd5 util.sasl: Add stub tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
27 assert.equals("user", username)
f1c0aa521dd5 util.sasl: Add stub tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
28 assert.equals("sasl.test", realm)
f1c0aa521dd5 util.sasl: Add stub tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
29 return "pencil", true;
f1c0aa521dd5 util.sasl: Add stub tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
30 end;
f1c0aa521dd5 util.sasl: Add stub tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
31 };
f1c0aa521dd5 util.sasl: Add stub tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
32
f1c0aa521dd5 util.sasl: Add stub tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
33 it("works with PLAIN", function ()
f1c0aa521dd5 util.sasl: Add stub tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
34 local plain = sasl.new("sasl.test", profile);
f1c0aa521dd5 util.sasl: Add stub tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
35 assert.truthy(plain:select("PLAIN"));
f1c0aa521dd5 util.sasl: Add stub tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
36 assert.truthy(plain:process("\000user\000pencil"));
f1c0aa521dd5 util.sasl: Add stub tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
37 assert.equals("user", plain.username);
f1c0aa521dd5 util.sasl: Add stub tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
38 end);
f1c0aa521dd5 util.sasl: Add stub tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
39
f1c0aa521dd5 util.sasl: Add stub tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
40 -- TODO SCRAM
f1c0aa521dd5 util.sasl: Add stub tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
41 end);
f1c0aa521dd5 util.sasl: Add stub tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
42 end);
f1c0aa521dd5 util.sasl: Add stub tests
Kim Alvefur <zash@zash.se>
parents:
diff changeset
43