add test coverage for activities api for a file

This commit is contained in:
Salipa-Gurung
2024-07-23 16:57:58 +05:45
parent 3787092749
commit 065c4fa027
3 changed files with 149 additions and 0 deletions

View File

@@ -2293,4 +2293,31 @@ class GraphHelper {
self::getRequestHeaders()
);
}
/**
* @param string $baseUrl
* @param string $requestId
* @param string $user
* @param string $password
* @param string $resourceId
*
* @return ResponseInterface
*/
public static function getActivities(
string $baseUrl,
string $requestId,
string $user,
string $password,
string $resourceId
): ResponseInterface {
// 'kql=itemId' filter is required for the current implementation but it might change in future
// See: https://github.com/owncloud/ocis/issues/9194
$fullUrl = self::getBetaFullUrl($baseUrl, "extensions/org.libregraph/activities?kql=itemid%3A$resourceId");
return HttpRequestHelper::get(
$fullUrl,
$requestId,
$user,
$password
);
}
}

View File

@@ -0,0 +1,99 @@
Feature: check activities
As a user
I want to check who made which changes to files
So that I can track modifications
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"
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"
}
}
},
"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"
}
}
}
}
}
}
},
"times": {
"type": "object",
"required": ["recordedTime"],
"properties": {
"recordedTime": {
"type": "string",
"format": "date-time"
}
}
}
}
}
}
}
}
"""

View File

@@ -2775,4 +2775,27 @@ class GraphContext implements Context {
)
);
}
/**
* @When /^user "([^"]*)" checks the activities for (?:folder|file) "([^"]*)" in space "([^"]*)" using the Graph API/
*
* @param string $user
* @param string $resource
* @param string $spaceName
*
* @return void
* @throws Exception
*
*/
public function userChecksTheActivitiesForResourceInSpaceUsingTheGraphAPI(string $user, string $resource, string $spaceName): void {
$resourceId = $this->featureContext->spacesContext->getResourceId($user, $spaceName, $resource);
$response = GraphHelper::getActivities(
$this->featureContext->getBaseUrl(),
$this->featureContext->getStepLineRef(),
$user,
$this->featureContext->getPasswordForUser($user),
$resourceId
);
$this->featureContext->setResponse($response);
}
}