10502
|
1 local sasl = require "util.sasl";
|
|
2
|
|
3 -- profile * mechanism
|
|
4 -- callbacks could use spies instead
|
|
5
|
|
6 describe("util.sasl", function ()
|
|
7 describe("plain_test profile", function ()
|
|
8 local profile = {
|
|
9 plain_test = function (_, username, password, realm)
|
|
10 assert.equals("user", username)
|
|
11 assert.equals("pencil", password)
|
|
12 assert.equals("sasl.test", realm)
|
|
13 return true, true;
|
|
14 end;
|
|
15 };
|
|
16 it("works with PLAIN", function ()
|
|
17 local plain = sasl.new("sasl.test", profile);
|
|
18 assert.truthy(plain:select("PLAIN"));
|
|
19 assert.truthy(plain:process("\000user\000pencil"));
|
|
20 assert.equals("user", plain.username);
|
|
21 end);
|
|
22 end);
|
|
23
|
|
24 describe("plain profile", function ()
|
|
25 local profile = {
|
|
26 plain = function (_, username, realm)
|
|
27 assert.equals("user", username)
|
|
28 assert.equals("sasl.test", realm)
|
|
29 return "pencil", true;
|
|
30 end;
|
|
31 };
|
|
32
|
|
33 it("works with PLAIN", function ()
|
|
34 local plain = sasl.new("sasl.test", profile);
|
|
35 assert.truthy(plain:select("PLAIN"));
|
|
36 assert.truthy(plain:process("\000user\000pencil"));
|
|
37 assert.equals("user", plain.username);
|
|
38 end);
|
|
39
|
|
40 -- TODO SCRAM
|
|
41 end);
|
|
42 end);
|
|
43
|