From e4d58d35fae3a3f39c2e2f8a83641479e3f70aaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Calvi=C3=B1o=20S=C3=A1nchez?= Date: Thu, 20 Mar 2025 08:34:50 +0100 Subject: [PATCH] test: Add integration tests for getting user and mail collaborators MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- .../features/bootstrap/Sharing.php | 8 +++- .../sharees_features/sharees.feature | 39 +++++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/build/integration/features/bootstrap/Sharing.php b/build/integration/features/bootstrap/Sharing.php index ad93db68353..d93f114f27b 100644 --- a/build/integration/features/bootstrap/Sharing.php +++ b/build/integration/features/bootstrap/Sharing.php @@ -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); diff --git a/build/integration/sharees_features/sharees.feature b/build/integration/sharees_features/sharees.feature index b2a88701988..57d5d1dc6dd 100644 --- a/build/integration/sharees_features/sharees.feature +++ b/build/integration/sharees_features/sharees.feature @@ -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