test: Add integration tests for getting user and mail collaborators

The OCS endpoint expects either an int or an array for "shareType".
However, when using "getRowsHash()" only a single key is taken into
account, so instead of:
  | shareType[] | 0 |
  | shareType[] | 4 |
the share types are provided in a single row like:
  | shareTypes | 0 4 |
and then converted to "shareType[]=0&shareType[]=4" when sending the
request.

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
This commit is contained in:
Daniel Calviño Sánchez 2025-03-20 08:34:50 +01:00
parent e68e5c3955
commit e4d58d35fa
2 changed files with 46 additions and 1 deletions

View file

@ -697,7 +697,13 @@ trait Sharing {
if ($body instanceof TableNode) {
$parameters = [];
foreach ($body->getRowsHash() as $key => $value) {
$parameters[] = $key . '=' . $value;
if ($key === 'shareTypes') {
foreach (explode(' ', $value) as $shareType) {
$parameters[] = 'shareType[]=' . $shareType;
}
} else {
$parameters[] = $key . '=' . $value;
}
}
if (!empty($parameters)) {
$url .= '?' . implode('&', $parameters);

View file

@ -445,3 +445,42 @@ Feature: sharees
And "exact emails" sharees returned are
| sharee2@secondary.c | 4 | sharee2@secondary.c |
And "emails" sharees returned is empty
Scenario: Search user and e-mail matching system e-mail address of user
Given 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
| 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 are
| Sharee2 (sharee2@secondary.com) | 0 | Sharee2 | sharee2@secondary.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