aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/scansion/lastactivity.scs45
-rw-r--r--spec/scansion/prosody.cfg.lua14
-rw-r--r--spec/scansion/uptime.scs21
-rw-r--r--spec/scansion/version.scs27
-rw-r--r--spec/util_hashes_spec.lua28
5 files changed, 130 insertions, 5 deletions
diff --git a/spec/scansion/lastactivity.scs b/spec/scansion/lastactivity.scs
new file mode 100644
index 00000000..44f4e516
--- /dev/null
+++ b/spec/scansion/lastactivity.scs
@@ -0,0 +1,45 @@
+# XEP-0012: Last Activity / mod_lastactivity
+
+[Client] Romeo
+ jid: romeo@localhost
+ password: password
+
+-----
+
+Romeo connects
+
+Romeo sends:
+ <presence>
+ <status>Hello</status>
+ </presence>
+
+Romeo receives:
+ <presence from="${Romeo's full JID}">
+ <status>Hello</status>
+ </presence>
+
+Romeo sends:
+ <presence type="unavailable">
+ <status>Goodbye</status>
+ </presence>
+
+Romeo receives:
+ <presence from="${Romeo's full JID}" type="unavailable">
+ <status>Goodbye</status>
+ </presence>
+
+# mod_lastlog saves time + status message from the last unavailable presence
+
+Romeo sends:
+ <iq id='a' type='get'>
+ <query xmlns='jabber:iq:last'/>
+ </iq>
+
+Romeo receives:
+ <iq type='result' id='a'>
+ <query xmlns='jabber:iq:last' seconds='0'>Goodbye</query>
+ </iq>
+
+Romeo disconnects
+
+# recording ended on 2020-04-20T14:39:47Z
diff --git a/spec/scansion/prosody.cfg.lua b/spec/scansion/prosody.cfg.lua
index 6a72584d..b7d6ccd5 100644
--- a/spec/scansion/prosody.cfg.lua
+++ b/spec/scansion/prosody.cfg.lua
@@ -1,5 +1,16 @@
--luacheck: ignore
+-- Mock time functions to simplify tests
+function _G.os.time()
+ return 1219439344;
+end
+package.preload["util.time"] = function ()
+ return {
+ now = function () return 1219439344.1; end;
+ monotonic = function () return 0.1; end;
+ }
+end
+
admins = { "admin@localhost" }
use_libevent = true
@@ -48,6 +59,7 @@ modules_enabled = {
--"motd"; -- Send a message to users when they log in
--"legacyauth"; -- Legacy authentication. Only used by some old clients and bots.
--"proxy65"; -- Enables a file transfer proxy service which clients behind NAT can use
+ "lastactivity";
-- Useful for testing
--"scansion_record"; -- Records things that happen in scansion test case format
@@ -84,6 +96,8 @@ pidfile = "prosody.pid"
VirtualHost "localhost"
+hide_os_type = true -- absense tested for in version.scs
+
Component "conference.localhost" "muc"
storage = "memory"
diff --git a/spec/scansion/uptime.scs b/spec/scansion/uptime.scs
new file mode 100644
index 00000000..188b9eb5
--- /dev/null
+++ b/spec/scansion/uptime.scs
@@ -0,0 +1,21 @@
+# XEP-0012: Last Activity / mod_uptime
+
+[Client] Romeo
+ jid: romeo@localhost
+ password: password
+
+-----
+
+Romeo connects
+
+Romeo sends:
+ <iq id='a' type='get' to='localhost'>
+ <query xmlns='jabber:iq:last'/>
+ </iq>
+
+Romeo receives:
+ <iq type='result' id='a' from='localhost'>
+ <query xmlns='jabber:iq:last' seconds='0'/>
+ </iq>
+
+Romeo disconnects
diff --git a/spec/scansion/version.scs b/spec/scansion/version.scs
new file mode 100644
index 00000000..6c841dd9
--- /dev/null
+++ b/spec/scansion/version.scs
@@ -0,0 +1,27 @@
+# XEP-0092: Software Version / mod_version
+
+[Client] Romeo
+ password: password
+ jid: romeo@localhost/dfaZpuxV
+
+-----
+
+Romeo connects
+
+Romeo sends:
+ <iq id='lx2' to='localhost' type='get'>
+ <query xmlns='jabber:iq:version'/>
+ </iq>
+
+# Version string would vary so we can't do an exact match atm
+# Inclusion of <os/> is disabled in the config, it should be absent
+Romeo receives:
+ <iq id='lx2' from='localhost' type='result'>
+ <query xmlns='jabber:iq:version' scansion:strict='true'>
+ <name>Prosody</name>
+ <version scansion:strict='false'/>
+ </query>
+ </iq>
+
+
+Romeo disconnects
diff --git a/spec/util_hashes_spec.lua b/spec/util_hashes_spec.lua
index 1e6187bb..3639dd4e 100644
--- a/spec/util_hashes_spec.lua
+++ b/spec/util_hashes_spec.lua
@@ -4,34 +4,52 @@ local hex = require "util.hex";
-- Also see spec for util.hmac where HMAC test cases reside
-describe("PBKDF2-SHA1", function ()
+describe("PBKDF2-HMAC-SHA1", function ()
it("test vector 1", function ()
local P = "password"
local S = "salt"
local c = 1
local DK = "0c60c80f961f0e71f3a9b524af6012062fe037a6";
- assert.equal(DK, hex.to(hashes.scram_Hi_sha1(P, S, c)));
+ assert.equal(DK, hex.to(hashes.pbkdf2_hmac_sha1(P, S, c)));
end);
it("test vector 2", function ()
local P = "password"
local S = "salt"
local c = 2
local DK = "ea6c014dc72d6f8ccd1ed92ace1d41f0d8de8957";
- assert.equal(DK, hex.to(hashes.scram_Hi_sha1(P, S, c)));
+ assert.equal(DK, hex.to(hashes.pbkdf2_hmac_sha1(P, S, c)));
end);
it("test vector 3", function ()
local P = "password"
local S = "salt"
local c = 4096
local DK = "4b007901b765489abead49d926f721d065a429c1";
- assert.equal(DK, hex.to(hashes.scram_Hi_sha1(P, S, c)));
+ assert.equal(DK, hex.to(hashes.pbkdf2_hmac_sha1(P, S, c)));
end);
it("test vector 4 #SLOW", function ()
local P = "password"
local S = "salt"
local c = 16777216
local DK = "eefe3d61cd4da4e4e9945b3d6ba2158c2634e984";
- assert.equal(DK, hex.to(hashes.scram_Hi_sha1(P, S, c)));
+ assert.equal(DK, hex.to(hashes.pbkdf2_hmac_sha1(P, S, c)));
end);
end);
+describe("PBKDF2-HMAC-SHA256", function ()
+ it("test vector 1", function ()
+ local P = "password";
+ local S = "salt";
+ local c = 1
+ local DK = "120fb6cffcf8b32c43e7225256c4f837a86548c92ccc35480805987cb70be17b";
+ assert.equal(DK, hex.to(hashes.pbkdf2_hmac_sha256(P, S, c)));
+ end);
+ it("test vector 2", function ()
+ local P = "password";
+ local S = "salt";
+ local c = 2
+ local DK = "ae4d0c95af6b46d32d0adff928f06dd02a303f8ef3c251dfd6e2d85a95474c43";
+ assert.equal(DK, hex.to(hashes.pbkdf2_hmac_sha256(P, S, c)));
+ end);
+end);
+
+