aboutsummaryrefslogtreecommitdiffstats
path: root/spec/util_roles_spec.lua
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2022-10-08 20:33:01 +0100
committerMatthew Wild <mwild1@gmail.com>2022-10-08 20:33:01 +0100
commite3d1958cc4f94d51030c2dac92ea6df5bb346995 (patch)
tree2ed458746c0693470c1cc6301e445666197dae3d /spec/util_roles_spec.lua
parentc1627c5d66877e8a0c581172b915ebee52f0ab05 (diff)
downloadprosody-e3d1958cc4f94d51030c2dac92ea6df5bb346995.tar.gz
prosody-e3d1958cc4f94d51030c2dac92ea6df5bb346995.zip
util.roles: Add some more missing test cases
Found via mutation testing.
Diffstat (limited to 'spec/util_roles_spec.lua')
-rw-r--r--spec/util_roles_spec.lua18
1 files changed, 18 insertions, 0 deletions
diff --git a/spec/util_roles_spec.lua b/spec/util_roles_spec.lua
index c74515e9..81723657 100644
--- a/spec/util_roles_spec.lua
+++ b/spec/util_roles_spec.lua
@@ -11,6 +11,24 @@ describe("util.roles", function ()
assert.is_truthy(roles.is_role(test_role));
end);
describe("role object", function ()
+ it("can be initialized with permissions", function ()
+ local test_role_2 = roles.new({
+ permissions = {
+ perm1 = true;
+ perm2 = false;
+ };
+ });
+ assert.truthy(test_role_2:may("perm1"));
+ assert.falsy(test_role_2:may("perm2"));
+ end);
+ it("has a sensible tostring", function ()
+ local test_role_2 = roles.new({
+ id = "test-role-2";
+ name = "Test Role 2";
+ });
+ assert.truthy(tostring(test_role_2):find("test-role-2", 1, true));
+ assert.truthy(tostring(test_role_2):find("Test Role 2", 1, true));
+ end);
it("is restrictive by default", function ()
assert.falsy(test_role:may("my-permission"));
end);