diff --git a/tests/acceptance/bootstrap/PublicWebDavContext.php b/tests/acceptance/bootstrap/PublicWebDavContext.php index 3d8c3e326cf..90f43b4f472 100644 --- a/tests/acceptance/bootstrap/PublicWebDavContext.php +++ b/tests/acceptance/bootstrap/PublicWebDavContext.php @@ -154,6 +154,23 @@ public function deleteFileFromPublicShare(string $fileName, string $publicWebDAV ); } + /** + * @Given /^the public has deleted (?:file|folder|entry) "([^"]*)" from the last public link share using the password "([^"]*)" and (old|new) public WebDAV API$/ + * + * @param string $file + * @param string $password + * @param string $publicWebDAVAPIVersion + * + * @return void + */ + public function thePublicHasDeletedFileFromTheLastPublicLinkShareUsingThePasswordAndNewPublicWebdavApi(string $file, string $password, string $publicWebDAVAPIVersion): void { + if ($publicWebDAVAPIVersion === "old") { + return; + } + $response = $this->deleteFileFromPublicShare($file, $publicWebDAVAPIVersion, $password); + $this->featureContext->theHTTPStatusCodeShouldBe([201, 204], "", $response); + } + /** * @When /^the public deletes (?:file|folder|entry) "([^"]*)" from the last public link share using the password "([^"]*)" and (old|new) public WebDAV API$/ * @@ -554,6 +571,26 @@ 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$/ * 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..dd4f91cbe6c 100644 --- a/tests/acceptance/features/apiActivities/shareActivities.feature +++ b/tests/acceptance/features/apiActivities/shareActivities.feature @@ -1104,3 +1104,467 @@ 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" + + @issue-9676 + Scenario: user checks public's activities on a publicly shared 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 "public test" using the new public 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" + } + } + } + } + } + ] + } + } + } + } + """ + + @issue-9676 + Scenario: user checks public's activities on a publicly shared folder + Given using SharingNG + And user "Alice" has created folder "/FOLDER" + And 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 "added by public user" using the new public WebDAV API + And the public has uploaded file "text.txt" with password "%public%" and content "updated by public user" using the new public WebDAV API + And the public has deleted file "text.txt" from the last public link share using the password "%public%" and new public WebDAV 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 + """ + { + "type": "object", + "required": ["value"], + "properties": { + "value": { + "type": "array", + "minItems": 5, + "maxItems": 5, + "uniqueItems": true, + "items": { + "oneOf": [ + { + "type": "object", + "required": ["id","template","times"], + "properties": { + "id": { + "type": "string", + "pattern": "^%user_id_pattern%$" + }, + "template": { + "type": "object", + "required": ["message","variables"], + "properties": { + "message": { + "const": "{user} added {resource} to {folder}" + }, + "variables": { + "type": "object", + "required": ["folder","resource","user"], + "properties": { + "folder": { + "type": "object", + "required": ["id","name"], + "properties": { + "name": { + "const": "Alice Hansen" + } + } + }, + "resource": { + "type": "object", + "required": ["id","name"], + "properties": { + "name": { + "const": "FOLDER" + } + } + }, + "user": { + "type": "object", + "required": ["id","displayName"], + "properties": { + "id": { + "type": "string", + "pattern": "%user_id_pattern%" + }, + "displayName": { + "const": "Alice Hansen" + } + } + } + } + } + } + } + } + }, + { + "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" + }, + "variables": { + "type": "object", + "required": ["folder","resource","user"], + "properties": { + "folder": { + "type": "object", + "required": ["id","name"], + "properties": { + "name": { + "const": "Alice Hansen" + } + } + }, + "resource": { + "type": "object", + "required": ["id","name"], + "properties": { + "name": { + "const": "FOLDER" + } + } + }, + "user": { + "type": "object", + "required": ["id","displayName"], + "properties": { + "id": { + "type": "string", + "pattern": "%user_id_pattern%" + }, + "displayName": { + "const": "Alice Hansen" + } + } + } + } + } + } + } + } + }, + { + "type": "object", + "required": ["id","template","times"], + "properties": { + "id": { + "type": "string", + "pattern": "^%user_id_pattern%$" + }, + "template": { + "type": "object", + "required": ["message","variables"], + "properties": { + "message": { + "const": "{user} added {resource} to {folder}" + }, + "variables": { + "type": "object", + "required": ["folder","resource","user"], + "properties": { + "folder": { + "type": "object", + "required": ["id","name"], + "properties": { + "name": { + "const": "FOLDER" + } + } + }, + "resource": { + "type": "object", + "required": ["id","name"], + "properties": { + "name": { + "const": "text.txt" + } + } + }, + "user": { + "type": "object", + "required": ["id","displayName"], + "properties": { + "id": { + "type": "string", + "pattern": "[a-zA-z]{15}" + }, + "displayName": { + "const": "Public" + } + } + } + } + } + } + } + } + }, + { + "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": { + "name": { + "const": "FOLDER" + } + } + }, + "resource": { + "type": "object", + "required": ["id","name"], + "properties": { + "name": { + "const": "text.txt" + } + } + }, + "user": { + "type": "object", + "required": ["id","displayName"], + "properties": { + "id": { + "type": "string", + "pattern": "[a-zA-z]{15}" + }, + "displayName": { + "const": "Public" + } + } + } + } + } + } + } + } + }, + { + "type": "object", + "required": ["id","template","times"], + "properties": { + "id": { + "type": "string", + "pattern": "^%user_id_pattern%$" + }, + "template": { + "type": "object", + "required": ["message","variables"], + "properties": { + "message": { + "const": "{user} deleted {resource} from {folder}" + }, + "variables": { + "type": "object", + "required": ["folder","resource","user"], + "properties": { + "folder": { + "type": "object", + "required": ["id","name"], + "properties": { + "name": { + "const": "Alice Hansen" + } + } + }, + "resource": { + "type": "object", + "required": ["id","name"], + "properties": { + "name": { + "const": "text.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" + } + } + } + } + } + ] + } + } + } + } + """ +