diff --git a/tests/acceptance/features/bootstrap/GraphContext.php b/tests/acceptance/features/bootstrap/GraphContext.php index 26ce1ff6af..ba1bb8a7dc 100644 --- a/tests/acceptance/features/bootstrap/GraphContext.php +++ b/tests/acceptance/features/bootstrap/GraphContext.php @@ -360,14 +360,16 @@ class GraphContext implements Context { /** * remove user from group * - * @param string $groupId - * @param string $userId + * @param string $group + * @param string $user * @param string|null $byUser * * @return ResponseInterface * @throws GuzzleException */ - public function removeUserFromGroup(string $groupId, string $userId, ?string $byUser = null): ResponseInterface { + public function removeUserFromGroup(string $group, string $user, ?string $byUser = null): ResponseInterface { + $groupId = $this->featureContext->getAttributeOfCreatedGroup($group, "id") ?: WebDavHelper::generateUUIDv4(); + $userId = $this->featureContext->getAttributeOfCreatedUser($user, "id"); $credentials = $this->getAdminOrUserCredentials($byUser); return GraphHelper::removeUserFromGroup( $this->featureContext->getBaseUrl(), @@ -453,11 +455,8 @@ class GraphContext implements Context { */ public function adminHasRemovedUserFromGroupUsingTheGraphApi(string $user, string $group): void { $user = $this->featureContext->getActualUsername($user); - $groupId = $this->featureContext->getAttributeOfCreatedGroup($group, "id"); - $userId = $this->featureContext->getAttributeOfCreatedUser($user, "id"); - $response = $this->removeUserFromGroup($groupId, $userId); - $this->featureContext->setResponse($response); - $this->featureContext->thenTheHTTPStatusCodeShouldBe(204); + $response = $this->removeUserFromGroup($group, $user); + $this->featureContext->TheHTTPStatusCodeShouldBe(204, '', $response); } /** @@ -1194,29 +1193,12 @@ class GraphContext implements Context { $usersGroups = $table->getColumnsHash(); foreach ($usersGroups as $userGroup) { - $groupId = $this->featureContext->getAttributeOfCreatedGroup($userGroup['groupname'], "id"); - $userId = $this->featureContext->getAttributeOfCreatedUser($userGroup['username'], "id"); - $this->featureContext->setResponse($this->removeUserFromGroup($groupId, $userId)); + $this->featureContext->setResponse($this->removeUserFromGroup($userGroup['groupname'], $userGroup['username'])); $this->featureContext->pushToLastHttpStatusCodesArray(); } } /** - * @When the administrator removes user :user from group :group using the Graph API - * - * @param string $user - * @param string $group - * - * @return void - */ - public function theAdministratorTriesToRemoveUserFromGroupUsingTheGraphAPI(string $user, string $group): void { - $groupId = $this->featureContext->getAttributeOfCreatedGroup($group, "id"); - $userId = $this->featureContext->getAttributeOfCreatedUser($user, "id"); - $this->featureContext->setResponse($this->removeUserFromGroup($groupId, $userId)); - } - - /** - * @When the administrator tries to remove user :user from group :group using the Graph API * @When user :byUser tries to remove user :user from group :group using the Graph API * * @param string $user @@ -1227,9 +1209,7 @@ class GraphContext implements Context { * @throws Exception | GuzzleException */ public function theUserTriesToRemoveAnotherUserFromGroupUsingTheGraphAPI(string $user, string $group, ?string $byUser = null): void { - $groupId = $this->featureContext->getAttributeOfCreatedGroup($group, "id"); - $userId = $this->featureContext->getAttributeOfCreatedUser($user, "id"); - $this->featureContext->setResponse($this->removeUserFromGroup($groupId, $userId, $byUser)); + $this->featureContext->setResponse($this->removeUserFromGroup($group, $user, $byUser)); } /** @@ -1243,9 +1223,7 @@ class GraphContext implements Context { * @throws GuzzleException */ public function theUserTriesToRemoveAnotherUserFromNonExistentGroupUsingTheGraphAPI(string $user, ?string $byUser = null): void { - $groupId = WebDavHelper::generateUUIDv4(); - $userId = $this->featureContext->getAttributeOfCreatedUser($user, "id"); - $this->featureContext->setResponse($this->removeUserFromGroup($groupId, $userId, $byUser)); + $this->featureContext->setResponse($this->removeUserFromGroup('', $user, $byUser)); } /** diff --git a/tests/acceptance/features/bootstrap/Provisioning.php b/tests/acceptance/features/bootstrap/Provisioning.php index cfd6f83626..2eda153fd9 100644 --- a/tests/acceptance/features/bootstrap/Provisioning.php +++ b/tests/acceptance/features/bootstrap/Provisioning.php @@ -3640,57 +3640,6 @@ trait Provisioning { return true; } - /** - * @param string $user - * @param string $group - * - * @return void - * @throws Exception - */ - public function removeUserFromGroupAsAdminUsingTheProvisioningApi(string $user, string $group):void { - $this->userRemovesUserFromGroupUsingTheProvisioningApi( - $this->getAdminUsername(), - $user, - $group - ); - } - - /** - * @When the administrator removes user :user from group :group using the provisioning API - * - * @param string $user - * @param string $group - * - * @return void - * @throws Exception - */ - public function adminRemovesUserFromGroupUsingTheProvisioningApi(string $user, string $group):void { - $user = $this->getActualUsername($user); - $this->removeUserFromGroupAsAdminUsingTheProvisioningApi( - $user, - $group - ); - $this->pushToLastStatusCodesArrays(); - } - - /** - * @When the administrator removes the following users from the following groups using the provisioning API - * - * @param TableNode $table - * - * @return void - * @throws Exception - */ - public function theAdministratorRemovesTheFollowingUserFromTheFollowingGroupUsingTheProvisioningApi(TableNode $table):void { - $this->verifyTableNodeColumns($table, ['username', 'groupname']); - $this->emptyLastHTTPStatusCodesArray(); - $this->emptyLastOCSStatusCodesArray(); - foreach ($table as $row) { - $this->adminRemovesUserFromGroupUsingTheProvisioningApi($row['username'], $row['groupname']); - $this->pushToLastStatusCodesArrays(); - } - } - /** * @Given user :user has been removed from group :group * @@ -3707,72 +3656,44 @@ trait Provisioning { ) { $this->removeUserFromLdapGroup($user, $group); } elseif (OcisHelper::isTestingWithGraphApi()) { - $this->graphContext->adminHasRemovedUserFromGroupUsingTheGraphApi($user, $group); - } else { - $this->removeUserFromGroupAsAdminUsingTheProvisioningApi( - $user, - $group - ); + $user = $this->getActualUsername($user); + $response = $this->graphContext->removeUserFromGroup($group, $user); + $this->TheHTTPStatusCodeShouldBe(204, '', $response); } $this->userShouldNotBelongToGroup($user, $group); } /** - * @When user :user removes user :otherUser from group :group using the provisioning API + * @When the administrator removes user :user from group :group using the provisioning API * * @param string $user - * @param string $otherUser * @param string $group * * @return void * @throws Exception */ - public function userRemovesUserFromGroupUsingTheProvisioningApi( - string $user, - string $otherUser, - string $group - ):void { - $this->userTriesToRemoveUserFromGroupUsingTheProvisioningApi( - $user, - $otherUser, - $group - ); - - if ($this->response->getStatusCode() !== 200) { - \error_log( - "INFORMATION: could not remove user '$user' from group '$group'" - . $this->response->getStatusCode() . " " . $this->response->getBody() + public function adminRemovesUserFromGroupUsingTheProvisioningApi(string $user, string $group):void { + $user = $this->getActualUsername($user); + if (OcisHelper::isTestingWithGraphApi()) { + $this->setResponse( + $this->graphContext->removeUserFromGroup( + $group, + $user + ) + ); + } else { + $this->response = UserHelper::removeUserFromGroup( + $this->getBaseUrl(), + $user, + $group, + $this->getAdminUsername(), + $this->getAdminPassword(), + $this->getStepLineRef(), + $this->ocsApiVersion ); } - } - /** - * @When user :user tries to remove user :otherUser from group :group using the provisioning API - * - * @param string $user - * @param string $otherUser - * @param string $group - * - * @return void - * @throws Exception - */ - public function userTriesToRemoveUserFromGroupUsingTheProvisioningApi( - string $user, - string $otherUser, - string $group - ):void { - $actualUser = $this->getActualUsername($user); - $actualPassword = $this->getUserPassword($actualUser); - $actualOtherUser = $this->getActualUsername($otherUser); - $this->response = UserHelper::removeUserFromGroup( - $this->getBaseUrl(), - $actualOtherUser, - $group, - $actualUser, - $actualPassword, - $this->getStepLineRef(), - $this->ocsApiVersion - ); + $this->pushToLastStatusCodesArrays(); } /** @@ -3928,55 +3849,6 @@ trait Provisioning { ); } - /** - * @When the administrator removes user :user from being a subadmin of group :group using the provisioning API - * - * @param string $user - * @param string $group - * - * @return void - */ - public function theAdministratorRemovesUserFromBeingASubadminOfGroupUsingTheProvisioningApi( - string $user, - string $group - ):void { - $this->userRemovesUserFromBeingASubadminOfGroupUsingTheProvisioningApi( - $this->getAdminUsername(), - $user, - $group - ); - } - - /** - * @When user :user removes user :otherUser from being a subadmin of group :group using the provisioning API - * - * @param string $user - * @param string $otherUser - * @param string $group - * - * @return void - * @throws Exception - */ - public function userRemovesUserFromBeingASubadminOfGroupUsingTheProvisioningApi( - string $user, - string $otherUser, - string $group - ):void { - $actualOtherUser = $this->getActualUsername($otherUser); - $fullUrl = $this->getBaseUrl() - . "/ocs/v$this->ocsApiVersion.php/cloud/users/$actualOtherUser/subadmins"; - $actualUser = $this->getActualUsername($user); - $actualPassword = $this->getUserPassword($actualUser); - $this->response = HttpRequestHelper::delete( - $fullUrl, - $this->getStepLineRef(), - $actualUser, - $actualPassword, - null, - ['groupid' => $group] - ); - } - /** * @Then /^the users returned by the API should be$/ * diff --git a/tests/acceptance/features/coreApiShareOperationsToShares1/gettingShares.feature b/tests/acceptance/features/coreApiShareOperationsToShares1/gettingShares.feature index 6b61d3f324..c5e5eba3c9 100644 --- a/tests/acceptance/features/coreApiShareOperationsToShares1/gettingShares.feature +++ b/tests/acceptance/features/coreApiShareOperationsToShares1/gettingShares.feature @@ -151,7 +151,7 @@ Feature: sharing | 1 | 200 | | 2 | 404 | - @issue-1289 @skipOnGraph + @issue-1289 Scenario: share a folder to a group, and remove user from that group Given using OCS API version "1" And user "Carol" has been created with default attributes and without skeleton files @@ -164,7 +164,7 @@ Feature: sharing And user "Brian" has accepted share "/PARENT" offered by user "Alice" And user "Carol" has accepted share "/PARENT" offered by user "Alice" When the administrator removes user "Carol" from group "group0" using the provisioning API - Then the HTTP status code should be "200" + Then the HTTP status code should be "204" And user "Brian" should see the following elements | /Shares/PARENT/ | | /Shares/PARENT/parent.txt |