From 13452e48cb48a354a8d2cee1a523fd0ec998e5e0 Mon Sep 17 00:00:00 2001 From: Sawjan Gurung Date: Thu, 24 Nov 2022 15:13:27 +0545 Subject: [PATCH] add Graph API tests for editign group display name (#5101) --- ...ected-failures-localAPI-on-OCIS-storage.md | 8 ++++ .../features/apiGraph/editGroup.feature | 25 +++++++++++++ .../features/bootstrap/GraphContext.php | 37 +++++++++++++++++++ 3 files changed, 70 insertions(+) create mode 100644 tests/acceptance/features/apiGraph/editGroup.feature diff --git a/tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md b/tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md index 79d3d1ec94..e27ee42f4e 100644 --- a/tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md +++ b/tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md @@ -60,3 +60,11 @@ The expected failures in this file are from features in the owncloud/ocis repo. #### [Share lists deleted user as 'user'](https://github.com/owncloud/ocis/issues/903) - [apiGraph/deleteGroup.feature:62](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/deleteGroup.feature#L62) + +#### [Updating group displayName request seems OK but group is not being renamed](https://github.com/owncloud/ocis/issues/5099) +- [apiGraph/editGroup.feature:20](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/editGroup.feature#L20) +- [apiGraph/editGroup.feature:21](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/editGroup.feature#L21) +- [apiGraph/editGroup.feature:22](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/editGroup.feature#L22) +- [apiGraph/editGroup.feature:23](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/editGroup.feature#L23) +- [apiGraph/editGroup.feature:24](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/editGroup.feature#L24) +- [apiGraph/editGroup.feature:25](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/editGroup.feature#L25) diff --git a/tests/acceptance/features/apiGraph/editGroup.feature b/tests/acceptance/features/apiGraph/editGroup.feature new file mode 100644 index 0000000000..e188c04be2 --- /dev/null +++ b/tests/acceptance/features/apiGraph/editGroup.feature @@ -0,0 +1,25 @@ +@api @skipOnOcV10 +Feature: edit group name + As an admin + I want to be able to edit group name + So that I can manage group name + + Background: + Given user "Alice" has been created with default attributes and without skeleton files + And the administrator has given "Alice" the role "Admin" using the settings api + + @issue-5099 + Scenario Outline: admin user renames a group + Given group "" has been created + When user "Alice" renames group "" to "" using the Graph API + Then the HTTP status code should be "204" + And group "" should not exist + And group "" should exist + Examples: + | old_group | new_group | + | grp1 | grp101 | + | grp1 | España§àôœ€ | + | grp1 | नेपाली | + | grp1 | $x<=>[y*z^2]! | + | grp1 | staff?group | + | grp1 | 50%pass | \ No newline at end of file diff --git a/tests/acceptance/features/bootstrap/GraphContext.php b/tests/acceptance/features/bootstrap/GraphContext.php index afb3aaa2ef..3206412662 100644 --- a/tests/acceptance/features/bootstrap/GraphContext.php +++ b/tests/acceptance/features/bootstrap/GraphContext.php @@ -889,4 +889,41 @@ class GraphContext implements Context { ); } } + + /** + * rename group name + * + * @param string $oldGroup + * @param string $newGroup + * @param string $user + * + * @return ResponseInterface + * @throws GuzzleException + */ + public function renameGroup(string $oldGroup, string $newGroup, ?string $user = null): ResponseInterface { + $credentials = $this->getAdminOrUserCredentials($user); + $groupId = $this->featureContext->getAttributeOfCreatedGroup($oldGroup, "id"); + + return GraphHelper::updateGroup( + $this->featureContext->getBaseUrl(), + $this->featureContext->getStepLineRef(), + $credentials['username'], + $credentials['password'], + $groupId, + $newGroup + ); + } + + /** + * @When user :user renames group :oldGroup to :newGroup using the Graph API + * + * @param string $user + * @param string $oldGroup + * @param string $newGroup + * + * @return void + */ + public function userRenamesGroupUsingTheGraphApi(string $user, string $oldGroup, string $newGroup): void { + $this->featureContext->setResponse($this->renameGroup($oldGroup, $newGroup, $user)); + } }