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 00ad36d
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 18 deletions.
53 changes: 51 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 @@ -2819,6 +2819,55 @@ public function userListsTheActivitiesForResourceOfSpaceUsingTheGraphAPI(string
$this->featureContext->setResponse($response);
}

/**
* @When user :user tries to list the activities of folder :folder from space :spaceName using share mount-point id using the Graph API
*
* @param string $user
* @param string $folder
* @param string $spaceName
*
* @return void
*/
public function userListsTheActivitiesOfFolderFromSpaceUsingShareMountPointIdUsingTheGraphApi(string $user, string $folder, string $spaceName): 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 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(),
$user,
$this->featureContext->getPasswordForUser($user),
$resourceId
);
$this->featureContext->setResponse($response);
}

/**
* @When user :user lists the activities of space :spaceName using the Graph API
*
Expand All @@ -2840,7 +2889,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
Expand Down
22 changes: 11 additions & 11 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 Expand Up @@ -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
"""
Expand Down Expand Up @@ -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
"""
Expand Down Expand Up @@ -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
"""
Expand Down
54 changes: 49 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,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" from space "Shares" using 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"

0 comments on commit 00ad36d

Please sign in to comment.