diff --git a/tests/acceptance/TestHelpers/GraphHelper.php b/tests/acceptance/TestHelpers/GraphHelper.php index bda24330d8..b77ab55100 100644 --- a/tests/acceptance/TestHelpers/GraphHelper.php +++ b/tests/acceptance/TestHelpers/GraphHelper.php @@ -2445,4 +2445,58 @@ class GraphHelper { self::getRequestHeaders() ); } + + /** + * @param string $baseUrl + * @param string $xRequestId + * @param string $user + * @param string $password + * @param string $fileId + * + * @return ResponseInterface + * @throws GuzzleException + */ + public static function markFavorite( + string $baseUrl, + string $xRequestId, + string $user, + string $password, + string $fileId + ): ResponseInterface { + $url = self::getFullUrl($baseUrl, "me/drive/items/$fileId/follow"); + return HttpRequestHelper::post( + $url, + $xRequestId, + $user, + $password, + self::getRequestHeaders() + ); + } + + /** + * @param string $baseUrl + * @param string $xRequestId + * @param string $user + * @param string $password + * @param string $fileId + * + * @return ResponseInterface + * @throws GuzzleException + */ + public static function unmarkFavorite( + string $baseUrl, + string $xRequestId, + string $user, + string $password, + string $fileId + ): ResponseInterface { + $url = self::getFullUrl($baseUrl, "me/drive/following/$fileId"); + return HttpRequestHelper::delete( + $url, + $xRequestId, + $user, + $password, + self::getRequestHeaders() + ); + } } diff --git a/tests/acceptance/bootstrap/FavoritesContext.php b/tests/acceptance/bootstrap/FavoritesContext.php index 29babb799f..c7637af539 100644 --- a/tests/acceptance/bootstrap/FavoritesContext.php +++ b/tests/acceptance/bootstrap/FavoritesContext.php @@ -21,7 +21,6 @@ use Behat\Behat\Context\Context; use Behat\Behat\Hook\Scope\BeforeScenarioScope; use Behat\Gherkin\Node\TableNode; -use Psr\Http\Message\ResponseInterface; use TestHelpers\WebDavHelper; use TestHelpers\BehatHelper; @@ -34,73 +33,6 @@ class FavoritesContext implements Context { private FeatureContext $featureContext; private WebDavPropertiesContext $webDavPropertiesContext; - /** - * @param string$user - * @param string $path - * @param string|null $spaceId - * - * @return ResponseInterface - */ - public function userFavoritesElement(string $user, string $path, ?string $spaceId = null): ResponseInterface { - return $this->changeFavStateOfAnElement( - $user, - $path, - 1, - $spaceId - ); - } - - /** - * @When user :user favorites element :path using the WebDAV API - * - * @param string $user - * @param string $path - * - * @return void - */ - public function userFavoritesElementUsingWebDavApi(string $user, string $path): void { - $this->featureContext->setResponse($this->userFavoritesElement($user, $path)); - } - - /** - * @Given user :user has favorited element :path - * - * @param string $user - * @param string $path - * - * @return void - */ - public function userHasFavoritedElementUsingWebDavApi(string $user, string $path): void { - $this->featureContext->theHTTPStatusCodeShouldBe(207, '', $this->userFavoritesElement($user, $path)); - } - - /** - * @param string $user - * @param string $path - * - * @return ResponseInterface - */ - public function userUnfavoritesElement(string $user, string $path): ResponseInterface { - return $this->changeFavStateOfAnElement( - $user, - $path, - 0, - null, - ); - } - - /** - * @When user :user unfavorites element :path using the WebDAV API - * - * @param string $user - * @param string $path - * - * @return void - */ - public function userUnfavoritesElementUsingWebDavApi(string $user, string $path): void { - $this->featureContext->setResponse($this->userUnfavoritesElement($user, $path)); - } - /** * @Then /^user "([^"]*)" should (not|)\s?have the following favorited items$/ * @@ -203,38 +135,6 @@ class FavoritesContext implements Context { $this->asUserFileOrFolderShouldBeFavorited($user, $path, 0); } - /** - * Set the elements of a proppatch - * - * @param string $user - * @param string $path - * @param int|null $favOrUnfav 1 = favorite, 0 = unfavorite - * @param string|null $spaceId - * - * @return ResponseInterface - */ - public function changeFavStateOfAnElement( - string $user, - string $path, - ?int $favOrUnfav, - ?string $spaceId, - ): ResponseInterface { - $renamedUser = $this->featureContext->getActualUsername($user); - return WebDavHelper::proppatch( - $this->featureContext->getBaseUrl(), - $renamedUser, - $this->featureContext->getPasswordForUser($user), - $path, - 'favorite', - (string)$favOrUnfav, - $this->featureContext->getStepLineRef(), - "oc='http://owncloud.org/ns'", - $this->featureContext->getDavPathVersion(), - 'files', - $spaceId - ); - } - /** * This will run before EVERY scenario. * It will set the properties for this object. diff --git a/tests/acceptance/bootstrap/GraphContext.php b/tests/acceptance/bootstrap/GraphContext.php index 483d42a1c6..49782fa137 100644 --- a/tests/acceptance/bootstrap/GraphContext.php +++ b/tests/acceptance/bootstrap/GraphContext.php @@ -3207,4 +3207,133 @@ class GraphContext implements Context { $this->featureContext->setResponse($response); } + + /** + * @param string $user + * @param string $itemId + * + * @return ResponseInterface + */ + public function markFavorite(string $user, string $itemId): ResponseInterface { + $response = GraphHelper::markFavorite( + $this->featureContext->getBaseUrl(), + $this->featureContext->getStepLineRef(), + $user, + $this->featureContext->getPasswordForUser($user), + $itemId + ); + + $this->featureContext->setResponse($response); + return $response; + } + + /** + * @param string $user + * @param string $itemId + * + * @return ResponseInterface + */ + public function unmarkFavorite(string $user, string $itemId): ResponseInterface { + $response = GraphHelper::unmarkFavorite( + $this->featureContext->getBaseUrl(), + $this->featureContext->getStepLineRef(), + $user, + $this->featureContext->getPasswordForUser($user), + $itemId + ); + $this->featureContext->setResponse($response); + return $response; + } + + /** + * @When user :user marks :item :itemName as favorite from space :spaceName using the Graph API + * + * @param string $user + * @param string $item (file|folder) + * @param string $itemName + * @param string $spaceName + * + * @return void + */ + public function userMarksItemFromSpaceAsFavoriteUsingTheGraphApi( + string $user, + string $item, + string $itemName, + string $spaceName + ): void { + $itemId = ($item === 'file') + ? $this->spacesContext->getFileId($user, $spaceName, $itemName) + : $this->spacesContext->getResourceId($user, $spaceName, $itemName); + $this->markFavorite($user, $itemId); + } + + /** + * @When user :user unmarks :item :itemName as favorite from space :spaceName using the Graph API + * + * @param string $user + * @param string $item (file|folder) + * @param string $itemName + * @param string $spaceName + * + * @return void + */ + public function userUnmarksItemFromSpaceAsFavoriteUsingTheGraphApi( + string $user, + string $item, + string $itemName, + string $spaceName + ): void { + $itemId = ($item === 'file') + ? $this->spacesContext->getFileId($user, $spaceName, $itemName) + : $this->spacesContext->getResourceId($user, $spaceName, $itemName); + $this->unmarkFavorite($user, $itemId); + } + + /** + * @Given user :user has marked :item :itemName as favorite from space :spaceName + * + * @param string $user + * @param string $item (folder|file) + * @param string $itemName + * @param string $spaceName + * + * @return void + */ + public function userHasMarkedItemFromSpaceAsFavoriteUsingTheGraphApi( + string $user, + string $item, + string $itemName, + string $spaceName + ): void { + $itemId = ($item === 'file') + ? $this->spacesContext->getFileId($user, $spaceName, $itemName) + : $this->spacesContext->getResourceId($user, $spaceName, $itemName); + + $response = $this->markFavorite($user, $itemId); + $this->featureContext->theHTTPStatusCodeShouldBe(201, '', $response); + } + + /** + * @Given user :user has unmarked :item :itemName as favorite from space :spaceName + * + * @param string $user + * @param string $item (folder|file) + * @param string $itemName + * @param string $spaceName + * + * @return void + */ + public function userHasUnmarkedItemFromSpaceAsFavoriteUsingTheGraphApi( + string $user, + string $item, + string $itemName, + string $spaceName + ): void { + $itemId = ($item === 'file') + ? $this->spacesContext->getFileId($user, $spaceName, $itemName) + : $this->spacesContext->getResourceId($user, $spaceName, $itemName); + + $response = $this->unmarkFavorite($user, $itemId); + $this->featureContext->theHTTPStatusCodeShouldBe(204, '', $response); + } } diff --git a/tests/acceptance/config/behat.yml b/tests/acceptance/config/behat.yml index 20050dc685..2aa3c15ad7 100644 --- a/tests/acceptance/config/behat.yml +++ b/tests/acceptance/config/behat.yml @@ -492,17 +492,6 @@ default: - FeatureContext: *common_feature_context_params - CapabilitiesContext: - coreApiFavorites: - paths: - - "%paths.base%/../features/coreApiFavorites" - context: *common_ldap_suite_context - contexts: - - FeatureContext: *common_feature_context_params - - SpacesContext: - - FavoritesContext: - - WebDavPropertiesContext: - - SharingNgContext: - coreApiShareCreateSpecialToShares1: paths: - "%paths.base%/../features/coreApiShareCreateSpecialToShares1" diff --git a/tests/acceptance/expected-failures-decomposed-storage.md b/tests/acceptance/expected-failures-decomposed-storage.md index db03bb77ac..eb1fee7fe0 100644 --- a/tests/acceptance/expected-failures-decomposed-storage.md +++ b/tests/acceptance/expected-failures-decomposed-storage.md @@ -268,27 +268,6 @@ _ocdav: api compatibility, return correct status code_ - [coreApiAuth/webDavLOCKAuth.feature:46](https://github.com/opencloud-eu/opencloud/blob/main/tests/acceptance/features/coreApiAuth/webDavLOCKAuth.feature#L46) - [coreApiAuth/webDavLOCKAuth.feature:58](https://github.com/opencloud-eu/opencloud/blob/main/tests/acceptance/features/coreApiAuth/webDavLOCKAuth.feature#L58) -#### [Support for favorites](https://github.com/owncloud/ocis/issues/1228) - -- [coreApiFavorites/favorites.feature:101](https://github.com/opencloud-eu/opencloud/blob/main/tests/acceptance/features/coreApiFavorites/favorites.feature#L101) -- [coreApiFavorites/favorites.feature:102](https://github.com/opencloud-eu/opencloud/blob/main/tests/acceptance/features/coreApiFavorites/favorites.feature#L102) -- [coreApiFavorites/favorites.feature:103](https://github.com/opencloud-eu/opencloud/blob/main/tests/acceptance/features/coreApiFavorites/favorites.feature#L103) -- [coreApiFavorites/favorites.feature:124](https://github.com/opencloud-eu/opencloud/blob/main/tests/acceptance/features/coreApiFavorites/favorites.feature#L124) -- [coreApiFavorites/favorites.feature:125](https://github.com/opencloud-eu/opencloud/blob/main/tests/acceptance/features/coreApiFavorites/favorites.feature#L125) -- [coreApiFavorites/favorites.feature:126](https://github.com/opencloud-eu/opencloud/blob/main/tests/acceptance/features/coreApiFavorites/favorites.feature#L126) -- [coreApiFavorites/favorites.feature:189](https://github.com/opencloud-eu/opencloud/blob/main/tests/acceptance/features/coreApiFavorites/favorites.feature#L189) -- [coreApiFavorites/favorites.feature:190](https://github.com/opencloud-eu/opencloud/blob/main/tests/acceptance/features/coreApiFavorites/favorites.feature#L190) -- [coreApiFavorites/favorites.feature:191](https://github.com/opencloud-eu/opencloud/blob/main/tests/acceptance/features/coreApiFavorites/favorites.feature#L191) -- [coreApiFavorites/favorites.feature:145](https://github.com/opencloud-eu/opencloud/blob/main/tests/acceptance/features/coreApiFavorites/favorites.feature#L145) -- [coreApiFavorites/favorites.feature:146](https://github.com/opencloud-eu/opencloud/blob/main/tests/acceptance/features/coreApiFavorites/favorites.feature#L146) -- [coreApiFavorites/favorites.feature:147](https://github.com/opencloud-eu/opencloud/blob/main/tests/acceptance/features/coreApiFavorites/favorites.feature#L147) -- [coreApiFavorites/favorites.feature:174](https://github.com/opencloud-eu/opencloud/blob/main/tests/acceptance/features/coreApiFavorites/favorites.feature#L174) -- [coreApiFavorites/favorites.feature:175](https://github.com/opencloud-eu/opencloud/blob/main/tests/acceptance/features/coreApiFavorites/favorites.feature#L175) -- [coreApiFavorites/favorites.feature:176](https://github.com/opencloud-eu/opencloud/blob/main/tests/acceptance/features/coreApiFavorites/favorites.feature#L176) -- [coreApiFavorites/favoritesSharingToShares.feature:91](https://github.com/opencloud-eu/opencloud/blob/main/tests/acceptance/features/coreApiFavorites/favoritesSharingToShares.feature#L91) -- [coreApiFavorites/favoritesSharingToShares.feature:92](https://github.com/opencloud-eu/opencloud/blob/main/tests/acceptance/features/coreApiFavorites/favoritesSharingToShares.feature#L92) -- [coreApiFavorites/favoritesSharingToShares.feature:93](https://github.com/opencloud-eu/opencloud/blob/main/tests/acceptance/features/coreApiFavorites/favoritesSharingToShares.feature#L93) - #### [WWW-Authenticate header for unauthenticated requests is not clear](https://github.com/owncloud/ocis/issues/2285) - [coreApiWebdavOperations/refuseAccess.feature:21](https://github.com/opencloud-eu/opencloud/blob/main/tests/acceptance/features/coreApiWebdavOperations/refuseAccess.feature#L21) diff --git a/tests/acceptance/expected-failures-posix-storage.md b/tests/acceptance/expected-failures-posix-storage.md index a463bd700f..a8c71b2368 100644 --- a/tests/acceptance/expected-failures-posix-storage.md +++ b/tests/acceptance/expected-failures-posix-storage.md @@ -268,31 +268,6 @@ _ocdav: api compatibility, return correct status code_ - [coreApiAuth/webDavLOCKAuth.feature:46](https://github.com/opencloud-eu/opencloud/blob/main/tests/acceptance/features/coreApiAuth/webDavLOCKAuth.feature#L46) - [coreApiAuth/webDavLOCKAuth.feature:58](https://github.com/opencloud-eu/opencloud/blob/main/tests/acceptance/features/coreApiAuth/webDavLOCKAuth.feature#L58) -#### [Support for favorites](https://github.com/owncloud/ocis/issues/1228) - -- [coreApiFavorites/favorites.feature:101](https://github.com/opencloud-eu/opencloud/blob/main/tests/acceptance/features/coreApiFavorites/favorites.feature#L101) -- [coreApiFavorites/favorites.feature:102](https://github.com/opencloud-eu/opencloud/blob/main/tests/acceptance/features/coreApiFavorites/favorites.feature#L102) -- [coreApiFavorites/favorites.feature:103](https://github.com/opencloud-eu/opencloud/blob/main/tests/acceptance/features/coreApiFavorites/favorites.feature#L103) -- [coreApiFavorites/favorites.feature:124](https://github.com/opencloud-eu/opencloud/blob/main/tests/acceptance/features/coreApiFavorites/favorites.feature#L124) -- [coreApiFavorites/favorites.feature:125](https://github.com/opencloud-eu/opencloud/blob/main/tests/acceptance/features/coreApiFavorites/favorites.feature#L125) -- [coreApiFavorites/favorites.feature:126](https://github.com/opencloud-eu/opencloud/blob/main/tests/acceptance/features/coreApiFavorites/favorites.feature#L126) -- [coreApiFavorites/favorites.feature:189](https://github.com/opencloud-eu/opencloud/blob/main/tests/acceptance/features/coreApiFavorites/favorites.feature#L189) -- [coreApiFavorites/favorites.feature:190](https://github.com/opencloud-eu/opencloud/blob/main/tests/acceptance/features/coreApiFavorites/favorites.feature#L190) -- [coreApiFavorites/favorites.feature:191](https://github.com/opencloud-eu/opencloud/blob/main/tests/acceptance/features/coreApiFavorites/favorites.feature#L191) -- [coreApiFavorites/favorites.feature:145](https://github.com/opencloud-eu/opencloud/blob/main/tests/acceptance/features/coreApiFavorites/favorites.feature#L145) -- [coreApiFavorites/favorites.feature:146](https://github.com/opencloud-eu/opencloud/blob/main/tests/acceptance/features/coreApiFavorites/favorites.feature#L146) -- [coreApiFavorites/favorites.feature:147](https://github.com/opencloud-eu/opencloud/blob/main/tests/acceptance/features/coreApiFavorites/favorites.feature#L147) -- [coreApiFavorites/favorites.feature:174](https://github.com/opencloud-eu/opencloud/blob/main/tests/acceptance/features/coreApiFavorites/favorites.feature#L174) -- [coreApiFavorites/favorites.feature:175](https://github.com/opencloud-eu/opencloud/blob/main/tests/acceptance/features/coreApiFavorites/favorites.feature#L175) -- [coreApiFavorites/favorites.feature:176](https://github.com/opencloud-eu/opencloud/blob/main/tests/acceptance/features/coreApiFavorites/favorites.feature#L176) -- [coreApiFavorites/favoritesSharingToShares.feature:91](https://github.com/opencloud-eu/opencloud/blob/main/tests/acceptance/features/coreApiFavorites/favoritesSharingToShares.feature#L91) -- [coreApiFavorites/favoritesSharingToShares.feature:92](https://github.com/opencloud-eu/opencloud/blob/main/tests/acceptance/features/coreApiFavorites/favoritesSharingToShares.feature#L92) -- [coreApiFavorites/favoritesSharingToShares.feature:93](https://github.com/opencloud-eu/opencloud/blob/main/tests/acceptance/features/coreApiFavorites/favoritesSharingToShares.feature#L93) -- [coreApiFavorites/favoritesSharingToShares.feature:112](https://github.com/opencloud-eu/opencloud/blob/main/tests/acceptance/features/coreApiFavorites/favoritesSharingToShares.feature#L112) -- [coreApiFavorites/favoritesSharingToShares.feature:113](https://github.com/opencloud-eu/opencloud/blob/main/tests/acceptance/features/coreApiFavorites/favoritesSharingToShares.feature#L113) -- [coreApiFavorites/favoritesSharingToShares.feature:114](https://github.com/opencloud-eu/opencloud/blob/main/tests/acceptance/features/coreApiFavorites/favoritesSharingToShares.feature#L114) -- [apiSpacesShares/favorite.feature:56](https://github.com/opencloud-eu/opencloud/blob/main/tests/acceptance/features/apiSpacesShares/favorite.feature#L56) - #### [WWW-Authenticate header for unauthenticated requests is not clear](https://github.com/owncloud/ocis/issues/2285) diff --git a/tests/acceptance/features/apiGraph/favorites.feature b/tests/acceptance/features/apiGraph/favorites.feature new file mode 100644 index 0000000000..a1c90db4ea --- /dev/null +++ b/tests/acceptance/features/apiGraph/favorites.feature @@ -0,0 +1,603 @@ +Feature: favorites + As a user + I want to check that I can mark and unmark files and folders as favorites using the Graph API + + Background: + Given user "Alice" has been created with default attributes + + + Scenario Outline: add a file to favorites in the personal space + Given user "Alice" has created folder "parent" + And user "Alice" has uploaded file "filesForUpload/" to "/parent/" + When user "Alice" marks file "parent/" as favorite from space "Personal" using the Graph API + Then the HTTP status code should be "201" + And the JSON data of the response should match + """ + { + "type": "object", + "required": [ + "eTag", + "file", + "id", + "lastModifiedDateTime", + "name", + "parentReference", + "size" + ], + "properties": { + "eTag": { + "type": "string", + "pattern": "%etag_pattern%" + }, + "file": { + "type": "object", + "required": ["mimeType"], + "properties": { + "mimeType": { + "const": "" + } + } + }, + "id": { + "type": "string", + "pattern": "^%file_id_pattern%$" + }, + "lastModifiedDateTime": { + "type": "string", + "format": "date-time" + }, + "name": { + "const": "" + }, + "parentReference": { + "type": "object", + "required": [ + "driveId", + "driveType", + "id", + "name", + "path" + ], + "properties": { + "driveId": { + "type": "string", + "pattern": "^%space_id_pattern%$" + }, + "driveType": { + "const": "personal" + }, + "id": { + "type": "string", + "pattern": "^%file_id_pattern%$" + }, + "name": { + "const": "parent" + }, + "path": { + "const": "/parent" + } + } + }, + "size": { + "type": "integer", + "const": + } + } + } + """ + And as user "Alice" file "parent/" should be favorited + Examples: + | file | size | mimeType | + | textfile.txt | 28 | text/plain | + | simple.odt | 10119 | application/vnd.oasis.opendocument.text | + | testavatar.jpg | 45343 | image/jpeg | + | simple.pdf | 17684 | application/pdf | + | testaudio.mp3 | 6144 | audio/mpeg | + + + Scenario: add a folder to favorites in the personal space + Given user "Alice" has created folder "parent" + And user "Alice" has uploaded file with content "first" to "/parent/first.txt" + And user "Alice" has uploaded file with content "second" to "/parent/second.txt" + When user "Alice" marks folder "parent" as favorite from space "Personal" using the Graph API + Then the HTTP status code should be "201" + And the JSON data of the response should match + """ + { + "type": "object", + "required": [ + "eTag", + "folder", + "id", + "lastModifiedDateTime", + "name", + "parentReference", + "size" + ], + "properties": { + "eTag": { + "type": "string", + "pattern": "%etag_pattern%" + }, + "folder": { + "type": "object" + }, + "id": { + "type": "string", + "pattern": "^%file_id_pattern%$" + }, + "lastModifiedDateTime": { + "type": "string", + "format": "date-time" + }, + "name": { + "const": "parent" + }, + "parentReference": { + "type": "object", + "required": [ + "driveId", + "driveType", + "id", + "name", + "path" + ], + "properties": { + "driveId": { + "type": "string", + "pattern": "^%space_id_pattern%$" + }, + "driveType": { + "const": "personal" + }, + "id": { + "type": "string", + "pattern": "^%file_id_pattern%$" + }, + "name": { + "const": "/" + }, + "path": { + "const": "/" + } + } + }, + "size": { + "type": "integer", + "const": 11 + } + } + } + """ + And as user "Alice" folder "parent" should be favorited + + + Scenario: add a shared file to favorites + Given user "Brian" has been created with default attributes + And user "Alice" has uploaded file with content "OpenCloud test text file" to "textfile.txt" + And user "Alice" has sent the following resource share invitation: + | resource | textfile.txt | + | space | Personal | + | sharee | Brian | + | shareType | user | + | permissionsRole | Viewer | + And user "Brian" has a share "textfile.txt" synced + When user "Brian" marks file "textfile.txt" as favorite from space "Shares" using the Graph API + Then the HTTP status code should be "201" + And the JSON data of the response should match + """ + { + "type": "object", + "required": [ + "eTag", + "file", + "id", + "lastModifiedDateTime", + "name", + "parentReference", + "size" + ], + "properties": { + "eTag": { + "type": "string", + "pattern": "%etag_pattern%" + }, + "file": { + "type": "object", + "required": ["mimeType"], + "properties": { + "mimeType": { + "const": "text/plain" + } + } + }, + "id": { + "type": "string", + "pattern": "^%file_id_pattern%$" + }, + "lastModifiedDateTime": { + "type": "string", + "format": "date-time" + }, + "name": { + "const": "textfile.txt" + }, + "parentReference": { + "type": "object", + "required": [ + "driveId", + "driveType", + "id", + "name", + "path" + ], + "properties": { + "driveId": { + "type": "string", + "pattern": "^%space_id_pattern%$" + }, + "driveType": { + "const": "personal" + }, + "id": { + "type": "string", + "pattern": "^%file_id_pattern%$" + }, + "name": { + "const": "/" + }, + "path": { + "const": "/" + } + } + }, + "size": { + "type": "integer", + "const": 24 + } + } + } + """ + And as user "Brian" file "Shares/textfile.txt" should be favorited + But as user "Alice" file "textfile.txt" should not be favorited + + + Scenario: add a shared folder to favorites + Given user "Brian" has been created with default attributes + And user "Alice" has created folder "parent" + And user "Alice" has created folder "parent/sub" + And user "Alice" has uploaded file with content "OpenCloud test text file" to "parent/textfile.txt" + And user "Alice" has sent the following resource share invitation: + | resource | parent | + | space | Personal | + | sharee | Brian | + | shareType | user | + | permissionsRole | Viewer | + And user "Brian" has a share "parent" synced + When user "Brian" marks folder "parent/sub" as favorite from space "Shares" using the Graph API + Then the HTTP status code should be "201" + And the JSON data of the response should match + """ + { + "type": "object", + "required": [ + "eTag", + "folder", + "id", + "lastModifiedDateTime", + "name", + "parentReference", + "size" + ], + "properties": { + "eTag": { + "type": "string", + "pattern": "%etag_pattern%" + }, + "folder": { + "type": "object" + }, + "id": { + "type": "string", + "pattern": "^%file_id_pattern%$" + }, + "lastModifiedDateTime": { + "type": "string", + "format": "date-time" + }, + "name": { + "const": "sub" + }, + "parentReference": { + "type": "object", + "required": [ + "driveId", + "driveType", + "id", + "name", + "path" + ], + "properties": { + "driveId": { + "type": "string", + "pattern": "^%space_id_pattern%$" + }, + "driveType": { + "const": "personal" + }, + "id": { + "type": "string", + "pattern": "^%file_id_pattern%$" + }, + "name": { + "const": "parent" + }, + "path": { + "const": "/parent" + } + } + }, + "size": { + "type": "integer", + "const": 0 + } + } + } + """ + And as user "Brian" folder "Shares/parent/sub" should be favorited + But as user "Alice" folder "parent/sub" should not be favorited + + + Scenario: add a file of the project space to favorites + Given user "Brian" has been created with default attributes + And the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API + And using spaces DAV path + And user "Alice" has created a space "new-space" with the default quota using the Graph API + And user "Alice" has uploaded a file inside space "new-space" with content "hello world" to "text.txt" + And user "Alice" has sent the following space share invitation: + | space | new-space | + | sharee | Brian | + | shareType | user | + | permissionsRole | Space Viewer | + When user "Brian" marks file "text.txt" as favorite from space "new-space" using the Graph API + Then the HTTP status code should be "201" + And the JSON data of the response should match + """ + { + "type": "object", + "required": [ + "eTag", + "file", + "id", + "lastModifiedDateTime", + "name", + "parentReference", + "size" + ], + "properties": { + "eTag": { + "type": "string", + "pattern": "%etag_pattern%" + }, + "file": { + "type": "object", + "required": ["mimeType"], + "properties": { + "mimeType": { + "const": "text/plain" + } + } + }, + "id": { + "type": "string", + "pattern": "^%file_id_pattern%$" + }, + "lastModifiedDateTime": { + "type": "string", + "format": "date-time" + }, + "name": { + "const": "text.txt" + }, + "parentReference": { + "type": "object", + "required": [ + "driveId", + "driveType", + "id", + "name", + "path" + ], + "properties": { + "driveId": { + "type": "string", + "pattern": "^%space_id_pattern%$" + }, + "driveType": { + "const": "project" + }, + "id": { + "type": "string", + "pattern": "^%file_id_pattern%$" + }, + "name": { + "const": "/" + }, + "path": { + "const": "/" + } + } + }, + "size": { + "type": "integer", + "const": 11 + } + } + } + """ + + + Scenario: add a folder of the project space to favorites + Given user "Brian" has been created with default attributes + And the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API + And using spaces DAV path + And user "Alice" has created a space "new-space" with the default quota using the Graph API + And user "Alice" has created a folder "space-folder" in space "new-space" + And user "Alice" has sent the following space share invitation: + | space | new-space | + | sharee | Brian | + | shareType | user | + | permissionsRole | Space Viewer | + When user "Brian" marks folder "space-folder" as favorite from space "new-space" using the Graph API + Then the HTTP status code should be "201" + And the JSON data of the response should match + """ + { + "type": "object", + "required": [ + "eTag", + "folder", + "id", + "lastModifiedDateTime", + "name", + "parentReference", + "size" + ], + "properties": { + "eTag": { + "type": "string", + "pattern": "%etag_pattern%" + }, + "folder": { + "type": "object" + }, + "id": { + "type": "string", + "pattern": "^%file_id_pattern%$" + }, + "lastModifiedDateTime": { + "type": "string", + "format": "date-time" + }, + "name": { + "const": "space-folder" + }, + "parentReference": { + "type": "object", + "required": [ + "driveId", + "driveType", + "id", + "name", + "path" + ], + "properties": { + "driveId": { + "type": "string", + "pattern": "^%space_id_pattern%$" + }, + "driveType": { + "const": "project" + }, + "id": { + "type": "string", + "pattern": "^%file_id_pattern%$" + }, + "name": { + "const": "/" + }, + "path": { + "const": "/" + } + } + }, + "size": { + "type": "integer", + "const": 0 + } + } + } + """ + + + Scenario: remove file from favorites from the personal space + Given user "Alice" has created folder "parent" + And user "Alice" has uploaded file "filesForUpload/textfile.txt" to "/parent/textfile.txt" + And user "Alice" has marked file "parent/textfile.txt" as favorite from space "Personal" + When user "Alice" unmarks file "parent/textfile.txt" as favorite from space "Personal" using the Graph API + Then the HTTP status code should be "204" + And as user "Alice" file "parent/textfile.txt" should not be favorited + + + Scenario: remove folder from favorites from the personal space + Given user "Alice" has created folder "parent" + And user "Alice" has marked folder "parent" as favorite from space "Personal" + When user "Alice" unmarks folder "parent" as favorite from space "Personal" using the Graph API + Then the HTTP status code should be "204" + And as user "Alice" folder "parent" should not be favorited + + + Scenario: remove file from favorites from the shares + Given user "Brian" has been created with default attributes + And user "Alice" has created folder "parent" + And user "Alice" has uploaded file "filesForUpload/textfile.txt" to "/parent/textfile.txt" + And user "Alice" has sent the following resource share invitation: + | resource | parent/textfile.txt | + | space | Personal | + | sharee | Brian | + | shareType | user | + | permissionsRole | Viewer | + And user "Brian" has a share "textfile.txt" synced + And user "Brian" has marked file "textfile.txt" as favorite from space "Shares" + When user "Brian" unmarks file "textfile.txt" as favorite from space "Shares" using the Graph API + Then the HTTP status code should be "204" + And as user "Brian" file "Shares/textfile.txt" should not be favorited + + + Scenario: remove folder from favorites from the shares + Given user "Brian" has been created with default attributes + And user "Alice" has created folder "parent" + And user "Alice" has created folder "parent/sub" + And user "Alice" has sent the following resource share invitation: + | resource | parent | + | space | Personal | + | sharee | Brian | + | shareType | user | + | permissionsRole | Viewer | + And user "Brian" has a share "parent" synced + And user "Brian" has marked folder "parent/sub" as favorite from space "Shares" + When user "Brian" unmarks folder "parent/sub" as favorite from space "Shares" using the Graph API + Then the HTTP status code should be "204" + And as user "Brian" folder "Shares/parent/sub" should not be favorited + + + Scenario: remove file from favorites from the project space + Given user "Brian" has been created with default attributes + And the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API + And using spaces DAV path + And user "Alice" has created a space "new-space" with the default quota using the Graph API + And user "Alice" has uploaded a file inside space "new-space" with content "hello world" to "text.txt" + And user "Alice" has sent the following space share invitation: + | space | new-space | + | sharee | Brian | + | shareType | user | + | permissionsRole | Space Viewer | + And user "Brian" has marked file "text.txt" as favorite from space "new-space" + When user "Brian" unmarks file "text.txt" as favorite from space "new-space" using the Graph API + Then the HTTP status code should be "204" + + + Scenario: remove folder from favorites from the project space + Given user "Brian" has been created with default attributes + And the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API + And using spaces DAV path + And user "Alice" has created a space "new-space" with the default quota using the Graph API + And user "Alice" has created a folder "space-folder" in space "new-space" + And user "Alice" has sent the following space share invitation: + | space | new-space | + | sharee | Brian | + | shareType | user | + | permissionsRole | Space Viewer | + And user "Brian" has marked folder "space-folder" as favorite from space "new-space" + When user "Brian" unmarks folder "space-folder" as favorite from space "new-space" using the Graph API + Then the HTTP status code should be "204" diff --git a/tests/acceptance/features/apiSearch1/favoriteSearch.feature b/tests/acceptance/features/apiSearch1/favoriteSearch.feature new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/acceptance/features/apiSpacesShares/favorite.feature b/tests/acceptance/features/apiSpacesShares/favorite.feature deleted file mode 100644 index 90784350c0..0000000000 --- a/tests/acceptance/features/apiSpacesShares/favorite.feature +++ /dev/null @@ -1,68 +0,0 @@ -Feature: favorite - As a user - I want to favorite resources - So that I can access them quickly - - Background: - Given these users have been created with default attributes: - | username | - | Alice | - | Brian | - And using spaces DAV path - And user "Alice" has created folder "/PARENT" - - - Scenario: favorite a received share itself - Given user "Alice" has sent the following resource share invitation: - | resource | PARENT | - | space | Personal | - | sharee | Brian | - | shareType | user | - | permissionsRole | Editor | - And user "Brian" has a share "PARENT" synced - When user "Brian" favorites element "/PARENT" in space "Shares" using the WebDAV API - Then the HTTP status code should be "207" - And as user "Brian" folder "/PARENT" inside space "Shares" should be favorited - - - Scenario: favorite a file inside of a received share - Given user "Alice" has uploaded file with content "some data" to "/PARENT/parent.txt" - And user "Alice" has sent the following resource share invitation: - | resource | PARENT | - | space | Personal | - | sharee | Brian | - | shareType | user | - | permissionsRole | Editor | - And user "Brian" has a share "PARENT" synced - When user "Brian" favorites element "/PARENT/parent.txt" in space "Shares" using the WebDAV API - Then the HTTP status code should be "207" - And as user "Brian" file "/PARENT/parent.txt" inside space "Shares" should be favorited - - - Scenario: favorite a folder inside of a received share - Given user "Alice" has created folder "/PARENT/sub-folder" - And user "Alice" has sent the following resource share invitation: - | resource | PARENT | - | space | Personal | - | sharee | Brian | - | shareType | user | - | permissionsRole | Editor | - And user "Brian" has a share "PARENT" synced - When user "Brian" favorites element "/PARENT/sub-folder" in space "Shares" using the WebDAV API - Then the HTTP status code should be "207" - And as user "Brian" folder "/PARENT/sub-folder" inside space "Shares" should be favorited - - - Scenario: sharee file favorite state should not change the favorite state of sharer - Given user "Alice" has uploaded file with content "some data" to "/PARENT/parent.txt" - And user "Alice" has sent the following resource share invitation: - | resource | PARENT/parent.txt | - | space | Personal | - | sharee | Brian | - | shareType | user | - | permissionsRole | File Editor | - And user "Brian" has a share "parent.txt" synced - When user "Brian" favorites element "/parent.txt" in space "Shares" using the WebDAV API - Then the HTTP status code should be "207" - And as user "Brian" file "/parent.txt" inside space "Shares" should be favorited - And as user "Alice" file "/PARENT/parent.txt" inside space "Personal" should not be favorited diff --git a/tests/acceptance/features/coreApiFavorites/favorites.feature b/tests/acceptance/features/coreApiFavorites/favorites.feature deleted file mode 100644 index bf1a1b8fc7..0000000000 --- a/tests/acceptance/features/coreApiFavorites/favorites.feature +++ /dev/null @@ -1,191 +0,0 @@ -Feature: favorite - As a user - I want to favorite resources - So that I can access them quickly - - Background: - Given using OCS API version "1" - And user "Alice" has been created with default attributes - And user "Alice" has uploaded file with content "some data" to "/textfile0.txt" - And user "Alice" has uploaded file with content "some data" to "/textfile1.txt" - And user "Alice" has uploaded file with content "some data" to "/textfile2.txt" - And user "Alice" has uploaded file with content "some data" to "/textfile3.txt" - And user "Alice" has uploaded file with content "some data" to "/textfile4.txt" - And user "Alice" has created folder "/FOLDER" - And user "Alice" has created folder "/PARENT" - And user "Alice" has uploaded file with content "some data" to "/PARENT/parent.txt" - - @issue-1263 - Scenario Outline: favorite a folder - Given using DAV path - When user "Alice" favorites element "/FOLDER" using the WebDAV API - Then the HTTP status code should be "207" - And as user "Alice" folder "/FOLDER" should be favorited - When user "Alice" gets the following properties of folder "/FOLDER" using the WebDAV API - | propertyName | - | oc:favorite | - Then the HTTP status code should be "207" - And the single response should contain a property "oc:favorite" with value "1" - Examples: - | dav-path-version | - | old | - | new | - | spaces | - - @issue-1263 - Scenario Outline: unfavorite a folder - Given using DAV path - And user "Alice" has favorited element "/FOLDER" - When user "Alice" unfavorites element "/FOLDER" using the WebDAV API - Then the HTTP status code should be "207" - And as user "Alice" folder "/FOLDER" should not be favorited - When user "Alice" gets the following properties of folder "/FOLDER" using the WebDAV API - | propertyName | - | oc:favorite | - Then the HTTP status code should be "207" - And the single response should contain a property "oc:favorite" with value "0" - Examples: - | dav-path-version | - | old | - | new | - | spaces | - - @smokeTest @issue-1263 - Scenario Outline: favorite a file - Given using DAV path - When user "Alice" favorites element "/textfile0.txt" using the WebDAV API - Then the HTTP status code should be "207" - And as user "Alice" file "/textfile0.txt" should be favorited - When user "Alice" gets the following properties of file "/textfile0.txt" using the WebDAV API - | propertyName | - | oc:favorite | - Then the HTTP status code should be "207" - And the single response should contain a property "oc:favorite" with value "1" - Examples: - | dav-path-version | - | old | - | new | - | spaces | - - @smokeTest @issue-1263 - Scenario Outline: unfavorite a file - Given using DAV path - And user "Alice" has favorited element "/textfile0.txt" - When user "Alice" unfavorites element "/textfile0.txt" using the WebDAV API - Then the HTTP status code should be "207" - And as user "Alice" file "/textfile0.txt" should not be favorited - When user "Alice" gets the following properties of file "/textfile0.txt" using the WebDAV API - | propertyName | - | oc:favorite | - Then the HTTP status code should be "207" - And the single response should contain a property "oc:favorite" with value "0" - Examples: - | dav-path-version | - | old | - | new | - | spaces | - - @smokeTest @issue-1228 - Scenario Outline: get favorited elements of a folder - Given using DAV path - When user "Alice" favorites element "/FOLDER" using the WebDAV API - And user "Alice" favorites element "/textfile0.txt" using the WebDAV API - And user "Alice" favorites element "/textfile1.txt" using the WebDAV API - Then the HTTP status code should be "207" - And user "Alice" should have the following favorited items - | /FOLDER | - | /textfile0.txt | - | /textfile1.txt | - Examples: - | dav-path-version | - | old | - | new | - | spaces | - - @issue-1228 - Scenario Outline: get favorited elements of a subfolder - Given using DAV path - And user "Alice" has created folder "/subfolder" - And user "Alice" has uploaded file with content "some data" to "/subfolder/textfile0.txt" - And user "Alice" has uploaded file with content "some data" to "/subfolder/textfile1.txt" - And user "Alice" has uploaded file with content "some data" to "/subfolder/textfile2.txt" - When user "Alice" favorites element "/subfolder/textfile0.txt" using the WebDAV API - And user "Alice" favorites element "/subfolder/textfile1.txt" using the WebDAV API - And user "Alice" favorites element "/subfolder/textfile2.txt" using the WebDAV API - And user "Alice" unfavorites element "/subfolder/textfile1.txt" using the WebDAV API - Then the HTTP status code should be "207" - And user "Alice" should have the following favorited items - | /subfolder/textfile0.txt | - | /subfolder/textfile2.txt | - And user "Alice" should not have the following favorited items - | /subfolder/textfile1.txt | - Examples: - | dav-path-version | - | old | - | new | - | spaces | - - @issue-1228 - Scenario Outline: get favorited elements and limit count of entries - Given using DAV path - And user "Alice" has favorited element "/textfile0.txt" - And user "Alice" has favorited element "/textfile1.txt" - And user "Alice" has favorited element "/textfile2.txt" - And user "Alice" has favorited element "/textfile3.txt" - And user "Alice" has favorited element "/textfile4.txt" - When user "Alice" lists the favorites and limits the result to 3 elements using the WebDAV API - Then the search result should contain any "3" of these entries: - | /textfile0.txt | - | /textfile1.txt | - | /textfile2.txt | - | /textfile3.txt | - | /textfile4.txt | - Examples: - | dav-path-version | - | old | - | new | - | spaces | - - @issue-1228 - Scenario Outline: get favorited elements paginated in subfolder - Given using DAV path - And user "Alice" has created folder "/subfolder" - And user "Alice" has copied file "/textfile0.txt" to "/subfolder/textfile0.txt" - And user "Alice" has copied file "/textfile0.txt" to "/subfolder/textfile1.txt" - And user "Alice" has copied file "/textfile0.txt" to "/subfolder/textfile2.txt" - And user "Alice" has copied file "/textfile0.txt" to "/subfolder/textfile3.txt" - And user "Alice" has copied file "/textfile0.txt" to "/subfolder/textfile4.txt" - And user "Alice" has copied file "/textfile0.txt" to "/subfolder/textfile5.txt" - And user "Alice" has favorited element "/subfolder/textfile0.txt" - And user "Alice" has favorited element "/subfolder/textfile1.txt" - And user "Alice" has favorited element "/subfolder/textfile2.txt" - And user "Alice" has favorited element "/subfolder/textfile3.txt" - And user "Alice" has favorited element "/subfolder/textfile4.txt" - And user "Alice" has favorited element "/subfolder/textfile5.txt" - When user "Alice" lists the favorites and limits the result to 3 elements using the WebDAV API - Then the search result should contain any "3" of these entries: - | /subfolder/textfile0.txt | - | /subfolder/textfile1.txt | - | /subfolder/textfile2.txt | - | /subfolder/textfile3.txt | - | /subfolder/textfile4.txt | - Examples: - | dav-path-version | - | old | - | new | - | spaces | - - @issue-1228 - Scenario Outline: favoriting a folder does not change the favorite state of elements inside the folder - Given using DAV path - When user "Alice" favorites element "/PARENT/parent.txt" using the WebDAV API - And user "Alice" favorites element "/PARENT" using the WebDAV API - Then the HTTP status code should be "207" - And user "Alice" should have the following favorited items - | /PARENT | - | /PARENT/parent.txt | - Examples: - | dav-path-version | - | old | - | new | - | spaces | diff --git a/tests/acceptance/features/coreApiFavorites/favoritesSharingToShares.feature b/tests/acceptance/features/coreApiFavorites/favoritesSharingToShares.feature deleted file mode 100644 index d2c8517c80..0000000000 --- a/tests/acceptance/features/coreApiFavorites/favoritesSharingToShares.feature +++ /dev/null @@ -1,114 +0,0 @@ -@skipOnReva -Feature: favorite - As a user - I want to favorite the shared resources - So that I can access them quickly - - Background: - Given user "Alice" has been created with default attributes - And user "Alice" has created folder "/PARENT" - And user "Alice" has uploaded file with content "some data" to "/PARENT/parent.txt" - - - Scenario Outline: favorite a file inside of a received share - Given using DAV path - And user "Brian" has been created with default attributes - And user "Alice" has sent the following resource share invitation: - | resource | PARENT | - | space | Personal | - | sharee | Brian | - | shareType | user | - | permissionsRole | Editor | - And user "Brian" has a share "PARENT" synced - When user "Brian" favorites element "/Shares/PARENT/parent.txt" using the WebDAV API - Then the HTTP status code should be "207" - And as user "Brian" file "/Shares/PARENT/parent.txt" should be favorited - Examples: - | dav-path-version | - | old | - | new | - | spaces | - - - Scenario Outline: favorite a folder inside of a received share - Given using DAV path - And user "Brian" has been created with default attributes - And user "Alice" has created folder "/PARENT/sub-folder" - And user "Alice" has sent the following resource share invitation: - | resource | PARENT | - | space | Personal | - | sharee | Brian | - | shareType | user | - | permissionsRole | Editor | - And user "Brian" has a share "PARENT" synced - When user "Brian" favorites element "/Shares/PARENT/sub-folder" using the WebDAV API - Then the HTTP status code should be "207" - And as user "Brian" folder "/Shares/PARENT/sub-folder" should be favorited - Examples: - | dav-path-version | - | old | - | new | - | spaces | - - - Scenario Outline: favorite a received share itself - Given using DAV path - And user "Brian" has been created with default attributes - And user "Alice" has sent the following resource share invitation: - | resource | PARENT | - | space | Personal | - | sharee | Brian | - | shareType | user | - | permissionsRole | Editor | - And user "Brian" has a share "PARENT" synced - When user "Brian" favorites element "/Shares/PARENT" using the WebDAV API - Then the HTTP status code should be "207" - And as user "Brian" folder "/Shares/PARENT" should be favorited - Examples: - | dav-path-version | - | old | - | new | - | spaces | - - @issue-1228 - Scenario Outline: moving a favorite file out of a share keeps favorite state - Given using DAV path - And user "Brian" has been created with default attributes - And user "Alice" has sent the following resource share invitation: - | resource | PARENT | - | space | Personal | - | sharee | Brian | - | shareType | user | - | permissionsRole | Editor | - And user "Brian" has a share "PARENT" synced - And user "Brian" has favorited element "/Shares/PARENT/parent.txt" - When user "Brian" moves file "/Shares/PARENT/parent.txt" to "/taken_out.txt" using the WebDAV API - Then the HTTP status code should be "201" - And as "Brian" file "/taken_out.txt" should exist - And as user "Brian" file "/taken_out.txt" should be favorited - Examples: - | dav-path-version | - | old | - | new | - | spaces | - - - Scenario Outline: sharee file favorite state should not change the favorite state of sharer - Given using DAV path - And user "Brian" has been created with default attributes - And user "Alice" has sent the following resource share invitation: - | resource | PARENT/parent.txt | - | space | Personal | - | sharee | Brian | - | shareType | user | - | permissionsRole | File Editor | - And user "Brian" has a share "parent.txt" synced - When user "Brian" favorites element "/Shares/parent.txt" using the WebDAV API - Then the HTTP status code should be "207" - And as user "Brian" file "/Shares/parent.txt" should be favorited - And as user "Alice" file "/PARENT/parent.txt" should not be favorited - Examples: - | dav-path-version | - | old | - | new | - | spaces | diff --git a/tests/acceptance/scripts/run_api_tests.sh b/tests/acceptance/scripts/run_api_tests.sh index acfba7b51d..6228420a83 100755 --- a/tests/acceptance/scripts/run_api_tests.sh +++ b/tests/acceptance/scripts/run_api_tests.sh @@ -72,7 +72,6 @@ SUITES=( CORE_SUITES=( "coreApiAuth" "coreApiCapabilities" - "coreApiFavorites" "coreApiMain" "coreApiShareCreateSpecialToShares1" "coreApiShareCreateSpecialToShares2"