mirror of
https://github.com/owncloud/ocis.git
synced 2025-04-18 23:44:07 +03:00
Merge pull request #11226 from owncloud/add-test-for-listing-shared-resource-activities
[tests-only][full-ci]Add tests for sharee listing resource activities
This commit is contained in:
commit
0f235e4f2e
@ -2919,6 +2919,34 @@ class GraphContext implements Context {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $user
|
||||
* @param string $resource
|
||||
* @param string $spaceName
|
||||
*
|
||||
* @return ResponseInterface
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function getActivities(
|
||||
string $user,
|
||||
string $resource,
|
||||
string $spaceName
|
||||
): ResponseInterface {
|
||||
if ($spaceName === "Shares") {
|
||||
$resourceId = $this->spacesContext->getSharesRemoteItemId($user, $resource);
|
||||
} else {
|
||||
$resourceId = $this->spacesContext->getResourceId($user, $spaceName, $resource);
|
||||
}
|
||||
return GraphHelper::getActivities(
|
||||
$this->featureContext->getBaseUrl(),
|
||||
$this->featureContext->getStepLineRef(),
|
||||
$user,
|
||||
$this->featureContext->getPasswordForUser($user),
|
||||
$resourceId
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @When /^user "([^"]*)" lists the activities of (?:folder|file) "([^"]*)" from space "([^"]*)" using the Graph API$/
|
||||
*
|
||||
@ -2928,25 +2956,77 @@ class GraphContext implements Context {
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function userListsTheActivitiesForResourceOfSpaceUsingTheGraphAPI(
|
||||
string $user,
|
||||
string $resource,
|
||||
string $spaceName
|
||||
): void {
|
||||
if ($spaceName === "Shares") {
|
||||
$resourceId = $this->spacesContext->getSharesRemoteItemId($user, $resource);
|
||||
} else {
|
||||
$resourceId = $this->spacesContext->getResourceId($user, $spaceName, $resource);
|
||||
}
|
||||
$response = GraphHelper::getActivities(
|
||||
$this->featureContext->getBaseUrl(),
|
||||
$this->featureContext->getStepLineRef(),
|
||||
$user,
|
||||
$this->featureContext->getPasswordForUser($user),
|
||||
$resourceId
|
||||
$this->featureContext->setResponse($this->getActivities($user, $resource, $spaceName));
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then /^for user "([^"]*)" (?:folder|file) "([^"]*)" of the space "([^"]*)" should have the following activities:$/
|
||||
*
|
||||
* @param string $user
|
||||
* @param string $resource
|
||||
* @param string $spaceName
|
||||
* @param TableNode $table
|
||||
*
|
||||
* @return void
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function forUserFolderOrFileOfTheSpaceShouldHaveTheseActivities(
|
||||
string $user,
|
||||
string $resource,
|
||||
string $spaceName,
|
||||
TableNode $table
|
||||
): void {
|
||||
$unmatchedActivities = [];
|
||||
$activities = $this->featureContext->getJsonDecodedResponse(
|
||||
$this->getActivities($user, $resource, $spaceName)
|
||||
);
|
||||
foreach ($table->getRows() as $expectedActivity) {
|
||||
$matched = false;
|
||||
foreach ($activities['value'] as $activity) {
|
||||
if ($expectedActivity[0] === $activity['template']['message']) {
|
||||
$matched = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!$matched) {
|
||||
$unmatchedActivities[] = "Expected activity '$expectedActivity[0]' was not found in the response. ";
|
||||
}
|
||||
}
|
||||
if (!empty($unmatchedActivities)) {
|
||||
Assert::fail(implode("\n", $unmatchedActivities));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then /^for user "([^"]*)" (?:folder|file) "([^"]*)" of the space "([^"]*)" should not have any activity$/
|
||||
*
|
||||
* @param string $user
|
||||
* @param string $resource
|
||||
* @param string $spaceName
|
||||
*
|
||||
* @return void
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function forUserFileOfTheSpaceShouldNotHaveAnyActivity(
|
||||
string $user,
|
||||
string $resource,
|
||||
string $spaceName
|
||||
): void {
|
||||
$activities = $this->getActivities($user, $resource, $spaceName);
|
||||
$responseBody = $activities->getBody()->getContents();
|
||||
Assert::assertEmpty(
|
||||
$responseBody,
|
||||
__METHOD__
|
||||
. "\nExpected no activity of resource '$resource' for user '$user', but some activities were found\n" .
|
||||
print_r(json_decode($responseBody, true), true)
|
||||
);
|
||||
$this->featureContext->setResponse($response);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -65,6 +65,9 @@ Feature: ListGrants role
|
||||
And for user "Brian" file "textfile1.txt" should have the following shares:
|
||||
| sharee | shareType | permissionsRole |
|
||||
| Brian | user | <permissions-role> |
|
||||
And for user "Brian" file "textfile1.txt" of the space "Shares" should have the following activities:
|
||||
| {user} added {resource} to {folder} |
|
||||
| {user} shared {resource} with {sharee} |
|
||||
Examples:
|
||||
| permissions-role |
|
||||
| Viewer With ListGrants |
|
||||
@ -125,6 +128,9 @@ Feature: ListGrants role
|
||||
And for user "Brian" folder "FolderToShare" should have the following shares:
|
||||
| sharee | shareType | permissionsRole |
|
||||
| Brian | user | <permissions-role> |
|
||||
And for user "Brian" folder "FolderToShare" of the space "Shares" should have the following activities:
|
||||
| {user} added {resource} to {folder} |
|
||||
| {user} shared {resource} with {sharee} |
|
||||
Examples:
|
||||
| permissions-role |
|
||||
| Viewer With ListGrants |
|
||||
@ -188,6 +194,9 @@ Feature: ListGrants role
|
||||
And for user "Brian" file "textfile1.txt" should have the following shares:
|
||||
| sharee | shareType | permissionsRole |
|
||||
| Brian | user | <permissions-role> |
|
||||
And for user "Brian" file "textfile1.txt" of the space "Shares" should have the following activities:
|
||||
| {user} added {resource} to {folder} |
|
||||
| {user} shared {resource} with {sharee} |
|
||||
Examples:
|
||||
| permissions-role |
|
||||
| Viewer With ListGrants |
|
||||
@ -251,6 +260,9 @@ Feature: ListGrants role
|
||||
And for user "Brian" folder "FolderToShare" should have the following shares:
|
||||
| sharee | shareType | permissionsRole |
|
||||
| Brian | user | <permissions-role> |
|
||||
And for user "Brian" folder "FolderToShare" of the space "Shares" should have the following activities:
|
||||
| {user} added {resource} to {folder} |
|
||||
| {user} shared {resource} with {sharee} |
|
||||
Examples:
|
||||
| permissions-role |
|
||||
| Viewer With ListGrants |
|
||||
@ -304,6 +316,9 @@ Feature: ListGrants role
|
||||
And for user "Brian" file "textfile1.txt" should have the following shares:
|
||||
| sharee | shareType | permissionsRole |
|
||||
| Brian | user | <new-permissions-role> |
|
||||
And for user "Brian" file "textfile1.txt" of the space "Shares" should have the following activities:
|
||||
| {user} added {resource} to {folder} |
|
||||
| {user} shared {resource} with {sharee} |
|
||||
Examples:
|
||||
| permissions-role | new-permissions-role |
|
||||
| Viewer | Viewer With ListGrants |
|
||||
@ -359,6 +374,9 @@ Feature: ListGrants role
|
||||
And for user "Brian" folder "FolderToShare" should have the following shares:
|
||||
| sharee | shareType | permissionsRole |
|
||||
| Brian | user | <new-permissions-role> |
|
||||
And for user "Brian" folder "FolderToShare" of the space "Shares" should have the following activities:
|
||||
| {user} added {resource} to {folder} |
|
||||
| {user} shared {resource} with {sharee} |
|
||||
Examples:
|
||||
| permissions-role | new-permissions-role |
|
||||
| Viewer | Viewer With ListGrants |
|
||||
@ -419,6 +437,10 @@ Feature: ListGrants role
|
||||
And for user "Brian" file "textfile1.txt" should have the following shares:
|
||||
| sharee | shareType | permissionsRole |
|
||||
| Brian | user | <new-permissions-role> |
|
||||
And for user "Brian" file "textfile1.txt" of the space "Shares" should have the following activities:
|
||||
| {user} added {resource} to {folder} |
|
||||
| {user} shared {resource} with {sharee} |
|
||||
| {user} updated {field} for the {resource} |
|
||||
Examples:
|
||||
| permissions-role | new-permissions-role |
|
||||
| Viewer | Viewer With ListGrants |
|
||||
@ -477,6 +499,10 @@ Feature: ListGrants role
|
||||
And for user "Brian" folder "FolderToShare" should have the following shares:
|
||||
| sharee | shareType | permissionsRole |
|
||||
| Brian | user | <new-permissions-role> |
|
||||
And for user "Brian" folder "FolderToShare" of the space "Shares" should have the following activities:
|
||||
| {user} added {resource} to {folder} |
|
||||
| {user} shared {resource} with {sharee} |
|
||||
| {user} updated {field} for the {resource} |
|
||||
Examples:
|
||||
| permissions-role | new-permissions-role |
|
||||
| Viewer | Viewer With ListGrants |
|
||||
@ -534,6 +560,7 @@ Feature: ListGrants role
|
||||
And for user "Brian" file "textfile1.txt" should have the following shares:
|
||||
| sharee | shareType | permissionsRole |
|
||||
| Brian | user | <new-permissions-role> |
|
||||
And for user "Brian" file "textfile1.txt" of the space "Shares" should not have any activity
|
||||
Examples:
|
||||
| permissions-role | new-permissions-role |
|
||||
| Viewer With ListGrants | Viewer |
|
||||
@ -589,6 +616,7 @@ Feature: ListGrants role
|
||||
And for user "Brian" folder "FolderToShare" should have the following shares:
|
||||
| sharee | shareType | permissionsRole |
|
||||
| Brian | user | <new-permissions-role> |
|
||||
And for user "Brian" folder "FolderToShare" of the space "Shares" should not have any activity
|
||||
Examples:
|
||||
| permissions-role | new-permissions-role |
|
||||
| Viewer With ListGrants | Viewer |
|
||||
@ -649,6 +677,10 @@ Feature: ListGrants role
|
||||
And for user "Brian" file "textfile1.txt" should have the following shares:
|
||||
| sharee | shareType | permissionsRole |
|
||||
| Brian | user | <new-permissions-role> |
|
||||
And for user "Brian" file "textfile1.txt" of the space "Shares" should have the following activities:
|
||||
| {user} added {resource} to {folder} |
|
||||
| {user} shared {resource} with {sharee} |
|
||||
| {user} updated {field} for the {resource} |
|
||||
Examples:
|
||||
| new-permissions-role | permissions-role |
|
||||
| Viewer With ListGrants | Viewer |
|
||||
@ -707,6 +739,10 @@ Feature: ListGrants role
|
||||
And for user "Brian" folder "FolderToShare" should have the following shares:
|
||||
| sharee | shareType | permissionsRole |
|
||||
| Brian | user | <new-permissions-role> |
|
||||
And for user "Brian" folder "FolderToShare" of the space "Shares" should have the following activities:
|
||||
| {user} added {resource} to {folder} |
|
||||
| {user} shared {resource} with {sharee} |
|
||||
| {user} updated {field} for the {resource} |
|
||||
Examples:
|
||||
| new-permissions-role | permissions-role |
|
||||
| Viewer With ListGrants | Viewer |
|
||||
@ -1306,6 +1342,9 @@ Feature: ListGrants role
|
||||
| sharee | shareType | permissionsRole |
|
||||
| Brian | user | Viewer |
|
||||
| grp1 | group | <permissions-role> |
|
||||
And for user "Brian" folder "folder" of the space "Shares" should have the following activities:
|
||||
| {user} added {resource} to {folder} |
|
||||
| {user} shared {resource} with {sharee} |
|
||||
Examples:
|
||||
| permissions-role |
|
||||
| Viewer With ListGrants |
|
||||
|
Loading…
x
Reference in New Issue
Block a user