Completed
Push — master ( 9350a6...db530d )
by
unknown
25:59
created
build/integration/features/bootstrap/RoutingContext.php 2 patches
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -11,32 +11,32 @@
 block discarded – undo
11 11
 require __DIR__ . '/autoload.php';
12 12
 
13 13
 class RoutingContext implements Context, SnippetAcceptingContext {
14
-	use Provisioning;
15
-	use AppConfiguration;
16
-	use CommandLine;
17
-
18
-	protected function resetAppConfigs(): void {
19
-	}
20
-
21
-	/**
22
-	 * @AfterScenario
23
-	 */
24
-	public function deleteMemcacheSetting(): void {
25
-		$this->invokingTheCommand('config:system:delete memcache.local');
26
-	}
27
-
28
-	/**
29
-	 * @Given /^route "([^"]*)" of app "([^"]*)" is defined in routes.php$/
30
-	 */
31
-	public function routeOfAppIsDefinedInRoutesPhP(string $route, string $app): void {
32
-		$previousUser = $this->currentUser;
33
-		$this->currentUser = 'admin';
34
-
35
-		$this->sendingTo('GET', "/apps/testing/api/v1/routes/routesphp/{$app}");
36
-		$this->theHTTPStatusCodeShouldBe('200');
37
-
38
-		Assert::assertStringContainsString($route, $this->response->getBody()->getContents());
39
-
40
-		$this->currentUser = $previousUser;
41
-	}
14
+    use Provisioning;
15
+    use AppConfiguration;
16
+    use CommandLine;
17
+
18
+    protected function resetAppConfigs(): void {
19
+    }
20
+
21
+    /**
22
+     * @AfterScenario
23
+     */
24
+    public function deleteMemcacheSetting(): void {
25
+        $this->invokingTheCommand('config:system:delete memcache.local');
26
+    }
27
+
28
+    /**
29
+     * @Given /^route "([^"]*)" of app "([^"]*)" is defined in routes.php$/
30
+     */
31
+    public function routeOfAppIsDefinedInRoutesPhP(string $route, string $app): void {
32
+        $previousUser = $this->currentUser;
33
+        $this->currentUser = 'admin';
34
+
35
+        $this->sendingTo('GET', "/apps/testing/api/v1/routes/routesphp/{$app}");
36
+        $this->theHTTPStatusCodeShouldBe('200');
37
+
38
+        Assert::assertStringContainsString($route, $this->response->getBody()->getContents());
39
+
40
+        $this->currentUser = $previousUser;
41
+    }
42 42
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@
 block discarded – undo
8 8
 use Behat\Behat\Context\SnippetAcceptingContext;
9 9
 use PHPUnit\Framework\Assert;
10 10
 
11
-require __DIR__ . '/autoload.php';
11
+require __DIR__.'/autoload.php';
12 12
 
13 13
 class RoutingContext implements Context, SnippetAcceptingContext {
14 14
 	use Provisioning;
Please login to merge, or discard this patch.
build/integration/features/bootstrap/Provisioning.php 1 patch
Indentation   +1020 added lines, -1020 removed lines patch added patch discarded remove patch
@@ -14,1024 +14,1024 @@
 block discarded – undo
14 14
 require __DIR__ . '/autoload.php';
15 15
 
16 16
 trait Provisioning {
17
-	use BasicStructure;
18
-
19
-	/** @var array */
20
-	private $appsToEnableAfterScenario = [];
21
-
22
-	/** @var array */
23
-	private $appsToDisableAfterScenario = [];
24
-
25
-	/** @var array */
26
-	private $createdUsers = [];
27
-
28
-	/** @var array */
29
-	private $createdRemoteUsers = [];
30
-
31
-	/** @var array */
32
-	private $createdRemoteGroups = [];
33
-
34
-	/** @var array */
35
-	private $createdGroups = [];
36
-
37
-	/** @AfterScenario */
38
-	public function restoreAppsEnabledStateAfterScenario() {
39
-		$this->asAn('admin');
40
-
41
-		foreach ($this->appsToEnableAfterScenario as $app) {
42
-			$this->sendingTo('POST', '/cloud/apps/' . $app);
43
-		}
44
-
45
-		foreach ($this->appsToDisableAfterScenario as $app) {
46
-			$this->sendingTo('DELETE', '/cloud/apps/' . $app);
47
-		}
48
-	}
49
-
50
-	/**
51
-	 * @Given /^user "([^"]*)" exists$/
52
-	 * @param string $user
53
-	 */
54
-	public function assureUserExists($user) {
55
-		try {
56
-			$this->userExists($user);
57
-		} catch (\GuzzleHttp\Exception\ClientException $ex) {
58
-			$previous_user = $this->currentUser;
59
-			$this->currentUser = 'admin';
60
-			$this->creatingTheUser($user);
61
-			$this->currentUser = $previous_user;
62
-		}
63
-		$this->userExists($user);
64
-		Assert::assertEquals(200, $this->response->getStatusCode());
65
-	}
66
-
67
-	/**
68
-	 * @Given /^user "([^"]*)" with displayname "((?:[^"]|\\")*)" exists$/
69
-	 * @param string $user
70
-	 */
71
-	public function assureUserWithDisplaynameExists($user, $displayname) {
72
-		try {
73
-			$this->userExists($user);
74
-		} catch (\GuzzleHttp\Exception\ClientException $ex) {
75
-			$previous_user = $this->currentUser;
76
-			$this->currentUser = 'admin';
77
-			$this->creatingTheUser($user, $displayname);
78
-			$this->currentUser = $previous_user;
79
-		}
80
-		$this->userExists($user);
81
-		Assert::assertEquals(200, $this->response->getStatusCode());
82
-	}
83
-
84
-	/**
85
-	 * @Given /^user "([^"]*)" does not exist$/
86
-	 * @param string $user
87
-	 */
88
-	public function userDoesNotExist($user) {
89
-		try {
90
-			$this->userExists($user);
91
-		} catch (\GuzzleHttp\Exception\ClientException $ex) {
92
-			$this->response = $ex->getResponse();
93
-			Assert::assertEquals(404, $ex->getResponse()->getStatusCode());
94
-			return;
95
-		}
96
-		$previous_user = $this->currentUser;
97
-		$this->currentUser = 'admin';
98
-		$this->deletingTheUser($user);
99
-		$this->currentUser = $previous_user;
100
-		try {
101
-			$this->userExists($user);
102
-		} catch (\GuzzleHttp\Exception\ClientException $ex) {
103
-			$this->response = $ex->getResponse();
104
-			Assert::assertEquals(404, $ex->getResponse()->getStatusCode());
105
-		}
106
-	}
107
-
108
-	public function creatingTheUser($user, $displayname = '') {
109
-		$fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/cloud/users";
110
-		$client = new Client();
111
-		$options = [];
112
-		if ($this->currentUser === 'admin') {
113
-			$options['auth'] = $this->adminUser;
114
-		}
115
-
116
-		$options['form_params'] = [
117
-			'userid' => $user,
118
-			'password' => '123456'
119
-		];
120
-		if ($displayname !== '') {
121
-			$options['form_params']['displayName'] = $displayname;
122
-		}
123
-		$options['headers'] = [
124
-			'OCS-APIREQUEST' => 'true',
125
-		];
126
-
127
-		$this->response = $client->post($fullUrl, $options);
128
-		if ($this->currentServer === 'LOCAL') {
129
-			$this->createdUsers[$user] = $user;
130
-		} elseif ($this->currentServer === 'REMOTE') {
131
-			$this->createdRemoteUsers[$user] = $user;
132
-		}
133
-
134
-		//Quick hack to login once with the current user
135
-		$options2 = [
136
-			'auth' => [$user, '123456'],
137
-		];
138
-		$options2['headers'] = [
139
-			'OCS-APIREQUEST' => 'true',
140
-		];
141
-		$url = $fullUrl . '/' . $user;
142
-		$client->get($url, $options2);
143
-	}
144
-
145
-	/**
146
-	 * @Then /^user "([^"]*)" has$/
147
-	 *
148
-	 * @param string $user
149
-	 * @param TableNode|null $settings
150
-	 */
151
-	public function userHasSetting($user, $settings) {
152
-		$fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/cloud/users/$user";
153
-		$client = new Client();
154
-		$options = [];
155
-		if ($this->currentUser === 'admin') {
156
-			$options['auth'] = $this->adminUser;
157
-		} else {
158
-			$options['auth'] = [$this->currentUser, $this->regularUser];
159
-		}
160
-		$options['headers'] = [
161
-			'OCS-APIREQUEST' => 'true',
162
-		];
163
-
164
-		$response = $client->get($fullUrl, $options);
165
-		foreach ($settings->getRows() as $setting) {
166
-			$value = json_decode(json_encode(simplexml_load_string($response->getBody())->data->{$setting[0]}), 1);
167
-			if (isset($value['element']) && in_array($setting[0], ['additional_mail', 'additional_mailScope'], true)) {
168
-				$expectedValues = explode(';', $setting[1]);
169
-				foreach ($expectedValues as $expected) {
170
-					Assert::assertTrue(in_array($expected, $value['element'], true), 'Data wrong for field: ' . $setting[0]);
171
-				}
172
-			} elseif (isset($value[0])) {
173
-				Assert::assertEqualsCanonicalizing($setting[1], $value[0], 'Data wrong for field: ' . $setting[0]);
174
-			} else {
175
-				Assert::assertEquals('', $setting[1], 'Data wrong for field: ' . $setting[0]);
176
-			}
177
-		}
178
-	}
179
-
180
-	/**
181
-	 * @Then /^user "([^"]*)" has the following profile data$/
182
-	 */
183
-	public function userHasProfileData(string $user, ?TableNode $settings): void {
184
-		$fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/profile/$user";
185
-		$client = new Client();
186
-		$options = [];
187
-		if ($this->currentUser === 'admin') {
188
-			$options['auth'] = $this->adminUser;
189
-		} else {
190
-			$options['auth'] = [$this->currentUser, $this->regularUser];
191
-		}
192
-		$options['headers'] = [
193
-			'OCS-APIREQUEST' => 'true',
194
-			'Accept' => 'application/json',
195
-		];
196
-
197
-		$response = $client->get($fullUrl, $options);
198
-		$body = $response->getBody()->getContents();
199
-		$data = json_decode($body, true);
200
-		$data = $data['ocs']['data'];
201
-		foreach ($settings->getRows() as $setting) {
202
-			Assert::assertArrayHasKey($setting[0], $data, 'Profile data field missing: ' . $setting[0]);
203
-			if ($setting[1] === 'NULL') {
204
-				Assert::assertNull($data[$setting[0]], 'Profile data wrong for field: ' . $setting[0]);
205
-			} else {
206
-				Assert::assertEquals($setting[1], $data[$setting[0]], 'Profile data wrong for field: ' . $setting[0]);
207
-			}
208
-		}
209
-	}
210
-
211
-	/**
212
-	 * @Then /^group "([^"]*)" has$/
213
-	 *
214
-	 * @param string $user
215
-	 * @param TableNode|null $settings
216
-	 */
217
-	public function groupHasSetting($group, $settings) {
218
-		$fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/cloud/groups/details?search=$group";
219
-		$client = new Client();
220
-		$options = [];
221
-		if ($this->currentUser === 'admin') {
222
-			$options['auth'] = $this->adminUser;
223
-		} else {
224
-			$options['auth'] = [$this->currentUser, $this->regularUser];
225
-		}
226
-		$options['headers'] = [
227
-			'OCS-APIREQUEST' => 'true',
228
-		];
229
-
230
-		$response = $client->get($fullUrl, $options);
231
-		$groupDetails = simplexml_load_string($response->getBody())->data[0]->groups[0]->element;
232
-		foreach ($settings->getRows() as $setting) {
233
-			$value = json_decode(json_encode($groupDetails->{$setting[0]}), 1);
234
-			if (isset($value[0])) {
235
-				Assert::assertEqualsCanonicalizing($setting[1], $value[0]);
236
-			} else {
237
-				Assert::assertEquals('', $setting[1]);
238
-			}
239
-		}
240
-	}
241
-
242
-
243
-	/**
244
-	 * @Then /^user "([^"]*)" has editable fields$/
245
-	 *
246
-	 * @param string $user
247
-	 * @param TableNode|null $fields
248
-	 */
249
-	public function userHasEditableFields($user, $fields) {
250
-		$fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/cloud/user/fields";
251
-		if ($user !== 'self') {
252
-			$fullUrl .= '/' . $user;
253
-		}
254
-		$client = new Client();
255
-		$options = [];
256
-		if ($this->currentUser === 'admin') {
257
-			$options['auth'] = $this->adminUser;
258
-		} else {
259
-			$options['auth'] = [$this->currentUser, $this->regularUser];
260
-		}
261
-		$options['headers'] = [
262
-			'OCS-APIREQUEST' => 'true',
263
-		];
264
-
265
-		$response = $client->get($fullUrl, $options);
266
-		$fieldsArray = json_decode(json_encode(simplexml_load_string($response->getBody())->data->element), 1);
267
-
268
-		$expectedFields = $fields->getRows();
269
-		$expectedFields = $this->simplifyArray($expectedFields);
270
-		Assert::assertEquals($expectedFields, $fieldsArray);
271
-	}
272
-
273
-	/**
274
-	 * @Then /^search users by phone for region "([^"]*)" with$/
275
-	 *
276
-	 * @param string $user
277
-	 * @param TableNode|null $settings
278
-	 */
279
-	public function searchUserByPhone($region, TableNode $searchTable) {
280
-		$fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/cloud/users/search/by-phone";
281
-		$client = new Client();
282
-		$options = [];
283
-		$options['auth'] = $this->adminUser;
284
-		$options['headers'] = [
285
-			'OCS-APIREQUEST' => 'true',
286
-		];
287
-
288
-		$search = [];
289
-		foreach ($searchTable->getRows() as $row) {
290
-			if (!isset($search[$row[0]])) {
291
-				$search[$row[0]] = [];
292
-			}
293
-			$search[$row[0]][] = $row[1];
294
-		}
295
-
296
-		$options['form_params'] = [
297
-			'location' => $region,
298
-			'search' => $search,
299
-		];
300
-
301
-		$this->response = $client->post($fullUrl, $options);
302
-	}
303
-
304
-	public function createUser($user) {
305
-		$previous_user = $this->currentUser;
306
-		$this->currentUser = 'admin';
307
-		$this->creatingTheUser($user);
308
-		$this->userExists($user);
309
-		$this->currentUser = $previous_user;
310
-	}
311
-
312
-	public function deleteUser($user) {
313
-		$previous_user = $this->currentUser;
314
-		$this->currentUser = 'admin';
315
-		$this->deletingTheUser($user);
316
-		$this->userDoesNotExist($user);
317
-		$this->currentUser = $previous_user;
318
-	}
319
-
320
-	public function createGroup($group) {
321
-		$previous_user = $this->currentUser;
322
-		$this->currentUser = 'admin';
323
-		$this->creatingTheGroup($group);
324
-		$this->groupExists($group);
325
-		$this->currentUser = $previous_user;
326
-	}
327
-
328
-	public function deleteGroup($group) {
329
-		$previous_user = $this->currentUser;
330
-		$this->currentUser = 'admin';
331
-		$this->deletingTheGroup($group);
332
-		$this->groupDoesNotExist($group);
333
-		$this->currentUser = $previous_user;
334
-	}
335
-
336
-	public function userExists($user) {
337
-		$fullUrl = $this->baseUrl . "v2.php/cloud/users/$user";
338
-		$client = new Client();
339
-		$options = [];
340
-		$options['auth'] = $this->adminUser;
341
-		$options['headers'] = [
342
-			'OCS-APIREQUEST' => 'true'
343
-		];
344
-
345
-		$this->response = $client->get($fullUrl, $options);
346
-	}
347
-
348
-	/**
349
-	 * @Then /^check that user "([^"]*)" belongs to group "([^"]*)"$/
350
-	 * @param string $user
351
-	 * @param string $group
352
-	 */
353
-	public function checkThatUserBelongsToGroup($user, $group) {
354
-		$fullUrl = $this->baseUrl . "v2.php/cloud/users/$user/groups";
355
-		$client = new Client();
356
-		$options = [];
357
-		if ($this->currentUser === 'admin') {
358
-			$options['auth'] = $this->adminUser;
359
-		}
360
-		$options['headers'] = [
361
-			'OCS-APIREQUEST' => 'true',
362
-		];
363
-
364
-		$this->response = $client->get($fullUrl, $options);
365
-		$respondedArray = $this->getArrayOfGroupsResponded($this->response);
366
-		sort($respondedArray);
367
-		Assert::assertContains($group, $respondedArray);
368
-		Assert::assertEquals(200, $this->response->getStatusCode());
369
-	}
370
-
371
-	public function userBelongsToGroup($user, $group) {
372
-		$fullUrl = $this->baseUrl . "v2.php/cloud/users/$user/groups";
373
-		$client = new Client();
374
-		$options = [];
375
-		if ($this->currentUser === 'admin') {
376
-			$options['auth'] = $this->adminUser;
377
-		}
378
-		$options['headers'] = [
379
-			'OCS-APIREQUEST' => 'true',
380
-		];
381
-
382
-		$this->response = $client->get($fullUrl, $options);
383
-		$respondedArray = $this->getArrayOfGroupsResponded($this->response);
384
-
385
-		if (array_key_exists($group, $respondedArray)) {
386
-			return true;
387
-		} else {
388
-			return false;
389
-		}
390
-	}
391
-
392
-	/**
393
-	 * @Given /^user "([^"]*)" belongs to group "([^"]*)"$/
394
-	 * @param string $user
395
-	 * @param string $group
396
-	 */
397
-	public function assureUserBelongsToGroup($user, $group) {
398
-		$previous_user = $this->currentUser;
399
-		$this->currentUser = 'admin';
400
-
401
-		if (!$this->userBelongsToGroup($user, $group)) {
402
-			$this->addingUserToGroup($user, $group);
403
-		}
404
-
405
-		$this->checkThatUserBelongsToGroup($user, $group);
406
-		$this->currentUser = $previous_user;
407
-	}
408
-
409
-	/**
410
-	 * @Given /^user "([^"]*)" does not belong to group "([^"]*)"$/
411
-	 * @param string $user
412
-	 * @param string $group
413
-	 */
414
-	public function userDoesNotBelongToGroup($user, $group) {
415
-		$fullUrl = $this->baseUrl . "v2.php/cloud/users/$user/groups";
416
-		$client = new Client();
417
-		$options = [];
418
-		if ($this->currentUser === 'admin') {
419
-			$options['auth'] = $this->adminUser;
420
-		}
421
-		$options['headers'] = [
422
-			'OCS-APIREQUEST' => 'true',
423
-		];
424
-
425
-		$this->response = $client->get($fullUrl, $options);
426
-		$groups = [$group];
427
-		$respondedArray = $this->getArrayOfGroupsResponded($this->response);
428
-		Assert::assertNotEqualsCanonicalizing($groups, $respondedArray);
429
-		Assert::assertEquals(200, $this->response->getStatusCode());
430
-	}
431
-
432
-	/**
433
-	 * @When /^creating the group "([^"]*)"$/
434
-	 * @param string $group
435
-	 */
436
-	public function creatingTheGroup($group) {
437
-		$fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/cloud/groups";
438
-		$client = new Client();
439
-		$options = [];
440
-		if ($this->currentUser === 'admin') {
441
-			$options['auth'] = $this->adminUser;
442
-		}
443
-
444
-		$options['form_params'] = [
445
-			'groupid' => $group,
446
-		];
447
-		$options['headers'] = [
448
-			'OCS-APIREQUEST' => 'true',
449
-		];
450
-
451
-		$this->response = $client->post($fullUrl, $options);
452
-		if ($this->currentServer === 'LOCAL') {
453
-			$this->createdGroups[$group] = $group;
454
-		} elseif ($this->currentServer === 'REMOTE') {
455
-			$this->createdRemoteGroups[$group] = $group;
456
-		}
457
-	}
458
-
459
-	/**
460
-	 * @When /^assure user "([^"]*)" is disabled$/
461
-	 */
462
-	public function assureUserIsDisabled($user) {
463
-		$fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/cloud/users/$user/disable";
464
-		$client = new Client();
465
-		$options = [];
466
-		if ($this->currentUser === 'admin') {
467
-			$options['auth'] = $this->adminUser;
468
-		}
469
-		$options['headers'] = [
470
-			'OCS-APIREQUEST' => 'true',
471
-		];
472
-		// TODO: fix hack
473
-		$options['form_params'] = [
474
-			'foo' => 'bar'
475
-		];
476
-
477
-		$this->response = $client->put($fullUrl, $options);
478
-	}
479
-
480
-	/**
481
-	 * @When /^Deleting the user "([^"]*)"$/
482
-	 * @param string $user
483
-	 */
484
-	public function deletingTheUser($user) {
485
-		$fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/cloud/users/$user";
486
-		$client = new Client();
487
-		$options = [];
488
-		if ($this->currentUser === 'admin') {
489
-			$options['auth'] = $this->adminUser;
490
-		}
491
-		$options['headers'] = [
492
-			'OCS-APIREQUEST' => 'true',
493
-		];
494
-
495
-		$this->response = $client->delete($fullUrl, $options);
496
-	}
497
-
498
-	/**
499
-	 * @When /^Deleting the group "([^"]*)"$/
500
-	 * @param string $group
501
-	 */
502
-	public function deletingTheGroup($group) {
503
-		$fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/cloud/groups/$group";
504
-		$client = new Client();
505
-		$options = [];
506
-		if ($this->currentUser === 'admin') {
507
-			$options['auth'] = $this->adminUser;
508
-		}
509
-		$options['headers'] = [
510
-			'OCS-APIREQUEST' => 'true',
511
-		];
512
-
513
-		$this->response = $client->delete($fullUrl, $options);
514
-
515
-		if ($this->currentServer === 'LOCAL') {
516
-			unset($this->createdGroups[$group]);
517
-		} elseif ($this->currentServer === 'REMOTE') {
518
-			unset($this->createdRemoteGroups[$group]);
519
-		}
520
-	}
521
-
522
-	/**
523
-	 * @Given /^Add user "([^"]*)" to the group "([^"]*)"$/
524
-	 * @param string $user
525
-	 * @param string $group
526
-	 */
527
-	public function addUserToGroup($user, $group) {
528
-		$this->userExists($user);
529
-		$this->groupExists($group);
530
-		$this->addingUserToGroup($user, $group);
531
-	}
532
-
533
-	/**
534
-	 * @When /^User "([^"]*)" is added to the group "([^"]*)"$/
535
-	 * @param string $user
536
-	 * @param string $group
537
-	 */
538
-	public function addingUserToGroup($user, $group) {
539
-		$fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/cloud/users/$user/groups";
540
-		$client = new Client();
541
-		$options = [];
542
-		if ($this->currentUser === 'admin') {
543
-			$options['auth'] = $this->adminUser;
544
-		}
545
-		$options['headers'] = [
546
-			'OCS-APIREQUEST' => 'true',
547
-		];
548
-
549
-		$options['form_params'] = [
550
-			'groupid' => $group,
551
-		];
552
-
553
-		$this->response = $client->post($fullUrl, $options);
554
-	}
555
-
556
-
557
-	public function groupExists($group) {
558
-		$fullUrl = $this->baseUrl . "v2.php/cloud/groups/$group";
559
-		$client = new Client();
560
-		$options = [];
561
-		$options['auth'] = $this->adminUser;
562
-		$options['headers'] = [
563
-			'OCS-APIREQUEST' => 'true',
564
-		];
565
-
566
-		$this->response = $client->get($fullUrl, $options);
567
-	}
568
-
569
-	/**
570
-	 * @Given /^group "([^"]*)" exists$/
571
-	 * @param string $group
572
-	 */
573
-	public function assureGroupExists($group) {
574
-		try {
575
-			$this->groupExists($group);
576
-		} catch (\GuzzleHttp\Exception\ClientException $ex) {
577
-			$previous_user = $this->currentUser;
578
-			$this->currentUser = 'admin';
579
-			$this->creatingTheGroup($group);
580
-			$this->currentUser = $previous_user;
581
-		}
582
-		$this->groupExists($group);
583
-		Assert::assertEquals(200, $this->response->getStatusCode());
584
-	}
585
-
586
-	/**
587
-	 * @Given /^group "([^"]*)" does not exist$/
588
-	 * @param string $group
589
-	 */
590
-	public function groupDoesNotExist($group) {
591
-		try {
592
-			$this->groupExists($group);
593
-		} catch (\GuzzleHttp\Exception\ClientException $ex) {
594
-			$this->response = $ex->getResponse();
595
-			Assert::assertEquals(404, $ex->getResponse()->getStatusCode());
596
-			return;
597
-		}
598
-		$previous_user = $this->currentUser;
599
-		$this->currentUser = 'admin';
600
-		$this->deletingTheGroup($group);
601
-		$this->currentUser = $previous_user;
602
-		try {
603
-			$this->groupExists($group);
604
-		} catch (\GuzzleHttp\Exception\ClientException $ex) {
605
-			$this->response = $ex->getResponse();
606
-			Assert::assertEquals(404, $ex->getResponse()->getStatusCode());
607
-		}
608
-	}
609
-
610
-	/**
611
-	 * @Given /^user "([^"]*)" is subadmin of group "([^"]*)"$/
612
-	 * @param string $user
613
-	 * @param string $group
614
-	 */
615
-	public function userIsSubadminOfGroup($user, $group) {
616
-		$fullUrl = $this->baseUrl . "v2.php/cloud/groups/$group/subadmins";
617
-		$client = new Client();
618
-		$options = [];
619
-		if ($this->currentUser === 'admin') {
620
-			$options['auth'] = $this->adminUser;
621
-		}
622
-		$options['headers'] = [
623
-			'OCS-APIREQUEST' => 'true',
624
-		];
625
-
626
-		$this->response = $client->get($fullUrl, $options);
627
-		$respondedArray = $this->getArrayOfSubadminsResponded($this->response);
628
-		sort($respondedArray);
629
-		Assert::assertContains($user, $respondedArray);
630
-		Assert::assertEquals(200, $this->response->getStatusCode());
631
-	}
632
-
633
-	/**
634
-	 * @Given /^Assure user "([^"]*)" is subadmin of group "([^"]*)"$/
635
-	 * @param string $user
636
-	 * @param string $group
637
-	 */
638
-	public function assureUserIsSubadminOfGroup($user, $group) {
639
-		$fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/cloud/users/$user/subadmins";
640
-		$client = new Client();
641
-		$options = [];
642
-		if ($this->currentUser === 'admin') {
643
-			$options['auth'] = $this->adminUser;
644
-		}
645
-		$options['form_params'] = [
646
-			'groupid' => $group
647
-		];
648
-		$options['headers'] = [
649
-			'OCS-APIREQUEST' => 'true',
650
-		];
651
-		$this->response = $client->post($fullUrl, $options);
652
-		Assert::assertEquals(200, $this->response->getStatusCode());
653
-	}
654
-
655
-	/**
656
-	 * @Given /^user "([^"]*)" is not a subadmin of group "([^"]*)"$/
657
-	 * @param string $user
658
-	 * @param string $group
659
-	 */
660
-	public function userIsNotSubadminOfGroup($user, $group) {
661
-		$fullUrl = $this->baseUrl . "v2.php/cloud/groups/$group/subadmins";
662
-		$client = new Client();
663
-		$options = [];
664
-		if ($this->currentUser === 'admin') {
665
-			$options['auth'] = $this->adminUser;
666
-		}
667
-		$options['headers'] = [
668
-			'OCS-APIREQUEST' => 'true',
669
-		];
670
-
671
-		$this->response = $client->get($fullUrl, $options);
672
-		$respondedArray = $this->getArrayOfSubadminsResponded($this->response);
673
-		sort($respondedArray);
674
-		Assert::assertNotContains($user, $respondedArray);
675
-		Assert::assertEquals(200, $this->response->getStatusCode());
676
-	}
677
-
678
-	/**
679
-	 * @Then /^users returned are$/
680
-	 * @param TableNode|null $usersList
681
-	 */
682
-	public function theUsersShouldBe($usersList) {
683
-		if ($usersList instanceof TableNode) {
684
-			$users = $usersList->getRows();
685
-			$usersSimplified = $this->simplifyArray($users);
686
-			$respondedArray = $this->getArrayOfUsersResponded($this->response);
687
-			Assert::assertEqualsCanonicalizing($usersSimplified, $respondedArray);
688
-		}
689
-	}
690
-
691
-	/**
692
-	 * @Then /^phone matches returned are$/
693
-	 * @param TableNode|null $usersList
694
-	 */
695
-	public function thePhoneUsersShouldBe($usersList) {
696
-		if ($usersList instanceof TableNode) {
697
-			$users = $usersList->getRowsHash();
698
-			$listCheckedElements = simplexml_load_string($this->response->getBody())->data;
699
-			$respondedArray = json_decode(json_encode($listCheckedElements), true);
700
-			Assert::assertEquals($users, $respondedArray);
701
-		}
702
-	}
703
-
704
-	/**
705
-	 * @Then /^detailed users returned are$/
706
-	 * @param TableNode|null $usersList
707
-	 */
708
-	public function theDetailedUsersShouldBe($usersList) {
709
-		if ($usersList instanceof TableNode) {
710
-			$users = $usersList->getRows();
711
-			$usersSimplified = $this->simplifyArray($users);
712
-			$respondedArray = $this->getArrayOfDetailedUsersResponded($this->response);
713
-			$respondedArray = array_keys($respondedArray);
714
-			Assert::assertEquals($usersSimplified, $respondedArray);
715
-		}
716
-	}
717
-
718
-	/**
719
-	 * @Then /^groups returned are$/
720
-	 * @param TableNode|null $groupsList
721
-	 */
722
-	public function theGroupsShouldBe($groupsList) {
723
-		if ($groupsList instanceof TableNode) {
724
-			$groups = $groupsList->getRows();
725
-			$groupsSimplified = $this->simplifyArray($groups);
726
-			$respondedArray = $this->getArrayOfGroupsResponded($this->response);
727
-			Assert::assertEqualsCanonicalizing($groupsSimplified, $respondedArray);
728
-		}
729
-	}
730
-
731
-	/**
732
-	 * @Then /^subadmin groups returned are$/
733
-	 * @param TableNode|null $groupsList
734
-	 */
735
-	public function theSubadminGroupsShouldBe($groupsList) {
736
-		if ($groupsList instanceof TableNode) {
737
-			$groups = $groupsList->getRows();
738
-			$groupsSimplified = $this->simplifyArray($groups);
739
-			$respondedArray = $this->getArrayOfSubadminsResponded($this->response);
740
-			Assert::assertEqualsCanonicalizing($groupsSimplified, $respondedArray);
741
-		}
742
-	}
743
-
744
-	/**
745
-	 * @Then /^apps returned are$/
746
-	 * @param TableNode|null $appList
747
-	 */
748
-	public function theAppsShouldBe($appList) {
749
-		if ($appList instanceof TableNode) {
750
-			$apps = $appList->getRows();
751
-			$appsSimplified = $this->simplifyArray($apps);
752
-			$respondedArray = $this->getArrayOfAppsResponded($this->response);
753
-			Assert::assertEqualsCanonicalizing($appsSimplified, $respondedArray);
754
-		}
755
-	}
756
-
757
-	/**
758
-	 * @Then /^subadmin users returned are$/
759
-	 * @param TableNode|null $groupsList
760
-	 */
761
-	public function theSubadminUsersShouldBe($groupsList) {
762
-		$this->theSubadminGroupsShouldBe($groupsList);
763
-	}
764
-
765
-	/**
766
-	 * Parses the xml answer to get the array of users returned.
767
-	 *
768
-	 * @param ResponseInterface $resp
769
-	 * @return array
770
-	 */
771
-	public function getArrayOfUsersResponded($resp) {
772
-		$listCheckedElements = simplexml_load_string($resp->getBody())->data[0]->users[0]->element;
773
-		$extractedElementsArray = json_decode(json_encode($listCheckedElements), 1);
774
-		return $extractedElementsArray;
775
-	}
776
-
777
-	/**
778
-	 * Parses the xml answer to get the array of detailed users returned.
779
-	 *
780
-	 * @param ResponseInterface $resp
781
-	 * @return array
782
-	 */
783
-	public function getArrayOfDetailedUsersResponded($resp) {
784
-		$listCheckedElements = simplexml_load_string($resp->getBody())->data[0]->users;
785
-		$extractedElementsArray = json_decode(json_encode($listCheckedElements), 1);
786
-		return $extractedElementsArray;
787
-	}
788
-
789
-	/**
790
-	 * Parses the xml answer to get the array of groups returned.
791
-	 *
792
-	 * @param ResponseInterface $resp
793
-	 * @return array
794
-	 */
795
-	public function getArrayOfGroupsResponded($resp) {
796
-		$listCheckedElements = simplexml_load_string($resp->getBody())->data[0]->groups[0]->element;
797
-		$extractedElementsArray = json_decode(json_encode($listCheckedElements), 1);
798
-		return $extractedElementsArray;
799
-	}
800
-
801
-	/**
802
-	 * Parses the xml answer to get the array of apps returned.
803
-	 *
804
-	 * @param ResponseInterface $resp
805
-	 * @return array
806
-	 */
807
-	public function getArrayOfAppsResponded($resp) {
808
-		$listCheckedElements = simplexml_load_string($resp->getBody())->data[0]->apps[0]->element;
809
-		$extractedElementsArray = json_decode(json_encode($listCheckedElements), 1);
810
-		return $extractedElementsArray;
811
-	}
812
-
813
-	/**
814
-	 * Parses the xml answer to get the array of subadmins returned.
815
-	 *
816
-	 * @param ResponseInterface $resp
817
-	 * @return array
818
-	 */
819
-	public function getArrayOfSubadminsResponded($resp) {
820
-		$listCheckedElements = simplexml_load_string($resp->getBody())->data[0]->element;
821
-		$extractedElementsArray = json_decode(json_encode($listCheckedElements), 1);
822
-		return $extractedElementsArray;
823
-	}
824
-
825
-	/**
826
-	 * @Given /^app "([^"]*)" enabled state will be restored once the scenario finishes$/
827
-	 * @param string $app
828
-	 */
829
-	public function appEnabledStateWillBeRestoredOnceTheScenarioFinishes($app) {
830
-		$previousUser = $this->currentUser;
831
-		$this->currentUser = 'admin';
832
-
833
-		if (in_array($app, $this->getAppsWithFilter('enabled'))) {
834
-			$this->appsToEnableAfterScenario[] = $app;
835
-		} elseif (in_array($app, $this->getAppsWithFilter('disabled'))) {
836
-			$this->appsToDisableAfterScenario[] = $app;
837
-		}
838
-
839
-		// Apps that were not installed before the scenario will not be
840
-		// disabled nor uninstalled after the scenario.
841
-
842
-		$this->currentUser = $previousUser;
843
-	}
844
-
845
-	private function getAppsWithFilter($filter) {
846
-		$fullUrl = $this->baseUrl . 'v2.php/cloud/apps?filter=' . $filter;
847
-		$client = new Client();
848
-		$options = [];
849
-		if ($this->currentUser === 'admin') {
850
-			$options['auth'] = $this->adminUser;
851
-		}
852
-		$options['headers'] = [
853
-			'OCS-APIREQUEST' => 'true',
854
-		];
855
-
856
-		$this->response = $client->get($fullUrl, $options);
857
-		return $this->getArrayOfAppsResponded($this->response);
858
-	}
859
-
860
-	/**
861
-	 * @Given /^app "([^"]*)" is disabled$/
862
-	 * @param string $app
863
-	 */
864
-	public function appIsDisabled($app) {
865
-		$respondedArray = $this->getAppsWithFilter('disabled');
866
-		Assert::assertContains($app, $respondedArray);
867
-		Assert::assertEquals(200, $this->response->getStatusCode());
868
-	}
869
-
870
-	/**
871
-	 * @Given /^app "([^"]*)" is enabled$/
872
-	 * @param string $app
873
-	 */
874
-	public function appIsEnabled($app) {
875
-		$respondedArray = $this->getAppsWithFilter('enabled');
876
-		Assert::assertContains($app, $respondedArray);
877
-		Assert::assertEquals(200, $this->response->getStatusCode());
878
-	}
879
-
880
-	/**
881
-	 * @Given /^app "([^"]*)" is not enabled$/
882
-	 *
883
-	 * Checks that the app is disabled or not installed.
884
-	 *
885
-	 * @param string $app
886
-	 */
887
-	public function appIsNotEnabled($app) {
888
-		$respondedArray = $this->getAppsWithFilter('enabled');
889
-		Assert::assertNotContains($app, $respondedArray);
890
-		Assert::assertEquals(200, $this->response->getStatusCode());
891
-	}
892
-
893
-	/**
894
-	 * @Then /^user "([^"]*)" is disabled$/
895
-	 * @param string $user
896
-	 */
897
-	public function userIsDisabled($user) {
898
-		$fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/cloud/users/$user";
899
-		$client = new Client();
900
-		$options = [];
901
-		if ($this->currentUser === 'admin') {
902
-			$options['auth'] = $this->adminUser;
903
-		}
904
-		$options['headers'] = [
905
-			'OCS-APIREQUEST' => 'true',
906
-		];
907
-
908
-		$this->response = $client->get($fullUrl, $options);
909
-		// false in xml is empty
910
-		Assert::assertTrue(empty(simplexml_load_string($this->response->getBody())->data[0]->enabled));
911
-	}
912
-
913
-	/**
914
-	 * @Then /^user "([^"]*)" is enabled$/
915
-	 * @param string $user
916
-	 */
917
-	public function userIsEnabled($user) {
918
-		$fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/cloud/users/$user";
919
-		$client = new Client();
920
-		$options = [];
921
-		if ($this->currentUser === 'admin') {
922
-			$options['auth'] = $this->adminUser;
923
-		}
924
-		$options['headers'] = [
925
-			'OCS-APIREQUEST' => 'true',
926
-		];
927
-
928
-		$this->response = $client->get($fullUrl, $options);
929
-		// boolean to string is integer
930
-		Assert::assertEquals('1', simplexml_load_string($this->response->getBody())->data[0]->enabled);
931
-	}
932
-
933
-	/**
934
-	 * @Given user :user has a quota of :quota
935
-	 * @param string $user
936
-	 * @param string $quota
937
-	 */
938
-	public function userHasAQuotaOf($user, $quota) {
939
-		$body = new TableNode([
940
-			0 => ['key', 'quota'],
941
-			1 => ['value', $quota],
942
-		]);
943
-
944
-		// method used from BasicStructure trait
945
-		$this->sendingToWith('PUT', '/cloud/users/' . $user, $body);
946
-	}
947
-
948
-	/**
949
-	 * @Given user :user has unlimited quota
950
-	 * @param string $user
951
-	 */
952
-	public function userHasUnlimitedQuota($user) {
953
-		$this->userHasAQuotaOf($user, 'none');
954
-	}
955
-
956
-	/**
957
-	 * Returns home path of the given user
958
-	 *
959
-	 * @param string $user
960
-	 */
961
-	public function getUserHome($user) {
962
-		$fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/cloud/users/$user";
963
-		$client = new Client();
964
-		$options = [];
965
-		$options['auth'] = $this->adminUser;
966
-		$this->response = $client->get($fullUrl, $options);
967
-		return simplexml_load_string($this->response->getBody())->data[0]->home;
968
-	}
969
-
970
-	/**
971
-	 * @BeforeScenario
972
-	 * @AfterScenario
973
-	 */
974
-	public function cleanupUsers() {
975
-		$previousServer = $this->currentServer;
976
-		$this->usingServer('LOCAL');
977
-		foreach ($this->createdUsers as $user) {
978
-			$this->deleteUser($user);
979
-		}
980
-		$this->usingServer('REMOTE');
981
-		foreach ($this->createdRemoteUsers as $remoteUser) {
982
-			$this->deleteUser($remoteUser);
983
-		}
984
-		$this->usingServer($previousServer);
985
-	}
986
-
987
-	/**
988
-	 * @BeforeScenario
989
-	 * @AfterScenario
990
-	 */
991
-	public function cleanupGroups() {
992
-		$previousServer = $this->currentServer;
993
-		$this->usingServer('LOCAL');
994
-		foreach ($this->createdGroups as $group) {
995
-			$this->deleteGroup($group);
996
-		}
997
-		$this->usingServer('REMOTE');
998
-		foreach ($this->createdRemoteGroups as $remoteGroup) {
999
-			$this->deleteGroup($remoteGroup);
1000
-		}
1001
-		$this->usingServer($previousServer);
1002
-	}
1003
-
1004
-	/**
1005
-	 * @Then /^user "([^"]*)" has not$/
1006
-	 */
1007
-	public function userHasNotSetting($user, TableNode $settings) {
1008
-		$fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/cloud/users/$user";
1009
-		$client = new Client();
1010
-		$options = [];
1011
-		if ($this->currentUser === 'admin') {
1012
-			$options['auth'] = $this->adminUser;
1013
-		} else {
1014
-			$options['auth'] = [$this->currentUser, $this->regularUser];
1015
-		}
1016
-		$options['headers'] = [
1017
-			'OCS-APIREQUEST' => 'true',
1018
-		];
1019
-
1020
-		$response = $client->get($fullUrl, $options);
1021
-		foreach ($settings->getRows() as $setting) {
1022
-			$value = json_decode(json_encode(simplexml_load_string($response->getBody())->data->{$setting[0]}), 1);
1023
-			if (isset($value[0])) {
1024
-				if (in_array($setting[0], ['additional_mail', 'additional_mailScope'], true)) {
1025
-					$expectedValues = explode(';', $setting[1]);
1026
-					foreach ($expectedValues as $expected) {
1027
-						Assert::assertFalse(in_array($expected, $value, true));
1028
-					}
1029
-				} else {
1030
-					Assert::assertNotEqualsCanonicalizing($setting[1], $value[0]);
1031
-				}
1032
-			} else {
1033
-				Assert::assertNotEquals('', $setting[1]);
1034
-			}
1035
-		}
1036
-	}
17
+    use BasicStructure;
18
+
19
+    /** @var array */
20
+    private $appsToEnableAfterScenario = [];
21
+
22
+    /** @var array */
23
+    private $appsToDisableAfterScenario = [];
24
+
25
+    /** @var array */
26
+    private $createdUsers = [];
27
+
28
+    /** @var array */
29
+    private $createdRemoteUsers = [];
30
+
31
+    /** @var array */
32
+    private $createdRemoteGroups = [];
33
+
34
+    /** @var array */
35
+    private $createdGroups = [];
36
+
37
+    /** @AfterScenario */
38
+    public function restoreAppsEnabledStateAfterScenario() {
39
+        $this->asAn('admin');
40
+
41
+        foreach ($this->appsToEnableAfterScenario as $app) {
42
+            $this->sendingTo('POST', '/cloud/apps/' . $app);
43
+        }
44
+
45
+        foreach ($this->appsToDisableAfterScenario as $app) {
46
+            $this->sendingTo('DELETE', '/cloud/apps/' . $app);
47
+        }
48
+    }
49
+
50
+    /**
51
+     * @Given /^user "([^"]*)" exists$/
52
+     * @param string $user
53
+     */
54
+    public function assureUserExists($user) {
55
+        try {
56
+            $this->userExists($user);
57
+        } catch (\GuzzleHttp\Exception\ClientException $ex) {
58
+            $previous_user = $this->currentUser;
59
+            $this->currentUser = 'admin';
60
+            $this->creatingTheUser($user);
61
+            $this->currentUser = $previous_user;
62
+        }
63
+        $this->userExists($user);
64
+        Assert::assertEquals(200, $this->response->getStatusCode());
65
+    }
66
+
67
+    /**
68
+     * @Given /^user "([^"]*)" with displayname "((?:[^"]|\\")*)" exists$/
69
+     * @param string $user
70
+     */
71
+    public function assureUserWithDisplaynameExists($user, $displayname) {
72
+        try {
73
+            $this->userExists($user);
74
+        } catch (\GuzzleHttp\Exception\ClientException $ex) {
75
+            $previous_user = $this->currentUser;
76
+            $this->currentUser = 'admin';
77
+            $this->creatingTheUser($user, $displayname);
78
+            $this->currentUser = $previous_user;
79
+        }
80
+        $this->userExists($user);
81
+        Assert::assertEquals(200, $this->response->getStatusCode());
82
+    }
83
+
84
+    /**
85
+     * @Given /^user "([^"]*)" does not exist$/
86
+     * @param string $user
87
+     */
88
+    public function userDoesNotExist($user) {
89
+        try {
90
+            $this->userExists($user);
91
+        } catch (\GuzzleHttp\Exception\ClientException $ex) {
92
+            $this->response = $ex->getResponse();
93
+            Assert::assertEquals(404, $ex->getResponse()->getStatusCode());
94
+            return;
95
+        }
96
+        $previous_user = $this->currentUser;
97
+        $this->currentUser = 'admin';
98
+        $this->deletingTheUser($user);
99
+        $this->currentUser = $previous_user;
100
+        try {
101
+            $this->userExists($user);
102
+        } catch (\GuzzleHttp\Exception\ClientException $ex) {
103
+            $this->response = $ex->getResponse();
104
+            Assert::assertEquals(404, $ex->getResponse()->getStatusCode());
105
+        }
106
+    }
107
+
108
+    public function creatingTheUser($user, $displayname = '') {
109
+        $fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/cloud/users";
110
+        $client = new Client();
111
+        $options = [];
112
+        if ($this->currentUser === 'admin') {
113
+            $options['auth'] = $this->adminUser;
114
+        }
115
+
116
+        $options['form_params'] = [
117
+            'userid' => $user,
118
+            'password' => '123456'
119
+        ];
120
+        if ($displayname !== '') {
121
+            $options['form_params']['displayName'] = $displayname;
122
+        }
123
+        $options['headers'] = [
124
+            'OCS-APIREQUEST' => 'true',
125
+        ];
126
+
127
+        $this->response = $client->post($fullUrl, $options);
128
+        if ($this->currentServer === 'LOCAL') {
129
+            $this->createdUsers[$user] = $user;
130
+        } elseif ($this->currentServer === 'REMOTE') {
131
+            $this->createdRemoteUsers[$user] = $user;
132
+        }
133
+
134
+        //Quick hack to login once with the current user
135
+        $options2 = [
136
+            'auth' => [$user, '123456'],
137
+        ];
138
+        $options2['headers'] = [
139
+            'OCS-APIREQUEST' => 'true',
140
+        ];
141
+        $url = $fullUrl . '/' . $user;
142
+        $client->get($url, $options2);
143
+    }
144
+
145
+    /**
146
+     * @Then /^user "([^"]*)" has$/
147
+     *
148
+     * @param string $user
149
+     * @param TableNode|null $settings
150
+     */
151
+    public function userHasSetting($user, $settings) {
152
+        $fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/cloud/users/$user";
153
+        $client = new Client();
154
+        $options = [];
155
+        if ($this->currentUser === 'admin') {
156
+            $options['auth'] = $this->adminUser;
157
+        } else {
158
+            $options['auth'] = [$this->currentUser, $this->regularUser];
159
+        }
160
+        $options['headers'] = [
161
+            'OCS-APIREQUEST' => 'true',
162
+        ];
163
+
164
+        $response = $client->get($fullUrl, $options);
165
+        foreach ($settings->getRows() as $setting) {
166
+            $value = json_decode(json_encode(simplexml_load_string($response->getBody())->data->{$setting[0]}), 1);
167
+            if (isset($value['element']) && in_array($setting[0], ['additional_mail', 'additional_mailScope'], true)) {
168
+                $expectedValues = explode(';', $setting[1]);
169
+                foreach ($expectedValues as $expected) {
170
+                    Assert::assertTrue(in_array($expected, $value['element'], true), 'Data wrong for field: ' . $setting[0]);
171
+                }
172
+            } elseif (isset($value[0])) {
173
+                Assert::assertEqualsCanonicalizing($setting[1], $value[0], 'Data wrong for field: ' . $setting[0]);
174
+            } else {
175
+                Assert::assertEquals('', $setting[1], 'Data wrong for field: ' . $setting[0]);
176
+            }
177
+        }
178
+    }
179
+
180
+    /**
181
+     * @Then /^user "([^"]*)" has the following profile data$/
182
+     */
183
+    public function userHasProfileData(string $user, ?TableNode $settings): void {
184
+        $fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/profile/$user";
185
+        $client = new Client();
186
+        $options = [];
187
+        if ($this->currentUser === 'admin') {
188
+            $options['auth'] = $this->adminUser;
189
+        } else {
190
+            $options['auth'] = [$this->currentUser, $this->regularUser];
191
+        }
192
+        $options['headers'] = [
193
+            'OCS-APIREQUEST' => 'true',
194
+            'Accept' => 'application/json',
195
+        ];
196
+
197
+        $response = $client->get($fullUrl, $options);
198
+        $body = $response->getBody()->getContents();
199
+        $data = json_decode($body, true);
200
+        $data = $data['ocs']['data'];
201
+        foreach ($settings->getRows() as $setting) {
202
+            Assert::assertArrayHasKey($setting[0], $data, 'Profile data field missing: ' . $setting[0]);
203
+            if ($setting[1] === 'NULL') {
204
+                Assert::assertNull($data[$setting[0]], 'Profile data wrong for field: ' . $setting[0]);
205
+            } else {
206
+                Assert::assertEquals($setting[1], $data[$setting[0]], 'Profile data wrong for field: ' . $setting[0]);
207
+            }
208
+        }
209
+    }
210
+
211
+    /**
212
+     * @Then /^group "([^"]*)" has$/
213
+     *
214
+     * @param string $user
215
+     * @param TableNode|null $settings
216
+     */
217
+    public function groupHasSetting($group, $settings) {
218
+        $fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/cloud/groups/details?search=$group";
219
+        $client = new Client();
220
+        $options = [];
221
+        if ($this->currentUser === 'admin') {
222
+            $options['auth'] = $this->adminUser;
223
+        } else {
224
+            $options['auth'] = [$this->currentUser, $this->regularUser];
225
+        }
226
+        $options['headers'] = [
227
+            'OCS-APIREQUEST' => 'true',
228
+        ];
229
+
230
+        $response = $client->get($fullUrl, $options);
231
+        $groupDetails = simplexml_load_string($response->getBody())->data[0]->groups[0]->element;
232
+        foreach ($settings->getRows() as $setting) {
233
+            $value = json_decode(json_encode($groupDetails->{$setting[0]}), 1);
234
+            if (isset($value[0])) {
235
+                Assert::assertEqualsCanonicalizing($setting[1], $value[0]);
236
+            } else {
237
+                Assert::assertEquals('', $setting[1]);
238
+            }
239
+        }
240
+    }
241
+
242
+
243
+    /**
244
+     * @Then /^user "([^"]*)" has editable fields$/
245
+     *
246
+     * @param string $user
247
+     * @param TableNode|null $fields
248
+     */
249
+    public function userHasEditableFields($user, $fields) {
250
+        $fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/cloud/user/fields";
251
+        if ($user !== 'self') {
252
+            $fullUrl .= '/' . $user;
253
+        }
254
+        $client = new Client();
255
+        $options = [];
256
+        if ($this->currentUser === 'admin') {
257
+            $options['auth'] = $this->adminUser;
258
+        } else {
259
+            $options['auth'] = [$this->currentUser, $this->regularUser];
260
+        }
261
+        $options['headers'] = [
262
+            'OCS-APIREQUEST' => 'true',
263
+        ];
264
+
265
+        $response = $client->get($fullUrl, $options);
266
+        $fieldsArray = json_decode(json_encode(simplexml_load_string($response->getBody())->data->element), 1);
267
+
268
+        $expectedFields = $fields->getRows();
269
+        $expectedFields = $this->simplifyArray($expectedFields);
270
+        Assert::assertEquals($expectedFields, $fieldsArray);
271
+    }
272
+
273
+    /**
274
+     * @Then /^search users by phone for region "([^"]*)" with$/
275
+     *
276
+     * @param string $user
277
+     * @param TableNode|null $settings
278
+     */
279
+    public function searchUserByPhone($region, TableNode $searchTable) {
280
+        $fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/cloud/users/search/by-phone";
281
+        $client = new Client();
282
+        $options = [];
283
+        $options['auth'] = $this->adminUser;
284
+        $options['headers'] = [
285
+            'OCS-APIREQUEST' => 'true',
286
+        ];
287
+
288
+        $search = [];
289
+        foreach ($searchTable->getRows() as $row) {
290
+            if (!isset($search[$row[0]])) {
291
+                $search[$row[0]] = [];
292
+            }
293
+            $search[$row[0]][] = $row[1];
294
+        }
295
+
296
+        $options['form_params'] = [
297
+            'location' => $region,
298
+            'search' => $search,
299
+        ];
300
+
301
+        $this->response = $client->post($fullUrl, $options);
302
+    }
303
+
304
+    public function createUser($user) {
305
+        $previous_user = $this->currentUser;
306
+        $this->currentUser = 'admin';
307
+        $this->creatingTheUser($user);
308
+        $this->userExists($user);
309
+        $this->currentUser = $previous_user;
310
+    }
311
+
312
+    public function deleteUser($user) {
313
+        $previous_user = $this->currentUser;
314
+        $this->currentUser = 'admin';
315
+        $this->deletingTheUser($user);
316
+        $this->userDoesNotExist($user);
317
+        $this->currentUser = $previous_user;
318
+    }
319
+
320
+    public function createGroup($group) {
321
+        $previous_user = $this->currentUser;
322
+        $this->currentUser = 'admin';
323
+        $this->creatingTheGroup($group);
324
+        $this->groupExists($group);
325
+        $this->currentUser = $previous_user;
326
+    }
327
+
328
+    public function deleteGroup($group) {
329
+        $previous_user = $this->currentUser;
330
+        $this->currentUser = 'admin';
331
+        $this->deletingTheGroup($group);
332
+        $this->groupDoesNotExist($group);
333
+        $this->currentUser = $previous_user;
334
+    }
335
+
336
+    public function userExists($user) {
337
+        $fullUrl = $this->baseUrl . "v2.php/cloud/users/$user";
338
+        $client = new Client();
339
+        $options = [];
340
+        $options['auth'] = $this->adminUser;
341
+        $options['headers'] = [
342
+            'OCS-APIREQUEST' => 'true'
343
+        ];
344
+
345
+        $this->response = $client->get($fullUrl, $options);
346
+    }
347
+
348
+    /**
349
+     * @Then /^check that user "([^"]*)" belongs to group "([^"]*)"$/
350
+     * @param string $user
351
+     * @param string $group
352
+     */
353
+    public function checkThatUserBelongsToGroup($user, $group) {
354
+        $fullUrl = $this->baseUrl . "v2.php/cloud/users/$user/groups";
355
+        $client = new Client();
356
+        $options = [];
357
+        if ($this->currentUser === 'admin') {
358
+            $options['auth'] = $this->adminUser;
359
+        }
360
+        $options['headers'] = [
361
+            'OCS-APIREQUEST' => 'true',
362
+        ];
363
+
364
+        $this->response = $client->get($fullUrl, $options);
365
+        $respondedArray = $this->getArrayOfGroupsResponded($this->response);
366
+        sort($respondedArray);
367
+        Assert::assertContains($group, $respondedArray);
368
+        Assert::assertEquals(200, $this->response->getStatusCode());
369
+    }
370
+
371
+    public function userBelongsToGroup($user, $group) {
372
+        $fullUrl = $this->baseUrl . "v2.php/cloud/users/$user/groups";
373
+        $client = new Client();
374
+        $options = [];
375
+        if ($this->currentUser === 'admin') {
376
+            $options['auth'] = $this->adminUser;
377
+        }
378
+        $options['headers'] = [
379
+            'OCS-APIREQUEST' => 'true',
380
+        ];
381
+
382
+        $this->response = $client->get($fullUrl, $options);
383
+        $respondedArray = $this->getArrayOfGroupsResponded($this->response);
384
+
385
+        if (array_key_exists($group, $respondedArray)) {
386
+            return true;
387
+        } else {
388
+            return false;
389
+        }
390
+    }
391
+
392
+    /**
393
+     * @Given /^user "([^"]*)" belongs to group "([^"]*)"$/
394
+     * @param string $user
395
+     * @param string $group
396
+     */
397
+    public function assureUserBelongsToGroup($user, $group) {
398
+        $previous_user = $this->currentUser;
399
+        $this->currentUser = 'admin';
400
+
401
+        if (!$this->userBelongsToGroup($user, $group)) {
402
+            $this->addingUserToGroup($user, $group);
403
+        }
404
+
405
+        $this->checkThatUserBelongsToGroup($user, $group);
406
+        $this->currentUser = $previous_user;
407
+    }
408
+
409
+    /**
410
+     * @Given /^user "([^"]*)" does not belong to group "([^"]*)"$/
411
+     * @param string $user
412
+     * @param string $group
413
+     */
414
+    public function userDoesNotBelongToGroup($user, $group) {
415
+        $fullUrl = $this->baseUrl . "v2.php/cloud/users/$user/groups";
416
+        $client = new Client();
417
+        $options = [];
418
+        if ($this->currentUser === 'admin') {
419
+            $options['auth'] = $this->adminUser;
420
+        }
421
+        $options['headers'] = [
422
+            'OCS-APIREQUEST' => 'true',
423
+        ];
424
+
425
+        $this->response = $client->get($fullUrl, $options);
426
+        $groups = [$group];
427
+        $respondedArray = $this->getArrayOfGroupsResponded($this->response);
428
+        Assert::assertNotEqualsCanonicalizing($groups, $respondedArray);
429
+        Assert::assertEquals(200, $this->response->getStatusCode());
430
+    }
431
+
432
+    /**
433
+     * @When /^creating the group "([^"]*)"$/
434
+     * @param string $group
435
+     */
436
+    public function creatingTheGroup($group) {
437
+        $fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/cloud/groups";
438
+        $client = new Client();
439
+        $options = [];
440
+        if ($this->currentUser === 'admin') {
441
+            $options['auth'] = $this->adminUser;
442
+        }
443
+
444
+        $options['form_params'] = [
445
+            'groupid' => $group,
446
+        ];
447
+        $options['headers'] = [
448
+            'OCS-APIREQUEST' => 'true',
449
+        ];
450
+
451
+        $this->response = $client->post($fullUrl, $options);
452
+        if ($this->currentServer === 'LOCAL') {
453
+            $this->createdGroups[$group] = $group;
454
+        } elseif ($this->currentServer === 'REMOTE') {
455
+            $this->createdRemoteGroups[$group] = $group;
456
+        }
457
+    }
458
+
459
+    /**
460
+     * @When /^assure user "([^"]*)" is disabled$/
461
+     */
462
+    public function assureUserIsDisabled($user) {
463
+        $fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/cloud/users/$user/disable";
464
+        $client = new Client();
465
+        $options = [];
466
+        if ($this->currentUser === 'admin') {
467
+            $options['auth'] = $this->adminUser;
468
+        }
469
+        $options['headers'] = [
470
+            'OCS-APIREQUEST' => 'true',
471
+        ];
472
+        // TODO: fix hack
473
+        $options['form_params'] = [
474
+            'foo' => 'bar'
475
+        ];
476
+
477
+        $this->response = $client->put($fullUrl, $options);
478
+    }
479
+
480
+    /**
481
+     * @When /^Deleting the user "([^"]*)"$/
482
+     * @param string $user
483
+     */
484
+    public function deletingTheUser($user) {
485
+        $fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/cloud/users/$user";
486
+        $client = new Client();
487
+        $options = [];
488
+        if ($this->currentUser === 'admin') {
489
+            $options['auth'] = $this->adminUser;
490
+        }
491
+        $options['headers'] = [
492
+            'OCS-APIREQUEST' => 'true',
493
+        ];
494
+
495
+        $this->response = $client->delete($fullUrl, $options);
496
+    }
497
+
498
+    /**
499
+     * @When /^Deleting the group "([^"]*)"$/
500
+     * @param string $group
501
+     */
502
+    public function deletingTheGroup($group) {
503
+        $fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/cloud/groups/$group";
504
+        $client = new Client();
505
+        $options = [];
506
+        if ($this->currentUser === 'admin') {
507
+            $options['auth'] = $this->adminUser;
508
+        }
509
+        $options['headers'] = [
510
+            'OCS-APIREQUEST' => 'true',
511
+        ];
512
+
513
+        $this->response = $client->delete($fullUrl, $options);
514
+
515
+        if ($this->currentServer === 'LOCAL') {
516
+            unset($this->createdGroups[$group]);
517
+        } elseif ($this->currentServer === 'REMOTE') {
518
+            unset($this->createdRemoteGroups[$group]);
519
+        }
520
+    }
521
+
522
+    /**
523
+     * @Given /^Add user "([^"]*)" to the group "([^"]*)"$/
524
+     * @param string $user
525
+     * @param string $group
526
+     */
527
+    public function addUserToGroup($user, $group) {
528
+        $this->userExists($user);
529
+        $this->groupExists($group);
530
+        $this->addingUserToGroup($user, $group);
531
+    }
532
+
533
+    /**
534
+     * @When /^User "([^"]*)" is added to the group "([^"]*)"$/
535
+     * @param string $user
536
+     * @param string $group
537
+     */
538
+    public function addingUserToGroup($user, $group) {
539
+        $fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/cloud/users/$user/groups";
540
+        $client = new Client();
541
+        $options = [];
542
+        if ($this->currentUser === 'admin') {
543
+            $options['auth'] = $this->adminUser;
544
+        }
545
+        $options['headers'] = [
546
+            'OCS-APIREQUEST' => 'true',
547
+        ];
548
+
549
+        $options['form_params'] = [
550
+            'groupid' => $group,
551
+        ];
552
+
553
+        $this->response = $client->post($fullUrl, $options);
554
+    }
555
+
556
+
557
+    public function groupExists($group) {
558
+        $fullUrl = $this->baseUrl . "v2.php/cloud/groups/$group";
559
+        $client = new Client();
560
+        $options = [];
561
+        $options['auth'] = $this->adminUser;
562
+        $options['headers'] = [
563
+            'OCS-APIREQUEST' => 'true',
564
+        ];
565
+
566
+        $this->response = $client->get($fullUrl, $options);
567
+    }
568
+
569
+    /**
570
+     * @Given /^group "([^"]*)" exists$/
571
+     * @param string $group
572
+     */
573
+    public function assureGroupExists($group) {
574
+        try {
575
+            $this->groupExists($group);
576
+        } catch (\GuzzleHttp\Exception\ClientException $ex) {
577
+            $previous_user = $this->currentUser;
578
+            $this->currentUser = 'admin';
579
+            $this->creatingTheGroup($group);
580
+            $this->currentUser = $previous_user;
581
+        }
582
+        $this->groupExists($group);
583
+        Assert::assertEquals(200, $this->response->getStatusCode());
584
+    }
585
+
586
+    /**
587
+     * @Given /^group "([^"]*)" does not exist$/
588
+     * @param string $group
589
+     */
590
+    public function groupDoesNotExist($group) {
591
+        try {
592
+            $this->groupExists($group);
593
+        } catch (\GuzzleHttp\Exception\ClientException $ex) {
594
+            $this->response = $ex->getResponse();
595
+            Assert::assertEquals(404, $ex->getResponse()->getStatusCode());
596
+            return;
597
+        }
598
+        $previous_user = $this->currentUser;
599
+        $this->currentUser = 'admin';
600
+        $this->deletingTheGroup($group);
601
+        $this->currentUser = $previous_user;
602
+        try {
603
+            $this->groupExists($group);
604
+        } catch (\GuzzleHttp\Exception\ClientException $ex) {
605
+            $this->response = $ex->getResponse();
606
+            Assert::assertEquals(404, $ex->getResponse()->getStatusCode());
607
+        }
608
+    }
609
+
610
+    /**
611
+     * @Given /^user "([^"]*)" is subadmin of group "([^"]*)"$/
612
+     * @param string $user
613
+     * @param string $group
614
+     */
615
+    public function userIsSubadminOfGroup($user, $group) {
616
+        $fullUrl = $this->baseUrl . "v2.php/cloud/groups/$group/subadmins";
617
+        $client = new Client();
618
+        $options = [];
619
+        if ($this->currentUser === 'admin') {
620
+            $options['auth'] = $this->adminUser;
621
+        }
622
+        $options['headers'] = [
623
+            'OCS-APIREQUEST' => 'true',
624
+        ];
625
+
626
+        $this->response = $client->get($fullUrl, $options);
627
+        $respondedArray = $this->getArrayOfSubadminsResponded($this->response);
628
+        sort($respondedArray);
629
+        Assert::assertContains($user, $respondedArray);
630
+        Assert::assertEquals(200, $this->response->getStatusCode());
631
+    }
632
+
633
+    /**
634
+     * @Given /^Assure user "([^"]*)" is subadmin of group "([^"]*)"$/
635
+     * @param string $user
636
+     * @param string $group
637
+     */
638
+    public function assureUserIsSubadminOfGroup($user, $group) {
639
+        $fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/cloud/users/$user/subadmins";
640
+        $client = new Client();
641
+        $options = [];
642
+        if ($this->currentUser === 'admin') {
643
+            $options['auth'] = $this->adminUser;
644
+        }
645
+        $options['form_params'] = [
646
+            'groupid' => $group
647
+        ];
648
+        $options['headers'] = [
649
+            'OCS-APIREQUEST' => 'true',
650
+        ];
651
+        $this->response = $client->post($fullUrl, $options);
652
+        Assert::assertEquals(200, $this->response->getStatusCode());
653
+    }
654
+
655
+    /**
656
+     * @Given /^user "([^"]*)" is not a subadmin of group "([^"]*)"$/
657
+     * @param string $user
658
+     * @param string $group
659
+     */
660
+    public function userIsNotSubadminOfGroup($user, $group) {
661
+        $fullUrl = $this->baseUrl . "v2.php/cloud/groups/$group/subadmins";
662
+        $client = new Client();
663
+        $options = [];
664
+        if ($this->currentUser === 'admin') {
665
+            $options['auth'] = $this->adminUser;
666
+        }
667
+        $options['headers'] = [
668
+            'OCS-APIREQUEST' => 'true',
669
+        ];
670
+
671
+        $this->response = $client->get($fullUrl, $options);
672
+        $respondedArray = $this->getArrayOfSubadminsResponded($this->response);
673
+        sort($respondedArray);
674
+        Assert::assertNotContains($user, $respondedArray);
675
+        Assert::assertEquals(200, $this->response->getStatusCode());
676
+    }
677
+
678
+    /**
679
+     * @Then /^users returned are$/
680
+     * @param TableNode|null $usersList
681
+     */
682
+    public function theUsersShouldBe($usersList) {
683
+        if ($usersList instanceof TableNode) {
684
+            $users = $usersList->getRows();
685
+            $usersSimplified = $this->simplifyArray($users);
686
+            $respondedArray = $this->getArrayOfUsersResponded($this->response);
687
+            Assert::assertEqualsCanonicalizing($usersSimplified, $respondedArray);
688
+        }
689
+    }
690
+
691
+    /**
692
+     * @Then /^phone matches returned are$/
693
+     * @param TableNode|null $usersList
694
+     */
695
+    public function thePhoneUsersShouldBe($usersList) {
696
+        if ($usersList instanceof TableNode) {
697
+            $users = $usersList->getRowsHash();
698
+            $listCheckedElements = simplexml_load_string($this->response->getBody())->data;
699
+            $respondedArray = json_decode(json_encode($listCheckedElements), true);
700
+            Assert::assertEquals($users, $respondedArray);
701
+        }
702
+    }
703
+
704
+    /**
705
+     * @Then /^detailed users returned are$/
706
+     * @param TableNode|null $usersList
707
+     */
708
+    public function theDetailedUsersShouldBe($usersList) {
709
+        if ($usersList instanceof TableNode) {
710
+            $users = $usersList->getRows();
711
+            $usersSimplified = $this->simplifyArray($users);
712
+            $respondedArray = $this->getArrayOfDetailedUsersResponded($this->response);
713
+            $respondedArray = array_keys($respondedArray);
714
+            Assert::assertEquals($usersSimplified, $respondedArray);
715
+        }
716
+    }
717
+
718
+    /**
719
+     * @Then /^groups returned are$/
720
+     * @param TableNode|null $groupsList
721
+     */
722
+    public function theGroupsShouldBe($groupsList) {
723
+        if ($groupsList instanceof TableNode) {
724
+            $groups = $groupsList->getRows();
725
+            $groupsSimplified = $this->simplifyArray($groups);
726
+            $respondedArray = $this->getArrayOfGroupsResponded($this->response);
727
+            Assert::assertEqualsCanonicalizing($groupsSimplified, $respondedArray);
728
+        }
729
+    }
730
+
731
+    /**
732
+     * @Then /^subadmin groups returned are$/
733
+     * @param TableNode|null $groupsList
734
+     */
735
+    public function theSubadminGroupsShouldBe($groupsList) {
736
+        if ($groupsList instanceof TableNode) {
737
+            $groups = $groupsList->getRows();
738
+            $groupsSimplified = $this->simplifyArray($groups);
739
+            $respondedArray = $this->getArrayOfSubadminsResponded($this->response);
740
+            Assert::assertEqualsCanonicalizing($groupsSimplified, $respondedArray);
741
+        }
742
+    }
743
+
744
+    /**
745
+     * @Then /^apps returned are$/
746
+     * @param TableNode|null $appList
747
+     */
748
+    public function theAppsShouldBe($appList) {
749
+        if ($appList instanceof TableNode) {
750
+            $apps = $appList->getRows();
751
+            $appsSimplified = $this->simplifyArray($apps);
752
+            $respondedArray = $this->getArrayOfAppsResponded($this->response);
753
+            Assert::assertEqualsCanonicalizing($appsSimplified, $respondedArray);
754
+        }
755
+    }
756
+
757
+    /**
758
+     * @Then /^subadmin users returned are$/
759
+     * @param TableNode|null $groupsList
760
+     */
761
+    public function theSubadminUsersShouldBe($groupsList) {
762
+        $this->theSubadminGroupsShouldBe($groupsList);
763
+    }
764
+
765
+    /**
766
+     * Parses the xml answer to get the array of users returned.
767
+     *
768
+     * @param ResponseInterface $resp
769
+     * @return array
770
+     */
771
+    public function getArrayOfUsersResponded($resp) {
772
+        $listCheckedElements = simplexml_load_string($resp->getBody())->data[0]->users[0]->element;
773
+        $extractedElementsArray = json_decode(json_encode($listCheckedElements), 1);
774
+        return $extractedElementsArray;
775
+    }
776
+
777
+    /**
778
+     * Parses the xml answer to get the array of detailed users returned.
779
+     *
780
+     * @param ResponseInterface $resp
781
+     * @return array
782
+     */
783
+    public function getArrayOfDetailedUsersResponded($resp) {
784
+        $listCheckedElements = simplexml_load_string($resp->getBody())->data[0]->users;
785
+        $extractedElementsArray = json_decode(json_encode($listCheckedElements), 1);
786
+        return $extractedElementsArray;
787
+    }
788
+
789
+    /**
790
+     * Parses the xml answer to get the array of groups returned.
791
+     *
792
+     * @param ResponseInterface $resp
793
+     * @return array
794
+     */
795
+    public function getArrayOfGroupsResponded($resp) {
796
+        $listCheckedElements = simplexml_load_string($resp->getBody())->data[0]->groups[0]->element;
797
+        $extractedElementsArray = json_decode(json_encode($listCheckedElements), 1);
798
+        return $extractedElementsArray;
799
+    }
800
+
801
+    /**
802
+     * Parses the xml answer to get the array of apps returned.
803
+     *
804
+     * @param ResponseInterface $resp
805
+     * @return array
806
+     */
807
+    public function getArrayOfAppsResponded($resp) {
808
+        $listCheckedElements = simplexml_load_string($resp->getBody())->data[0]->apps[0]->element;
809
+        $extractedElementsArray = json_decode(json_encode($listCheckedElements), 1);
810
+        return $extractedElementsArray;
811
+    }
812
+
813
+    /**
814
+     * Parses the xml answer to get the array of subadmins returned.
815
+     *
816
+     * @param ResponseInterface $resp
817
+     * @return array
818
+     */
819
+    public function getArrayOfSubadminsResponded($resp) {
820
+        $listCheckedElements = simplexml_load_string($resp->getBody())->data[0]->element;
821
+        $extractedElementsArray = json_decode(json_encode($listCheckedElements), 1);
822
+        return $extractedElementsArray;
823
+    }
824
+
825
+    /**
826
+     * @Given /^app "([^"]*)" enabled state will be restored once the scenario finishes$/
827
+     * @param string $app
828
+     */
829
+    public function appEnabledStateWillBeRestoredOnceTheScenarioFinishes($app) {
830
+        $previousUser = $this->currentUser;
831
+        $this->currentUser = 'admin';
832
+
833
+        if (in_array($app, $this->getAppsWithFilter('enabled'))) {
834
+            $this->appsToEnableAfterScenario[] = $app;
835
+        } elseif (in_array($app, $this->getAppsWithFilter('disabled'))) {
836
+            $this->appsToDisableAfterScenario[] = $app;
837
+        }
838
+
839
+        // Apps that were not installed before the scenario will not be
840
+        // disabled nor uninstalled after the scenario.
841
+
842
+        $this->currentUser = $previousUser;
843
+    }
844
+
845
+    private function getAppsWithFilter($filter) {
846
+        $fullUrl = $this->baseUrl . 'v2.php/cloud/apps?filter=' . $filter;
847
+        $client = new Client();
848
+        $options = [];
849
+        if ($this->currentUser === 'admin') {
850
+            $options['auth'] = $this->adminUser;
851
+        }
852
+        $options['headers'] = [
853
+            'OCS-APIREQUEST' => 'true',
854
+        ];
855
+
856
+        $this->response = $client->get($fullUrl, $options);
857
+        return $this->getArrayOfAppsResponded($this->response);
858
+    }
859
+
860
+    /**
861
+     * @Given /^app "([^"]*)" is disabled$/
862
+     * @param string $app
863
+     */
864
+    public function appIsDisabled($app) {
865
+        $respondedArray = $this->getAppsWithFilter('disabled');
866
+        Assert::assertContains($app, $respondedArray);
867
+        Assert::assertEquals(200, $this->response->getStatusCode());
868
+    }
869
+
870
+    /**
871
+     * @Given /^app "([^"]*)" is enabled$/
872
+     * @param string $app
873
+     */
874
+    public function appIsEnabled($app) {
875
+        $respondedArray = $this->getAppsWithFilter('enabled');
876
+        Assert::assertContains($app, $respondedArray);
877
+        Assert::assertEquals(200, $this->response->getStatusCode());
878
+    }
879
+
880
+    /**
881
+     * @Given /^app "([^"]*)" is not enabled$/
882
+     *
883
+     * Checks that the app is disabled or not installed.
884
+     *
885
+     * @param string $app
886
+     */
887
+    public function appIsNotEnabled($app) {
888
+        $respondedArray = $this->getAppsWithFilter('enabled');
889
+        Assert::assertNotContains($app, $respondedArray);
890
+        Assert::assertEquals(200, $this->response->getStatusCode());
891
+    }
892
+
893
+    /**
894
+     * @Then /^user "([^"]*)" is disabled$/
895
+     * @param string $user
896
+     */
897
+    public function userIsDisabled($user) {
898
+        $fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/cloud/users/$user";
899
+        $client = new Client();
900
+        $options = [];
901
+        if ($this->currentUser === 'admin') {
902
+            $options['auth'] = $this->adminUser;
903
+        }
904
+        $options['headers'] = [
905
+            'OCS-APIREQUEST' => 'true',
906
+        ];
907
+
908
+        $this->response = $client->get($fullUrl, $options);
909
+        // false in xml is empty
910
+        Assert::assertTrue(empty(simplexml_load_string($this->response->getBody())->data[0]->enabled));
911
+    }
912
+
913
+    /**
914
+     * @Then /^user "([^"]*)" is enabled$/
915
+     * @param string $user
916
+     */
917
+    public function userIsEnabled($user) {
918
+        $fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/cloud/users/$user";
919
+        $client = new Client();
920
+        $options = [];
921
+        if ($this->currentUser === 'admin') {
922
+            $options['auth'] = $this->adminUser;
923
+        }
924
+        $options['headers'] = [
925
+            'OCS-APIREQUEST' => 'true',
926
+        ];
927
+
928
+        $this->response = $client->get($fullUrl, $options);
929
+        // boolean to string is integer
930
+        Assert::assertEquals('1', simplexml_load_string($this->response->getBody())->data[0]->enabled);
931
+    }
932
+
933
+    /**
934
+     * @Given user :user has a quota of :quota
935
+     * @param string $user
936
+     * @param string $quota
937
+     */
938
+    public function userHasAQuotaOf($user, $quota) {
939
+        $body = new TableNode([
940
+            0 => ['key', 'quota'],
941
+            1 => ['value', $quota],
942
+        ]);
943
+
944
+        // method used from BasicStructure trait
945
+        $this->sendingToWith('PUT', '/cloud/users/' . $user, $body);
946
+    }
947
+
948
+    /**
949
+     * @Given user :user has unlimited quota
950
+     * @param string $user
951
+     */
952
+    public function userHasUnlimitedQuota($user) {
953
+        $this->userHasAQuotaOf($user, 'none');
954
+    }
955
+
956
+    /**
957
+     * Returns home path of the given user
958
+     *
959
+     * @param string $user
960
+     */
961
+    public function getUserHome($user) {
962
+        $fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/cloud/users/$user";
963
+        $client = new Client();
964
+        $options = [];
965
+        $options['auth'] = $this->adminUser;
966
+        $this->response = $client->get($fullUrl, $options);
967
+        return simplexml_load_string($this->response->getBody())->data[0]->home;
968
+    }
969
+
970
+    /**
971
+     * @BeforeScenario
972
+     * @AfterScenario
973
+     */
974
+    public function cleanupUsers() {
975
+        $previousServer = $this->currentServer;
976
+        $this->usingServer('LOCAL');
977
+        foreach ($this->createdUsers as $user) {
978
+            $this->deleteUser($user);
979
+        }
980
+        $this->usingServer('REMOTE');
981
+        foreach ($this->createdRemoteUsers as $remoteUser) {
982
+            $this->deleteUser($remoteUser);
983
+        }
984
+        $this->usingServer($previousServer);
985
+    }
986
+
987
+    /**
988
+     * @BeforeScenario
989
+     * @AfterScenario
990
+     */
991
+    public function cleanupGroups() {
992
+        $previousServer = $this->currentServer;
993
+        $this->usingServer('LOCAL');
994
+        foreach ($this->createdGroups as $group) {
995
+            $this->deleteGroup($group);
996
+        }
997
+        $this->usingServer('REMOTE');
998
+        foreach ($this->createdRemoteGroups as $remoteGroup) {
999
+            $this->deleteGroup($remoteGroup);
1000
+        }
1001
+        $this->usingServer($previousServer);
1002
+    }
1003
+
1004
+    /**
1005
+     * @Then /^user "([^"]*)" has not$/
1006
+     */
1007
+    public function userHasNotSetting($user, TableNode $settings) {
1008
+        $fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/cloud/users/$user";
1009
+        $client = new Client();
1010
+        $options = [];
1011
+        if ($this->currentUser === 'admin') {
1012
+            $options['auth'] = $this->adminUser;
1013
+        } else {
1014
+            $options['auth'] = [$this->currentUser, $this->regularUser];
1015
+        }
1016
+        $options['headers'] = [
1017
+            'OCS-APIREQUEST' => 'true',
1018
+        ];
1019
+
1020
+        $response = $client->get($fullUrl, $options);
1021
+        foreach ($settings->getRows() as $setting) {
1022
+            $value = json_decode(json_encode(simplexml_load_string($response->getBody())->data->{$setting[0]}), 1);
1023
+            if (isset($value[0])) {
1024
+                if (in_array($setting[0], ['additional_mail', 'additional_mailScope'], true)) {
1025
+                    $expectedValues = explode(';', $setting[1]);
1026
+                    foreach ($expectedValues as $expected) {
1027
+                        Assert::assertFalse(in_array($expected, $value, true));
1028
+                    }
1029
+                } else {
1030
+                    Assert::assertNotEqualsCanonicalizing($setting[1], $value[0]);
1031
+                }
1032
+            } else {
1033
+                Assert::assertNotEquals('', $setting[1]);
1034
+            }
1035
+        }
1036
+    }
1037 1037
 }
Please login to merge, or discard this patch.
lib/private/Route/CachingRouter.php 2 patches
Indentation   +129 added lines, -129 removed lines patch added patch discarded remove patch
@@ -21,144 +21,144 @@
 block discarded – undo
21 21
 use Symfony\Component\Routing\RouteCollection;
22 22
 
23 23
 class CachingRouter extends Router {
24
-	protected ICache $cache;
24
+    protected ICache $cache;
25 25
 
26
-	protected array $legacyCreatedRoutes = [];
26
+    protected array $legacyCreatedRoutes = [];
27 27
 
28
-	public function __construct(
29
-		ICacheFactory $cacheFactory,
30
-		LoggerInterface $logger,
31
-		IRequest $request,
32
-		IConfig $config,
33
-		IEventLogger $eventLogger,
34
-		ContainerInterface $container,
35
-		IAppManager $appManager,
36
-	) {
37
-		$this->cache = $cacheFactory->createLocal('route');
38
-		parent::__construct($logger, $request, $config, $eventLogger, $container, $appManager);
39
-	}
28
+    public function __construct(
29
+        ICacheFactory $cacheFactory,
30
+        LoggerInterface $logger,
31
+        IRequest $request,
32
+        IConfig $config,
33
+        IEventLogger $eventLogger,
34
+        ContainerInterface $container,
35
+        IAppManager $appManager,
36
+    ) {
37
+        $this->cache = $cacheFactory->createLocal('route');
38
+        parent::__construct($logger, $request, $config, $eventLogger, $container, $appManager);
39
+    }
40 40
 
41
-	/**
42
-	 * Generate url based on $name and $parameters
43
-	 *
44
-	 * @param string $name Name of the route to use.
45
-	 * @param array $parameters Parameters for the route
46
-	 * @param bool $absolute
47
-	 * @return string
48
-	 */
49
-	public function generate($name, $parameters = [], $absolute = false) {
50
-		asort($parameters);
51
-		$key = $this->context->getHost() . '#' . $this->context->getBaseUrl() . $name . sha1(json_encode($parameters)) . (int)$absolute;
52
-		$cachedKey = $this->cache->get($key);
53
-		if ($cachedKey) {
54
-			return $cachedKey;
55
-		} else {
56
-			$url = parent::generate($name, $parameters, $absolute);
57
-			if ($url) {
58
-				$this->cache->set($key, $url, 3600);
59
-			}
60
-			return $url;
61
-		}
62
-	}
41
+    /**
42
+     * Generate url based on $name and $parameters
43
+     *
44
+     * @param string $name Name of the route to use.
45
+     * @param array $parameters Parameters for the route
46
+     * @param bool $absolute
47
+     * @return string
48
+     */
49
+    public function generate($name, $parameters = [], $absolute = false) {
50
+        asort($parameters);
51
+        $key = $this->context->getHost() . '#' . $this->context->getBaseUrl() . $name . sha1(json_encode($parameters)) . (int)$absolute;
52
+        $cachedKey = $this->cache->get($key);
53
+        if ($cachedKey) {
54
+            return $cachedKey;
55
+        } else {
56
+            $url = parent::generate($name, $parameters, $absolute);
57
+            if ($url) {
58
+                $this->cache->set($key, $url, 3600);
59
+            }
60
+            return $url;
61
+        }
62
+    }
63 63
 
64
-	private function serializeRouteCollection(RouteCollection $collection): array {
65
-		$dumper = new CompiledUrlMatcherDumper($collection);
66
-		return $dumper->getCompiledRoutes();
67
-	}
64
+    private function serializeRouteCollection(RouteCollection $collection): array {
65
+        $dumper = new CompiledUrlMatcherDumper($collection);
66
+        return $dumper->getCompiledRoutes();
67
+    }
68 68
 
69
-	/**
70
-	 * Find the route matching $url
71
-	 *
72
-	 * @param string $url The url to find
73
-	 * @throws \Exception
74
-	 * @return array
75
-	 */
76
-	public function findMatchingRoute(string $url): array {
77
-		$this->eventLogger->start('cacheroute:match', 'Match route');
78
-		$key = $this->context->getHost() . '#' . $this->context->getBaseUrl() . '#rootCollection';
79
-		$cachedRoutes = $this->cache->get($key);
80
-		if (!$cachedRoutes) {
81
-			// Ensure that all apps are loaded, as for users with an active
82
-			// session only the apps that are enabled for that user might have
83
-			// been loaded.
84
-			$enabledApps = $this->appManager->getEnabledApps();
85
-			foreach ($enabledApps as $app) {
86
-				$this->appManager->loadApp($app);
87
-			}
88
-			parent::loadRoutes();
89
-			$cachedRoutes = $this->serializeRouteCollection($this->root);
90
-			$this->cache->set($key, $cachedRoutes, ($this->config->getSystemValueBool('debug') ? 3 : 3600));
91
-		}
92
-		$matcher = new CompiledUrlMatcher($cachedRoutes, $this->context);
93
-		$this->eventLogger->start('cacheroute:url:match', 'Symfony URL match call');
94
-		try {
95
-			$parameters = $matcher->match($url);
96
-		} catch (ResourceNotFoundException $e) {
97
-			if (!str_ends_with($url, '/')) {
98
-				// We allow links to apps/files? for backwards compatibility reasons
99
-				// However, since Symfony does not allow empty route names, the route
100
-				// we need to match is '/', so we need to append the '/' here.
101
-				try {
102
-					$parameters = $matcher->match($url . '/');
103
-				} catch (ResourceNotFoundException $newException) {
104
-					// If we still didn't match a route, we throw the original exception
105
-					throw $e;
106
-				}
107
-			} else {
108
-				throw $e;
109
-			}
110
-		}
111
-		$this->eventLogger->end('cacheroute:url:match');
69
+    /**
70
+     * Find the route matching $url
71
+     *
72
+     * @param string $url The url to find
73
+     * @throws \Exception
74
+     * @return array
75
+     */
76
+    public function findMatchingRoute(string $url): array {
77
+        $this->eventLogger->start('cacheroute:match', 'Match route');
78
+        $key = $this->context->getHost() . '#' . $this->context->getBaseUrl() . '#rootCollection';
79
+        $cachedRoutes = $this->cache->get($key);
80
+        if (!$cachedRoutes) {
81
+            // Ensure that all apps are loaded, as for users with an active
82
+            // session only the apps that are enabled for that user might have
83
+            // been loaded.
84
+            $enabledApps = $this->appManager->getEnabledApps();
85
+            foreach ($enabledApps as $app) {
86
+                $this->appManager->loadApp($app);
87
+            }
88
+            parent::loadRoutes();
89
+            $cachedRoutes = $this->serializeRouteCollection($this->root);
90
+            $this->cache->set($key, $cachedRoutes, ($this->config->getSystemValueBool('debug') ? 3 : 3600));
91
+        }
92
+        $matcher = new CompiledUrlMatcher($cachedRoutes, $this->context);
93
+        $this->eventLogger->start('cacheroute:url:match', 'Symfony URL match call');
94
+        try {
95
+            $parameters = $matcher->match($url);
96
+        } catch (ResourceNotFoundException $e) {
97
+            if (!str_ends_with($url, '/')) {
98
+                // We allow links to apps/files? for backwards compatibility reasons
99
+                // However, since Symfony does not allow empty route names, the route
100
+                // we need to match is '/', so we need to append the '/' here.
101
+                try {
102
+                    $parameters = $matcher->match($url . '/');
103
+                } catch (ResourceNotFoundException $newException) {
104
+                    // If we still didn't match a route, we throw the original exception
105
+                    throw $e;
106
+                }
107
+            } else {
108
+                throw $e;
109
+            }
110
+        }
111
+        $this->eventLogger->end('cacheroute:url:match');
112 112
 
113
-		$this->eventLogger->end('cacheroute:match');
114
-		return $parameters;
115
-	}
113
+        $this->eventLogger->end('cacheroute:match');
114
+        return $parameters;
115
+    }
116 116
 
117
-	/**
118
-	 * @param array{action:mixed, ...} $parameters
119
-	 */
120
-	protected function callLegacyActionRoute(array $parameters): void {
121
-		/*
117
+    /**
118
+     * @param array{action:mixed, ...} $parameters
119
+     */
120
+    protected function callLegacyActionRoute(array $parameters): void {
121
+        /*
122 122
 		 * Closures cannot be serialized to cache, so for legacy routes calling an action we have to include the routes.php file again
123 123
 		 */
124
-		$app = $parameters['app'];
125
-		$this->useCollection($app);
126
-		parent::requireRouteFile($parameters['route-file'], $app);
127
-		$collection = $this->getCollection($app);
128
-		$parameters['action'] = $collection->get($parameters['_route'])?->getDefault('action');
129
-		parent::callLegacyActionRoute($parameters);
130
-	}
124
+        $app = $parameters['app'];
125
+        $this->useCollection($app);
126
+        parent::requireRouteFile($parameters['route-file'], $app);
127
+        $collection = $this->getCollection($app);
128
+        $parameters['action'] = $collection->get($parameters['_route'])?->getDefault('action');
129
+        parent::callLegacyActionRoute($parameters);
130
+    }
131 131
 
132
-	/**
133
-	 * Create a \OC\Route\Route.
134
-	 * Deprecated
135
-	 *
136
-	 * @param string $name Name of the route to create.
137
-	 * @param string $pattern The pattern to match
138
-	 * @param array $defaults An array of default parameter values
139
-	 * @param array $requirements An array of requirements for parameters (regexes)
140
-	 */
141
-	public function create($name, $pattern, array $defaults = [], array $requirements = []): Route {
142
-		$this->legacyCreatedRoutes[] = $name;
143
-		return parent::create($name, $pattern, $defaults, $requirements);
144
-	}
132
+    /**
133
+     * Create a \OC\Route\Route.
134
+     * Deprecated
135
+     *
136
+     * @param string $name Name of the route to create.
137
+     * @param string $pattern The pattern to match
138
+     * @param array $defaults An array of default parameter values
139
+     * @param array $requirements An array of requirements for parameters (regexes)
140
+     */
141
+    public function create($name, $pattern, array $defaults = [], array $requirements = []): Route {
142
+        $this->legacyCreatedRoutes[] = $name;
143
+        return parent::create($name, $pattern, $defaults, $requirements);
144
+    }
145 145
 
146
-	/**
147
-	 * Require a routes.php file
148
-	 */
149
-	protected function requireRouteFile(string $file, string $appName): void {
150
-		$this->legacyCreatedRoutes = [];
151
-		parent::requireRouteFile($file, $appName);
152
-		foreach ($this->legacyCreatedRoutes as $routeName) {
153
-			$route = $this->collection?->get($routeName);
154
-			if ($route === null) {
155
-				/* Should never happen */
156
-				throw new \Exception("Could not find route $routeName");
157
-			}
158
-			if ($route->hasDefault('action')) {
159
-				$route->setDefault('route-file', $file);
160
-				$route->setDefault('app', $appName);
161
-			}
162
-		}
163
-	}
146
+    /**
147
+     * Require a routes.php file
148
+     */
149
+    protected function requireRouteFile(string $file, string $appName): void {
150
+        $this->legacyCreatedRoutes = [];
151
+        parent::requireRouteFile($file, $appName);
152
+        foreach ($this->legacyCreatedRoutes as $routeName) {
153
+            $route = $this->collection?->get($routeName);
154
+            if ($route === null) {
155
+                /* Should never happen */
156
+                throw new \Exception("Could not find route $routeName");
157
+            }
158
+            if ($route->hasDefault('action')) {
159
+                $route->setDefault('route-file', $file);
160
+                $route->setDefault('app', $appName);
161
+            }
162
+        }
163
+    }
164 164
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 	 */
49 49
 	public function generate($name, $parameters = [], $absolute = false) {
50 50
 		asort($parameters);
51
-		$key = $this->context->getHost() . '#' . $this->context->getBaseUrl() . $name . sha1(json_encode($parameters)) . (int)$absolute;
51
+		$key = $this->context->getHost().'#'.$this->context->getBaseUrl().$name.sha1(json_encode($parameters)).(int) $absolute;
52 52
 		$cachedKey = $this->cache->get($key);
53 53
 		if ($cachedKey) {
54 54
 			return $cachedKey;
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 	 */
76 76
 	public function findMatchingRoute(string $url): array {
77 77
 		$this->eventLogger->start('cacheroute:match', 'Match route');
78
-		$key = $this->context->getHost() . '#' . $this->context->getBaseUrl() . '#rootCollection';
78
+		$key = $this->context->getHost().'#'.$this->context->getBaseUrl().'#rootCollection';
79 79
 		$cachedRoutes = $this->cache->get($key);
80 80
 		if (!$cachedRoutes) {
81 81
 			// Ensure that all apps are loaded, as for users with an active
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 				// However, since Symfony does not allow empty route names, the route
100 100
 				// we need to match is '/', so we need to append the '/' here.
101 101
 				try {
102
-					$parameters = $matcher->match($url . '/');
102
+					$parameters = $matcher->match($url.'/');
103 103
 				} catch (ResourceNotFoundException $newException) {
104 104
 					// If we still didn't match a route, we throw the original exception
105 105
 					throw $e;
Please login to merge, or discard this patch.
apps/testing/lib/Controller/RoutesController.php 2 patches
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -15,28 +15,28 @@
 block discarded – undo
15 15
 
16 16
 class RoutesController extends OCSController {
17 17
 
18
-	public function __construct(
19
-		string $appName,
20
-		IRequest $request,
21
-		private IAppManager $appManager,
22
-	) {
23
-		parent::__construct($appName, $request);
24
-	}
25
-
26
-	public function getRoutesInRoutesPhp(string $app): DataResponse {
27
-		try {
28
-			$appPath = $this->appManager->getAppPath($app);
29
-		} catch (AppPathNotFoundException) {
30
-			return new DataResponse([], Http::STATUS_NOT_FOUND);
31
-		}
32
-
33
-		$file = $appPath . '/appinfo/routes.php';
34
-		if (!file_exists($file)) {
35
-			return new DataResponse();
36
-		}
37
-
38
-		$routes = include $file;
39
-
40
-		return new DataResponse($routes);
41
-	}
18
+    public function __construct(
19
+        string $appName,
20
+        IRequest $request,
21
+        private IAppManager $appManager,
22
+    ) {
23
+        parent::__construct($appName, $request);
24
+    }
25
+
26
+    public function getRoutesInRoutesPhp(string $app): DataResponse {
27
+        try {
28
+            $appPath = $this->appManager->getAppPath($app);
29
+        } catch (AppPathNotFoundException) {
30
+            return new DataResponse([], Http::STATUS_NOT_FOUND);
31
+        }
32
+
33
+        $file = $appPath . '/appinfo/routes.php';
34
+        if (!file_exists($file)) {
35
+            return new DataResponse();
36
+        }
37
+
38
+        $routes = include $file;
39
+
40
+        return new DataResponse($routes);
41
+    }
42 42
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@
 block discarded – undo
30 30
 			return new DataResponse([], Http::STATUS_NOT_FOUND);
31 31
 		}
32 32
 
33
-		$file = $appPath . '/appinfo/routes.php';
33
+		$file = $appPath.'/appinfo/routes.php';
34 34
 		if (!file_exists($file)) {
35 35
 			return new DataResponse();
36 36
 		}
Please login to merge, or discard this patch.
apps/testing/appinfo/routes.php 1 patch
Indentation   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -6,67 +6,67 @@
 block discarded – undo
6 6
  * SPDX-License-Identifier: AGPL-3.0-only
7 7
  */
8 8
 return [
9
-	'routes' => [
10
-		[
11
-			'name' => 'RateLimitTest#userAndAnonProtected',
12
-			'url' => '/userAndAnonProtected',
13
-			'verb' => 'GET',
14
-		],
15
-		[
16
-			'name' => 'RateLimitTest#onlyAnonProtected',
17
-			'url' => '/anonProtected',
18
-			'verb' => 'GET',
19
-		],
20
-	],
9
+    'routes' => [
10
+        [
11
+            'name' => 'RateLimitTest#userAndAnonProtected',
12
+            'url' => '/userAndAnonProtected',
13
+            'verb' => 'GET',
14
+        ],
15
+        [
16
+            'name' => 'RateLimitTest#onlyAnonProtected',
17
+            'url' => '/anonProtected',
18
+            'verb' => 'GET',
19
+        ],
20
+    ],
21 21
 
22
-	'ocs' => [
23
-		[
24
-			'name' => 'Config#setAppValue',
25
-			'url' => '/api/v1/app/{appid}/{configkey}',
26
-			'verb' => 'POST',
27
-		],
28
-		[
29
-			'name' => 'Config#deleteAppValue',
30
-			'url' => '/api/v1/app/{appid}/{configkey}',
31
-			'verb' => 'DELETE',
32
-		],
33
-		[
34
-			'name' => 'Locking#isLockingEnabled',
35
-			'url' => '/api/v1/lockprovisioning',
36
-			'verb' => 'GET',
37
-		],
38
-		[
39
-			'name' => 'Locking#isLocked',
40
-			'url' => '/api/v1/lockprovisioning/{type}/{user}',
41
-			'verb' => 'GET',
42
-		],
43
-		[
44
-			'name' => 'Locking#acquireLock',
45
-			'url' => '/api/v1/lockprovisioning/{type}/{user}',
46
-			'verb' => 'POST',
47
-		],
48
-		[
49
-			'name' => 'Locking#changeLock',
50
-			'url' => '/api/v1/lockprovisioning/{type}/{user}',
51
-			'verb' => 'PUT',
52
-		],
53
-		[
54
-			'name' => 'Locking#releaseLock',
55
-			'url' => '/api/v1/lockprovisioning/{type}/{user}',
56
-			'verb' => 'DELETE',
57
-		],
58
-		[
59
-			'name' => 'Locking#releaseAll',
60
-			'url' => '/api/v1/lockprovisioning/{type}',
61
-			'verb' => 'DELETE',
62
-			'defaults' => [
63
-				'type' => null
64
-			]
65
-		],
66
-		[
67
-			'name' => 'Routes#getRoutesInRoutesPhp',
68
-			'url' => '/api/v1/routes/routesphp/{app}',
69
-			'verb' => 'GET',
70
-		],
71
-	],
22
+    'ocs' => [
23
+        [
24
+            'name' => 'Config#setAppValue',
25
+            'url' => '/api/v1/app/{appid}/{configkey}',
26
+            'verb' => 'POST',
27
+        ],
28
+        [
29
+            'name' => 'Config#deleteAppValue',
30
+            'url' => '/api/v1/app/{appid}/{configkey}',
31
+            'verb' => 'DELETE',
32
+        ],
33
+        [
34
+            'name' => 'Locking#isLockingEnabled',
35
+            'url' => '/api/v1/lockprovisioning',
36
+            'verb' => 'GET',
37
+        ],
38
+        [
39
+            'name' => 'Locking#isLocked',
40
+            'url' => '/api/v1/lockprovisioning/{type}/{user}',
41
+            'verb' => 'GET',
42
+        ],
43
+        [
44
+            'name' => 'Locking#acquireLock',
45
+            'url' => '/api/v1/lockprovisioning/{type}/{user}',
46
+            'verb' => 'POST',
47
+        ],
48
+        [
49
+            'name' => 'Locking#changeLock',
50
+            'url' => '/api/v1/lockprovisioning/{type}/{user}',
51
+            'verb' => 'PUT',
52
+        ],
53
+        [
54
+            'name' => 'Locking#releaseLock',
55
+            'url' => '/api/v1/lockprovisioning/{type}/{user}',
56
+            'verb' => 'DELETE',
57
+        ],
58
+        [
59
+            'name' => 'Locking#releaseAll',
60
+            'url' => '/api/v1/lockprovisioning/{type}',
61
+            'verb' => 'DELETE',
62
+            'defaults' => [
63
+                'type' => null
64
+            ]
65
+        ],
66
+        [
67
+            'name' => 'Routes#getRoutesInRoutesPhp',
68
+            'url' => '/api/v1/routes/routesphp/{app}',
69
+            'verb' => 'GET',
70
+        ],
71
+    ],
72 72
 ];
Please login to merge, or discard this patch.
apps/testing/composer/composer/autoload_static.php 1 patch
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -6,52 +6,52 @@
 block discarded – undo
6 6
 
7 7
 class ComposerStaticInitTesting
8 8
 {
9
-    public static $prefixLengthsPsr4 = array (
9
+    public static $prefixLengthsPsr4 = array(
10 10
         'O' =>
11
-        array (
11
+        array(
12 12
             'OCA\\Testing\\' => 12,
13 13
         ),
14 14
     );
15 15
 
16
-    public static $prefixDirsPsr4 = array (
16
+    public static $prefixDirsPsr4 = array(
17 17
         'OCA\\Testing\\' =>
18
-        array (
19
-            0 => __DIR__ . '/..' . '/../lib',
18
+        array(
19
+            0 => __DIR__.'/..'.'/../lib',
20 20
         ),
21 21
     );
22 22
 
23
-    public static $classMap = array (
24
-        'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
25
-        'OCA\\Testing\\AlternativeHomeUserBackend' => __DIR__ . '/..' . '/../lib/AlternativeHomeUserBackend.php',
26
-        'OCA\\Testing\\AppInfo\\Application' => __DIR__ . '/..' . '/../lib/AppInfo/Application.php',
27
-        'OCA\\Testing\\Controller\\ConfigController' => __DIR__ . '/..' . '/../lib/Controller/ConfigController.php',
28
-        'OCA\\Testing\\Controller\\LockingController' => __DIR__ . '/..' . '/../lib/Controller/LockingController.php',
29
-        'OCA\\Testing\\Controller\\RateLimitTestController' => __DIR__ . '/..' . '/../lib/Controller/RateLimitTestController.php',
30
-        'OCA\\Testing\\Controller\\RoutesController' => __DIR__ . '/..' . '/../lib/Controller/RoutesController.php',
31
-        'OCA\\Testing\\Conversion\\ConversionProvider' => __DIR__ . '/..' . '/../lib/Conversion/ConversionProvider.php',
32
-        'OCA\\Testing\\HiddenGroupBackend' => __DIR__ . '/..' . '/../lib/HiddenGroupBackend.php',
33
-        'OCA\\Testing\\Listener\\GetDeclarativeSettingsValueListener' => __DIR__ . '/..' . '/../lib/Listener/GetDeclarativeSettingsValueListener.php',
34
-        'OCA\\Testing\\Listener\\RegisterDeclarativeSettingsListener' => __DIR__ . '/..' . '/../lib/Listener/RegisterDeclarativeSettingsListener.php',
35
-        'OCA\\Testing\\Listener\\SetDeclarativeSettingsValueListener' => __DIR__ . '/..' . '/../lib/Listener/SetDeclarativeSettingsValueListener.php',
36
-        'OCA\\Testing\\Locking\\FakeDBLockingProvider' => __DIR__ . '/..' . '/../lib/Locking/FakeDBLockingProvider.php',
37
-        'OCA\\Testing\\Migration\\Version30000Date20240102030405' => __DIR__ . '/..' . '/../lib/Migration/Version30000Date20240102030405.php',
38
-        'OCA\\Testing\\Provider\\FakeText2ImageProvider' => __DIR__ . '/..' . '/../lib/Provider/FakeText2ImageProvider.php',
39
-        'OCA\\Testing\\Provider\\FakeTextProcessingProvider' => __DIR__ . '/..' . '/../lib/Provider/FakeTextProcessingProvider.php',
40
-        'OCA\\Testing\\Provider\\FakeTextProcessingProviderSync' => __DIR__ . '/..' . '/../lib/Provider/FakeTextProcessingProviderSync.php',
41
-        'OCA\\Testing\\Provider\\FakeTranslationProvider' => __DIR__ . '/..' . '/../lib/Provider/FakeTranslationProvider.php',
42
-        'OCA\\Testing\\Settings\\DeclarativeSettingsForm' => __DIR__ . '/..' . '/../lib/Settings/DeclarativeSettingsForm.php',
43
-        'OCA\\Testing\\TaskProcessing\\FakeContextWriteProvider' => __DIR__ . '/..' . '/../lib/TaskProcessing/FakeContextWriteProvider.php',
44
-        'OCA\\Testing\\TaskProcessing\\FakeTextToImageProvider' => __DIR__ . '/..' . '/../lib/TaskProcessing/FakeTextToImageProvider.php',
45
-        'OCA\\Testing\\TaskProcessing\\FakeTextToTextChatProvider' => __DIR__ . '/..' . '/../lib/TaskProcessing/FakeTextToTextChatProvider.php',
46
-        'OCA\\Testing\\TaskProcessing\\FakeTextToTextProvider' => __DIR__ . '/..' . '/../lib/TaskProcessing/FakeTextToTextProvider.php',
47
-        'OCA\\Testing\\TaskProcessing\\FakeTextToTextSummaryProvider' => __DIR__ . '/..' . '/../lib/TaskProcessing/FakeTextToTextSummaryProvider.php',
48
-        'OCA\\Testing\\TaskProcessing\\FakeTranscribeProvider' => __DIR__ . '/..' . '/../lib/TaskProcessing/FakeTranscribeProvider.php',
49
-        'OCA\\Testing\\TaskProcessing\\FakeTranslateProvider' => __DIR__ . '/..' . '/../lib/TaskProcessing/FakeTranslateProvider.php',
23
+    public static $classMap = array(
24
+        'Composer\\InstalledVersions' => __DIR__.'/..'.'/composer/InstalledVersions.php',
25
+        'OCA\\Testing\\AlternativeHomeUserBackend' => __DIR__.'/..'.'/../lib/AlternativeHomeUserBackend.php',
26
+        'OCA\\Testing\\AppInfo\\Application' => __DIR__.'/..'.'/../lib/AppInfo/Application.php',
27
+        'OCA\\Testing\\Controller\\ConfigController' => __DIR__.'/..'.'/../lib/Controller/ConfigController.php',
28
+        'OCA\\Testing\\Controller\\LockingController' => __DIR__.'/..'.'/../lib/Controller/LockingController.php',
29
+        'OCA\\Testing\\Controller\\RateLimitTestController' => __DIR__.'/..'.'/../lib/Controller/RateLimitTestController.php',
30
+        'OCA\\Testing\\Controller\\RoutesController' => __DIR__.'/..'.'/../lib/Controller/RoutesController.php',
31
+        'OCA\\Testing\\Conversion\\ConversionProvider' => __DIR__.'/..'.'/../lib/Conversion/ConversionProvider.php',
32
+        'OCA\\Testing\\HiddenGroupBackend' => __DIR__.'/..'.'/../lib/HiddenGroupBackend.php',
33
+        'OCA\\Testing\\Listener\\GetDeclarativeSettingsValueListener' => __DIR__.'/..'.'/../lib/Listener/GetDeclarativeSettingsValueListener.php',
34
+        'OCA\\Testing\\Listener\\RegisterDeclarativeSettingsListener' => __DIR__.'/..'.'/../lib/Listener/RegisterDeclarativeSettingsListener.php',
35
+        'OCA\\Testing\\Listener\\SetDeclarativeSettingsValueListener' => __DIR__.'/..'.'/../lib/Listener/SetDeclarativeSettingsValueListener.php',
36
+        'OCA\\Testing\\Locking\\FakeDBLockingProvider' => __DIR__.'/..'.'/../lib/Locking/FakeDBLockingProvider.php',
37
+        'OCA\\Testing\\Migration\\Version30000Date20240102030405' => __DIR__.'/..'.'/../lib/Migration/Version30000Date20240102030405.php',
38
+        'OCA\\Testing\\Provider\\FakeText2ImageProvider' => __DIR__.'/..'.'/../lib/Provider/FakeText2ImageProvider.php',
39
+        'OCA\\Testing\\Provider\\FakeTextProcessingProvider' => __DIR__.'/..'.'/../lib/Provider/FakeTextProcessingProvider.php',
40
+        'OCA\\Testing\\Provider\\FakeTextProcessingProviderSync' => __DIR__.'/..'.'/../lib/Provider/FakeTextProcessingProviderSync.php',
41
+        'OCA\\Testing\\Provider\\FakeTranslationProvider' => __DIR__.'/..'.'/../lib/Provider/FakeTranslationProvider.php',
42
+        'OCA\\Testing\\Settings\\DeclarativeSettingsForm' => __DIR__.'/..'.'/../lib/Settings/DeclarativeSettingsForm.php',
43
+        'OCA\\Testing\\TaskProcessing\\FakeContextWriteProvider' => __DIR__.'/..'.'/../lib/TaskProcessing/FakeContextWriteProvider.php',
44
+        'OCA\\Testing\\TaskProcessing\\FakeTextToImageProvider' => __DIR__.'/..'.'/../lib/TaskProcessing/FakeTextToImageProvider.php',
45
+        'OCA\\Testing\\TaskProcessing\\FakeTextToTextChatProvider' => __DIR__.'/..'.'/../lib/TaskProcessing/FakeTextToTextChatProvider.php',
46
+        'OCA\\Testing\\TaskProcessing\\FakeTextToTextProvider' => __DIR__.'/..'.'/../lib/TaskProcessing/FakeTextToTextProvider.php',
47
+        'OCA\\Testing\\TaskProcessing\\FakeTextToTextSummaryProvider' => __DIR__.'/..'.'/../lib/TaskProcessing/FakeTextToTextSummaryProvider.php',
48
+        'OCA\\Testing\\TaskProcessing\\FakeTranscribeProvider' => __DIR__.'/..'.'/../lib/TaskProcessing/FakeTranscribeProvider.php',
49
+        'OCA\\Testing\\TaskProcessing\\FakeTranslateProvider' => __DIR__.'/..'.'/../lib/TaskProcessing/FakeTranslateProvider.php',
50 50
     );
51 51
 
52 52
     public static function getInitializer(ClassLoader $loader)
53 53
     {
54
-        return \Closure::bind(function () use ($loader) {
54
+        return \Closure::bind(function() use ($loader) {
55 55
             $loader->prefixLengthsPsr4 = ComposerStaticInitTesting::$prefixLengthsPsr4;
56 56
             $loader->prefixDirsPsr4 = ComposerStaticInitTesting::$prefixDirsPsr4;
57 57
             $loader->classMap = ComposerStaticInitTesting::$classMap;
Please login to merge, or discard this patch.
apps/testing/composer/composer/autoload_classmap.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -6,30 +6,30 @@
 block discarded – undo
6 6
 $baseDir = $vendorDir;
7 7
 
8 8
 return array(
9
-    'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php',
10
-    'OCA\\Testing\\AlternativeHomeUserBackend' => $baseDir . '/../lib/AlternativeHomeUserBackend.php',
11
-    'OCA\\Testing\\AppInfo\\Application' => $baseDir . '/../lib/AppInfo/Application.php',
12
-    'OCA\\Testing\\Controller\\ConfigController' => $baseDir . '/../lib/Controller/ConfigController.php',
13
-    'OCA\\Testing\\Controller\\LockingController' => $baseDir . '/../lib/Controller/LockingController.php',
14
-    'OCA\\Testing\\Controller\\RateLimitTestController' => $baseDir . '/../lib/Controller/RateLimitTestController.php',
15
-    'OCA\\Testing\\Controller\\RoutesController' => $baseDir . '/../lib/Controller/RoutesController.php',
16
-    'OCA\\Testing\\Conversion\\ConversionProvider' => $baseDir . '/../lib/Conversion/ConversionProvider.php',
17
-    'OCA\\Testing\\HiddenGroupBackend' => $baseDir . '/../lib/HiddenGroupBackend.php',
18
-    'OCA\\Testing\\Listener\\GetDeclarativeSettingsValueListener' => $baseDir . '/../lib/Listener/GetDeclarativeSettingsValueListener.php',
19
-    'OCA\\Testing\\Listener\\RegisterDeclarativeSettingsListener' => $baseDir . '/../lib/Listener/RegisterDeclarativeSettingsListener.php',
20
-    'OCA\\Testing\\Listener\\SetDeclarativeSettingsValueListener' => $baseDir . '/../lib/Listener/SetDeclarativeSettingsValueListener.php',
21
-    'OCA\\Testing\\Locking\\FakeDBLockingProvider' => $baseDir . '/../lib/Locking/FakeDBLockingProvider.php',
22
-    'OCA\\Testing\\Migration\\Version30000Date20240102030405' => $baseDir . '/../lib/Migration/Version30000Date20240102030405.php',
23
-    'OCA\\Testing\\Provider\\FakeText2ImageProvider' => $baseDir . '/../lib/Provider/FakeText2ImageProvider.php',
24
-    'OCA\\Testing\\Provider\\FakeTextProcessingProvider' => $baseDir . '/../lib/Provider/FakeTextProcessingProvider.php',
25
-    'OCA\\Testing\\Provider\\FakeTextProcessingProviderSync' => $baseDir . '/../lib/Provider/FakeTextProcessingProviderSync.php',
26
-    'OCA\\Testing\\Provider\\FakeTranslationProvider' => $baseDir . '/../lib/Provider/FakeTranslationProvider.php',
27
-    'OCA\\Testing\\Settings\\DeclarativeSettingsForm' => $baseDir . '/../lib/Settings/DeclarativeSettingsForm.php',
28
-    'OCA\\Testing\\TaskProcessing\\FakeContextWriteProvider' => $baseDir . '/../lib/TaskProcessing/FakeContextWriteProvider.php',
29
-    'OCA\\Testing\\TaskProcessing\\FakeTextToImageProvider' => $baseDir . '/../lib/TaskProcessing/FakeTextToImageProvider.php',
30
-    'OCA\\Testing\\TaskProcessing\\FakeTextToTextChatProvider' => $baseDir . '/../lib/TaskProcessing/FakeTextToTextChatProvider.php',
31
-    'OCA\\Testing\\TaskProcessing\\FakeTextToTextProvider' => $baseDir . '/../lib/TaskProcessing/FakeTextToTextProvider.php',
32
-    'OCA\\Testing\\TaskProcessing\\FakeTextToTextSummaryProvider' => $baseDir . '/../lib/TaskProcessing/FakeTextToTextSummaryProvider.php',
33
-    'OCA\\Testing\\TaskProcessing\\FakeTranscribeProvider' => $baseDir . '/../lib/TaskProcessing/FakeTranscribeProvider.php',
34
-    'OCA\\Testing\\TaskProcessing\\FakeTranslateProvider' => $baseDir . '/../lib/TaskProcessing/FakeTranslateProvider.php',
9
+    'Composer\\InstalledVersions' => $vendorDir.'/composer/InstalledVersions.php',
10
+    'OCA\\Testing\\AlternativeHomeUserBackend' => $baseDir.'/../lib/AlternativeHomeUserBackend.php',
11
+    'OCA\\Testing\\AppInfo\\Application' => $baseDir.'/../lib/AppInfo/Application.php',
12
+    'OCA\\Testing\\Controller\\ConfigController' => $baseDir.'/../lib/Controller/ConfigController.php',
13
+    'OCA\\Testing\\Controller\\LockingController' => $baseDir.'/../lib/Controller/LockingController.php',
14
+    'OCA\\Testing\\Controller\\RateLimitTestController' => $baseDir.'/../lib/Controller/RateLimitTestController.php',
15
+    'OCA\\Testing\\Controller\\RoutesController' => $baseDir.'/../lib/Controller/RoutesController.php',
16
+    'OCA\\Testing\\Conversion\\ConversionProvider' => $baseDir.'/../lib/Conversion/ConversionProvider.php',
17
+    'OCA\\Testing\\HiddenGroupBackend' => $baseDir.'/../lib/HiddenGroupBackend.php',
18
+    'OCA\\Testing\\Listener\\GetDeclarativeSettingsValueListener' => $baseDir.'/../lib/Listener/GetDeclarativeSettingsValueListener.php',
19
+    'OCA\\Testing\\Listener\\RegisterDeclarativeSettingsListener' => $baseDir.'/../lib/Listener/RegisterDeclarativeSettingsListener.php',
20
+    'OCA\\Testing\\Listener\\SetDeclarativeSettingsValueListener' => $baseDir.'/../lib/Listener/SetDeclarativeSettingsValueListener.php',
21
+    'OCA\\Testing\\Locking\\FakeDBLockingProvider' => $baseDir.'/../lib/Locking/FakeDBLockingProvider.php',
22
+    'OCA\\Testing\\Migration\\Version30000Date20240102030405' => $baseDir.'/../lib/Migration/Version30000Date20240102030405.php',
23
+    'OCA\\Testing\\Provider\\FakeText2ImageProvider' => $baseDir.'/../lib/Provider/FakeText2ImageProvider.php',
24
+    'OCA\\Testing\\Provider\\FakeTextProcessingProvider' => $baseDir.'/../lib/Provider/FakeTextProcessingProvider.php',
25
+    'OCA\\Testing\\Provider\\FakeTextProcessingProviderSync' => $baseDir.'/../lib/Provider/FakeTextProcessingProviderSync.php',
26
+    'OCA\\Testing\\Provider\\FakeTranslationProvider' => $baseDir.'/../lib/Provider/FakeTranslationProvider.php',
27
+    'OCA\\Testing\\Settings\\DeclarativeSettingsForm' => $baseDir.'/../lib/Settings/DeclarativeSettingsForm.php',
28
+    'OCA\\Testing\\TaskProcessing\\FakeContextWriteProvider' => $baseDir.'/../lib/TaskProcessing/FakeContextWriteProvider.php',
29
+    'OCA\\Testing\\TaskProcessing\\FakeTextToImageProvider' => $baseDir.'/../lib/TaskProcessing/FakeTextToImageProvider.php',
30
+    'OCA\\Testing\\TaskProcessing\\FakeTextToTextChatProvider' => $baseDir.'/../lib/TaskProcessing/FakeTextToTextChatProvider.php',
31
+    'OCA\\Testing\\TaskProcessing\\FakeTextToTextProvider' => $baseDir.'/../lib/TaskProcessing/FakeTextToTextProvider.php',
32
+    'OCA\\Testing\\TaskProcessing\\FakeTextToTextSummaryProvider' => $baseDir.'/../lib/TaskProcessing/FakeTextToTextSummaryProvider.php',
33
+    'OCA\\Testing\\TaskProcessing\\FakeTranscribeProvider' => $baseDir.'/../lib/TaskProcessing/FakeTranscribeProvider.php',
34
+    'OCA\\Testing\\TaskProcessing\\FakeTranslateProvider' => $baseDir.'/../lib/TaskProcessing/FakeTranslateProvider.php',
35 35
 );
Please login to merge, or discard this patch.