From 7163d8c5436a18ce2f0db56b6789fee4d01dd340 Mon Sep 17 00:00:00 2001 From: prashant-gurung899 Date: Tue, 1 Oct 2024 12:40:07 +0545 Subject: [PATCH] add tests to check activites of file after public edits it Signed-off-by: prashant-gurung899 --- .../bootstrap/PublicWebDavContext.php | 24 ++- tests/acceptance/config/behat.yml | 1 + .../apiActivities/shareActivities.feature | 162 ++++++++++++++++++ 3 files changed, 186 insertions(+), 1 deletion(-) diff --git a/tests/acceptance/bootstrap/PublicWebDavContext.php b/tests/acceptance/bootstrap/PublicWebDavContext.php index 3d8c3e326cf..44f18718b68 100644 --- a/tests/acceptance/bootstrap/PublicWebDavContext.php +++ b/tests/acceptance/bootstrap/PublicWebDavContext.php @@ -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 diff --git a/tests/acceptance/config/behat.yml b/tests/acceptance/config/behat.yml index 77adc1a097e..476e8717c52 100644 --- a/tests/acceptance/config/behat.yml +++ b/tests/acceptance/config/behat.yml @@ -403,6 +403,7 @@ default: - FeatureContext: *common_feature_context_params - SharingNgContext: - GraphContext: + - PublicWebDavContext: apiCollaboration: paths: diff --git a/tests/acceptance/features/apiActivities/shareActivities.feature b/tests/acceptance/features/apiActivities/shareActivities.feature index 08e6df6c9cf..8acc15335bd 100644 --- a/tests/acceptance/features/apiActivities/shareActivities.feature +++ b/tests/acceptance/features/apiActivities/shareActivities.feature @@ -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"