From 8e99f19c2833142543f893c784173e9891d27be2 Mon Sep 17 00:00:00 2001 From: Sergio Bertolin Date: Tue, 10 Jan 2017 15:55:00 +0000 Subject: [PATCH 1/8] Added tests using v2.php Signed-off-by: Morris Jobke --- .../features/bootstrap/AppConfiguration.php | 8 +- .../sharees_provisioningapiv2.feature | 240 ++++++++++++++++++ 2 files changed, 246 insertions(+), 2 deletions(-) create mode 100644 build/integration/sharees_features/sharees_provisioningapiv2.feature diff --git a/build/integration/features/bootstrap/AppConfiguration.php b/build/integration/features/bootstrap/AppConfiguration.php index 2f84dce3f1..5752150e8d 100644 --- a/build/integration/features/bootstrap/AppConfiguration.php +++ b/build/integration/features/bootstrap/AppConfiguration.php @@ -62,13 +62,17 @@ trait AppConfiguration { $body = new \Behat\Gherkin\Node\TableNode([['value', $value]]); $this->sendingToWith('post', "/apps/testing/api/v1/app/{$app}/{$parameter}", $body); $this->theHTTPStatusCodeShouldBe('200'); - $this->theOCSStatusCodeShouldBe('100'); + if ($this->apiVersion == 1) { + $this->theOCSStatusCodeShouldBe('100'); + } } protected function setStatusTestingApp($enabled) { $this->sendingTo(($enabled ? 'post' : 'delete'), '/cloud/apps/testing'); $this->theHTTPStatusCodeShouldBe('200'); - $this->theOCSStatusCodeShouldBe('100'); + if ($this->apiVersion == 1) { + $this->theOCSStatusCodeShouldBe('100'); + } $this->sendingTo('get', '/cloud/apps?filter=enabled'); $this->theHTTPStatusCodeShouldBe('200'); diff --git a/build/integration/sharees_features/sharees_provisioningapiv2.feature b/build/integration/sharees_features/sharees_provisioningapiv2.feature new file mode 100644 index 0000000000..961f07b1d6 --- /dev/null +++ b/build/integration/sharees_features/sharees_provisioningapiv2.feature @@ -0,0 +1,240 @@ +Feature: sharees_provisioningapiv2 + Background: + Given using api version "2" + And user "test" exists + And user "Sharee1" exists + And group "ShareeGroup" exists + And user "test" belongs to group "ShareeGroup" + + Scenario: Search without exact match + Given As an "test" + When getting sharees for + | search | Sharee | + | itemType | file | + 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 are + | Sharee1 | 0 | Sharee1 | + And "exact groups" sharees returned is empty + And "groups" sharees returned are + | ShareeGroup | 1 | ShareeGroup | + And "exact remotes" sharees returned is empty + And "remotes" sharees returned is empty + + Scenario: Search without exact match not-exact casing + Given As an "test" + When getting sharees for + | search | sharee | + | itemType | file | + 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 are + | Sharee1 | 0 | Sharee1 | + And "exact groups" sharees returned is empty + And "groups" sharees returned are + | ShareeGroup | 1 | ShareeGroup | + And "exact remotes" sharees returned is empty + And "remotes" sharees returned is empty + + Scenario: Search only with group members - denied + Given As an "test" + And parameter "shareapi_only_share_with_group_members" of app "core" is set to "yes" + When getting sharees for + | search | sharee | + | itemType | file | + 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 are + | ShareeGroup | 1 | ShareeGroup | + And "exact remotes" sharees returned is empty + And "remotes" sharees returned is empty + + Scenario: Search only with group members - allowed + Given As an "test" + And parameter "shareapi_only_share_with_group_members" of app "core" is set to "yes" + And user "Sharee1" belongs to group "ShareeGroup" + When getting sharees for + | search | sharee | + | itemType | file | + 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 are + | Sharee1 | 0 | Sharee1 | + And "exact groups" sharees returned is empty + And "groups" sharees returned are + | ShareeGroup | 1 | ShareeGroup | + And "exact remotes" sharees returned is empty + And "remotes" sharees returned is empty + + Scenario: Search only with group members - no group as non-member + Given As an "Sharee1" + And parameter "shareapi_only_share_with_group_members" of app "core" is set to "yes" + When getting sharees for + | search | sharee | + | itemType | file | + 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 + + Scenario: Search without exact match no iteration allowed + Given As an "test" + And parameter "shareapi_allow_share_dialog_user_enumeration" of app "core" is set to "no" + When getting sharees for + | search | Sharee | + | itemType | file | + 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 + + Scenario: Search with exact match no iteration allowed + Given As an "test" + And parameter "shareapi_allow_share_dialog_user_enumeration" of app "core" is set to "no" + When getting sharees for + | search | Sharee1 | + | itemType | file | + Then the OCS status code should be "100" + And the HTTP status code should be "200" + And "exact users" sharees returned are + | Sharee1 | 0 | Sharee1 | + 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 + + Scenario: Search with exact match group no iteration allowed + Given As an "test" + And parameter "shareapi_allow_share_dialog_user_enumeration" of app "core" is set to "no" + When getting sharees for + | search | ShareeGroup | + | itemType | file | + 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 are + | ShareeGroup | 1 | ShareeGroup | + And "groups" sharees returned is empty + And "exact remotes" sharees returned is empty + And "remotes" sharees returned is empty + + Scenario: Search with exact match + Given As an "test" + When getting sharees for + | search | Sharee1 | + | itemType | file | + Then the OCS status code should be "100" + And the HTTP status code should be "200" + Then "exact users" sharees returned are + | Sharee1 | 0 | Sharee1 | + Then "users" sharees returned is empty + Then "exact groups" sharees returned is empty + Then "groups" sharees returned is empty + Then "exact remotes" sharees returned is empty + Then "remotes" sharees returned is empty + + Scenario: Search with exact match not-exact casing + Given As an "test" + When getting sharees for + | search | sharee1 | + | itemType | file | + Then the OCS status code should be "100" + And the HTTP status code should be "200" + Then "exact users" sharees returned are + | Sharee1 | 0 | Sharee1 | + Then "users" sharees returned is empty + Then "exact groups" sharees returned is empty + Then "groups" sharees returned is empty + Then "exact remotes" sharees returned is empty + Then "remotes" sharees returned is empty + + Scenario: Search with exact match not-exact casing group + Given As an "test" + When getting sharees for + | search | shareegroup | + | itemType | file | + Then the OCS status code should be "100" + And the HTTP status code should be "200" + Then "exact users" sharees returned is empty + Then "users" sharees returned is empty + Then "exact groups" sharees returned are + | ShareeGroup | 1 | ShareeGroup | + Then "groups" sharees returned is empty + Then "exact remotes" sharees returned is empty + Then "remotes" sharees returned is empty + + Scenario: Search with "self" + Given As an "Sharee1" + When getting sharees for + | search | Sharee1 | + | itemType | file | + Then the OCS status code should be "100" + And the HTTP status code should be "200" + Then "exact users" sharees returned are + | Sharee1 | 0 | Sharee1 | + Then "users" sharees returned is empty + Then "exact groups" sharees returned is empty + Then "groups" sharees returned is empty + Then "exact remotes" sharees returned is empty + Then "remotes" sharees returned is empty + + Scenario: Remote sharee for files + Given As an "test" + When getting sharees for + | search | test@localhost | + | itemType | file | + Then the OCS status code should be "100" + And the HTTP status code should be "200" + Then "exact users" sharees returned is empty + Then "users" sharees returned is empty + Then "exact groups" sharees returned is empty + Then "groups" sharees returned is empty + Then "exact remotes" sharees returned are + | test@localhost | 6 | test@localhost | + Then "remotes" sharees returned is empty + + Scenario: Remote sharee for calendars not allowed + Given As an "test" + When getting sharees for + | search | test@localhost | + | itemType | calendar | + Then the OCS status code should be "100" + And the HTTP status code should be "200" + Then "exact users" sharees returned is empty + Then "users" sharees returned is empty + Then "exact groups" sharees returned is empty + Then "groups" sharees returned is empty + Then "exact remotes" sharees returned is empty + Then "remotes" sharees returned is empty + + Scenario: Group sharees not returned when group sharing is disabled + Given As an "test" + And parameter "shareapi_allow_group_sharing" of app "core" is set to "no" + When getting sharees for + | search | sharee | + | itemType | file | + 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 are + | Sharee1 | 0 | Sharee1 | + 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 From 036f5a6e084a66f28de77993d2b13dce279e1d4a Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Thu, 16 Mar 2017 17:24:00 -0600 Subject: [PATCH 2/8] add drone config Signed-off-by: Morris Jobke --- .drone.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.drone.yml b/.drone.yml index 5d4ab2ca96..c7c3764459 100644 --- a/.drone.yml +++ b/.drone.yml @@ -387,6 +387,15 @@ pipeline: when: matrix: TESTS: integration-sharees-features + integration-sharees-v2-features: + image: nextcloudci/integration-php7.0:integration-php7.0-3 + commands: + - ./occ maintenance:install --admin-pass=admin + - cd build/integration + - ./run.sh sharees_features/sharees_provisioningapiv2.feature + when: + matrix: + TESTS: integration-sharees-v2-features integration-setup-features: image: nextcloudci/integration-php7.0:integration-php7.0-3 commands: @@ -487,6 +496,7 @@ matrix: - TESTS: integration-provisioning-v2 - TESTS: integration-webdav-related - TESTS: integration-sharees-features + - TESTS: integration-sharees-v2-features - TESTS: integration-setup-features - TESTS: integration-filesdrop-features - TESTS: integration-transfer-ownership-features From 4626514a35510a6c730fd1d484936524012f44d8 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 17 Mar 2017 11:07:51 +0100 Subject: [PATCH 3/8] Strict comparisons Signed-off-by: Joas Schilling --- build/integration/features/bootstrap/AppConfiguration.php | 4 ++-- build/integration/features/bootstrap/BasicStructure.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build/integration/features/bootstrap/AppConfiguration.php b/build/integration/features/bootstrap/AppConfiguration.php index 5752150e8d..39fee5e361 100644 --- a/build/integration/features/bootstrap/AppConfiguration.php +++ b/build/integration/features/bootstrap/AppConfiguration.php @@ -62,7 +62,7 @@ trait AppConfiguration { $body = new \Behat\Gherkin\Node\TableNode([['value', $value]]); $this->sendingToWith('post', "/apps/testing/api/v1/app/{$app}/{$parameter}", $body); $this->theHTTPStatusCodeShouldBe('200'); - if ($this->apiVersion == 1) { + if ($this->apiVersion === 1) { $this->theOCSStatusCodeShouldBe('100'); } } @@ -70,7 +70,7 @@ trait AppConfiguration { protected function setStatusTestingApp($enabled) { $this->sendingTo(($enabled ? 'post' : 'delete'), '/cloud/apps/testing'); $this->theHTTPStatusCodeShouldBe('200'); - if ($this->apiVersion == 1) { + if ($this->apiVersion === 1) { $this->theOCSStatusCodeShouldBe('100'); } diff --git a/build/integration/features/bootstrap/BasicStructure.php b/build/integration/features/bootstrap/BasicStructure.php index 8961efc6f3..ec23916d61 100644 --- a/build/integration/features/bootstrap/BasicStructure.php +++ b/build/integration/features/bootstrap/BasicStructure.php @@ -83,11 +83,11 @@ trait BasicStructure { } /** - * @Given /^using api version "([^"]*)"$/ + * @Given /^using api version "(\d+)"$/ * @param string $version */ public function usingApiVersion($version) { - $this->apiVersion = $version; + $this->apiVersion = (int) $version; } /** From 4157e7914ab4d9eb72ac0eecf4ed5c5fcaef89a5 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 17 Mar 2017 14:38:27 +0100 Subject: [PATCH 4/8] Fix deletion of groups Signed-off-by: Joas Schilling --- build/integration/features/bootstrap/Provisioning.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/build/integration/features/bootstrap/Provisioning.php b/build/integration/features/bootstrap/Provisioning.php index 0055ff15de..2e17508120 100644 --- a/build/integration/features/bootstrap/Provisioning.php +++ b/build/integration/features/bootstrap/Provisioning.php @@ -331,6 +331,12 @@ trait Provisioning { ]; $this->response = $client->send($client->createRequest("DELETE", $fullUrl, $options)); + + if ($this->currentServer === 'LOCAL'){ + unset($this->createdGroups[$group]); + } elseif ($this->currentServer === 'REMOTE') { + unset($this->createdRemoteGroups[$group]); + } } /** @@ -748,7 +754,7 @@ trait Provisioning { } $this->usingServer('REMOTE'); foreach($this->createdRemoteGroups as $remoteGroup) { - $this->deleteUser($remoteGroup); + $this->deleteGroup($remoteGroup); } $this->usingServer($previousServer); } From a8e3168c171937b31227f0ef3bd94d5e791db666 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 17 Mar 2017 14:39:18 +0100 Subject: [PATCH 5/8] 200 is ok Signed-off-by: Joas Schilling --- .../sharees_provisioningapiv2.feature | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/build/integration/sharees_features/sharees_provisioningapiv2.feature b/build/integration/sharees_features/sharees_provisioningapiv2.feature index 961f07b1d6..37ab896ee2 100644 --- a/build/integration/sharees_features/sharees_provisioningapiv2.feature +++ b/build/integration/sharees_features/sharees_provisioningapiv2.feature @@ -11,7 +11,7 @@ Feature: sharees_provisioningapiv2 When getting sharees for | search | Sharee | | itemType | file | - Then the OCS status code should be "100" + Then the OCS status code should be "200" And the HTTP status code should be "200" And "exact users" sharees returned is empty And "users" sharees returned are @@ -27,7 +27,7 @@ Feature: sharees_provisioningapiv2 When getting sharees for | search | sharee | | itemType | file | - Then the OCS status code should be "100" + Then the OCS status code should be "200" And the HTTP status code should be "200" And "exact users" sharees returned is empty And "users" sharees returned are @@ -44,7 +44,7 @@ Feature: sharees_provisioningapiv2 When getting sharees for | search | sharee | | itemType | file | - Then the OCS status code should be "100" + Then the OCS status code should be "200" And the HTTP status code should be "200" And "exact users" sharees returned is empty And "users" sharees returned is empty @@ -61,7 +61,7 @@ Feature: sharees_provisioningapiv2 When getting sharees for | search | sharee | | itemType | file | - Then the OCS status code should be "100" + Then the OCS status code should be "200" And the HTTP status code should be "200" And "exact users" sharees returned is empty And "users" sharees returned are @@ -78,7 +78,7 @@ Feature: sharees_provisioningapiv2 When getting sharees for | search | sharee | | itemType | file | - Then the OCS status code should be "100" + Then the OCS status code should be "200" And the HTTP status code should be "200" And "exact users" sharees returned is empty And "users" sharees returned is empty @@ -93,7 +93,7 @@ Feature: sharees_provisioningapiv2 When getting sharees for | search | Sharee | | itemType | file | - Then the OCS status code should be "100" + Then the OCS status code should be "200" And the HTTP status code should be "200" And "exact users" sharees returned is empty And "users" sharees returned is empty @@ -108,7 +108,7 @@ Feature: sharees_provisioningapiv2 When getting sharees for | search | Sharee1 | | itemType | file | - Then the OCS status code should be "100" + Then the OCS status code should be "200" And the HTTP status code should be "200" And "exact users" sharees returned are | Sharee1 | 0 | Sharee1 | @@ -124,7 +124,7 @@ Feature: sharees_provisioningapiv2 When getting sharees for | search | ShareeGroup | | itemType | file | - Then the OCS status code should be "100" + Then the OCS status code should be "200" And the HTTP status code should be "200" And "exact users" sharees returned is empty And "users" sharees returned is empty @@ -139,7 +139,7 @@ Feature: sharees_provisioningapiv2 When getting sharees for | search | Sharee1 | | itemType | file | - Then the OCS status code should be "100" + Then the OCS status code should be "200" And the HTTP status code should be "200" Then "exact users" sharees returned are | Sharee1 | 0 | Sharee1 | @@ -154,7 +154,7 @@ Feature: sharees_provisioningapiv2 When getting sharees for | search | sharee1 | | itemType | file | - Then the OCS status code should be "100" + Then the OCS status code should be "200" And the HTTP status code should be "200" Then "exact users" sharees returned are | Sharee1 | 0 | Sharee1 | @@ -169,7 +169,7 @@ Feature: sharees_provisioningapiv2 When getting sharees for | search | shareegroup | | itemType | file | - Then the OCS status code should be "100" + Then the OCS status code should be "200" And the HTTP status code should be "200" Then "exact users" sharees returned is empty Then "users" sharees returned is empty @@ -184,7 +184,7 @@ Feature: sharees_provisioningapiv2 When getting sharees for | search | Sharee1 | | itemType | file | - Then the OCS status code should be "100" + Then the OCS status code should be "200" And the HTTP status code should be "200" Then "exact users" sharees returned are | Sharee1 | 0 | Sharee1 | @@ -199,7 +199,7 @@ Feature: sharees_provisioningapiv2 When getting sharees for | search | test@localhost | | itemType | file | - Then the OCS status code should be "100" + Then the OCS status code should be "200" And the HTTP status code should be "200" Then "exact users" sharees returned is empty Then "users" sharees returned is empty @@ -214,7 +214,7 @@ Feature: sharees_provisioningapiv2 When getting sharees for | search | test@localhost | | itemType | calendar | - Then the OCS status code should be "100" + Then the OCS status code should be "200" And the HTTP status code should be "200" Then "exact users" sharees returned is empty Then "users" sharees returned is empty @@ -229,7 +229,7 @@ Feature: sharees_provisioningapiv2 When getting sharees for | search | sharee | | itemType | file | - Then the OCS status code should be "100" + Then the OCS status code should be "200" And the HTTP status code should be "200" And "exact users" sharees returned is empty And "users" sharees returned are From ce302aea11b16f2f8fc3ad892b9c0cb51e65c87f Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 17 Mar 2017 14:43:06 +0100 Subject: [PATCH 6/8] Fix warning Signed-off-by: Joas Schilling --- build/integration/features/favorites.feature | 1 - 1 file changed, 1 deletion(-) diff --git a/build/integration/features/favorites.feature b/build/integration/features/favorites.feature index 9722948dac..3f90b7b42b 100644 --- a/build/integration/features/favorites.feature +++ b/build/integration/features/favorites.feature @@ -133,4 +133,3 @@ Feature: favorite Then user "user0" in folder "/subfolder" should have favorited the following elements | /subfolder/textfile0.txt | | /subfolder/textfile2.txt | - From 209e3e39e2511ccffde44afb4f1b8694f39ca683 Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Mon, 20 Mar 2017 18:48:55 -0600 Subject: [PATCH 7/8] Use proper bash test syntax Signed-off-by: Morris Jobke --- build/integration/run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/integration/run.sh b/build/integration/run.sh index 83600d8323..dc7889c5ae 100755 --- a/build/integration/run.sh +++ b/build/integration/run.sh @@ -58,7 +58,7 @@ RESULT=$? kill $PHPPID kill $PHPPID_FED -if [ "$INSTALLED" -eq "true" ]; then +if [ "$INSTALLED" == "true" ]; then $OCC files_external:delete -y $ID_STORAGE From 3c1e7e5ada0710988cb6ff498ae430d9718179c4 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 23 Mar 2017 19:24:02 +0100 Subject: [PATCH 8/8] Make deleting a group compatible with ocs v2 Signed-off-by: Joas Schilling --- apps/provisioning_api/lib/Controller/GroupsController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/provisioning_api/lib/Controller/GroupsController.php b/apps/provisioning_api/lib/Controller/GroupsController.php index c772076c3d..2d329bf974 100644 --- a/apps/provisioning_api/lib/Controller/GroupsController.php +++ b/apps/provisioning_api/lib/Controller/GroupsController.php @@ -164,7 +164,7 @@ class GroupsController extends OCSController { throw new OCSException('', 102); } - return new DataResponse(null, 100); + return new DataResponse(); } /**