Mercurial > prosody-hg
comparison spec/util_roles_spec.lua @ 12753:2eb02b32bb4c
util.roles: Add some more missing test cases
Found via mutation testing.
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Sat, 08 Oct 2022 20:33:01 +0100 |
| parents | 9d6d64fb7641 |
| children | a92ca737d05f |
comparison
equal
deleted
inserted
replaced
| 12752:9ef8f248635c | 12753:2eb02b32bb4c |
|---|---|
| 9 test_role = roles.new(); | 9 test_role = roles.new(); |
| 10 assert.is_not_nil(test_role); | 10 assert.is_not_nil(test_role); |
| 11 assert.is_truthy(roles.is_role(test_role)); | 11 assert.is_truthy(roles.is_role(test_role)); |
| 12 end); | 12 end); |
| 13 describe("role object", function () | 13 describe("role object", function () |
| 14 it("can be initialized with permissions", function () | |
| 15 local test_role_2 = roles.new({ | |
| 16 permissions = { | |
| 17 perm1 = true; | |
| 18 perm2 = false; | |
| 19 }; | |
| 20 }); | |
| 21 assert.truthy(test_role_2:may("perm1")); | |
| 22 assert.falsy(test_role_2:may("perm2")); | |
| 23 end); | |
| 24 it("has a sensible tostring", function () | |
| 25 local test_role_2 = roles.new({ | |
| 26 id = "test-role-2"; | |
| 27 name = "Test Role 2"; | |
| 28 }); | |
| 29 assert.truthy(tostring(test_role_2):find("test-role-2", 1, true)); | |
| 30 assert.truthy(tostring(test_role_2):find("Test Role 2", 1, true)); | |
| 31 end); | |
| 14 it("is restrictive by default", function () | 32 it("is restrictive by default", function () |
| 15 assert.falsy(test_role:may("my-permission")); | 33 assert.falsy(test_role:may("my-permission")); |
| 16 end); | 34 end); |
| 17 it("allows you to set permissions", function () | 35 it("allows you to set permissions", function () |
| 18 test_role:set_permission("my-permission", true); | 36 test_role:set_permission("my-permission", true); |
