diff options
author | Kim Alvefur <zash@zash.se> | 2019-12-24 00:39:45 +0100 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2019-12-24 00:39:45 +0100 |
commit | 1eabf5bdb449b0312dfa272884e02cc84175775c (patch) | |
tree | 94b4ebcb9443e8e6751e1903ade3c9dc8ec9d678 /spec/util_sasl_spec.lua | |
parent | 575cd4c57d062a1addc761aa0036b1db752900a9 (diff) | |
parent | 8537138d41a6bca5e855040c8928ef2aae59802f (diff) | |
download | prosody-1eabf5bdb449b0312dfa272884e02cc84175775c.tar.gz prosody-1eabf5bdb449b0312dfa272884e02cc84175775c.zip |
Merge 0.11->trunk
Diffstat (limited to 'spec/util_sasl_spec.lua')
-rw-r--r-- | spec/util_sasl_spec.lua | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/spec/util_sasl_spec.lua b/spec/util_sasl_spec.lua new file mode 100644 index 00000000..368291b3 --- /dev/null +++ b/spec/util_sasl_spec.lua @@ -0,0 +1,43 @@ +local sasl = require "util.sasl"; + +-- profile * mechanism +-- callbacks could use spies instead + +describe("util.sasl", function () + describe("plain_test profile", function () + local profile = { + plain_test = function (_, username, password, realm) + assert.equals("user", username) + assert.equals("pencil", password) + assert.equals("sasl.test", realm) + return true, true; + end; + }; + it("works with PLAIN", function () + local plain = sasl.new("sasl.test", profile); + assert.truthy(plain:select("PLAIN")); + assert.truthy(plain:process("\000user\000pencil")); + assert.equals("user", plain.username); + end); + end); + + describe("plain profile", function () + local profile = { + plain = function (_, username, realm) + assert.equals("user", username) + assert.equals("sasl.test", realm) + return "pencil", true; + end; + }; + + it("works with PLAIN", function () + local plain = sasl.new("sasl.test", profile); + assert.truthy(plain:select("PLAIN")); + assert.truthy(plain:process("\000user\000pencil")); + assert.equals("user", plain.username); + end); + + -- TODO SCRAM + end); +end); + |