Skip to content

Commit

Permalink
add tests to check activites of file after public edits it
Browse files Browse the repository at this point in the history
Signed-off-by: prashant-gurung899 <[email protected]>
  • Loading branch information
prashant-gurung899 committed Oct 1, 2024
1 parent d549f48 commit 7163d8c
Show file tree
Hide file tree
Showing 3 changed files with 186 additions and 1 deletion.
24 changes: 23 additions & 1 deletion tests/acceptance/bootstrap/PublicWebDavContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,29 @@ public function publiclyUploadingContentWithPassword(
);
}

/**
/**
* @Given /^the public has uploaded file "([^"]*)" with password "([^"]*)" and content "([^"]*)" using the (old|new) public WebDAV API$/
*
* @param string $filename
* @param string $password
* @param string $content
* @param string $publicWebDAVAPIVersion
*
* @return void
*/
public function thePublicHasUploadedFileWithPasswordAndContentUsingTheNewPublicWebdavApi(string $filename, string $password = '', string $content = 'test', string $publicWebDAVAPIVersion = "old"): void
{
$response = $this->publiclyUploadingContentWithPassword(
$filename,
$password,
$content,
$publicWebDAVAPIVersion
);
$this->featureContext->theHTTPStatusCodeShouldBe([201, 204], "", $response);
}


/**
* @When /^the public uploads file "([^"]*)" with password "([^"]*)" and content "([^"]*)" using the (old|new) public WebDAV API$/
*
* @param string $filename target file name
Expand Down
1 change: 1 addition & 0 deletions tests/acceptance/config/behat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,7 @@ default:
- FeatureContext: *common_feature_context_params
- SharingNgContext:
- GraphContext:
- PublicWebDavContext:

apiCollaboration:
paths:
Expand Down
162 changes: 162 additions & 0 deletions tests/acceptance/features/apiActivities/shareActivities.feature
Original file line number Diff line number Diff line change
Expand Up @@ -1104,3 +1104,165 @@ Feature: check share activity
| 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"


Scenario: user checks public's activities on a file
Given using SharingNG
And user "Alice" has created the following resource link share:
| resource | textfile.txt |
| space | Personal |
| permissionsRole | edit |
| password | %public% |
And the public has uploaded file "textfile.txt" with password "%public%" and content "test" using the new public WebDAV API
# When the public uploads file "textfile.txt" with password "%public%" and content "test" using the new public WebDAV API
# And the public has uploaded file "textfile.txt" with password "%public%" and content "update"
# When the public overwrites file "test.txt" with content "public content" using the new WebDAV 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
"""
{
"type": "object",
"required": ["value"],
"properties": {
"value": {
"type": "array",
"minItems": 3,
"maxItems": 3,
"uniqueItems": true,
"items": {
"oneOf": [
{
"type": "object",
"required": ["id","template","times"],
"properties": {
"template": {
"type": "object",
"required": ["message","variables"],
"properties": {
"message": {
"const": "{user} added {resource} to {folder}"
}
}
}
}
},
{
"type": "object",
"required": ["id","template","times"],
"properties": {
"id": {
"type": "string",
"pattern": "^%user_id_pattern%$"
},
"template": {
"type": "object",
"required": ["message","variables"],
"properties": {
"message": {
"const": "{user} shared {resource} via link"
}
}
}
}
},
{
"type": "object",
"required": ["id","template","times"],
"properties": {
"id": {
"type": "string",
"pattern": "^%user_id_pattern%$"
},
"template": {
"type": "object",
"required": ["message","variables"],
"properties": {
"message": {
"const": "{user} updated {resource} in {folder}"
},
"variables": {
"type": "object",
"required": ["folder","resource","user"],
"properties": {
"folder": {
"type": "object",
"required": ["id","name"],
"properties": {
"id": {
"type": "string",
"pattern": "%user_id_pattern%"
},
"name": {
"const": "Alice Hansen"
}
}
},
"resource": {
"type": "object",
"required": ["id","name"],
"properties": {
"id": {
"type": "string",
"pattern": "%file_id_pattern%"
},
"displayName": {
"const": "textfile.txt"
}
}
},
"user": {
"type": "object",
"required": ["id","displayName"],
"properties": {
"id": {
"type": "string",
"pattern": "[a-zA-z]{15}"
},
"displayName": {
"const": "Public"
}
}
}
}
}
}
},
"times": {
"type": "object",
"required": ["recordedTime"],
"properties": {
"recordedTime": {
"type": "string",
"format": "date-time"
}
}
}
}
}
]
}
}
}
}
"""


Scenario: user checks public's activities on a folder
Given using SharingNG
And user "Alice" has created folder "/FOLDER"
And user "Alice" has uploaded file with content "some data" to "FOLDER/test.txt"
Given user "Alice" has created the following resource link share:
| resource | /FOLDER |
| space | Personal |
| permissionsRole | edit |
| password | %public% |
And the public has uploaded file "text.txt" with password "%public%" and content "test" using the new public WebDAV API
# And the public has uploaded file "public.txt" with content "by public"
# And the public has uploaded file "public.txt" with password "aasd" and content "by public"
# And the public has overwritten file "/FOLDER/public.txt" with content "updated by public"
# And the public creates a file "simple.odt" inside the last shared public link folder with password "%public%" using wopi endpoint
# And the public has uploaded file with content "by public" to "FOLDER/textfile.txt" SELF MADE
# And the public uploaded file with content "updated by public" to "FOLDER/textfile.txt" SELF MADE
When user "Alice" lists the activities of file "/FOLDER" from space "Personal" using the Graph API
Then the HTTP status code should be "200"

0 comments on commit 7163d8c

Please sign in to comment.