From 5f6d25347e9c807b64b714e949c99bc0fa1ffacb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Calvi=C3=B1o=20S=C3=A1nchez?= Date: Sat, 4 Oct 2025 01:37:52 +0200 Subject: [PATCH] test: Add integration tests to get collaborators without sharebymail app MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- .../features/bootstrap/Provisioning.php | 34 +++++++++++ .../sharees_features/sharees.feature | 61 +++++++++++++++++++ 2 files changed, 95 insertions(+) diff --git a/build/integration/features/bootstrap/Provisioning.php b/build/integration/features/bootstrap/Provisioning.php index d44e2301163..e1a32171077 100644 --- a/build/integration/features/bootstrap/Provisioning.php +++ b/build/integration/features/bootstrap/Provisioning.php @@ -15,6 +15,12 @@ require __DIR__ . '/../../vendor/autoload.php'; trait Provisioning { use BasicStructure; + /** @var array */ + private $appsToEnableAfterScenario = []; + + /** @var array */ + private $appsToDisableAfterScenario = []; + /** @var array */ private $createdUsers = []; @@ -27,6 +33,19 @@ trait Provisioning { /** @var array */ private $createdGroups = []; + /** @AfterScenario */ + public function restoreAppsEnabledStateAfterScenario() { + $this->asAn('admin'); + + foreach ($this->appsToEnableAfterScenario as $app) { + $this->sendingTo('POST', '/cloud/apps/' . $app); + } + + foreach ($this->appsToDisableAfterScenario as $app) { + $this->sendingTo('DELETE', '/cloud/apps/' . $app); + } + } + /** * @Given /^user "([^"]*)" exists$/ * @param string $user @@ -802,6 +821,21 @@ trait Provisioning { return $extractedElementsArray; } + /** + * @Given /^app "([^"]*)" enabled state will be restored once the scenario finishes$/ + * @param string $app + */ + public function appEnabledStateWillBeRestoredOnceTheScenarioFinishes($app) { + if (in_array($app, $this->getAppsWithFilter('enabled'))) { + $this->appsToEnableAfterScenario[] = $app; + } elseif (in_array($app, $this->getAppsWithFilter('disabled'))) { + $this->appsToDisableAfterScenario[] = $app; + } + + // Apps that were not installed before the scenario will not be + // disabled nor uninstalled after the scenario. + } + private function getAppsWithFilter($filter) { $fullUrl = $this->baseUrl . 'v2.php/cloud/apps?filter=' . $filter; $client = new Client(); diff --git a/build/integration/sharees_features/sharees.feature b/build/integration/sharees_features/sharees.feature index b589673a39c..438be13becd 100644 --- a/build/integration/sharees_features/sharees.feature +++ b/build/integration/sharees_features/sharees.feature @@ -362,6 +362,26 @@ Feature: sharees | sharee2@unknown.com | 4 | sharee2@unknown.com | And "emails" sharees returned is empty + Scenario: Search e-mail when sharebymail app is disabled + Given app "sharebymail" enabled state will be restored once the scenario finishes + And sending "DELETE" to "/cloud/apps/sharebymail" + And app "sharebymail" is disabled + And As an "test" + When getting sharees for + | search | sharee2@unknown.com | + | itemType | file | + | shareType | 4 | + Then the OCS status code should be "100" + And the HTTP status code should be "200" + And "exact users" sharees returned is empty + And "users" sharees returned is empty + And "exact groups" sharees returned is empty + And "groups" sharees returned is empty + And "exact remotes" sharees returned is empty + And "remotes" sharees returned is empty + And "exact emails" sharees returned is empty + And "emails" sharees returned is empty + Scenario: Search e-mail matching system e-mail address of user Given As an "test" When getting sharees for @@ -460,6 +480,27 @@ Feature: sharees And "exact emails" sharees returned is empty And "emails" sharees returned is empty + Scenario: Search user and e-mail matching system e-mail address of user when sharebymail app is disabled + Given app "sharebymail" enabled state will be restored once the scenario finishes + And sending "DELETE" to "/cloud/apps/sharebymail" + And app "sharebymail" is disabled + And As an "test" + When getting sharees for + | search | sharee2@system.com | + | itemType | file | + | shareTypes | 0 4 | + Then the OCS status code should be "100" + And the HTTP status code should be "200" + And "exact users" sharees returned are + | Sharee2 | 0 | Sharee2 | sharee2@system.com | + And "users" sharees returned is empty + And "exact groups" sharees returned is empty + And "groups" sharees returned is empty + And "exact remotes" sharees returned is empty + And "remotes" sharees returned is empty + And "exact emails" sharees returned is empty + And "emails" sharees returned is empty + Scenario: Search user and e-mail matching secondary e-mail address of user Given As an "test" When getting sharees for @@ -477,3 +518,23 @@ Feature: sharees And "remotes" sharees returned is empty And "exact emails" sharees returned is empty And "emails" sharees returned is empty + + Scenario: Search user and e-mail matching secondary e-mail address of user when sharebymail app is disabled + Given app "sharebymail" enabled state will be restored once the scenario finishes + And sending "DELETE" to "/cloud/apps/sharebymail" + And app "sharebymail" is disabled + And As an "test" + When getting sharees for + | search | sharee2@secondary.com | + | itemType | file | + | shareTypes | 0 4 | + Then the OCS status code should be "100" + And the HTTP status code should be "200" + And "exact users" sharees returned is empty + And "users" sharees returned is empty + And "exact groups" sharees returned is empty + And "groups" sharees returned is empty + And "exact remotes" sharees returned is empty + And "remotes" sharees returned is empty + And "exact emails" sharees returned is empty + And "emails" sharees returned is empty