diff --git a/tests/acceptance/features/apiSharingNg/shareInvitations.feature b/tests/acceptance/features/apiSharingNg/shareInvitations.feature index 187a62122ed..148863a32ae 100644 --- a/tests/acceptance/features/apiSharingNg/shareInvitations.feature +++ b/tests/acceptance/features/apiSharingNg/shareInvitations.feature @@ -863,7 +863,7 @@ Feature: Send a sharing invitations | Carol | grp1 | And user "Alice" has uploaded file with content "to share" to "/textfile1.txt" And user "Alice" has created folder "FolderToShare" - And the administrator has deleted group "grp1" + And group "grp1" has been deleted When user "Alice" sends the following share invitation using the Graph API: | resource | | | space | Personal | diff --git a/tests/acceptance/features/apiSharingNg/sharedByMe.feature b/tests/acceptance/features/apiSharingNg/sharedByMe.feature index 9676a392bd3..db36568b3e7 100644 --- a/tests/acceptance/features/apiSharingNg/sharedByMe.feature +++ b/tests/acceptance/features/apiSharingNg/sharedByMe.feature @@ -1463,7 +1463,7 @@ Feature: resources shared by user | sharee | Brian | | shareType | user | | permissionsRole | Viewer | - And the administrator has deleted user "Brian" using the provisioning API + And user "Brian" has been deleted When user "Alice" lists the shares shared by her after clearing user cache using the Graph API Then the HTTP status code should be "200" And the JSON data of the response should match diff --git a/tests/acceptance/features/bootstrap/GraphContext.php b/tests/acceptance/features/bootstrap/GraphContext.php index 2d06a49d69e..9faf086cb9a 100644 --- a/tests/acceptance/features/bootstrap/GraphContext.php +++ b/tests/acceptance/features/bootstrap/GraphContext.php @@ -274,7 +274,7 @@ public function adminHasRetrievedUserUsingTheGraphApi(string $user): ResponseInt * @return ResponseInterface * @throws GuzzleException */ - public function userDeletesGroupWithGroupId( + public function deleteGroupWithId( string $groupId, ?string $user = null ): ResponseInterface { @@ -289,31 +289,18 @@ public function userDeletesGroupWithGroupId( ); } - /** - * @param string $groupId - * - * @return void - * @throws GuzzleException - */ - public function adminDeletesGroupWithGroupId( - string $groupId - ): void { - $response = $this->userDeletesGroupWithGroupId($groupId); - $this->featureContext->theHTTPStatusCodeShouldBe(204, "", $response); - } - /** * @param string $group * - * @return void + * @return ResponseInterface * @throws Exception * @throws GuzzleException */ - public function adminDeletesGroupUsingTheGraphApi( + public function deleteGroupWithName( string $group - ): void { + ): ResponseInterface { $groupId = $this->featureContext->getAttributeOfCreatedGroup($group, "id"); - $this->adminDeletesGroupWithGroupId($groupId); + return $this->deleteGroupWithId($groupId); } /** @@ -1054,23 +1041,13 @@ public function userRetrievesAllMemberInformationOfSingleOrAllGroups(string $use */ public function userDeletesGroupUsingTheGraphApi(string $group, ?string $user = null): void { $groupId = $this->featureContext->getAttributeOfCreatedGroup($group, "id"); - $response = $this->userDeletesGroupWithGroupId($groupId, $user); + $response = $this->deleteGroupWithId($groupId, $user); + if ($response->getStatusCode() === 204) { + $this->featureContext->rememberThatGroupIsNotExpectedToExist($group); + } $this->featureContext->setResponse($response); } - /** - * @Given the administrator has deleted group :group - * - * @param string $group - * - * @return void - */ - public function theAdministratorHasDeletedGroup(string $group): void { - $groupId = $this->featureContext->getAttributeOfCreatedGroup($group, "id"); - $response = $this->userDeletesGroupWithGroupId($groupId); - $this->featureContext->theHTTPStatusCodeShouldBe(204, "", $response); - } - /** * @Then the following users should be listed in the following groups * diff --git a/tests/acceptance/features/bootstrap/Provisioning.php b/tests/acceptance/features/bootstrap/Provisioning.php index 0a8c1b22ba6..97a7122b064 100644 --- a/tests/acceptance/features/bootstrap/Provisioning.php +++ b/tests/acceptance/features/bootstrap/Provisioning.php @@ -222,18 +222,11 @@ public function getAttributeOfCreatedUser(string $user, string $attribute) { $usersList = $this->getCreatedUsers(); $normalizedUsername = $this->normalizeUsername($user); if (\array_key_exists($normalizedUsername, $usersList)) { - // provide attributes only if the user exists - if ($usersList[$normalizedUsername]["shouldExist"]) { - if (\array_key_exists($attribute, $usersList[$normalizedUsername])) { - return $usersList[$normalizedUsername][$attribute]; - } else { - throw new Exception( - __METHOD__ . ": User '$user' has no attribute with name '$attribute'." - ); - } + if (\array_key_exists($attribute, $usersList[$normalizedUsername])) { + return $usersList[$normalizedUsername][$attribute]; } else { throw new Exception( - __METHOD__ . ": User '$user' has been deleted." + __METHOD__ . ": User '$user' has no attribute with name '$attribute'." ); } } else { @@ -251,18 +244,11 @@ public function getAttributeOfCreatedUser(string $user, string $attribute) { public function getAttributeOfCreatedGroup(string $group, string $attribute) { $groupsList = $this->getCreatedGroups(); if (\array_key_exists($group, $groupsList)) { - // provide attributes only if the group exists - if ($groupsList[$group]["shouldExist"]) { - if (\array_key_exists($attribute, $groupsList[$group])) { - return $groupsList[$group][$attribute]; - } else { - throw new Exception( - __METHOD__ . ": Group '$group' has no attribute with name '$attribute'." - ); - } + if (\array_key_exists($attribute, $groupsList[$group])) { + return $groupsList[$group][$attribute]; } else { throw new Exception( - __METHOD__ . ": Group '$group' has been deleted." + __METHOD__ . ": Group '$group' has no attribute with name '$attribute'." ); } } else { @@ -1361,22 +1347,6 @@ public function userHasTriedToResetPasswordOfUserUsingTheProvisioningApi(?string $this->theHTTPStatusCodeShouldBeSuccess(); } - /** - * @Given /^the administrator has deleted user "([^"]*)" using the provisioning API$/ - * - * @param string|null $user - * - * @return void - * @throws Exception - */ - public function theAdministratorHasDeletedUserUsingTheProvisioningApi(?string $user):void { - $user = $this->getActualUsername($user); - $response = $this->deleteUser($user); - $this->theHttpStatusCodeShouldBe(204, "", $response); - WebDavHelper::removeSpaceIdReferenceForUser($user); - $this->userShouldNotExist($user); - } - /** * @When /^the administrator deletes user "([^"]*)" using the provisioning API$/ * @@ -1929,8 +1899,10 @@ public function userHasBeenDeleted(string $user):void { } else { $response = $this->deleteUser($user); $this->theHTTPStatusCodeShouldBe(204, "", $response); + WebDavHelper::removeSpaceIdReferenceForUser($user); } } + $this->rememberThatUserIsNotExpectedToExist($user); $this->userShouldNotExist($user); } @@ -2213,6 +2185,7 @@ public function rememberThatUserIsNotExpectedToExist(string $user):void { $normalizedUsername = $this->normalizeUsername($user); if (\array_key_exists($normalizedUsername, $this->createdUsers)) { $this->createdUsers[$normalizedUsername]['shouldExist'] = false; + $this->createdUsers[$normalizedUsername]['possibleToDelete'] = false; } } @@ -2316,7 +2289,8 @@ public function cleanupGroup(string $group):void { if ($this->isTestingWithLdap()) { $this->deleteLdapGroup($group); } else { - $this->graphContext->adminDeletesGroupUsingTheGraphApi($group); + $response = $this->graphContext->deleteGroupWithName($group); + $this->theHTTPStatusCodeShouldBe(204, "", $response); } } catch (Exception $e) { \error_log( @@ -2623,6 +2597,7 @@ public function addGroupToCreatedGroupsList( public function rememberThatGroupIsNotExpectedToExist(string $group):void { if (\array_key_exists($group, $this->createdGroups)) { $this->createdGroups[$group]['shouldExist'] = false; + $this->createdGroups[$group]['possibleToDelete'] = false; } } @@ -3121,8 +3096,10 @@ public function groupHasBeenDeleted(string $group):void { if ($this->isTestingWithLdap()) { $this->deleteLdapGroup($group); } else { - $this->graphContext->adminDeletesGroupUsingTheGraphApi($group); + $response = $this->graphContext->deleteGroupWithName($group); + $this->theHTTPStatusCodeShouldBe(204, "", $response); } + $this->rememberThatGroupIsNotExpectedToExist($group); $this->groupShouldNotExist($group); } @@ -4247,22 +4224,24 @@ public function cleanupDatabaseGroups():void { $previousServer = $this->currentServer; $this->usingServer('LOCAL'); foreach ($this->createdGroups as $group => $groupData) { - if ($this->isTestingWithLdap()) { - $this->cleanupGroup((string)$group); - } else { - $this->graphContext->adminDeletesGroupWithGroupId( - $groupData['id'] - ); + if ($groupData["possibleToDelete"]) { + if ($this->isTestingWithLdap()) { + $this->cleanupGroup((string)$group); + } else { + $response = $this->graphContext->deleteGroupWithId($groupData['id']); + $this->theHTTPStatusCodeShouldBe(204, "", $response); + } } } $this->usingServer('REMOTE'); foreach ($this->createdRemoteGroups as $remoteGroup => $groupData) { - if ($this->isTestingWithLdap()) { - $this->cleanupGroup((string)$remoteGroup); - } else { - $this->graphContext->adminDeletesGroupWithGroupId( - $groupData['id'] - ); + if ($groupData["possibleToDelete"]) { + if ($this->isTestingWithLdap()) { + $this->cleanupGroup((string)$remoteGroup); + } else { + $response = $this->graphContext->deleteGroupWithId($groupData['id']); + $this->theHTTPStatusCodeShouldBe(204, "", $response); + } } } $this->usingServer($previousServer); diff --git a/tests/acceptance/features/bootstrap/SharingNgContext.php b/tests/acceptance/features/bootstrap/SharingNgContext.php index 61b7ffe9b51..ef510e191e5 100644 --- a/tests/acceptance/features/bootstrap/SharingNgContext.php +++ b/tests/acceptance/features/bootstrap/SharingNgContext.php @@ -193,10 +193,16 @@ public function sendShareInvitation(string $user, TableNode $table, string $file $sharees = array_map('trim', explode(',', $rows['sharee'])); $shareTypes = array_map('trim', explode(',', $rows['shareType'])); - foreach ($sharees as $sharee) { - // for non-exiting group or user, generate random id - $shareeIds[] = $this->featureContext->getAttributeOfCreatedUser($sharee, 'id') - ?: ($this->featureContext->getAttributeOfCreatedGroup($sharee, 'id') ?: WebDavHelper::generateUUIDv4()); + foreach ($sharees as $index => $sharee) { + $shareType = $shareTypes[$index]; + $shareeId = ""; + if ($shareType === "user") { + $shareeId = $this->featureContext->getAttributeOfCreatedUser($sharee, 'id'); + } elseif ($shareType === "group") { + $shareeId = $this->featureContext->getAttributeOfCreatedGroup($sharee, 'id'); + } + // for non-existing group or user, generate random id + $shareeIds[] = $shareeId ?: WebDavHelper::generateUUIDv4(); } } diff --git a/tests/acceptance/features/coreApiShareManagementBasicToShares/createShareToSharesFolder.feature b/tests/acceptance/features/coreApiShareManagementBasicToShares/createShareToSharesFolder.feature index 8aead7e68e3..23f17b44d40 100644 --- a/tests/acceptance/features/coreApiShareManagementBasicToShares/createShareToSharesFolder.feature +++ b/tests/acceptance/features/coreApiShareManagementBasicToShares/createShareToSharesFolder.feature @@ -533,7 +533,7 @@ Feature: sharing And user "Alice" has uploaded file with content "ownCloud test text file 0" to "/textfile0.txt" And user "Alice" has shared file "textfile0.txt" with user "Brian" And user "Alice" has shared file "textfile0.txt" with user "Carol" - And the administrator has deleted user "Brian" using the provisioning API + And user "Brian" has been deleted When user "Alice" gets all the shares of the file "textfile0.txt" using the sharing API Then the OCS status code should be "" And the HTTP status code should be "200" diff --git a/tests/acceptance/features/coreApiTrashbin/trashbinFilesFolders.feature b/tests/acceptance/features/coreApiTrashbin/trashbinFilesFolders.feature index 40174bf53b1..039951792a7 100644 --- a/tests/acceptance/features/coreApiTrashbin/trashbinFilesFolders.feature +++ b/tests/acceptance/features/coreApiTrashbin/trashbinFilesFolders.feature @@ -206,7 +206,7 @@ Feature: files and folders exist in the trashbin after being deleted And user "Brian" has been created with default attributes and without skeleton files And user "testtrashbin102" has deleted file "/textfile0.txt" And user "testtrashbin102" has deleted file "/textfile2.txt" - And the administrator has deleted user "testtrashbin102" using the provisioning API + And user "testtrashbin102" has been deleted And user "testtrashbin102" has been created with default attributes and without skeleton files And user "testtrashbin102" has uploaded file "filesForUpload/textfile.txt" to "/textfile3.txt" And user "testtrashbin102" has deleted file "/textfile3.txt"