From 59673bb176e8ebfefb338e2609df7690e6dfb9ac Mon Sep 17 00:00:00 2001 From: prashant-gurung899 Date: Mon, 19 Aug 2024 09:55:19 +0545 Subject: [PATCH] add test to check acivities by sharee Signed-off-by: prashant-gurung899 --- tests/acceptance/bootstrap/GraphContext.php | 52 +++++++++++++++++- .../features/apiActivities/activities.feature | 22 ++++---- .../apiActivities/shareActivities.feature | 54 +++++++++++++++++-- 3 files changed, 110 insertions(+), 18 deletions(-) diff --git a/tests/acceptance/bootstrap/GraphContext.php b/tests/acceptance/bootstrap/GraphContext.php index 24f57057ba0..11cc694de84 100644 --- a/tests/acceptance/bootstrap/GraphContext.php +++ b/tests/acceptance/bootstrap/GraphContext.php @@ -2802,7 +2802,7 @@ public function getPermissionRoleDefinitionUsingGraphAPI(string $user, string $p } /** - * @When /^user "([^"]*)" lists the activities for (?:folder|file) "([^"]*)" of space "([^"]*)" using the Graph API/ + * @When /^user "([^"]*)" lists the activities of (?:folder|file) "([^"]*)" from space "([^"]*)" using the Graph API/ * * @param string $user * @param string $resource @@ -2823,6 +2823,54 @@ public function userListsTheActivitiesForResourceOfSpaceUsingTheGraphAPI(string $this->featureContext->setResponse($response); } + /** + * @When user :user tries to list the activities of folder :folder with share mount-point id using the Graph API + * + * @param string $user + * @param string $folder + * + * @return void + */ + public function userTriesToListTheActivitiesOfFolderWithShareMountIdPointIdUsingTheGraphApi(string $user, string $folder): void { + $resourceId = GraphHelper::getShareMountId( + $this->featureContext->getBaseUrl(), + $this->featureContext->getStepLineRef(), + $user, + $this->featureContext->getPasswordForUser($user), + $folder + ); + $response = GraphHelper::getActivities( + $this->featureContext->getBaseUrl(), + $this->featureContext->getStepLineRef(), + $user, + $this->featureContext->getPasswordForUser($user), + $resourceId + ); + $this->featureContext->setResponse($response); + } + + /** + * @When user :user tries to list the activities of file :file from space :spaceName owned by user :owner using the Graph API + * + * @param string $user + * @param string $file + * @param string $owner + * @param string $spaceName + * + * @return void + */ + public function userTriesToListActivitiesOfFileFromSpaceOwnedByUserUsingTheGraphApi(string $user, string $file, string $owner, string $spaceName): void { + $resourceId = $this->featureContext->spacesContext->getResourceId($owner, $spaceName, $file); + $response = GraphHelper::getActivities( + $this->featureContext->getBaseUrl(), + $this->featureContext->getStepLineRef(), + $user, + $this->featureContext->getPasswordForUser($user), + $resourceId + ); + $this->featureContext->setResponse($response); + } + /** * @When user :user lists the activities of space :spaceName using the Graph API * @@ -2844,7 +2892,7 @@ public function userListsTheActivitiesOfSpaceUsingTheGraphApi(string $user, stri } /** - * @When /^user "([^"]*)" lists the activities for (?:folder|file) "([^"]*)" of space "([^"]*)" with (depth|limit) "([^"]*)" using the Graph API/ + * @When /^user "([^"]*)" lists the activities of (?:folder|file) "([^"]*)" from space "([^"]*)" with (depth|limit) "([^"]*)" using the Graph API/ * * @param string $user * @param string $resource diff --git a/tests/acceptance/features/apiActivities/activities.feature b/tests/acceptance/features/apiActivities/activities.feature index 29cc288334b..759032451cd 100644 --- a/tests/acceptance/features/apiActivities/activities.feature +++ b/tests/acceptance/features/apiActivities/activities.feature @@ -10,7 +10,7 @@ Feature: check activities Scenario: check activities after uploading a file and a folder Given user "Alice" has uploaded file with content "ownCloud test text file 0" to "/textfile.txt" And user "Alice" has created folder "/FOLDER" - When user "Alice" lists the activities for file "textfile.txt" of space "Personal" using the Graph API + When user "Alice" lists the activities of file "textfile.txt" from space "Personal" using the Graph API Then the HTTP status code should be "200" And the JSON data of the response should match """ @@ -100,7 +100,7 @@ Feature: check activities } } """ - When user "Alice" lists the activities for folder "FOLDER" of space "Personal" using the Graph API + When user "Alice" lists the activities of folder "FOLDER" from space "Personal" using the Graph API Then the HTTP status code should be "200" And the JSON data of the response should match """ @@ -434,7 +434,7 @@ Feature: check activities And user "Alice" has created folder "/New Folder" And user "Alice" has moved file "textfile.txt" to "New Folder/textfile.txt" And user "Alice" has moved folder "FOLDER" to "New Folder/FOLDER" - When user "Alice" lists the activities for file "New Folder/textfile.txt" of space "Personal" using the Graph API + When user "Alice" lists the activities of file "New Folder/textfile.txt" from space "Personal" using the Graph API Then the HTTP status code should be "200" And the JSON data of the response should match """ @@ -544,7 +544,7 @@ Feature: check activities } } """ - When user "Alice" lists the activities for folder "New Folder/FOLDER" of space "Personal" using the Graph API + When user "Alice" lists the activities of folder "New Folder/FOLDER" from space "Personal" using the Graph API Then the HTTP status code should be "200" And the JSON data of the response should match """ @@ -661,7 +661,7 @@ Feature: check activities And user "Alice" has created folder "/FOLDER" And user "Alice" has moved file "textfile.txt" to "renamed.txt" And user "Alice" has moved folder "/FOLDER" to "RENAMED FOLDER" - When user "Alice" lists the activities for file "renamed.txt" of space "Personal" using the Graph API + When user "Alice" lists the activities of file "renamed.txt" from space "Personal" using the Graph API Then the HTTP status code should be "200" And the JSON data of the response should match """ @@ -770,7 +770,7 @@ Feature: check activities } } """ - When user "Alice" lists the activities for folder "RENAMED FOLDER" of space "Personal" using the Graph API + When user "Alice" lists the activities of folder "RENAMED FOLDER" from space "Personal" using the Graph API Then the HTTP status code should be "200" And the JSON data of the response should match """ @@ -892,7 +892,7 @@ Feature: check activities And user "Alice" has moved folder "/New Folder/Sub Folder/Folder" to "/New Folder/Sub Folder/Renamed Folder" And user "Alice" has deleted file "/New Folder/Sub Folder/renamed.txt" And user "Alice" has deleted folder "/New Folder/Sub Folder/Renamed Folder" - When user "Alice" lists the activities for folder "/New Folder" of space "Personal" using the Graph API + When user "Alice" lists the activities of folder "/New Folder" from space "Personal" using the Graph API Then the HTTP status code should be "200" And the JSON data of the response should match """ @@ -1236,7 +1236,7 @@ Feature: check activities Scenario: check activity message with different language Given user "Alice" has uploaded file with content "ownCloud test text file" to "textfile.txt" And user "Alice" has switched the system language to "de" using the Graph API - When user "Alice" lists the activities for file "textfile.txt" of space "Personal" using the Graph API + When user "Alice" lists the activities of file "textfile.txt" from space "Personal" using the Graph API Then the HTTP status code should be "200" And the JSON data of the response should match """ @@ -1332,7 +1332,7 @@ Feature: check activities Given user "Alice" has created folder "/New Folder" And user "Alice" has created folder "/New Folder/Sub Folder" And user "Alice" has uploaded file with content "ownCloud test text file 0" to "/New Folder/Sub Folder/textfile.txt" - When user "Alice" lists the activities for folder "New Folder" of space "Personal" with depth "-1" using the Graph API + When user "Alice" lists the activities of folder "New Folder" from space "Personal" with depth "-1" using the Graph API Then the HTTP status code should be "200" And the JSON data of the response should match """ @@ -1461,7 +1461,7 @@ Feature: check activities Given user "Alice" has created folder "/New Folder" And user "Alice" has created folder "/New Folder/Sub Folder" And user "Alice" has uploaded file with content "ownCloud test text file 0" to "/New Folder/Sub Folder/textfile.txt" - When user "Alice" lists the activities for folder "New Folder" of space "Personal" with depth "1" using the Graph API + When user "Alice" lists the activities of folder "New Folder" from space "Personal" with depth "1" using the Graph API Then the HTTP status code should be "200" And the JSON data of the response should match """ @@ -1556,7 +1556,7 @@ Feature: check activities Given user "Alice" has created folder "/New Folder" And user "Alice" has created folder "/New Folder/Sub Folder" And user "Alice" has uploaded file with content "ownCloud test text file 0" to "/New Folder/Sub Folder/textfile.txt" - When user "Alice" lists the activities for folder "New Folder" of space "Personal" with limit "2" using the Graph API + When user "Alice" lists the activities of folder "New Folder" from space "Personal" with limit "2" 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/apiActivities/shareActivities.feature b/tests/acceptance/features/apiActivities/shareActivities.feature index 7637bc9d2c8..6234ea7e84c 100644 --- a/tests/acceptance/features/apiActivities/shareActivities.feature +++ b/tests/acceptance/features/apiActivities/shareActivities.feature @@ -18,7 +18,7 @@ Feature: check share activity | sharee | Brian | | shareType | user | | permissionsRole | Viewer | - When user "Alice" lists the activities for file "textfile.txt" of space "Personal" using the Graph API + When user "Alice" lists the activities of file "textfile.txt" from space "Personal" using the Graph API Then the HTTP status code should be "200" And the JSON data of the response should match """ @@ -138,7 +138,7 @@ Feature: check share activity | shareType | user | | permissionsRole | Viewer | And user "Alice" has removed the access of user "Brian" from resource "textfile.txt" of space "Personal" - When user "Alice" lists the activities for file "textfile.txt" of space "Personal" using the Graph API + When user "Alice" lists the activities of file "textfile.txt" from space "Personal" using the Graph API Then the HTTP status code should be "200" And the JSON data of the response should match """ @@ -275,7 +275,7 @@ Feature: check share activity | space | Personal | | permissionsRole | view | | password | %public% | - When user "Alice" lists the activities for file "textfile.txt" of space "Personal" using the Graph API + When user "Alice" lists the activities of file "textfile.txt" from space "Personal" using the Graph API Then the HTTP status code should be "200" And the JSON data of the response should match """ @@ -381,7 +381,7 @@ Feature: check share activity | permissionsRole | view | | password | %public% | And user "Alice" has removed the last link share of file "textfile.txt" from space "Personal" - When user "Alice" lists the activities for file "textfile.txt" of space "Personal" using the Graph API + When user "Alice" lists the activities of file "textfile.txt" from space "Personal" using the Graph API Then the HTTP status code should be "200" And the JSON data of the response should match """ @@ -511,7 +511,7 @@ Feature: check share activity And user "Brian" has uploaded file with content "some data" to "Shares/FOLDER/newfile.txt" And user "Brian" has uploaded file with content "edited data" to "Shares/FOLDER/newfile.txt" And user "Brian" has deleted file "Shares/FOLDER/newfile.txt" - When user "Alice" lists the activities for file "FOLDER" of space "Personal" using the Graph API + When user "Alice" lists the activities of file "FOLDER" from space "Personal" using the Graph API Then the HTTP status code should be "200" And the JSON data of the response should match """ @@ -1076,3 +1076,47 @@ Feature: check share activity } } """ + + + Scenario: sharee tries to check the activities of a shared folder using share mount-point id + Given user "Alice" has created folder "/FOLDER" + And user "Alice" has sent the following resource share invitation: + | resource | /FOLDER | + | space | Personal | + | sharee | Brian | + | shareType | user | + | permissionsRole | Editor | + And user "Brian" has a share "/FOLDER" synced + And user "Brian" has uploaded file with content "some data" to "Shares/FOLDER/newfile.txt" + And user "Brian" has uploaded file with content "edited data" to "Shares/FOLDER/newfile.txt" + And user "Brian" has deleted file "Shares/FOLDER/newfile.txt" + When user "Brian" tries to list the activities of folder "FOLDER" with share mount-point id using the Graph API + Then the HTTP status code should be "403" + + @issue-9849 + Scenario: sharee tries to check the activities of a shared folder using file-id + Given user "Alice" has created folder "/FOLDER" + And user "Alice" has uploaded file with content "some data" to "FOLDER/newfile.txt" + And user "ALice" has uploaded file with content "edited data" to "FOLDER/newfile.txt" + And user "ALice" has deleted file "FOLDER/newfile.txt" + And user "Alice" has sent the following resource share invitation: + | resource | /FOLDER | + | space | Personal | + | sharee | Brian | + | shareType | user | + | permissionsRole | Editor | + And user "Brian" has a share "/FOLDER" synced + When user "Brian" lists the activities of folder "FOLDER" from space "Shares" using the Graph API + Then the HTTP status code should be "403" + + @issue-9860 + Scenario: sharee tries to check the activities of unshared file + Given user "Alice" has uploaded file with content "another ownCloud test text file" to "anotherTextfile.txt" + And user "Alice" has sent the following resource share invitation: + | resource | textfile.txt | + | space | Personal | + | sharee | Brian | + | shareType | user | + | permissionsRole | Viewer | + When user "Brian" tries to list the activities of file "anotherTextfile.txt" from space "Personal" owned by user "Alice" using the Graph API + Then the HTTP status code should be "403"