@quenty/permissionprovider 14.50.0 → 14.51.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/package.json +8 -7
- package/src/Client/PermissionServiceClient.spec.lua +17 -12
- package/src/Client/Providers/PermissionProviderClient.spec.lua +17 -12
- package/src/Server/PermissionService.spec.lua +18 -13
- package/src/Server/Providers/CreatorPermissionProvider.spec.lua +14 -9
- package/src/Server/Providers/GroupPermissionProvider.spec.lua +17 -12
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [14.51.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/permissionprovider@14.50.0...@quenty/permissionprovider@14.51.0) (2026-08-28)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @quenty/permissionprovider
|
|
9
|
+
|
|
6
10
|
# [14.50.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/permissionprovider@14.49.2...@quenty/permissionprovider@14.50.0) (2026-08-28)
|
|
7
11
|
|
|
8
12
|
**Note:** Version bump only for package @quenty/permissionprovider
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/permissionprovider",
|
|
3
|
-
"version": "14.
|
|
3
|
+
"version": "14.51.0",
|
|
4
4
|
"description": "Permission provider for Roblox, including authenticating against group membership",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -29,16 +29,17 @@
|
|
|
29
29
|
],
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@quenty/baseobject": "10.16.0",
|
|
32
|
-
"@quenty/brio": "14.
|
|
32
|
+
"@quenty/brio": "14.37.0",
|
|
33
33
|
"@quenty/enums": "1.3.1",
|
|
34
|
-
"@quenty/grouputils": "10.
|
|
34
|
+
"@quenty/grouputils": "10.30.0",
|
|
35
|
+
"@quenty/jestutils": "1.1.0",
|
|
35
36
|
"@quenty/loader": "10.11.1",
|
|
36
37
|
"@quenty/maid": "3.12.0",
|
|
37
38
|
"@quenty/nevermore-test-runner": "1.6.0",
|
|
38
|
-
"@quenty/playermock": "1.
|
|
39
|
-
"@quenty/playerutils": "8.
|
|
39
|
+
"@quenty/playermock": "1.8.0",
|
|
40
|
+
"@quenty/playerutils": "8.43.0",
|
|
40
41
|
"@quenty/promise": "10.24.0",
|
|
41
|
-
"@quenty/remoting": "12.
|
|
42
|
+
"@quenty/remoting": "12.43.0",
|
|
42
43
|
"@quenty/rx": "13.34.0",
|
|
43
44
|
"@quenty/servicebag": "11.21.0",
|
|
44
45
|
"@quenty/table": "3.9.2",
|
|
@@ -47,5 +48,5 @@
|
|
|
47
48
|
"publishConfig": {
|
|
48
49
|
"access": "public"
|
|
49
50
|
},
|
|
50
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "346201e192e467cb71160f43029863853be855b5"
|
|
51
52
|
}
|
|
@@ -18,6 +18,7 @@ local require = require(script.Parent.loader).load(script)
|
|
|
18
18
|
local Workspace = game:GetService("Workspace")
|
|
19
19
|
|
|
20
20
|
local Jest = require("Jest")
|
|
21
|
+
local JestUtils = require("JestUtils")
|
|
21
22
|
local Maid = require("Maid")
|
|
22
23
|
local PermissionServiceClient = require("PermissionServiceClient")
|
|
23
24
|
local PlayerMock = require("PlayerMock")
|
|
@@ -36,7 +37,7 @@ local function setup()
|
|
|
36
37
|
|
|
37
38
|
local localPlayer = maid:Add(PlayerMock.new({ UserId = LOCAL_USER_ID }))
|
|
38
39
|
localPlayer.Parent = Workspace
|
|
39
|
-
PlayerMock.setMockedLocalPlayer(localPlayer)
|
|
40
|
+
local restoreLocalPlayer = PlayerMock.setMockedLocalPlayer(localPlayer)
|
|
40
41
|
|
|
41
42
|
local serviceBag = maid:Add(ServiceBag.new())
|
|
42
43
|
local service: PermissionServiceClient.PermissionServiceClient =
|
|
@@ -44,7 +45,7 @@ local function setup()
|
|
|
44
45
|
serviceBag:Init()
|
|
45
46
|
serviceBag:Start()
|
|
46
47
|
|
|
47
|
-
|
|
48
|
+
local controller = {
|
|
48
49
|
localPlayer = localPlayer,
|
|
49
50
|
serviceBag = serviceBag,
|
|
50
51
|
service = service,
|
|
@@ -68,11 +69,15 @@ local function setup()
|
|
|
68
69
|
expect(ok).toEqual(true)
|
|
69
70
|
return value
|
|
70
71
|
end,
|
|
71
|
-
|
|
72
|
-
|
|
72
|
+
Destroy = function(_self)
|
|
73
|
+
restoreLocalPlayer()
|
|
73
74
|
maid:DoCleaning()
|
|
74
75
|
end,
|
|
75
76
|
}
|
|
77
|
+
|
|
78
|
+
maid:GiveTask(JestUtils.afterThis(controller))
|
|
79
|
+
|
|
80
|
+
return controller
|
|
76
81
|
end
|
|
77
82
|
|
|
78
83
|
describe("PermissionServiceClient initialization", function()
|
|
@@ -86,7 +91,7 @@ describe("PermissionServiceClient initialization", function()
|
|
|
86
91
|
expect(ok).toEqual(true)
|
|
87
92
|
expect((provider :: any).ClassName).toEqual("PermissionProviderClient")
|
|
88
93
|
|
|
89
|
-
controller:
|
|
94
|
+
controller:Destroy()
|
|
90
95
|
end)
|
|
91
96
|
|
|
92
97
|
it("rejects double initialization", function()
|
|
@@ -100,7 +105,7 @@ describe("PermissionServiceClient initialization", function()
|
|
|
100
105
|
end).toThrow("Already initialized")
|
|
101
106
|
|
|
102
107
|
bare:Destroy()
|
|
103
|
-
controller:
|
|
108
|
+
controller:Destroy()
|
|
104
109
|
end)
|
|
105
110
|
end)
|
|
106
111
|
|
|
@@ -112,7 +117,7 @@ describe("PermissionServiceClient.PromiseIsAdmin", function()
|
|
|
112
117
|
controller.service:PromiseIsAdmin(5 :: any)
|
|
113
118
|
end).toThrow("Bad player")
|
|
114
119
|
|
|
115
|
-
controller:
|
|
120
|
+
controller:Destroy()
|
|
116
121
|
end)
|
|
117
122
|
|
|
118
123
|
it("resolves the server's answer for the designated local player", function()
|
|
@@ -123,7 +128,7 @@ describe("PermissionServiceClient.PromiseIsAdmin", function()
|
|
|
123
128
|
|
|
124
129
|
expect(controller.awaitBool(controller.service:PromiseIsAdmin(controller.localPlayer))).toEqual(true)
|
|
125
130
|
|
|
126
|
-
controller:
|
|
131
|
+
controller:Destroy()
|
|
127
132
|
end)
|
|
128
133
|
|
|
129
134
|
it("resolves the server's answer for a nil player", function()
|
|
@@ -134,7 +139,7 @@ describe("PermissionServiceClient.PromiseIsAdmin", function()
|
|
|
134
139
|
|
|
135
140
|
expect(controller.awaitBool(controller.service:PromiseIsAdmin(nil))).toEqual(true)
|
|
136
141
|
|
|
137
|
-
controller:
|
|
142
|
+
controller:Destroy()
|
|
138
143
|
end)
|
|
139
144
|
|
|
140
145
|
it("denies the designated local player when the server answers false", function()
|
|
@@ -145,7 +150,7 @@ describe("PermissionServiceClient.PromiseIsAdmin", function()
|
|
|
145
150
|
|
|
146
151
|
expect(controller.awaitBool(controller.service:PromiseIsAdmin(controller.localPlayer))).toEqual(false)
|
|
147
152
|
|
|
148
|
-
controller:
|
|
153
|
+
controller:Destroy()
|
|
149
154
|
end)
|
|
150
155
|
|
|
151
156
|
it("throws for a mock that is not the designated local player", function()
|
|
@@ -156,7 +161,7 @@ describe("PermissionServiceClient.PromiseIsAdmin", function()
|
|
|
156
161
|
controller.service:PromiseIsAdmin(otherPlayer)
|
|
157
162
|
end).toThrow("We only support local player")
|
|
158
163
|
|
|
159
|
-
controller:
|
|
164
|
+
controller:Destroy()
|
|
160
165
|
end)
|
|
161
166
|
|
|
162
167
|
it("caches the server answer across calls", function()
|
|
@@ -171,6 +176,6 @@ describe("PermissionServiceClient.PromiseIsAdmin", function()
|
|
|
171
176
|
expect(controller.awaitBool(controller.service:PromiseIsAdmin(controller.localPlayer))).toEqual(true)
|
|
172
177
|
expect(invokeCount).toEqual(1)
|
|
173
178
|
|
|
174
|
-
controller:
|
|
179
|
+
controller:Destroy()
|
|
175
180
|
end)
|
|
176
181
|
end)
|
|
@@ -14,6 +14,7 @@ local require = require(script.Parent.loader).load(script)
|
|
|
14
14
|
local Workspace = game:GetService("Workspace")
|
|
15
15
|
|
|
16
16
|
local Jest = require("Jest")
|
|
17
|
+
local JestUtils = require("JestUtils")
|
|
17
18
|
local Maid = require("Maid")
|
|
18
19
|
local PermissionProviderClient = require("PermissionProviderClient")
|
|
19
20
|
local PermissionProviderConstants = require("PermissionProviderConstants")
|
|
@@ -32,9 +33,9 @@ local function setup()
|
|
|
32
33
|
|
|
33
34
|
local localPlayer = maid:Add(PlayerMock.new({ UserId = LOCAL_USER_ID }))
|
|
34
35
|
localPlayer.Parent = Workspace
|
|
35
|
-
PlayerMock.setMockedLocalPlayer(localPlayer)
|
|
36
|
+
local restoreLocalPlayer = PlayerMock.setMockedLocalPlayer(localPlayer)
|
|
36
37
|
|
|
37
|
-
|
|
38
|
+
local controller = {
|
|
38
39
|
localPlayer = localPlayer,
|
|
39
40
|
makeProvider = function(invokeServer: (() -> any)?): any
|
|
40
41
|
local provider: any = PermissionProviderClient.new("PermissionProviderClientSpecRemote")
|
|
@@ -62,11 +63,15 @@ local function setup()
|
|
|
62
63
|
expect(ok).toEqual(false)
|
|
63
64
|
return tostring(err)
|
|
64
65
|
end,
|
|
65
|
-
|
|
66
|
-
|
|
66
|
+
Destroy = function(_self)
|
|
67
|
+
restoreLocalPlayer()
|
|
67
68
|
maid:DoCleaning()
|
|
68
69
|
end,
|
|
69
70
|
}
|
|
71
|
+
|
|
72
|
+
maid:GiveTask(JestUtils.afterThis(controller))
|
|
73
|
+
|
|
74
|
+
return controller
|
|
70
75
|
end
|
|
71
76
|
|
|
72
77
|
describe("PermissionProviderClient construction", function()
|
|
@@ -92,7 +97,7 @@ describe("PermissionProviderClient.PromiseIsAdmin argument validation", function
|
|
|
92
97
|
provider:PromiseIsAdmin(5 :: any)
|
|
93
98
|
end).toThrow("Bad player")
|
|
94
99
|
|
|
95
|
-
controller:
|
|
100
|
+
controller:Destroy()
|
|
96
101
|
end)
|
|
97
102
|
|
|
98
103
|
it("rejects a player other than the designated local player", function()
|
|
@@ -104,7 +109,7 @@ describe("PermissionProviderClient.PromiseIsAdmin argument validation", function
|
|
|
104
109
|
provider:PromiseIsAdmin(otherPlayer)
|
|
105
110
|
end).toThrow("We only support local player")
|
|
106
111
|
|
|
107
|
-
controller:
|
|
112
|
+
controller:Destroy()
|
|
108
113
|
end)
|
|
109
114
|
end)
|
|
110
115
|
|
|
@@ -117,7 +122,7 @@ describe("PermissionProviderClient.PromiseIsAdmin", function()
|
|
|
117
122
|
|
|
118
123
|
expect(controller.awaitBool(provider:PromiseIsAdmin(controller.localPlayer))).toEqual(true)
|
|
119
124
|
|
|
120
|
-
controller:
|
|
125
|
+
controller:Destroy()
|
|
121
126
|
end)
|
|
122
127
|
|
|
123
128
|
it("resolves the server's answer for a nil player", function()
|
|
@@ -128,7 +133,7 @@ describe("PermissionProviderClient.PromiseIsAdmin", function()
|
|
|
128
133
|
|
|
129
134
|
expect(controller.awaitBool(provider:PromiseIsAdmin(nil))).toEqual(true)
|
|
130
135
|
|
|
131
|
-
controller:
|
|
136
|
+
controller:Destroy()
|
|
132
137
|
end)
|
|
133
138
|
|
|
134
139
|
it("denies when the server answers false", function()
|
|
@@ -139,7 +144,7 @@ describe("PermissionProviderClient.PromiseIsAdmin", function()
|
|
|
139
144
|
|
|
140
145
|
expect(controller.awaitBool(provider:PromiseIsAdmin(controller.localPlayer))).toEqual(false)
|
|
141
146
|
|
|
142
|
-
controller:
|
|
147
|
+
controller:Destroy()
|
|
143
148
|
end)
|
|
144
149
|
|
|
145
150
|
it("rejects a non-boolean server answer", function()
|
|
@@ -151,7 +156,7 @@ describe("PermissionProviderClient.PromiseIsAdmin", function()
|
|
|
151
156
|
local message = controller.awaitError(provider:PromiseIsAdmin(controller.localPlayer))
|
|
152
157
|
expect(message).toContain("Got non-boolean from server")
|
|
153
158
|
|
|
154
|
-
controller:
|
|
159
|
+
controller:Destroy()
|
|
155
160
|
end)
|
|
156
161
|
|
|
157
162
|
it("rejects when the server invoke throws", function()
|
|
@@ -163,7 +168,7 @@ describe("PermissionProviderClient.PromiseIsAdmin", function()
|
|
|
163
168
|
local message = controller.awaitError(provider:PromiseIsAdmin(controller.localPlayer))
|
|
164
169
|
expect(message).toContain("Server invoke failed")
|
|
165
170
|
|
|
166
|
-
controller:
|
|
171
|
+
controller:Destroy()
|
|
167
172
|
end)
|
|
168
173
|
|
|
169
174
|
it("caches the admin answer across calls", function()
|
|
@@ -181,6 +186,6 @@ describe("PermissionProviderClient.PromiseIsAdmin", function()
|
|
|
181
186
|
expect(controller.awaitBool(first)).toEqual(true)
|
|
182
187
|
expect(invokeCount).toEqual(1)
|
|
183
188
|
|
|
184
|
-
controller:
|
|
189
|
+
controller:Destroy()
|
|
185
190
|
end)
|
|
186
191
|
end)
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
local require = require(script.Parent.loader).load(script)
|
|
13
13
|
|
|
14
14
|
local Jest = require("Jest")
|
|
15
|
+
local JestUtils = require("JestUtils")
|
|
15
16
|
local Maid = require("Maid")
|
|
16
17
|
local PermissionLevel = require("PermissionLevel")
|
|
17
18
|
local PermissionProviderUtils = require("PermissionProviderUtils")
|
|
@@ -38,7 +39,7 @@ local function setup()
|
|
|
38
39
|
remoteNameCounter += 1
|
|
39
40
|
local remoteFunctionName = string.format("PermissionServiceSpecRemote%d", remoteNameCounter)
|
|
40
41
|
|
|
41
|
-
|
|
42
|
+
local controller = {
|
|
42
43
|
serviceBag = serviceBag,
|
|
43
44
|
permissionService = permissionService,
|
|
44
45
|
singleUserConfig = function(userId: number)
|
|
@@ -56,10 +57,14 @@ local function setup()
|
|
|
56
57
|
expect(ok).toEqual(true)
|
|
57
58
|
return value
|
|
58
59
|
end,
|
|
59
|
-
|
|
60
|
+
Destroy = function(_self)
|
|
60
61
|
maid:DoCleaning()
|
|
61
62
|
end,
|
|
62
63
|
}
|
|
64
|
+
|
|
65
|
+
maid:GiveTask(JestUtils.afterThis(controller))
|
|
66
|
+
|
|
67
|
+
return controller
|
|
63
68
|
end
|
|
64
69
|
|
|
65
70
|
describe("PermissionService initialization", function()
|
|
@@ -71,7 +76,7 @@ describe("PermissionService initialization", function()
|
|
|
71
76
|
controller.serviceBag:Start()
|
|
72
77
|
end).never.toThrow()
|
|
73
78
|
|
|
74
|
-
controller:
|
|
79
|
+
controller:Destroy()
|
|
75
80
|
end)
|
|
76
81
|
|
|
77
82
|
it("should start with a provider derived from the game when none is configured", function()
|
|
@@ -81,7 +86,7 @@ describe("PermissionService initialization", function()
|
|
|
81
86
|
controller.serviceBag:Start()
|
|
82
87
|
end).never.toThrow()
|
|
83
88
|
|
|
84
|
-
controller:
|
|
89
|
+
controller:Destroy()
|
|
85
90
|
end)
|
|
86
91
|
|
|
87
92
|
it("should resolve the permission provider after start", function()
|
|
@@ -98,7 +103,7 @@ describe("PermissionService initialization", function()
|
|
|
98
103
|
expect(ok).toEqual(true)
|
|
99
104
|
expect((provider :: any).ClassName).toEqual("CreatorPermissionProvider")
|
|
100
105
|
|
|
101
|
-
controller:
|
|
106
|
+
controller:Destroy()
|
|
102
107
|
end)
|
|
103
108
|
end)
|
|
104
109
|
|
|
@@ -111,7 +116,7 @@ describe("PermissionService.SetProviderFromConfig", function()
|
|
|
111
116
|
controller.permissionService:SetProviderFromConfig(controller.singleUserConfig(CREATOR_USER_ID))
|
|
112
117
|
end).toThrow("Already have provider set")
|
|
113
118
|
|
|
114
|
-
controller:
|
|
119
|
+
controller:Destroy()
|
|
115
120
|
end)
|
|
116
121
|
|
|
117
122
|
it("should reject an unknown config type", function()
|
|
@@ -121,7 +126,7 @@ describe("PermissionService.SetProviderFromConfig", function()
|
|
|
121
126
|
controller.permissionService:SetProviderFromConfig({ type = "UnknownConfigType" } :: any)
|
|
122
127
|
end).toThrow("Bad provider")
|
|
123
128
|
|
|
124
|
-
controller:
|
|
129
|
+
controller:Destroy()
|
|
125
130
|
end)
|
|
126
131
|
end)
|
|
127
132
|
|
|
@@ -134,7 +139,7 @@ describe("PermissionService permission queries", function()
|
|
|
134
139
|
local player = controller.fakePlayer(CREATOR_USER_ID)
|
|
135
140
|
expect(controller.awaitBool(controller.permissionService:PromiseIsAdmin(player))).toEqual(true)
|
|
136
141
|
|
|
137
|
-
controller:
|
|
142
|
+
controller:Destroy()
|
|
138
143
|
end)
|
|
139
144
|
|
|
140
145
|
it("should treat the configured user as a creator", function()
|
|
@@ -145,7 +150,7 @@ describe("PermissionService permission queries", function()
|
|
|
145
150
|
local player = controller.fakePlayer(CREATOR_USER_ID)
|
|
146
151
|
expect(controller.awaitBool(controller.permissionService:PromiseIsCreator(player))).toEqual(true)
|
|
147
152
|
|
|
148
|
-
controller:
|
|
153
|
+
controller:Destroy()
|
|
149
154
|
end)
|
|
150
155
|
|
|
151
156
|
it("should deny another user admin permission", function()
|
|
@@ -156,7 +161,7 @@ describe("PermissionService permission queries", function()
|
|
|
156
161
|
local player = controller.fakePlayer(CREATOR_USER_ID + 1)
|
|
157
162
|
expect(controller.awaitBool(controller.permissionService:PromiseIsAdmin(player))).toEqual(false)
|
|
158
163
|
|
|
159
|
-
controller:
|
|
164
|
+
controller:Destroy()
|
|
160
165
|
end)
|
|
161
166
|
|
|
162
167
|
it("should reject a non-player value", function()
|
|
@@ -168,7 +173,7 @@ describe("PermissionService permission queries", function()
|
|
|
168
173
|
controller.permissionService:PromiseIsAdmin(nil :: any)
|
|
169
174
|
end).toThrow("bad player")
|
|
170
175
|
|
|
171
|
-
controller:
|
|
176
|
+
controller:Destroy()
|
|
172
177
|
end)
|
|
173
178
|
|
|
174
179
|
it("should reject an invalid permission level", function()
|
|
@@ -181,7 +186,7 @@ describe("PermissionService permission queries", function()
|
|
|
181
186
|
controller.permissionService:PromiseIsPermissionLevel(player, "not-a-level" :: any)
|
|
182
187
|
end).toThrow("Bad permissionLevel")
|
|
183
188
|
|
|
184
|
-
controller:
|
|
189
|
+
controller:Destroy()
|
|
185
190
|
end)
|
|
186
191
|
end)
|
|
187
192
|
|
|
@@ -198,6 +203,6 @@ describe("PermissionService.ObservePermissionedPlayersBrio", function()
|
|
|
198
203
|
subscription:Destroy()
|
|
199
204
|
end).never.toThrow()
|
|
200
205
|
|
|
201
|
-
controller:
|
|
206
|
+
controller:Destroy()
|
|
202
207
|
end)
|
|
203
208
|
end)
|
|
@@ -14,6 +14,7 @@ local require = require(script.Parent.loader).load(script)
|
|
|
14
14
|
|
|
15
15
|
local CreatorPermissionProvider = require("CreatorPermissionProvider")
|
|
16
16
|
local Jest = require("Jest")
|
|
17
|
+
local JestUtils = require("JestUtils")
|
|
17
18
|
local Maid = require("Maid")
|
|
18
19
|
local PermissionLevel = require("PermissionLevel")
|
|
19
20
|
local PermissionProviderUtils = require("PermissionProviderUtils")
|
|
@@ -32,7 +33,7 @@ local function setup()
|
|
|
32
33
|
userId = CREATOR_USER_ID,
|
|
33
34
|
})))
|
|
34
35
|
|
|
35
|
-
|
|
36
|
+
local controller = {
|
|
36
37
|
provider = provider,
|
|
37
38
|
fakePlayer = function(userId: number): Player
|
|
38
39
|
return maid:Add(PlayerMock.new({ UserId = userId }))
|
|
@@ -43,10 +44,14 @@ local function setup()
|
|
|
43
44
|
expect(ok).toEqual(true)
|
|
44
45
|
return value
|
|
45
46
|
end,
|
|
46
|
-
|
|
47
|
+
Destroy = function(_self)
|
|
47
48
|
maid:DoCleaning()
|
|
48
49
|
end,
|
|
49
50
|
}
|
|
51
|
+
|
|
52
|
+
maid:GiveTask(JestUtils.afterThis(controller))
|
|
53
|
+
|
|
54
|
+
return controller
|
|
50
55
|
end
|
|
51
56
|
|
|
52
57
|
describe("CreatorPermissionProvider.new", function()
|
|
@@ -68,7 +73,7 @@ describe("CreatorPermissionProvider.PromiseIsPermissionLevel", function()
|
|
|
68
73
|
|
|
69
74
|
expect(controller.awaitBool(controller.provider:PromiseIsAdmin(player))).toEqual(true)
|
|
70
75
|
|
|
71
|
-
controller:
|
|
76
|
+
controller:Destroy()
|
|
72
77
|
end)
|
|
73
78
|
|
|
74
79
|
it("should treat the configured user as a creator", function()
|
|
@@ -77,7 +82,7 @@ describe("CreatorPermissionProvider.PromiseIsPermissionLevel", function()
|
|
|
77
82
|
|
|
78
83
|
expect(controller.awaitBool(controller.provider:PromiseIsCreator(player))).toEqual(true)
|
|
79
84
|
|
|
80
|
-
controller:
|
|
85
|
+
controller:Destroy()
|
|
81
86
|
end)
|
|
82
87
|
|
|
83
88
|
it("should deny another user admin permission", function()
|
|
@@ -86,7 +91,7 @@ describe("CreatorPermissionProvider.PromiseIsPermissionLevel", function()
|
|
|
86
91
|
|
|
87
92
|
expect(controller.awaitBool(controller.provider:PromiseIsAdmin(player))).toEqual(false)
|
|
88
93
|
|
|
89
|
-
controller:
|
|
94
|
+
controller:Destroy()
|
|
90
95
|
end)
|
|
91
96
|
|
|
92
97
|
it("should deny another user creator permission", function()
|
|
@@ -95,7 +100,7 @@ describe("CreatorPermissionProvider.PromiseIsPermissionLevel", function()
|
|
|
95
100
|
|
|
96
101
|
expect(controller.awaitBool(controller.provider:PromiseIsCreator(player))).toEqual(false)
|
|
97
102
|
|
|
98
|
-
controller:
|
|
103
|
+
controller:Destroy()
|
|
99
104
|
end)
|
|
100
105
|
|
|
101
106
|
it("should resolve synchronously for the IsAdmin wrapper", function()
|
|
@@ -104,7 +109,7 @@ describe("CreatorPermissionProvider.PromiseIsPermissionLevel", function()
|
|
|
104
109
|
|
|
105
110
|
expect(controller.provider:IsAdmin(player)).toEqual(true)
|
|
106
111
|
|
|
107
|
-
controller:
|
|
112
|
+
controller:Destroy()
|
|
108
113
|
end)
|
|
109
114
|
|
|
110
115
|
it("should reject a non-player value", function()
|
|
@@ -114,7 +119,7 @@ describe("CreatorPermissionProvider.PromiseIsPermissionLevel", function()
|
|
|
114
119
|
controller.provider:PromiseIsPermissionLevel(nil :: any, PermissionLevel.ADMIN)
|
|
115
120
|
end).toThrow("Bad player")
|
|
116
121
|
|
|
117
|
-
controller:
|
|
122
|
+
controller:Destroy()
|
|
118
123
|
end)
|
|
119
124
|
|
|
120
125
|
it("should reject an invalid permission level", function()
|
|
@@ -125,6 +130,6 @@ describe("CreatorPermissionProvider.PromiseIsPermissionLevel", function()
|
|
|
125
130
|
controller.provider:PromiseIsPermissionLevel(player, "not-a-level" :: any)
|
|
126
131
|
end).toThrow()
|
|
127
132
|
|
|
128
|
-
controller:
|
|
133
|
+
controller:Destroy()
|
|
129
134
|
end)
|
|
130
135
|
end)
|
|
@@ -16,6 +16,7 @@ local Workspace = game:GetService("Workspace")
|
|
|
16
16
|
local GroupPermissionProvider = require("GroupPermissionProvider")
|
|
17
17
|
local GroupTestUtils = require("GroupTestUtils")
|
|
18
18
|
local Jest = require("Jest")
|
|
19
|
+
local JestUtils = require("JestUtils")
|
|
19
20
|
local Maid = require("Maid")
|
|
20
21
|
local PermissionLevel = require("PermissionLevel")
|
|
21
22
|
local PermissionProviderUtils = require("PermissionProviderUtils")
|
|
@@ -40,7 +41,7 @@ local function setup(options: { minAdminRequiredRank: number, minCreatorRequired
|
|
|
40
41
|
remoteFunctionName = string.format("GroupPermissionProviderSpecRemote%d", remoteNameCounter),
|
|
41
42
|
})))
|
|
42
43
|
|
|
43
|
-
|
|
44
|
+
local controller = {
|
|
44
45
|
provider = provider,
|
|
45
46
|
fakePlayer = function(userId: number): Player
|
|
46
47
|
local player = maid:Add(PlayerMock.new({ UserId = userId }))
|
|
@@ -53,10 +54,14 @@ local function setup(options: { minAdminRequiredRank: number, minCreatorRequired
|
|
|
53
54
|
expect(ok).toEqual(true)
|
|
54
55
|
return value
|
|
55
56
|
end,
|
|
56
|
-
|
|
57
|
+
Destroy = function(_self)
|
|
57
58
|
maid:DoCleaning()
|
|
58
59
|
end,
|
|
59
60
|
}
|
|
61
|
+
|
|
62
|
+
maid:GiveTask(JestUtils.afterThis(controller))
|
|
63
|
+
|
|
64
|
+
return controller
|
|
60
65
|
end
|
|
61
66
|
|
|
62
67
|
describe("GroupPermissionProvider.new", function()
|
|
@@ -77,7 +82,7 @@ describe("GroupPermissionProvider.PromiseIsPermissionLevel", function()
|
|
|
77
82
|
expect(controller.awaitBool(controller.provider:PromiseIsAdmin(player))).toEqual(true)
|
|
78
83
|
expect(controller.awaitBool(controller.provider:PromiseIsCreator(player))).toEqual(true)
|
|
79
84
|
|
|
80
|
-
controller:
|
|
85
|
+
controller:Destroy()
|
|
81
86
|
end)
|
|
82
87
|
|
|
83
88
|
it("should deny both levels when the rank thresholds are not met", function()
|
|
@@ -87,7 +92,7 @@ describe("GroupPermissionProvider.PromiseIsPermissionLevel", function()
|
|
|
87
92
|
expect(controller.awaitBool(controller.provider:PromiseIsAdmin(player))).toEqual(false)
|
|
88
93
|
expect(controller.awaitBool(controller.provider:PromiseIsCreator(player))).toEqual(false)
|
|
89
94
|
|
|
90
|
-
controller:
|
|
95
|
+
controller:Destroy()
|
|
91
96
|
end)
|
|
92
97
|
|
|
93
98
|
it("should grant admin but deny creator for a tiered config", function()
|
|
@@ -97,7 +102,7 @@ describe("GroupPermissionProvider.PromiseIsPermissionLevel", function()
|
|
|
97
102
|
expect(controller.awaitBool(controller.provider:PromiseIsAdmin(player))).toEqual(true)
|
|
98
103
|
expect(controller.awaitBool(controller.provider:PromiseIsCreator(player))).toEqual(false)
|
|
99
104
|
|
|
100
|
-
controller:
|
|
105
|
+
controller:Destroy()
|
|
101
106
|
end)
|
|
102
107
|
|
|
103
108
|
it("should grant admin but deny creator from an injected group rank", function()
|
|
@@ -108,7 +113,7 @@ describe("GroupPermissionProvider.PromiseIsPermissionLevel", function()
|
|
|
108
113
|
expect(controller.awaitBool(controller.provider:PromiseIsAdmin(player))).toEqual(true)
|
|
109
114
|
expect(controller.awaitBool(controller.provider:PromiseIsCreator(player))).toEqual(false)
|
|
110
115
|
|
|
111
|
-
controller:
|
|
116
|
+
controller:Destroy()
|
|
112
117
|
end)
|
|
113
118
|
|
|
114
119
|
it("should grant both levels from an injected group rank meeting both thresholds", function()
|
|
@@ -119,7 +124,7 @@ describe("GroupPermissionProvider.PromiseIsPermissionLevel", function()
|
|
|
119
124
|
expect(controller.awaitBool(controller.provider:PromiseIsAdmin(player))).toEqual(true)
|
|
120
125
|
expect(controller.awaitBool(controller.provider:PromiseIsCreator(player))).toEqual(true)
|
|
121
126
|
|
|
122
|
-
controller:
|
|
127
|
+
controller:Destroy()
|
|
123
128
|
end)
|
|
124
129
|
|
|
125
130
|
it("should ignore a rank injected for a different group", function()
|
|
@@ -129,7 +134,7 @@ describe("GroupPermissionProvider.PromiseIsPermissionLevel", function()
|
|
|
129
134
|
|
|
130
135
|
expect(controller.awaitBool(controller.provider:PromiseIsAdmin(player))).toEqual(false)
|
|
131
136
|
|
|
132
|
-
controller:
|
|
137
|
+
controller:Destroy()
|
|
133
138
|
end)
|
|
134
139
|
|
|
135
140
|
it("should reject a player outside the game hierarchy", function()
|
|
@@ -142,7 +147,7 @@ describe("GroupPermissionProvider.PromiseIsPermissionLevel", function()
|
|
|
142
147
|
end).toThrow("Bad player")
|
|
143
148
|
|
|
144
149
|
maid:DoCleaning()
|
|
145
|
-
controller:
|
|
150
|
+
controller:Destroy()
|
|
146
151
|
end)
|
|
147
152
|
|
|
148
153
|
it("should reject a non-player value", function()
|
|
@@ -152,7 +157,7 @@ describe("GroupPermissionProvider.PromiseIsPermissionLevel", function()
|
|
|
152
157
|
controller.provider:PromiseIsPermissionLevel(nil :: any, PermissionLevel.ADMIN)
|
|
153
158
|
end).toThrow("Bad player")
|
|
154
159
|
|
|
155
|
-
controller:
|
|
160
|
+
controller:Destroy()
|
|
156
161
|
end)
|
|
157
162
|
|
|
158
163
|
it("should reject an invalid permission level", function()
|
|
@@ -163,7 +168,7 @@ describe("GroupPermissionProvider.PromiseIsPermissionLevel", function()
|
|
|
163
168
|
controller.provider:PromiseIsPermissionLevel(player, "not-a-level" :: any)
|
|
164
169
|
end).toThrow()
|
|
165
170
|
|
|
166
|
-
controller:
|
|
171
|
+
controller:Destroy()
|
|
167
172
|
end)
|
|
168
173
|
end)
|
|
169
174
|
|
|
@@ -175,6 +180,6 @@ describe("GroupPermissionProvider.Start", function()
|
|
|
175
180
|
controller.provider:Start()
|
|
176
181
|
end).never.toThrow()
|
|
177
182
|
|
|
178
|
-
controller:
|
|
183
|
+
controller:Destroy()
|
|
179
184
|
end)
|
|
180
185
|
end)
|