-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Expand file tree
/
Copy pathWebUIAdminSharingSettingsContext.php
More file actions
608 lines (560 loc) · 17.5 KB
/
WebUIAdminSharingSettingsContext.php
File metadata and controls
608 lines (560 loc) · 17.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
<?php declare(strict_types=1);
/**
* ownCloud
*
* @author Paurakh Sharma Humagain <paurakh@jankaritech.com>
* @copyright Copyright (c) 2018 Paurakh Sharma Humagain paurakh@jankaritech.com
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License,
* as published by the Free Software Foundation;
* either version 3 of the License, or any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
namespace Tests\Acceptance;
use Behat\Behat\Context\Context;
use Behat\Behat\Hook\Scope\BeforeScenarioScope;
use Behat\Mink\Element\NodeElement;
use Behat\MinkExtension\Context\RawMinkContext;
use PHPUnit\Framework\Assert;
use TestHelpers\SetupHelper;
use Tests\Acceptance\Page\AdminSharingSettingsPage;
require_once 'bootstrap.php';
/**
* WebUI AdminSharingSettings context.
*/
class WebUIAdminSharingSettingsContext extends RawMinkContext implements Context {
private AdminSharingSettingsPage $adminSharingSettingsPage;
private WebUIGeneralContext $webUIGeneralContext;
private FeatureContext $featureContext;
/**
* WebUIAdminSharingSettingsContext constructor.
*
* @param AdminSharingSettingsPage $adminSharingSettingsPage
*/
public function __construct(
AdminSharingSettingsPage $adminSharingSettingsPage
) {
$this->adminSharingSettingsPage = $adminSharingSettingsPage;
}
/**
* @When the administrator browses to the admin sharing settings page
* @Given the administrator has browsed to the admin sharing settings page
*
* @return void
* @throws Exception
*/
public function theAdminBrowsesToTheAdminSharingSettingsPage():void {
$this->webUIGeneralContext->adminLogsInUsingTheWebUI();
$this->adminSharingSettingsPage->open();
$this->adminSharingSettingsPage->waitTillPageIsLoaded($this->getSession());
$this->webUIGeneralContext->setCurrentPageObject($this->adminSharingSettingsPage);
}
/**
* @When /^the administrator (enables|disables) the share API using the webUI$/
*
* @param string $action
*
* @return void
*/
public function adminTogglesShareApiUsingTheWebui(string $action):void {
$this->adminSharingSettingsPage->toggleShareApi(
$this->getSession(),
$action
);
}
/**
* @When /^the administrator (enables|disables) share via link using the webUI$/
*
* @param string $action
*
* @return void
*/
public function adminTogglesShareViaLink(string $action):void {
$this->adminSharingSettingsPage->toggleShareViaLink(
$this->getSession(),
$action
);
}
/**
*
* @param NodeElement|null $checkbox
*
* @return void
*/
private function assertCheckBoxIsChecked(?NodeElement $checkbox):void {
Assert::assertNotNull($checkbox, "checkbox does not exist");
Assert::assertTrue($checkbox->isChecked(), "checkbox is not checked");
}
/**
* @Then the default expiration date checkbox for user shares should be enabled on the webUI
*
* @return void
*/
public function setDefaultExpirationDateForUserSharesCheckboxShouldBeEnabled():void {
$checkboxElement = $this->adminSharingSettingsPage->getDefaultExpirationForUserShareElement();
$this->assertCheckBoxIsChecked($checkboxElement);
}
/**
* @Then the default expiration date checkbox for group shares should be enabled on the webUI
*
* @return void
*/
public function setDefaultExpirationDateForGroupCheckboxSharesShouldBeEnabled():void {
$checkboxElement = $this->adminSharingSettingsPage->getDefaultExpirationForGroupShareElement();
$this->assertCheckBoxIsChecked($checkboxElement);
}
/**
* @Then the default expiration date checkbox for federated shares should be enabled on the webUI
*
* @return void
*/
public function setDefaultExpirationDateForFederatedCheckboxSharesShouldBeEnabled():void {
$checkboxElement = $this->adminSharingSettingsPage->getDefaultExpirationForFederatedShareElement();
$this->assertCheckBoxIsChecked($checkboxElement);
}
/**
* @Then the enforce maximum expiration date checkbox for user shares should be enabled on the webUI
*
* @return void
*/
public function enforceMaximumExpirationDateForUserSharesCheckboxShouldBeEnabled():void {
$checkboxElement = $this->adminSharingSettingsPage->getEnforceExpireDateUserShareElement();
$this->assertCheckBoxIsChecked($checkboxElement);
}
/**
* @Then the enforce maximum expiration date checkbox for group shares should be enabled on the webUI
*
* @return void
*/
public function enforceMaximumExpirationDateForGroupSharesCheckboxShouldBeEnabled():void {
$checkboxElement = $this->adminSharingSettingsPage->getEnforceExpireDateGroupShareElement();
$this->assertCheckBoxIsChecked($checkboxElement);
}
/**
* @Then the enforce maximum expiration date checkbox for federated shares should be enabled on the webUI
*
* @return void
*/
public function enforceMaximumExpirationDateForFederatedSharesCheckboxShouldBeEnabled():void {
$checkboxElement = $this->adminSharingSettingsPage->getEnforceExpireDateFederatedShareElement();
$this->assertCheckBoxIsChecked($checkboxElement);
}
/**
* @Then the expiration date for user shares should set to :days days on the webUI
*
* @param int $days
*
* @return void
*/
public function expirationDateForUserSharesShouldBeSetToXDays(int $days):void {
$expirationDays = $this->adminSharingSettingsPage->getUserShareExpirationDays();
Assert::assertEquals(
$days,
$expirationDays,
__METHOD__
. " The expiration date for user shares was expected to be set to '$days' days, "
. "but was actually set to '$expirationDays' days"
);
}
/**
* @Then the expiration date for group shares should set to :days days on the webUI
*
* @param int $days
*
* @return void
*/
public function expirationDateForGroupSharesShouldBeSetToXDays(int $days):void {
$expirationDays = $this->adminSharingSettingsPage->getGroupShareExpirationDays();
Assert::assertEquals(
$days,
$expirationDays,
__METHOD__
. " The expiration date for group shares was expected to be set to '$days' days, "
. "but was actually set to '$expirationDays' days"
);
}
/**
* @Then the expiration date for federated shares should set to :days days on the webUI
*
* @param int $days
*
* @return void
*/
public function expirationDateForFederatedSharesShouldBeSetToXDays(int $days):void {
$expirationDays = $this->adminSharingSettingsPage->getFederatedShareExpirationDays();
Assert::assertEquals(
$days,
$expirationDays,
__METHOD__
. " The expiration date for federated shares was expected to be set to '$days' days, "
. "but was actually set to '$expirationDays' days"
);
}
/**
* @When /^the administrator (enables|disables) public uploads using the webUI$/
*
* @param string $action
*
* @return void
*/
public function adminTogglesPublicUpload(string $action):void {
$this->adminSharingSettingsPage->togglePublicUpload(
$this->getSession(),
$action
);
}
/**
* @When /^the administrator (enables|disables) mail notification on public link share using the webUI$/
*
* @param string $action
*
* @return void
*/
public function adminTogglesMailNotificationOnPublicLinkShare(string $action):void {
$this->adminSharingSettingsPage->toggleMailNotification(
$this->getSession(),
$action
);
}
/**
* @When /^the administrator (enables|disables) social media share on public link share using the webUI$/
*
* @param string $action
*
* @return void
*/
public function adminTogglesSocialShareOnPublicLinkShare(string $action):void {
$this->adminSharingSettingsPage->toggleSocialShareOnPublicLinkShare(
$this->getSession(),
$action
);
}
/**
* @When /^the administrator (enables|disables) enforce password protection for read-only links using the webUI$/
*
* @param string $action
*
* @return void
*/
public function adminTogglesEnforcePasswordProtectionForReadOnlyLinks(string $action):void {
$this->adminSharingSettingsPage->toggleEnforcePasswordProtectionForReadOnlyLinks(
$this->getSession(),
$action
);
}
/**
* @When /^the administrator (enables|disables) enforce password protection for read and write links using the webUI$/
*
* @param string $action
*
* @return void
*/
public function adminTogglesEnforcePasswordProtectionForReadWriteLinks(string $action):void {
$this->adminSharingSettingsPage->toggleEnforcePasswordProtectionForReadWriteLinks(
$this->getSession(),
$action
);
}
/**
* @When /^the administrator (enables|disables) enforce password protection for read and write and delete links using the webUI$/
*
* @param string $action
*
* @return void
*/
public function adminTogglesEnforcePasswordProtectionForReadWriteDeleteLinks(string $action):void {
$this->adminSharingSettingsPage->toggleEnforcePasswordProtectionForReadWriteDeleteLinks(
$this->getSession(),
$action
);
}
/**
* @When /^the administrator (enables|disables) enforce password protection for upload only links using the webUI$/
*
* @param string $action
*
* @return void
*/
public function adminTogglesEnforcePasswordProtectionForWriteOnlyLinks(string $action):void {
$this->adminSharingSettingsPage->toggleEnforcePasswordProtectionForWriteOnlyLinks(
$this->getSession(),
$action
);
}
/**
* @When /^the administrator (enables|disables) resharing using the webUI$/
*
* @param string $action
*
* @return void
*/
public function adminTogglesDisableResharing(string $action):void {
$this->adminSharingSettingsPage->toggleResharing(
$this->getSession(),
$action
);
}
/**
* @When /^the administrator (enables|disables) sharing with groups using the webUI$/
*
* @param string $action
*
* @return void
*/
public function adminTogglesSharingWithGroupUsingTheWebui(string $action):void {
$this->adminSharingSettingsPage->toggleGroupSharing(
$this->getSession(),
$action
);
}
/**
* @When /^the administrator (enables|disables) restrict users to only share with their group members using the webUI$/
*
* @param string $action
*
* @return void
*/
public function theAdminRestrictsUsersToOnlyShareWithTheirGroupMemberUsingTheWebui(string $action):void {
$this->adminSharingSettingsPage->toggleRestrictUsersToOnlyShareWithTheirGroupMembers(
$this->getSession(),
$action
);
}
/**
* @When the administrator enables exclude groups from sharing using the webUI
*
* @return void
*/
public function theAdministratorEnablesExcludeGroupsFromSharingUsingTheWebui():void {
$this->adminSharingSettingsPage->enableExcludeGroupFromSharing(
$this->getSession()
);
}
/**
* @When the administrator enables default expiration date for user shares using the webUI
*
* @return void
*/
public function administratorEnablesDefaultExpirationDateForUserShares():void {
$this->adminSharingSettingsPage->enableDefaultExpirationDateForUserShares(
$this->getSession()
);
}
/**
* @When the administrator enforces maximum expiration date for user shares using the webUI
*
* @return void
*/
public function administratorEnforcesMaximumExpirationDateForUserShares():void {
$this->adminSharingSettingsPage->enforceMaximumExpirationDateForUserShares(
$this->getSession()
);
}
/**
* @When the administrator enforces maximum expiration date for group shares using the webUI
*
* @return void
*/
public function administratorEnforcesMaximumExpirationDateForGroupShares():void {
$this->adminSharingSettingsPage->enforceMaximumExpirationDateForGroupShares(
$this->getSession()
);
}
/**
* @When the administrator enforces maximum expiration date for federated shares using the webUI
*
* @return void
*/
public function administratorEnforcesMaximumExpirationDateForFederatedShares():void {
$this->adminSharingSettingsPage->enforceMaximumExpirationDateForFederatedShares(
$this->getSession()
);
}
/**
* @When the administrator updates the user share expiration date to :days days using the webUI
*
* @param int $days
*
* @return void
*/
public function administratorUpdatesUserShareExpirationTo(int $days):void {
$this->adminSharingSettingsPage->setExpirationDaysForUserShare($days, $this->getSession());
}
/**
* @When the administrator updates the group share expiration date to :days days using the webUI
*
* @param int $days
*
* @return void
*/
public function administratorUpdatesGroupShareExpirationTo(int $days):void {
$this->adminSharingSettingsPage->setExpirationDaysForGroupShare($days, $this->getSession());
}
/**
* @When the administrator updates the federated share expiration date to :days days using the webUI
*
* @param int $days
*
* @return void
*/
public function administratorUpdatesFederatedShareExpirationTo(int $days):void {
$this->adminSharingSettingsPage->setExpirationDaysForFederatedShare($days, $this->getSession());
}
/**
* @When the administrator enables default expiration date for group shares using the webUI
*
* @return void
*/
public function theAdministratorEnablesDefaultExpirationDateForGroupShares():void {
$this->adminSharingSettingsPage->enableDefaultExpirationDateForGroupShares(
$this->getSession()
);
}
/**
* @When the administrator enables default expiration date for federated shares using the webUI
*
* @return void
*/
public function theAdministratorEnablesDefaultExpirationDateForFederatedShares():void {
$this->adminSharingSettingsPage->enableDefaultExpirationDateForFederatedShares(
$this->getSession()
);
}
/**
* @When the administrator enables restrict users to only share with groups they are member of using the webUI
*
* @return void
*/
public function theAdministratorEnablesRestrictUsersToOnlyShareWithGroupsTheyAreMemberOfUsingTheWebui():void {
$this->adminSharingSettingsPage->restrictUserToOnlyShareWithMembershipGroup(
$this->getSession()
);
}
/**
* @When the administrator adds group :group to the exclude group from sharing list using the webUI
*
* @param string $group
*
* @return void
*/
public function theAdministratorAddsGroupToTheExcludeGroupFromSharingList(string $group):void {
$this->adminSharingSettingsPage->addGroupToExcludeGroupsFromSharingList(
$this->getSession(),
$group
);
}
/**
* @When the administrator excludes group :group from receiving shares using the webUI
*
* @param string $group
*
* @return void
*/
public function theAdministratorExcludesGroupFromReceivingSharesUsingTheWebui(string $group):void {
$this->adminSharingSettingsPage->addGroupToExcludedFromReceivingShares(
$this->getSession(),
$group
);
}
/**
* @When /^the administrator (enables|disables) add server automatically once a federation share was created successfully using the webUI$/
*
* @param string (enable | disable) $action
*
* @return void
*/
public function theAdministratorEnablesAddServerAutomatically(string $action):void {
$this->adminSharingSettingsPage->toggleAutoAddServer(
$this->getSession(),
$action
);
}
/**
* @When /^the administrator (enables|disables) permission (create|change|delete|share) for default user and group share using the webUI$/
*
* @param string (enable | disable) $action
* @param string $permissionValue
*
* @return void
*/
public function theAdministratorEnablesDefaultSharePermission(string $action, string $permissionValue):void {
$this->adminSharingSettingsPage->toggleDefaultSharePermissions(
$this->getSession(),
$action,
$permissionValue
);
}
/**
* @When the administrator adds :url as a trusted server using the webUI
*
* @param string $url
*
* @return void
*/
public function theAdministratorAddsAsATrustedServerUsingTheWebui(string $url) {
$this->adminSharingSettingsPage->addTrustedServer(
$this->getSession(),
$this->featureContext->substituteInLineCodes($url)
);
}
/**
* @When the administrator deletes url :url from the trusted server list using the webUI
*
* @param string $url
*
* @return void
*/
public function theAdministratorDeletesAsATrustedServerUsingTheWebui(string $url):void {
$this->adminSharingSettingsPage->deleteTrustedServer(
$this->getSession(),
$this->featureContext->substituteInLineCodes($url)
);
}
/**
* @Then a trusted server error message should be displayed on the webUI with the text :text
*
* @param string $text
*
* @return void
*/
public function aErrorMessageForTrustedServerShouldContain(string $text):void {
$msg = $this->adminSharingSettingsPage->getTrustedServerErrorMsg();
Assert::assertStringContainsString(
$text,
$msg,
__METHOD__
. " The text in the trusted server error message was expected to be '$text', but got '$msg' instead "
);
}
/**
* This will run before EVERY scenario.
* It will set the properties for this object.
*
* @BeforeScenario @webUI
*
* @param BeforeScenarioScope $scope
*
* @return void
* @throws Exception
*/
public function before(BeforeScenarioScope $scope):void {
// Get the environment
$environment = $scope->getEnvironment();
// Get all the contexts you need in this context
$this->webUIGeneralContext = $environment->getContext('WebUIGeneralContext');
$this->featureContext = $environment->getContext('FeatureContext');
SetupHelper::runOcc(
['config:app:set files_sharing blacklisted_receiver_groups --value='],
$this->featureContext->getStepLineRef()
);
}
}