1
1
let conf = require ( '../../conf.json' )
2
2
3
- let auth_options = {
3
+ let admin_auth = {
4
+ method : 'POST' ,
5
+ url : conf . url ,
6
+ auth : {
7
+ user : conf . client ,
8
+ pass : conf . clientsecret
9
+ } ,
10
+ form : true ,
11
+ body : {
12
+ grant_type : 'password' ,
13
+ username : conf . adminuser ,
14
+ password : conf . adminusersecret
15
+ }
16
+ }
17
+
18
+ let user_auth = {
4
19
method : 'POST' ,
5
20
url : conf . url ,
6
21
auth : {
@@ -15,9 +30,18 @@ let auth_options = {
15
30
}
16
31
}
17
32
18
- function authAndVisitUI ( ) {
33
+ function adminAuthAndVisitUI ( ) {
34
+ return new Promise ( ( ) => {
35
+ cy . request ( admin_auth ) . then ( res => {
36
+ let token = res . body . access_token
37
+ cy . visit ( 'http://localhost:2000?token=' + token )
38
+ } )
39
+ } )
40
+ }
41
+
42
+ function userAuthAndVisitUI ( ) {
19
43
return new Promise ( ( ) => {
20
- cy . request ( auth_options ) . then ( res => {
44
+ cy . request ( user_auth ) . then ( res => {
21
45
let token = res . body . access_token
22
46
cy . visit ( 'http://localhost:2000?token=' + token )
23
47
} )
@@ -26,17 +50,18 @@ function authAndVisitUI() {
26
50
27
51
function expand ( ) {
28
52
return cy . location ( ) . then ( loc => {
53
+ cy . wait ( 1000 )
29
54
let parts = loc . pathname . split ( '/' )
30
55
let id = parts . find ( part => {
31
56
return part . includes ( '!@!' )
32
57
} )
33
- cy . get ( '#' + id . replace ( '!@!' , '-' ) ) . click ( )
58
+ cy . get ( '#' + id . replace ( '!@!' , '-' ) ) . click ( 'left' )
34
59
} )
35
60
}
36
61
37
- describe ( 'User view privileges ' , ( ) => {
62
+ describe ( 'Security User ' , ( ) => {
38
63
beforeEach ( ( ) => {
39
- authAndVisitUI ( )
64
+ userAuthAndVisitUI ( )
40
65
cy . wait ( 3000 ) //Let react load all state objects
41
66
} )
42
67
@@ -62,13 +87,13 @@ describe('User view privileges', () => {
62
87
cy . get ( '#navigation' ) . get ( 'button' ) . then ( tabs => {
63
88
tabs [ conf . tabs . userlist . index ] . click ( )
64
89
cy . location ( 'pathname' ) . should ( 'eq' , conf . tabs . userlist . path )
65
- cy . get ( '#group_agile -agile-local' ) . click ( )
90
+ cy . get ( '#group_' + conf . adminuser + ' -agile-local') . click ( )
66
91
cy . get ( '#root_groups' ) . should ( 'exist' )
67
92
cy . get ( '#root_groups' ) . contains ( 'cypress-group' ) . find ( ':checkbox' ) . should ( 'be.not.checked' )
68
93
cy . get ( '#root_groups' ) . contains ( 'cypress-group' ) . find ( ':checkbox' ) . check ( )
69
94
cy . get ( 'button[type="submit"]' ) . then ( submit => {
70
95
submit . click ( )
71
- cy . wait ( 500 )
96
+ cy . wait ( 3000 )
72
97
tabs [ conf . tabs . groups . index ] . click ( )
73
98
} )
74
99
cy . get ( '#view_cypress-group' ) . click ( )
@@ -80,17 +105,177 @@ describe('User view privileges', () => {
80
105
cy . get ( '#navigation' ) . get ( 'button' ) . then ( tabs => {
81
106
tabs [ conf . tabs . userlist . index ] . click ( )
82
107
cy . location ( 'pathname' ) . should ( 'eq' , conf . tabs . userlist . path )
83
- cy . get ( '#group_agile-agile-local' ) . click ( )
108
+ cy . get ( '#group_' + conf . adminuser + '-agile-local' ) . click ( )
109
+ cy . wait ( 1000 )
84
110
cy . get ( '#root_groups' ) . should ( 'exist' )
85
111
cy . get ( '#root_groups' ) . contains ( 'cypress-group' ) . find ( ':checkbox' ) . should ( 'be.checked' )
86
112
cy . get ( '#root_groups' ) . contains ( 'cypress-group' ) . find ( ':checkbox' ) . uncheck ( )
87
113
cy . get ( 'button[type="submit"]' ) . then ( submit => {
88
114
submit . click ( )
89
- cy . wait ( 500 )
115
+ cy . wait ( 3000 )
90
116
tabs [ conf . tabs . groups . index ] . click ( )
91
117
} )
92
118
cy . get ( '#view_cypress-group' ) . click ( )
93
- cy . get ( '.container--app' ) . should ( 'not.contain' , 'agile!@!agile-local' )
119
+ cy . get ( '.container--app' ) . should ( 'not.contain' , conf . adminuser + '!@!agile-local' )
120
+ } )
121
+
122
+ //Delete group
123
+ cy . get ( '#navigation' ) . get ( 'button' ) . then ( tabs => {
124
+ tabs [ conf . tabs . groups . index ] . click ( )
125
+ cy . get ( '#cypress-group' ) . should ( 'exist' )
126
+ cy . get ( '#delete_cypress-group' ) . click ( )
127
+ cy . wait ( 1000 )
128
+ cy . get ( '#cypress-group' ) . should ( 'not.exist' )
129
+ } )
130
+ } )
131
+
132
+ it ( 'Create and delete entities' , ( ) => {
133
+ cy . get ( '#navigation' ) . get ( 'button' ) . then ( tabs => {
134
+ tabs [ conf . tabs . userlist . index ] . click ( )
135
+ cy . get ( '#cypress-agile-local' ) . should ( 'not.exist' )
136
+ } )
137
+
138
+ cy . get ( '#navigation' ) . get ( 'button' ) . then ( tabs => {
139
+ tabs [ conf . tabs . userlist . index ] . click ( )
140
+ let regex = new RegExp ( conf . tabs . userlist . path . replace ( / : [ a - z A - Z ] * / , '.*' ) )
141
+ cy . url ( ) . should ( 'match' , regex )
142
+ cy . wait ( 1500 )
143
+ cy . get ( '#new_entity_button' ) . click ( )
144
+ cy . location ( 'pathname' ) . should ( 'eq' , conf . views . addUser . path )
145
+ cy . get ( '#root_user_name' ) . type ( 'cypress' )
146
+ cy . get ( '#root_auth_type' ) . select ( 'agile-local' )
147
+ cy . get ( '#root_password' ) . type ( 'secret' )
148
+ cy . get ( '#root_role' ) . select ( 'admin' )
149
+ cy . get ( 'button[type="submit"]' ) . click ( )
150
+ cy . wait ( 3000 )
151
+
152
+ } )
153
+
154
+ cy . get ( '#navigation' ) . get ( 'button' ) . then ( tabs => {
155
+ let workingtab = conf . tabs . userlist
156
+ tabs [ workingtab . index ] . click ( )
157
+ cy . get ( '#cypress-agile-local' ) . should ( 'not.exist' )
158
+ } )
159
+ } )
160
+
161
+ it ( 'Add and update attribute to own user entity and delete it' , ( ) => {
162
+ cy . get ( '#navigation' ) . get ( 'button' ) . then ( tabs => {
163
+ let workingtab = conf . tabs . profile
164
+ tabs [ workingtab . index ] . click ( )
165
+ let regex = new RegExp ( workingtab . path . replace ( / : [ a - z A - Z ] * / , '.*' ) )
166
+ cy . url ( ) . should ( 'match' , regex )
167
+ expand ( )
168
+ cy . get ( '#cypress' ) . should ( 'not.exist' )
169
+ cy . get ( 'span' ) . contains ( 'cypress' ) . should ( 'not.exist' )
170
+ cy . get ( 'span' ) . contains ( 'cypress.value' ) . should ( 'not.exist' )
171
+ cy . get ( '#new-attribute' ) . type ( 'cypress' )
172
+ cy . get ( '#new-attribute-value' ) . type ( 'cypress.value' )
173
+ cy . get ( '#new-attribute-submit' ) . click ( )
174
+ cy . get ( '#cypress' ) . should ( 'exist' )
175
+ cy . get ( '#cypress_value' ) . should ( 'have.value' , 'cypress.value' )
176
+ cy . get ( '#cypress_value' ) . clear ( )
177
+ cy . get ( '#cypress_value' ) . type ( 'updated.value' )
178
+ cy . get ( '#navigation' )
179
+ cy . get ( '#cypress_value' ) . should ( 'have.value' , 'updated.value' )
180
+ cy . get ( '#delete_cypress' ) . click ( )
181
+ cy . get ( '#cypress' ) . should ( 'not.exist' )
182
+ } )
183
+ } )
184
+
185
+ it ( 'Switch to user overview tab and view first user attributes' , ( ) => {
186
+ cy . get ( '#navigation' ) . get ( 'button' ) . then ( tabs => {
187
+ let workingtab = conf . tabs . userlist
188
+ tabs [ workingtab . index ] . click ( )
189
+ cy . location ( 'pathname' ) . should ( 'eq' , workingtab . path )
190
+ cy . wait ( 1500 )
191
+ cy . get ( '#view_' + conf . adminuser + '-agile-local' ) . click ( ) //First user attributes
192
+ let regex = new RegExp ( conf . views . user . path . replace ( / : [ a - z A - Z ] * / , '.*' ) )
193
+ cy . url ( ) . should ( 'match' , regex )
194
+ cy . get ( '#' + conf . adminuser + '-agile-local' )
195
+ cy . get ( '#new_password' ) . should ( 'not.exist' )
196
+ cy . get ( '#old_password' ) . should ( 'not.exist' )
197
+ expand ( )
198
+ cy . get ( 'span' ) . contains ( 'id' ) . should ( 'be.visible' )
199
+ } )
200
+ } )
201
+
202
+ it ( 'Switch to user overview tab and view second user attributes' , ( ) => {
203
+ cy . get ( '#navigation' ) . get ( 'button' ) . then ( tabs => {
204
+ let workingtab = conf . tabs . userlist
205
+ tabs [ workingtab . index ] . click ( )
206
+ cy . location ( 'pathname' ) . should ( 'eq' , workingtab . path )
207
+ cy . wait ( 1500 )
208
+ cy . get ( '#view_' + conf . user + '-agile-local' ) . click ( ) //First user attributes
209
+ let regex = new RegExp ( conf . views . user . path . replace ( / : [ a - z A - Z ] * / , '.*' ) )
210
+ cy . url ( ) . should ( 'match' , regex )
211
+ cy . wait ( 1500 )
212
+ cy . get ( '#new_password' ) . should ( 'exist' )
213
+ cy . get ( '#old_password' ) . should ( 'exist' )
214
+ expand ( )
215
+ cy . get ( 'span' ) . contains ( 'id' ) . should ( 'be.visible' )
216
+ } )
217
+ } )
218
+ } )
219
+
220
+ describe ( 'Security Admin' , ( ) => {
221
+ beforeEach ( ( ) => {
222
+ adminAuthAndVisitUI ( )
223
+ cy . wait ( 3000 ) //Let react load all state objects
224
+ } )
225
+
226
+ it ( 'Create, assign and delete group' , ( ) => {
227
+ cy . get ( '#navigation' ) . get ( 'button' ) . then ( tabs => {
228
+ tabs [ conf . tabs . groups . index ] . click ( )
229
+ cy . get ( '#cypress-agile-local' ) . should ( 'not.exist' )
230
+ } )
231
+
232
+ //Create group
233
+ cy . get ( '#navigation' ) . get ( 'button' ) . then ( tabs => {
234
+ tabs [ conf . tabs . groups . index ] . click ( )
235
+ let regex = new RegExp ( conf . tabs . groups . path . replace ( / : [ a - z A - Z ] * / , '.*' ) )
236
+ cy . url ( ) . should ( 'match' , regex )
237
+ cy . wait ( 500 )
238
+ cy . get ( '#new_entity_button' ) . click ( )
239
+ cy . get ( '#root_group_name' ) . type ( 'cypress-group' )
240
+ cy . get ( 'button[type="submit"]' ) . click ( )
241
+ cy . wait ( 500 )
242
+ } )
243
+
244
+ //Assign group
245
+ cy . get ( '#navigation' ) . get ( 'button' ) . then ( tabs => {
246
+ tabs [ conf . tabs . userlist . index ] . click ( )
247
+ cy . location ( 'pathname' ) . should ( 'eq' , conf . tabs . userlist . path )
248
+ cy . get ( '#group_' + conf . adminuser + '-agile-local' ) . click ( )
249
+ cy . wait ( 1000 )
250
+ cy . get ( '#root_groups' ) . should ( 'exist' )
251
+ cy . get ( '#root_groups' ) . contains ( 'cypress-group' ) . find ( ':checkbox' ) . should ( 'be.not.checked' )
252
+ cy . get ( '#root_groups' ) . contains ( 'cypress-group' ) . find ( ':checkbox' ) . check ( )
253
+ cy . get ( 'button[type="submit"]' ) . then ( submit => {
254
+ submit . click ( )
255
+ cy . wait ( 3000 )
256
+ tabs [ conf . tabs . groups . index ] . click ( )
257
+ } )
258
+ cy . get ( '#view_cypress-group' ) . click ( )
259
+ cy . wait ( 1000 )
260
+ cy . get ( '.container--app' ) . should ( 'contain' , conf . adminuser + '!@!agile-local' )
261
+ } )
262
+
263
+ //Remove user from group
264
+ cy . get ( '#navigation' ) . get ( 'button' ) . then ( tabs => {
265
+ tabs [ conf . tabs . userlist . index ] . click ( )
266
+ cy . location ( 'pathname' ) . should ( 'eq' , conf . tabs . userlist . path )
267
+ cy . get ( '#group_' + conf . adminuser + '-agile-local' ) . click ( )
268
+ cy . wait ( 1000 )
269
+ cy . get ( '#root_groups' ) . should ( 'exist' )
270
+ cy . get ( '#root_groups' ) . contains ( 'cypress-group' ) . find ( ':checkbox' ) . should ( 'be.checked' )
271
+ cy . get ( '#root_groups' ) . contains ( 'cypress-group' ) . find ( ':checkbox' ) . uncheck ( )
272
+ cy . get ( 'button[type="submit"]' ) . then ( submit => {
273
+ submit . click ( )
274
+ cy . wait ( 3000 )
275
+ tabs [ conf . tabs . groups . index ] . click ( )
276
+ } )
277
+ cy . get ( '#view_cypress-group' ) . click ( )
278
+ cy . get ( '.container--app' ) . should ( 'not.contain' , conf . adminuser + '!@!agile-local' )
94
279
} )
95
280
96
281
//Delete group
@@ -165,16 +350,14 @@ describe('User view privileges', () => {
165
350
tabs [ workingtab . index ] . click ( )
166
351
cy . location ( 'pathname' ) . should ( 'eq' , workingtab . path )
167
352
cy . wait ( 1500 )
168
- cy . get ( '.container--app' ) . get ( 'a' ) . then ( viewbuttons => {
169
- viewbuttons [ workingtab . buttons . view ] . click ( ) //First user attributes
170
- let regex = new RegExp ( conf . views . user . path . replace ( / : [ a - z A - Z ] * / , '.*' ) )
171
- cy . url ( ) . should ( 'match' , regex )
172
- cy . wait ( 1500 )
173
- cy . get ( '#new_password' ) . should ( 'exist' )
174
- cy . get ( '#old_password' ) . should ( 'exist' )
175
- expand ( )
176
- cy . get ( 'span' ) . contains ( 'id' ) . should ( 'be.visible' )
177
- } )
353
+ cy . get ( '#view_' + conf . adminuser + '-agile-local' ) . click ( ) //First user attributes //First user attributes
354
+ let regex = new RegExp ( conf . views . user . path . replace ( / : [ a - z A - Z ] * / , '.*' ) )
355
+ cy . url ( ) . should ( 'match' , regex )
356
+ cy . wait ( 1500 )
357
+ cy . get ( '#new_password' ) . should ( 'exist' )
358
+ cy . get ( '#old_password' ) . should ( 'exist' )
359
+ expand ( )
360
+ cy . get ( 'span' ) . contains ( 'id' ) . should ( 'be.visible' )
178
361
} )
179
362
} )
180
363
@@ -184,16 +367,14 @@ describe('User view privileges', () => {
184
367
tabs [ workingtab . index ] . click ( )
185
368
cy . location ( 'pathname' ) . should ( 'eq' , workingtab . path )
186
369
cy . wait ( 1500 )
187
- cy . get ( '.container--app' ) . get ( 'a' ) . then ( viewbuttons => {
188
- viewbuttons [ workingtab . buttons . view + Object . keys ( workingtab . buttons ) . length ] . click ( ) //Second user attributes
189
- let regex = new RegExp ( conf . views . user . path . replace ( / : [ a - z A - Z ] * / , '.*' ) )
190
- cy . url ( ) . should ( 'match' , regex )
191
- cy . wait ( 1500 )
192
- cy . get ( '#new_password' ) . should ( 'exist' )
193
- cy . get ( '#old_password' ) . should ( 'not.exist' )
194
- expand ( )
195
- cy . get ( 'span' ) . contains ( 'id' ) . should ( 'be.visible' )
196
- } )
370
+ cy . get ( '#view_' + conf . user + '-agile-local' ) . click ( ) //First user attributes //Second user attributes
371
+ let regex = new RegExp ( conf . views . user . path . replace ( / : [ a - z A - Z ] * / , '.*' ) )
372
+ cy . url ( ) . should ( 'match' , regex )
373
+ cy . wait ( 1500 )
374
+ cy . get ( '#new_password' ) . should ( 'exist' )
375
+ cy . get ( '#old_password' ) . should ( 'not.exist' )
376
+ expand ( )
377
+ cy . get ( 'span' ) . contains ( 'id' ) . should ( 'be.visible' )
197
378
} )
198
379
} )
199
380
} )
0 commit comments