From 3fadeed33a59f1fc666c70793160dc7307585904 Mon Sep 17 00:00:00 2001 From: prashant-gurung899 Date: Wed, 25 Sep 2024 16:26:13 +0545 Subject: [PATCH] add tests to check activites of space after updating public share link Signed-off-by: prashant-gurung899 --- tests/acceptance/bootstrap/GraphContext.php | 22 ++ .../apiActivities/shareActivities.feature | 373 ++++++++++++++++++ 2 files changed, 395 insertions(+) diff --git a/tests/acceptance/bootstrap/GraphContext.php b/tests/acceptance/bootstrap/GraphContext.php index 856da67d92d..769c93285d1 100644 --- a/tests/acceptance/bootstrap/GraphContext.php +++ b/tests/acceptance/bootstrap/GraphContext.php @@ -2839,6 +2839,28 @@ public function userListsTheActivitiesOfSpaceUsingTheGraphApi(string $user, stri $this->featureContext->setResponse($response); } + /** + * @When the public tries to check the activities of space :spaceName of user :user with password :password" + * + * @param string $spaceName + * @param string $user + * @param string $password + * + * @return void + */ + public function thePublicTriesToCheckTheActivitiesOfSpaceWithPassword(string $spaceName, string $user, string $password): void { + $spaceId = ($this->featureContext->spacesContext->getSpaceByName($user, $spaceName))["id"]; + $password = $this->featureContext->getActualPassword($password); + $response = GraphHelper::getActivities( + $this->featureContext->getBaseUrl(), + $this->featureContext->getStepLineRef(), + "public", + $password, + $spaceId + ); + $this->featureContext->setResponse($response); + } + /** * @When /^user "([^"]*)" lists the activities for (?:folder|file) "([^"]*)" of space "([^"]*)" with (depth|limit) "([^"]*)" using the Graph API/ * diff --git a/tests/acceptance/features/apiActivities/shareActivities.feature b/tests/acceptance/features/apiActivities/shareActivities.feature index c1022d1b86d..5ba0e4845cc 100644 --- a/tests/acceptance/features/apiActivities/shareActivities.feature +++ b/tests/acceptance/features/apiActivities/shareActivities.feature @@ -1076,3 +1076,376 @@ Feature: check share activity } } """ + + + Scenario: check space public link change activity + Given the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API + And user "Alice" has created a space "new-space" with the default quota using the Graph API + And user "Alice" has created the following space link share: + | space | new-space | + | permissionsRole | view | + | password | %public% | + And user "Alice" has updated the last resource link share with + | space | new-space | + | permissionsRole | edit | + | expirationDateTime | 2200-07-15T14:00:00.000Z | + | password | 6a0Q;A3 +i^m[ | + When user "Alice" lists the activities of space "new-space" 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} 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 {field} for a link {token} on {resource}" + } + } + } + } + }, + { + "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 {field} for a link {token} on {resource}" + }, + "variables": { + "type": "object", + "required": ["field","folder","resource","token","user"], + "properties": { + "field": { + "type": "object", + "required": ["id","name"], + "properties": { + "id": { + "type": "string", + "pattern": "%file_id_pattern%" + }, + "name": { + "const": "permission" + } + } + }, + "folder": { + "type": "object", + "required": ["id","name"], + "properties": { + "id": { + "type": "string", + "pattern": "%user_id_pattern%" + }, + "displayName": { + "const": "new-space" + } + } + }, + "resource": { + "type": "object", + "required": ["id","name"], + "properties": { + "id": { + "type": "string", + "pattern": "%file_id_pattern%" + }, + "displayName": { + "const": "new-space" + } + } + }, + "token": { + "type": "object", + "required": ["id","name"], + "properties": { + "id": { + "type": "string", + "pattern": "%user_id_pattern%" + }, + "displayName": { + "const": "xVZQNFKvYEUUTbL" + } + } + }, + "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" + } + } + } + } + } + ] + } + } + } + } + """ + + + Scenario: check activities of a file from space after updating public link change + Given using spaces DAV path + And the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API + And user "Alice" has created a space "new-space" with the default quota using the Graph API + And user "Alice" has uploaded a file inside space "new-space" with content "some content" to "textfile.txt" + And user "Alice" has created the following resource link share: + | resource | textfile.txt | + | space | new-space | + | permissionsRole | view | + | password | %public% | + And user "Alice" has updated the last resource link share with + | resource | textfile.txt | + | space | new-space | + | permissionsRole | edit | + | expirationDateTime | 2200-07-15T14:00:00.000Z | + | password | 6a0Q;A3 +i^m[ | + When user "Alice" lists the activities for file "textfile.txt" of space "new-space" 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": 4, + "maxItems": 4, + "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": { + "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 {field} for a link {token} on {resource}" + } + } + } + } + }, + { + "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 {field} for a link {token} on {resource}" + }, + "variables": { + "type": "object", + "required": ["field","folder","resource","token","user"], + "properties": { + "field": { + "type": "object", + "required": ["id","name"], + "properties": { + "id": { + "type": "string", + "pattern": "%file_id_pattern%" + }, + "name": { + "const": "permission" + } + } + }, + "folder": { + "type": "object", + "required": ["id","name"], + "properties": { + "id": { + "type": "string", + "pattern": "%user_id_pattern%" + }, + "displayName": { + "const": "new-space" + } + } + }, + "resource": { + "type": "object", + "required": ["id","name"], + "properties": { + "id": { + "type": "string", + "pattern": "%file_id_pattern%" + }, + "displayName": { + "const": "textfile.txt" + } + } + }, + "token": { + "type": "object", + "required": ["id","name"], + "properties": { + "id": { + "type": "string", + "pattern": "%user_id_pattern%" + }, + "displayName": { + "const": "MRRNMYVaiBLYVNb" + } + } + }, + "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" + } + } + } + } + } + ] + } + } + } + } + """ + + + Scenario: public tries to check space public link change activity + Given the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API + And user "Alice" has created a space "new-space" with the default quota using the Graph API + And user "Alice" has created the following space link share: + | space | new-space | + | permissionsRole | view | + | password | %public% | + And user "Alice" has updated the last resource link share with + | space | new-space | + | permissionsRole | edit | + | expirationDateTime | 2200-07-15T14:00:00.000Z | + | password | 6a0Q;A3 +i^m[ | + When the public tries to check the activities of space "new-space" of user "Alice" with password "%public%"" + Then the HTTP status code should be "401"