/
RoleService.feature
418 lines (374 loc) · 17.8 KB
/
RoleService.feature
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
###############################################################################
# Copyright (c) 2017, 2019 Eurotech and/or its affiliates and others
#
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html
#
# Contributors:
# Eurotech - initial API and implementation
###############################################################################
@security
@roleService
@integration
Feature: Role Service tests
Scenario: Regular role creation
Create a regular role entry. The entry must match the creator details.
When I login as user with name "kapua-sys" and password "kapua-password"
When I configure the role service
| type | name | value | scopeId |
| boolean | infiniteChildEntities | true | 1 |
| integer | maxNumberChildEntities | 5 | 1 |
And I create the domain
| name | actions |
| test | read,write, execute |
Given I create the following role
| scopeId | name | actions |
| 1 | test_role | write, read, connect |
Then The role matches the creator
When I examine the permissions for the last role
Then I find the following actions
| actions |
| write, read, connect |
And The permissions match
Scenario: Nameless role entry
It must not be possible to create a role entry without a name.
Such an attempt must throw an exception.
When I login as user with name "kapua-sys" and password "kapua-password"
When I configure the role service
| type | name | value | scopeId |
| boolean | infiniteChildEntities | true | 1 |
| integer | maxNumberChildEntities | 5 | 1 |
And I create the domain
| name | actions |
| test | read,write, execute |
Given I expect the exception "KapuaIllegalNullArgumentException" with the text "An illegal null value was provided"
When I create the following role
| scopeId | actions |
| 1 | write, read, connect |
Then An exception was thrown
Scenario: Duplicate role names
It must not be possible to create role entries with duplicate names.
Such an attempt must throw an exception.
When I login as user with name "kapua-sys" and password "kapua-password"
When I configure the role service
| type | name | value | scopeId |
| boolean | infiniteChildEntities | true | 1 |
| integer | maxNumberChildEntities | 5 | 1 |
And I create the domain
| name | actions |
| test | read,write, execute |
Given I expect the exception "KapuaDuplicateNameException" with the text "An entity with the same name test_role already exists."
When I create the following role
| scopeId | name | actions |
| 1 | test_role | write, read, connect |
| 1 | test_role | write, execute, connect |
Then An exception was thrown
Scenario: Role entry with no actions
It should be possible to create a role entry without a single action.
When I login as user with name "kapua-sys" and password "kapua-password"
When I configure the role service
| type | name | value | scopeId |
| boolean | infiniteChildEntities | true | 1 |
| integer | maxNumberChildEntities | 5 | 1 |
Given I create the following role
| scopeId | name |
| 1 | test_role |
Then No exception was thrown
And The role matches the creator
Scenario: Find role by ID
It must be possible to find a specific role entry in the database based
on the known role ID.
When I login as user with name "kapua-sys" and password "kapua-password"
When I configure the role service
| type | name | value | scopeId |
| boolean | infiniteChildEntities | true | 1 |
| integer | maxNumberChildEntities | 5 | 1 |
And I create the domain
| name | actions |
| test | read,write, execute |
Given I create the following role
| scopeId | name | actions |
| 1 | test_role | write, read, connect |
When I search for the last created role
Then The correct role entry was found
Scenario: Search the role database for a random ID
Searching the database for an unknown ID should be silently ignored. No
exception should be raised.
When I login as user with name "kapua-sys" and password "kapua-password"
When I configure the role service
| type | name | value | scopeId |
| boolean | infiniteChildEntities | true | 1 |
| integer | maxNumberChildEntities | 5 | 1 |
And I create the domain
| name | actions |
| test | read,write, execute |
Given I create the following role
| scopeId | name | actions |
| 1 | test_role | write, read, connect |
When I search for a random role ID
Then I find no roles
Scenario: Delete an existing role
It must be possible to delete an existing role item from the database.
When I login as user with name "kapua-sys" and password "kapua-password"
When I configure the role service
| type | name | value | scopeId |
| boolean | infiniteChildEntities | true | 1 |
| integer | maxNumberChildEntities | 5 | 1 |
And I create the domain
| name | actions |
| test | read,write, execute |
Given I create the following role
| scopeId | name | actions |
| 1 | test_role | write, read, connect |
And I search for the last created role
Then The role was found
When I delete the last created role
And I search for the last created role
Then I find no roles
Scenario: Delete a non existing role entry
Deleting a non existing role must throw an exception. This scenario explores what
happens when it is attempted to delete the same role twice.
When I login as user with name "kapua-sys" and password "kapua-password"
When I configure the role service
| type | name | value | scopeId |
| boolean | infiniteChildEntities | true | 1 |
| integer | maxNumberChildEntities | 5 | 1 |
And I create the domain
| name | actions |
| test | read,write, execute |
Given I create the following role
| scopeId | name | actions |
| 1 | test_role | write, read, connect |
When I delete the last created role
And I search for the last created role
Then I find no roles
Given I expect the exception "KapuaEntityNotFoundException" with the text "The entity of type role"
When I delete the last created role
Then An exception was thrown
Scenario: Update existing role name
It must be possible to change the name of an already existing role.
When I login as user with name "kapua-sys" and password "kapua-password"
When I configure the role service
| type | name | value | scopeId |
| boolean | infiniteChildEntities | true | 1 |
| integer | maxNumberChildEntities | 5 | 1 |
And I create the domain
| name | actions |
| test | read,write, execute |
Given I create the following role
| scopeId | name | actions |
| 1 | test_role | write, read, connect |
When I update the last created role name to "test_role_changed"
And I search for the last created role
Then The role was successfully updated
Scenario: Modify a role that was deleted
If an update operation is tried on a role that was previously deleted,
an exception must be thrown.
When I login as user with name "kapua-sys" and password "kapua-password"
When I configure the role service
| type | name | value | scopeId |
| boolean | infiniteChildEntities | true | 1 |
| integer | maxNumberChildEntities | 5 | 1 |
And I create the domain
| name | actions |
| test | read,write, execute |
Given I create the following role
| scopeId | name | actions |
| 1 | test_role | write, read, connect |
And I delete the last created role
Given I expect the exception "KapuaEntityNotFoundException" with the text "The entity of type role"
When I update the last created role name to "test_role_changed"
Then An exception was thrown
Scenario: Count roles in specific scopes
It must be possible to count all the roles defined for specific scopes. If
there is no role for a specific domain a 0 should be returned. No error or
exception is expected.
When I login as user with name "kapua-sys" and password "kapua-password"
And I create the domain
| name | actions |
| test | read,write, execute |
When I configure the role service
| type | name | value | scopeId | parentId |
| boolean | infiniteChildEntities | true | 2 | 1 |
| integer | maxNumberChildEntities | 5 | 2 | 1 |
When I configure the role service
| type | name | value | scopeId | parentId |
| boolean | infiniteChildEntities | true | 3 | 1 |
| integer | maxNumberChildEntities | 5 | 3 | 1 |
When I configure the role service
| type | name | value | scopeId | parentId |
| boolean | infiniteChildEntities | true | 4 | 1 |
| integer | maxNumberChildEntities | 5 | 4 | 1 |
Given I create the following roles
| scopeId | name | actions |
| 4 | test_role_1 | write, read, connect |
| 2 | test_role_2 | write, read, connect |
| 3 | test_role_3 | write, read, connect |
| 4 | test_role_4 | write, read, connect |
| 2 | test_role_5 | write, read, connect |
| 4 | test_role_6 | write, read, connect |
| 4 | test_role_7 | write, read, connect |
| 2 | test_role_8 | write, read, connect |
When I count the roles in scope 4
Then I count 4
When I count the roles in scope 2
Then I count 3
When I count the roles in scope 3
Then I count 1
When I count the roles in scope 15
Then I count 0
Scenario: A fresh database must contain 1 default role in the root scope
When I login as user with name "kapua-sys" and password "kapua-password"
When I count the roles in scope 1
Then I count 1
Scenario: It must be possible to query for specific entries in the role database
When I login as user with name "kapua-sys" and password "kapua-password"
When I configure the role service
| type | name | value | scopeId |
| boolean | infiniteChildEntities | true | 1 |
| integer | maxNumberChildEntities | 5 | 1 |
And I create the domain
| name | actions |
| test | read,write, execute |
Given I create the following role
| scopeId | name | actions |
| 1 | test_role | write, read, connect |
When I query for the role "test_role" in scope 1
Then I count 1
And The correct role entry was found
Scenario: Empty query results are supported
If a query does not yield any result only an empty list must be returned. This is not
an error situation.
When I login as user with name "kapua-sys" and password "kapua-password"
When I configure the role service
| type | name | value | scopeId |
| boolean | infiniteChildEntities | true | 1 |
| integer | maxNumberChildEntities | 5 | 1 |
And I create the domain
| name | actions |
| test | read,write, execute |
Given I create the following role
| scopeId | name | actions |
| 1 | test_role | write, read, connect |
When I query for the role "test_role_unknown" in scope 1
Then No exception was thrown
And I count 0
Scenario: Create some regular role permissions
When I login as user with name "kapua-sys" and password "kapua-password"
When I configure the role service
| type | name | value | scopeId |
| boolean | infiniteChildEntities | true | 1 |
| integer | maxNumberChildEntities | 5 | 1 |
And I create the domain
| name | actions |
| test | read,write, execute |
Given I create the following role
| scopeId | name |
| 1 | test_role |
And I create the following role permissions
| scopeId | actionName | targetScopeId |
| 1 | read | 1 |
| 1 | write | 1 |
| 1 | connect | 3 |
Then No exception was thrown
When I search for the last created role permission
Then The correct role permission entry was found
Scenario: Delete role permissions
It must be possible to delete an existing role permission record from the database.
When I login as user with name "kapua-sys" and password "kapua-password"
When I configure the role service
| type | name | value | scopeId |
| boolean | infiniteChildEntities | true | 1 |
| integer | maxNumberChildEntities | 5 | 1 |
And I create the domain
| name | actions |
| test | read,write, execute |
Given I create the following role
| scopeId | name |
| 1 | test_role |
And I create the following role permission
| scopeId | actionName |
| 1 | read |
Then No exception was thrown
When I delete the last created role permission
And I search for the last created role permission
Then I find no permissions
Scenario: Delete nonexisting role permission
An attempt to delete a non existing role permission from the database must result
in an exception being thrown.
When I login as user with name "kapua-sys" and password "kapua-password"
When I configure the role service
| type | name | value | scopeId |
| boolean | infiniteChildEntities | true | 1 |
| integer | maxNumberChildEntities | 5 | 1 |
And I create the domain
| name | actions |
| test | read,write, execute |
Given I create the following role
| scopeId | name |
| 1 | test_role |
And I create the following role permission
| scopeId | actionName |
| 1 | read |
Then No exception was thrown
When I delete the last created role permission
And I search for the last created role permission
Then I find no permissions
Given I expect the exception "KapuaEntityNotFoundException" with the text "The entity of type rolePermission"
When I delete the last created role permission
Then An exception was thrown
Scenario: Count role permissions in specific scopes
It must be possible to count all the role permissions defined for specific scopes. If
there is no role permission for a specific domain a 0 should be returned. No error or
exception is expected.
When I login as user with name "kapua-sys" and password "kapua-password"
When I configure the role service
| type | name | value | scopeId |
| boolean | infiniteChildEntities | true | 1 |
| integer | maxNumberChildEntities | 5 | 1 |
And I create the domain
| name | actions |
| test | read,write, execute |
Given I create the following role
| scopeId | name |
| 2 | test_role_2 |
And I create the following role permissions
| scopeId | actionName | targetScopeId |
| 2 | read | 1 |
| 2 | read | 2 |
| 2 | read | 3 |
And I create the following role
| scopeId | name |
| 3 | test_role_3 |
And I create the following role permissions
| scopeId | actionName | targetScopeId |
| 3 | read | 3 |
| 3 | read | 10 |
And I create the following role
| scopeId | name |
| 4 | test_role_4 |
And I create the following role permissions
| scopeId | actionName | targetScopeId |
| 4 | read | 4 |
When I count the role permissions in scope 2
Then I count 3
When I count the role permissions in scope 3
Then I count 2
When I count the role permissions in scope 4
Then I count 1
When I count the role permissions in scope 5
Then I count 0
Scenario: Role creator sanity checks
Check that the role factory returns non null objects.
Then The role factory returns sane results
Scenario: Role object equality check
Check that the role object comparator method correctly compares two objects and returns the
expected results.
Then The role comparator does its job
Scenario: Role service related objects sanity checks
Check that the objects related to the shiro role service behave sanely.
Then The role permission factory returns sane results
Then The role permission object constructors are sane
Then The role permission comparator does its job