From ecf32012f4366373bcd6a1eefc5dd24f7530f485 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 | 64 +++++++++++++++++++ 2 files changed, 98 insertions(+) diff --git a/build/integration/features/bootstrap/Provisioning.php b/build/integration/features/bootstrap/Provisioning.php index 1d0984abd72..16fb9e297c7 100644 --- a/build/integration/features/bootstrap/Provisioning.php +++ b/build/integration/features/bootstrap/Provisioning.php @@ -16,6 +16,12 @@ require __DIR__ . '/../../vendor/autoload.php'; trait Provisioning { use BasicStructure; + /** @var array */ + private $appsToEnableAfterScenario = []; + + /** @var array */ + private $appsToDisableAfterScenario = []; + /** @var array */ private $createdUsers = []; @@ -28,6 +34,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 @@ -803,6 +822,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 57d5d1dc6dd..e9e7b7ab6fb 100644 --- a/build/integration/sharees_features/sharees.feature +++ b/build/integration/sharees_features/sharees.feature @@ -366,6 +366,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 @@ -467,6 +487,30 @@ 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" + # UserPlugin provides two identical results (except for the field order, but + # that is hidden by the check) + And "exact users" sharees returned are + | Sharee2 | 0 | Sharee2 | sharee2@system.com | + | 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 @@ -484,3 +528,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