diff --git a/tests/acceptance/features/apiGraph/activities.feature b/tests/acceptance/features/apiGraph/activities.feature index e3b22857f1b..7abf36c417c 100644 --- a/tests/acceptance/features/apiGraph/activities.feature +++ b/tests/acceptance/features/apiGraph/activities.feature @@ -3,97 +3,367 @@ Feature: check activities I want to check who made which changes to files So that I can track modifications + Background: + Given user "Alice" has been created with default attributes and without skeleton files + @issue-9712 Scenario: check activities after uploading a file - Given user "Alice" has been created with default attributes and without skeleton files - And user "Alice" has uploaded file with content "ownCloud test text file 0" to "/textfile0.txt" + Given user "Alice" has uploaded file with content "ownCloud test text file 0" to "/textfile0.txt" When user "Alice" checks the activities for file "textfile0.txt" in 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": 1, - "maxItems": 1, - "items": { - "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 {space}" - }, - "variables": { - "type": "object", - "required": ["resource","space","user"], - "properties": { - "resource": { - "type": "object", - "required": ["id","name"], - "properties": { - "id": { - "type": "string", - "pattern": "%file_id_pattern%" - }, - "name": { - "const": "textfile0.txt" + "type": "object", + "required": ["value"], + "properties": { + "value": { + "type": "array", + "minItems": 1, + "maxItems": 1, + "items": { + "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 {space}" + }, + "variables": { + "type": "object", + "required": ["resource","space","user"], + "properties": { + "resource": { + "type": "object", + "required": ["id","name"], + "properties": { + "id": { + "type": "string", + "pattern": "%file_id_pattern%" + }, + "name": { + "const": "textfile0.txt" + } + } + }, + "space": { + "type": "object", + "required": ["id","name"], + "properties": { + "id": { + "type": "string", + "pattern": "^%user_id_pattern%!%user_id_pattern%$" + }, + "name": { + "const": "Alice Hansen" + } + } + }, + "user": { + "type": "object", + "required": ["id","displayName"], + "properties": { + "id": { + "type": "string", + "pattern": "%user_id_pattern%" + }, + "displayName": { + "const": "Alice" + } } } - }, - "space": { - "type": "object", - "required": ["id","name"], - "properties": { - "id": { - "type": "string", - "pattern": "^%user_id_pattern%!%user_id_pattern%$" - }, - "name": { - "const": "Alice Hansen" + } + } + } + }, + "times": { + "type": "object", + "required": ["recordedTime"], + "properties": { + "recordedTime": { + "type": "string", + "format": "date-time" + } + } + } + } + } + } + } + } + """ + + @issue-9712 + Scenario: check activities after deleting a file + Given user "Alice" has uploaded file with content "ownCloud test text file 0" to "/textfile0.txt" + When user "Alice" deletes file "/textfile0.txt" using the WebDAV API + And user "Alice" lists the activities of 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": 2, + "maxItems": 2, + "uniqueItems": true, + "items": { + "oneOf": [ + { + "type": "object", + "required": ["id","template","times"], + "properties": { + "template": { + "type": "object", + "required": ["message","variables"], + "properties": { + "message": { + "const": "{user} added {resource} to {space}" + }, + "variables": { + "type": "object", + "required": ["resource","space","user"], + "properties": { + "resource": { + "type": "object", + "required": ["id", "name"], + "properties": { + "name": { + "const": "textfile0.txt" + } + } + } } } - }, - "user": { - "type": "object", - "required": ["id","displayName"], - "properties": { - "id": { - "type": "string", - "pattern": "%user_id_pattern%" - }, - "displayName": { - "const": "Alice" + } + }, + "times": { + "type": "object", + "required": ["recordedTime"] + } + } + }, + { + "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 {space}" + }, + "variables": { + "type": "object", + "required": ["resource","space","user"], + "properties": { + "resource": { + "type": "object", + "required": ["id","name"], + "properties": { + "id": { + "type": "string", + "pattern": "%file_id_pattern%" + }, + "name": { + "const": "textfile0.txt" + } + } + }, + "space": { + "type": "object", + "required": ["id","name"], + "properties": { + "id": { + "type": "string", + "pattern": "^%file_id_pattern%$" + }, + "name": { + "const": "Alice Hansen" + } + } + }, + "user": { + "type": "object", + "required": ["id","displayName"], + "properties": { + "id": { + "type": "string", + "pattern": "%user_id_pattern%" + }, + "displayName": { + "const": "Alice" + } + } + } } } } + }, + "times": { + "type": "object", + "required": ["recordedTime"], + "properties": { + "recordedTime": { + "type": "string", + "format": "date-time" + } + } } } } - }, - "times": { - "type": "object", - "required": ["recordedTime"], - "properties": { - "recordedTime": { - "type": "string", - "format": "date-time" + ] + } + } + } + } + """ + + @issue-9712 + Scenario: check activities after deleting a folder + Given user "Alice" has created folder "/FOLDER" + When user "Alice" deletes folder "/FOLDER" using the WebDAV API + And user "Alice" lists the activities of 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": 2, + "maxItems": 2, + "uniqueItems": true, + "items": { + "oneOf": [ + { + "type": "object", + "required": ["id","template","times"], + "properties": { + "template": { + "type": "object", + "required": ["message","variables"], + "properties": { + "message": { + "const": "{user} added {resource} to {space}" + }, + "variables": { + "type": "object", + "required": ["resource","space","user"], + "properties": { + "resource": { + "type": "object", + "required": ["id", "name"], + "properties": { + "name": { + "const": "FOLDER" + } + } + } + } + } + } + }, + "times": { + "type": "object", + "required": ["recordedTime"] + } + } + }, + { + "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 {space}" + }, + "variables": { + "type": "object", + "required": ["resource","space","user"], + "properties": { + "resource": { + "type": "object", + "required": ["id","name"], + "properties": { + "id": { + "type": "string", + "pattern": "%file_id_pattern%" + }, + "name": { + "const": "FOLDER" + } + } + }, + "space": { + "type": "object", + "required": ["id","name"], + "properties": { + "id": { + "type": "string", + "pattern": "^%file_id_pattern%$" + }, + "name": { + "const": "Alice Hansen" + } + } + }, + "user": { + "type": "object", + "required": ["id","displayName"], + "properties": { + "id": { + "type": "string", + "pattern": "%user_id_pattern%" + }, + "displayName": { + "const": "Alice" + } + } + } + } + } + } + }, + "times": { + "type": "object", + "required": ["recordedTime"], + "properties": { + "recordedTime": { + "type": "string", + "format": "date-time" + } + } + } } } - } + ] } } } } - } - """ + """ diff --git a/tests/acceptance/features/bootstrap/GraphContext.php b/tests/acceptance/features/bootstrap/GraphContext.php index 9f6e0074ca2..d01ba2b4e3f 100644 --- a/tests/acceptance/features/bootstrap/GraphContext.php +++ b/tests/acceptance/features/bootstrap/GraphContext.php @@ -2785,7 +2785,6 @@ public function getPermissionRoleDefinitionUsingGraphAPI(string $user, string $p * * @return void * @throws Exception - * */ public function userChecksTheActivitiesForResourceInSpaceUsingTheGraphAPI(string $user, string $resource, string $spaceName): void { $resourceId = $this->featureContext->spacesContext->getResourceId($user, $spaceName, $resource); @@ -2798,4 +2797,24 @@ public function userChecksTheActivitiesForResourceInSpaceUsingTheGraphAPI(string ); $this->featureContext->setResponse($response); } + + /** + * @When user :user lists the activities of space :spaceName using the Graph API + * + * @param string $user + * @param string $spaceName + * + * @return void + */ + public function userListsTheActivitiesInSpaceUsingTheGraphApi(string $user, string $spaceName): void { + $spaceId = ($this->featureContext->spacesContext->getSpaceByName($user, $spaceName))["id"]; + $response = GraphHelper::getActivities( + $this->featureContext->getBaseUrl(), + $this->featureContext->getStepLineRef(), + $user, + $this->featureContext->getPasswordForUser($user), + $spaceId + ); + $this->featureContext->setResponse($response); + } }