Skip to content

Commit 0f235e4

Browse files
Merge pull request #11226 from owncloud/add-test-for-listing-shared-resource-activities
[tests-only][full-ci]Add tests for sharee listing resource activities
2 parents 20f32d4 + 34fe308 commit 0f235e4

File tree

2 files changed

+126
-7
lines changed

2 files changed

+126
-7
lines changed

tests/acceptance/bootstrap/GraphContext.php

Lines changed: 87 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2920,33 +2920,113 @@ public function getPermissionRoleDefinitionUsingGraphAPI(string $user, string $p
29202920
}
29212921

29222922
/**
2923-
* @When /^user "([^"]*)" lists the activities of (?:folder|file) "([^"]*)" from space "([^"]*)" using the Graph API$/
29242923
*
29252924
* @param string $user
29262925
* @param string $resource
29272926
* @param string $spaceName
29282927
*
2929-
* @return void
2930-
* @throws Exception
2928+
* @return ResponseInterface
2929+
* @throws GuzzleException
29312930
*/
2932-
public function userListsTheActivitiesForResourceOfSpaceUsingTheGraphAPI(
2931+
public function getActivities(
29332932
string $user,
29342933
string $resource,
29352934
string $spaceName
2936-
): void {
2935+
): ResponseInterface {
29372936
if ($spaceName === "Shares") {
29382937
$resourceId = $this->spacesContext->getSharesRemoteItemId($user, $resource);
29392938
} else {
29402939
$resourceId = $this->spacesContext->getResourceId($user, $spaceName, $resource);
29412940
}
2942-
$response = GraphHelper::getActivities(
2941+
return GraphHelper::getActivities(
29432942
$this->featureContext->getBaseUrl(),
29442943
$this->featureContext->getStepLineRef(),
29452944
$user,
29462945
$this->featureContext->getPasswordForUser($user),
29472946
$resourceId
29482947
);
2949-
$this->featureContext->setResponse($response);
2948+
}
2949+
2950+
/**
2951+
* @When /^user "([^"]*)" lists the activities of (?:folder|file) "([^"]*)" from space "([^"]*)" using the Graph API$/
2952+
*
2953+
* @param string $user
2954+
* @param string $resource
2955+
* @param string $spaceName
2956+
*
2957+
* @return void
2958+
* @throws Exception
2959+
* @throws GuzzleException
2960+
*/
2961+
public function userListsTheActivitiesForResourceOfSpaceUsingTheGraphAPI(
2962+
string $user,
2963+
string $resource,
2964+
string $spaceName
2965+
): void {
2966+
$this->featureContext->setResponse($this->getActivities($user, $resource, $spaceName));
2967+
}
2968+
2969+
/**
2970+
* @Then /^for user "([^"]*)" (?:folder|file) "([^"]*)" of the space "([^"]*)" should have the following activities:$/
2971+
*
2972+
* @param string $user
2973+
* @param string $resource
2974+
* @param string $spaceName
2975+
* @param TableNode $table
2976+
*
2977+
* @return void
2978+
* @throws GuzzleException
2979+
*/
2980+
public function forUserFolderOrFileOfTheSpaceShouldHaveTheseActivities(
2981+
string $user,
2982+
string $resource,
2983+
string $spaceName,
2984+
TableNode $table
2985+
): void {
2986+
$unmatchedActivities = [];
2987+
$activities = $this->featureContext->getJsonDecodedResponse(
2988+
$this->getActivities($user, $resource, $spaceName)
2989+
);
2990+
foreach ($table->getRows() as $expectedActivity) {
2991+
$matched = false;
2992+
foreach ($activities['value'] as $activity) {
2993+
if ($expectedActivity[0] === $activity['template']['message']) {
2994+
$matched = true;
2995+
break;
2996+
}
2997+
}
2998+
if (!$matched) {
2999+
$unmatchedActivities[] = "Expected activity '$expectedActivity[0]' was not found in the response. ";
3000+
}
3001+
}
3002+
if (!empty($unmatchedActivities)) {
3003+
Assert::fail(implode("\n", $unmatchedActivities));
3004+
}
3005+
}
3006+
3007+
/**
3008+
* @Then /^for user "([^"]*)" (?:folder|file) "([^"]*)" of the space "([^"]*)" should not have any activity$/
3009+
*
3010+
* @param string $user
3011+
* @param string $resource
3012+
* @param string $spaceName
3013+
*
3014+
* @return void
3015+
* @throws GuzzleException
3016+
*/
3017+
public function forUserFileOfTheSpaceShouldNotHaveAnyActivity(
3018+
string $user,
3019+
string $resource,
3020+
string $spaceName
3021+
): void {
3022+
$activities = $this->getActivities($user, $resource, $spaceName);
3023+
$responseBody = $activities->getBody()->getContents();
3024+
Assert::assertEmpty(
3025+
$responseBody,
3026+
__METHOD__
3027+
. "\nExpected no activity of resource '$resource' for user '$user', but some activities were found\n" .
3028+
print_r(json_decode($responseBody, true), true)
3029+
);
29503030
}
29513031

29523032
/**

tests/acceptance/features/apiSharingNgAdditionalShareRole/listGrantsShareRole.feature

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ Feature: ListGrants role
6565
And for user "Brian" file "textfile1.txt" should have the following shares:
6666
| sharee | shareType | permissionsRole |
6767
| Brian | user | <permissions-role> |
68+
And for user "Brian" file "textfile1.txt" of the space "Shares" should have the following activities:
69+
| {user} added {resource} to {folder} |
70+
| {user} shared {resource} with {sharee} |
6871
Examples:
6972
| permissions-role |
7073
| Viewer With ListGrants |
@@ -125,6 +128,9 @@ Feature: ListGrants role
125128
And for user "Brian" folder "FolderToShare" should have the following shares:
126129
| sharee | shareType | permissionsRole |
127130
| Brian | user | <permissions-role> |
131+
And for user "Brian" folder "FolderToShare" of the space "Shares" should have the following activities:
132+
| {user} added {resource} to {folder} |
133+
| {user} shared {resource} with {sharee} |
128134
Examples:
129135
| permissions-role |
130136
| Viewer With ListGrants |
@@ -188,6 +194,9 @@ Feature: ListGrants role
188194
And for user "Brian" file "textfile1.txt" should have the following shares:
189195
| sharee | shareType | permissionsRole |
190196
| Brian | user | <permissions-role> |
197+
And for user "Brian" file "textfile1.txt" of the space "Shares" should have the following activities:
198+
| {user} added {resource} to {folder} |
199+
| {user} shared {resource} with {sharee} |
191200
Examples:
192201
| permissions-role |
193202
| Viewer With ListGrants |
@@ -251,6 +260,9 @@ Feature: ListGrants role
251260
And for user "Brian" folder "FolderToShare" should have the following shares:
252261
| sharee | shareType | permissionsRole |
253262
| Brian | user | <permissions-role> |
263+
And for user "Brian" folder "FolderToShare" of the space "Shares" should have the following activities:
264+
| {user} added {resource} to {folder} |
265+
| {user} shared {resource} with {sharee} |
254266
Examples:
255267
| permissions-role |
256268
| Viewer With ListGrants |
@@ -304,6 +316,9 @@ Feature: ListGrants role
304316
And for user "Brian" file "textfile1.txt" should have the following shares:
305317
| sharee | shareType | permissionsRole |
306318
| Brian | user | <new-permissions-role> |
319+
And for user "Brian" file "textfile1.txt" of the space "Shares" should have the following activities:
320+
| {user} added {resource} to {folder} |
321+
| {user} shared {resource} with {sharee} |
307322
Examples:
308323
| permissions-role | new-permissions-role |
309324
| Viewer | Viewer With ListGrants |
@@ -359,6 +374,9 @@ Feature: ListGrants role
359374
And for user "Brian" folder "FolderToShare" should have the following shares:
360375
| sharee | shareType | permissionsRole |
361376
| Brian | user | <new-permissions-role> |
377+
And for user "Brian" folder "FolderToShare" of the space "Shares" should have the following activities:
378+
| {user} added {resource} to {folder} |
379+
| {user} shared {resource} with {sharee} |
362380
Examples:
363381
| permissions-role | new-permissions-role |
364382
| Viewer | Viewer With ListGrants |
@@ -419,6 +437,10 @@ Feature: ListGrants role
419437
And for user "Brian" file "textfile1.txt" should have the following shares:
420438
| sharee | shareType | permissionsRole |
421439
| Brian | user | <new-permissions-role> |
440+
And for user "Brian" file "textfile1.txt" of the space "Shares" should have the following activities:
441+
| {user} added {resource} to {folder} |
442+
| {user} shared {resource} with {sharee} |
443+
| {user} updated {field} for the {resource} |
422444
Examples:
423445
| permissions-role | new-permissions-role |
424446
| Viewer | Viewer With ListGrants |
@@ -477,6 +499,10 @@ Feature: ListGrants role
477499
And for user "Brian" folder "FolderToShare" should have the following shares:
478500
| sharee | shareType | permissionsRole |
479501
| Brian | user | <new-permissions-role> |
502+
And for user "Brian" folder "FolderToShare" of the space "Shares" should have the following activities:
503+
| {user} added {resource} to {folder} |
504+
| {user} shared {resource} with {sharee} |
505+
| {user} updated {field} for the {resource} |
480506
Examples:
481507
| permissions-role | new-permissions-role |
482508
| Viewer | Viewer With ListGrants |
@@ -534,6 +560,7 @@ Feature: ListGrants role
534560
And for user "Brian" file "textfile1.txt" should have the following shares:
535561
| sharee | shareType | permissionsRole |
536562
| Brian | user | <new-permissions-role> |
563+
And for user "Brian" file "textfile1.txt" of the space "Shares" should not have any activity
537564
Examples:
538565
| permissions-role | new-permissions-role |
539566
| Viewer With ListGrants | Viewer |
@@ -589,6 +616,7 @@ Feature: ListGrants role
589616
And for user "Brian" folder "FolderToShare" should have the following shares:
590617
| sharee | shareType | permissionsRole |
591618
| Brian | user | <new-permissions-role> |
619+
And for user "Brian" folder "FolderToShare" of the space "Shares" should not have any activity
592620
Examples:
593621
| permissions-role | new-permissions-role |
594622
| Viewer With ListGrants | Viewer |
@@ -649,6 +677,10 @@ Feature: ListGrants role
649677
And for user "Brian" file "textfile1.txt" should have the following shares:
650678
| sharee | shareType | permissionsRole |
651679
| Brian | user | <new-permissions-role> |
680+
And for user "Brian" file "textfile1.txt" of the space "Shares" should have the following activities:
681+
| {user} added {resource} to {folder} |
682+
| {user} shared {resource} with {sharee} |
683+
| {user} updated {field} for the {resource} |
652684
Examples:
653685
| new-permissions-role | permissions-role |
654686
| Viewer With ListGrants | Viewer |
@@ -707,6 +739,10 @@ Feature: ListGrants role
707739
And for user "Brian" folder "FolderToShare" should have the following shares:
708740
| sharee | shareType | permissionsRole |
709741
| Brian | user | <new-permissions-role> |
742+
And for user "Brian" folder "FolderToShare" of the space "Shares" should have the following activities:
743+
| {user} added {resource} to {folder} |
744+
| {user} shared {resource} with {sharee} |
745+
| {user} updated {field} for the {resource} |
710746
Examples:
711747
| new-permissions-role | permissions-role |
712748
| Viewer With ListGrants | Viewer |
@@ -1306,6 +1342,9 @@ Feature: ListGrants role
13061342
| sharee | shareType | permissionsRole |
13071343
| Brian | user | Viewer |
13081344
| grp1 | group | <permissions-role> |
1345+
And for user "Brian" folder "folder" of the space "Shares" should have the following activities:
1346+
| {user} added {resource} to {folder} |
1347+
| {user} shared {resource} with {sharee} |
13091348
Examples:
13101349
| permissions-role |
13111350
| Viewer With ListGrants |

0 commit comments

Comments
 (0)