Skip to content

Commit dcda12c

Browse files
committed
test: Add integration tests to get collaborators without sharebymail app
The "sharebymail" app is enabled by default, so it needs to be enabled once the scenario ends as other scenarios could expect that the app is enabled. To solve that now a special step is added that records the enabled state of the given app and restores it once the scenario ends. This step only restores the state of already installed apps. If an app is installed during the test it will not be neither disabled nor uninstalled after the test ends. Therefore, at least for now, it is necessary to explicitly call the step to record the app to be restored, rather than automatically keeping track of the changes in the enabled state of the apps during the scenario. Signed-off-by: Daniel Calviño Sánchez <[email protected]>
1 parent cee2492 commit dcda12c

File tree

2 files changed

+98
-0
lines changed

2 files changed

+98
-0
lines changed

build/integration/features/bootstrap/Provisioning.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@
1616
trait Provisioning {
1717
use BasicStructure;
1818

19+
/** @var array */
20+
private $appsToEnableAfterScenario = [];
21+
22+
/** @var array */
23+
private $appsToDisableAfterScenario = [];
24+
1925
/** @var array */
2026
private $createdUsers = [];
2127

@@ -28,6 +34,19 @@ trait Provisioning {
2834
/** @var array */
2935
private $createdGroups = [];
3036

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+
3150
/**
3251
* @Given /^user "([^"]*)" exists$/
3352
* @param string $user
@@ -803,6 +822,21 @@ public function getArrayOfSubadminsResponded($resp) {
803822
return $extractedElementsArray;
804823
}
805824

825+
/**
826+
* @Given /^app "([^"]*)" enabled state will be restored once the scenario finishes$/
827+
* @param string $app
828+
*/
829+
public function appEnabledStateWillBeRestoredOnceTheScenarioFinishes($app) {
830+
if (in_array($app, $this->getAppsWithFilter('enabled'))) {
831+
$this->appsToEnableAfterScenario[] = $app;
832+
} elseif (in_array($app, $this->getAppsWithFilter('disabled'))) {
833+
$this->appsToDisableAfterScenario[] = $app;
834+
}
835+
836+
// Apps that were not installed before the scenario will not be
837+
// disabled nor uninstalled after the scenario.
838+
}
839+
806840
private function getAppsWithFilter($filter) {
807841
$fullUrl = $this->baseUrl . 'v2.php/cloud/apps?filter=' . $filter;
808842
$client = new Client();

build/integration/sharees_features/sharees.feature

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,26 @@ Feature: sharees
366366
| sharee2@unknown.com | 4 | sharee2@unknown.com |
367367
And "emails" sharees returned is empty
368368

369+
Scenario: Search e-mail when sharebymail app is disabled
370+
Given app "sharebymail" enabled state will be restored once the scenario finishes
371+
And sending "DELETE" to "/cloud/apps/sharebymail"
372+
And app "sharebymail" is disabled
373+
And As an "test"
374+
When getting sharees for
375+
| search | sharee2@unknown.com |
376+
| itemType | file |
377+
| shareType | 4 |
378+
Then the OCS status code should be "100"
379+
And the HTTP status code should be "200"
380+
And "exact users" sharees returned is empty
381+
And "users" sharees returned is empty
382+
And "exact groups" sharees returned is empty
383+
And "groups" sharees returned is empty
384+
And "exact remotes" sharees returned is empty
385+
And "remotes" sharees returned is empty
386+
And "exact emails" sharees returned is empty
387+
And "emails" sharees returned is empty
388+
369389
Scenario: Search e-mail matching system e-mail address of user
370390
Given As an "test"
371391
When getting sharees for
@@ -467,6 +487,30 @@ Feature: sharees
467487
And "exact emails" sharees returned is empty
468488
And "emails" sharees returned is empty
469489

490+
Scenario: Search user and e-mail matching system e-mail address of user when sharebymail app is disabled
491+
Given app "sharebymail" enabled state will be restored once the scenario finishes
492+
And sending "DELETE" to "/cloud/apps/sharebymail"
493+
And app "sharebymail" is disabled
494+
And As an "test"
495+
When getting sharees for
496+
| search | sharee2@system.com |
497+
| itemType | file |
498+
| shareTypes | 0 4 |
499+
Then the OCS status code should be "100"
500+
And the HTTP status code should be "200"
501+
# UserPlugin provides two identical results (except for the field order, but
502+
# that is hidden by the check)
503+
And "exact users" sharees returned are
504+
| Sharee2 | 0 | Sharee2 | sharee2@system.com |
505+
| Sharee2 | 0 | Sharee2 | sharee2@system.com |
506+
And "users" sharees returned is empty
507+
And "exact groups" sharees returned is empty
508+
And "groups" sharees returned is empty
509+
And "exact remotes" sharees returned is empty
510+
And "remotes" sharees returned is empty
511+
And "exact emails" sharees returned is empty
512+
And "emails" sharees returned is empty
513+
470514
Scenario: Search user and e-mail matching secondary e-mail address of user
471515
Given As an "test"
472516
When getting sharees for
@@ -484,3 +528,23 @@ Feature: sharees
484528
And "remotes" sharees returned is empty
485529
And "exact emails" sharees returned is empty
486530
And "emails" sharees returned is empty
531+
532+
Scenario: Search user and e-mail matching secondary e-mail address of user when sharebymail app is disabled
533+
Given app "sharebymail" enabled state will be restored once the scenario finishes
534+
And sending "DELETE" to "/cloud/apps/sharebymail"
535+
And app "sharebymail" is disabled
536+
And As an "test"
537+
When getting sharees for
538+
| search | sharee2@secondary.com |
539+
| itemType | file |
540+
| shareTypes | 0 4 |
541+
Then the OCS status code should be "100"
542+
And the HTTP status code should be "200"
543+
And "exact users" sharees returned is empty
544+
And "users" sharees returned is empty
545+
And "exact groups" sharees returned is empty
546+
And "groups" sharees returned is empty
547+
And "exact remotes" sharees returned is empty
548+
And "remotes" sharees returned is empty
549+
And "exact emails" sharees returned is empty
550+
And "emails" sharees returned is empty

0 commit comments

Comments
 (0)