Skip to content

Commit

Permalink
add test to check acivities by sharee
Browse files Browse the repository at this point in the history
Signed-off-by: prashant-gurung899 <[email protected]>
  • Loading branch information
prashant-gurung899 committed Sep 24, 2024
1 parent 8ba090e commit 97798cf
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 15 deletions.
36 changes: 34 additions & 2 deletions tests/acceptance/bootstrap/GraphContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -2798,7 +2798,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
Expand All @@ -2808,7 +2808,39 @@ public function getPermissionRoleDefinitionUsingGraphAPI(string $user, string $p
* @throws Exception
*/
public function userListsTheActivitiesForResourceOfSpaceUsingTheGraphAPI(string $user, string $resource, string $spaceName): void {
$resourceId = $this->featureContext->spacesContext->getResourceId($user, $spaceName, $resource);
if ($spaceName === "Shares") {
$resourceId = GraphHelper::getShareMountId(
$this->featureContext->getBaseUrl(),
$this->featureContext->getStepLineRef(),
$user,
$this->featureContext->getPasswordForUser($user),
$resource
);
} else {
$resourceId = $this->featureContext->spacesContext->getResourceId($user, $spaceName, $resource);
}
$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 owned by user :user1 from space :spaceName using the Graph API
*
* @param string $user
* @param string $file
* @param string $owner
* @param string $spaceName
*
* @return void
*/
public function userTriesToListActivitiesOfUnsharedFile(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(),
Expand Down
16 changes: 8 additions & 8 deletions tests/acceptance/features/apiActivities/activities.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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
"""
Expand Down Expand Up @@ -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
"""
Expand Down Expand Up @@ -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
"""
Expand Down Expand Up @@ -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
"""
Expand Down Expand Up @@ -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
"""
Expand Down Expand Up @@ -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
"""
Expand Down Expand Up @@ -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
"""
Expand Down Expand Up @@ -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
"""
Expand Down
71 changes: 66 additions & 5 deletions tests/acceptance/features/apiActivities/shareActivities.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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
"""
Expand Down Expand Up @@ -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
"""
Expand Down Expand Up @@ -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
"""
Expand Down Expand Up @@ -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
"""
Expand Down Expand Up @@ -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
"""
Expand Down Expand Up @@ -1076,3 +1076,64 @@ 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" lists the activities of folder "FOLDER" from space "Shares" using the Graph API
Then the HTTP status code should be "200"
And the JSON data of the response should match
"""
{
"type": "object",
"required": ["value"],
"properties": {
"value": {
"type": "array",
"minItems": 0,
"maxItems": 0,
"uniqueItems": true,
"items": {
}
}
}
}
"""

@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" owned by user "Alice" from space "Personal" 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 folder 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"

0 comments on commit 97798cf

Please sign in to comment.