Annotate

spec/util_sasl_spec.lua @ 11632:21a1b9fb08a1

mod_admin_adhoc: Delete "Get User Password" command This doesn't really make sense today. It doesn't even work with mod_auth_internal_hashed, which should be the default. And even with a supporting authentication module, why would we just hand out the password? One use case may be to recover a forgotten password. While not yet included with Prosody, there are better ways to handle forgotten passwords, usually by resetting them to a new password.
author Kim Alvefur <zash@zash.se>
date Sun, 27 Jun 2021 21:51:21 +0200
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