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 <danxuliu@gmail.com>
This commit is contained in:
Daniel Calviño Sánchez 2025-10-04 01:37:52 +02:00
parent e30875742b
commit 5f6d25347e
2 changed files with 95 additions and 0 deletions

View file

@ -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();

View file

@ -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