Skip to content

Commit 0832c9b

Browse files
Merge pull request #10672 from owncloud/tests-ocm-delete-share
[tests-only][full-ci] add tests to remove access of shared resource to federated user
2 parents fe4e66c + 2841217 commit 0832c9b

File tree

2 files changed

+57
-15
lines changed

2 files changed

+57
-15
lines changed

tests/acceptance/bootstrap/SharingNgContext.php

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1738,36 +1738,39 @@ public function userRemovesTheLastLinkShareOfSpaceUsingPermissionsEndpointOfGrap
17381738
* @param string $sharer
17391739
* @param string $space
17401740
* @param bool $shouldExist
1741+
* @param bool $federatedShare
17411742
*
17421743
* @return void
17431744
* @throws GuzzleException
17441745
* @throws JsonException
17451746
* @throws Exception
17461747
*/
1747-
public function checkIfShareExists(string $share, string $sharee, string $sharer, string $space, bool $shouldExist = true): void {
1748+
public function checkIfShareExists(string $share, string $sharee, string $sharer, string $space, bool $shouldExist = true, bool $federatedShare = false): void {
17481749
$share = \ltrim($share, "/");
17491750
if (\strtolower($space) === "personal") {
17501751
$remoteDriveAlias = "personal/" . \strtolower($sharer);
17511752
} else {
17521753
$remoteDriveAlias = "project/" . \strtolower($space);
17531754
}
17541755

1755-
// check share mountpoint
1756-
$response = GraphHelper::getMySpaces(
1757-
$this->featureContext->getBaseUrl(),
1758-
$sharee,
1759-
$this->featureContext->getPasswordForUser($sharee),
1760-
"",
1761-
$this->featureContext->getStepLineRef()
1762-
);
1763-
$driveList = HttpRequestHelper::getJsonDecodedResponseBodyContent($response)->value;
1764-
$foundShareMountpoint = false;
1765-
foreach ($driveList as $drive) {
1766-
if ($drive->driveType === "mountpoint" && $drive->name === $share && $drive->root->remoteItem->driveAlias === $remoteDriveAlias) {
1767-
$foundShareMountpoint = true;
1756+
if (!$federatedShare) {
1757+
// check share mountpoint
1758+
$response = GraphHelper::getMySpaces(
1759+
$this->featureContext->getBaseUrl(),
1760+
$sharee,
1761+
$this->featureContext->getPasswordForUser($sharee),
1762+
"",
1763+
$this->featureContext->getStepLineRef()
1764+
);
1765+
$driveList = HttpRequestHelper::getJsonDecodedResponseBodyContent($response)->value;
1766+
$foundShareMountpoint = false;
1767+
foreach ($driveList as $drive) {
1768+
if ($drive->driveType === "mountpoint" && $drive->name === $share && $drive->root->remoteItem->driveAlias === $remoteDriveAlias) {
1769+
$foundShareMountpoint = true;
1770+
}
17681771
}
1772+
Assert::assertSame($shouldExist, $foundShareMountpoint, "Share mountpoint '$share' was not found in the drives list.");
17691773
}
1770-
Assert::assertSame($shouldExist, $foundShareMountpoint, "Share mountpoint '$share' was not found in the drives list.");
17711774

17721775
// check share in shared-with-me list
17731776
$response = GraphHelper::getSharesSharedWithMe(
@@ -1808,6 +1811,21 @@ public function userShouldHaveShareSharedByUserFromSpace(string $sharee, string
18081811
$this->checkIfShareExists($share, $sharee, $sharer, $space, $shouldOrNot === "should");
18091812
}
18101813

1814+
/**
1815+
* @Then /^user "([^"]*)" (should|should not) have a federated share "([^"]*)" shared by user "([^"]*)" from space "([^"]*)"$/
1816+
*
1817+
* @param string $sharee
1818+
* @param string $shouldOrNot
1819+
* @param string $share
1820+
* @param string $sharer
1821+
* @param string $space
1822+
*
1823+
* @return void
1824+
*/
1825+
public function userShouldOrShouldNotHaveFederatedShareSharedByUserFromSpace(string $sharee, string $shouldOrNot, string $share, string $sharer, string $space): void {
1826+
$this->checkIfShareExists($share, $sharee, $sharer, $space, $shouldOrNot === "should", true);
1827+
}
1828+
18111829
/**
18121830
* @Given /^user "([^"]*)" has shared the following (?:files|folders) from space "([^"]*)" with user "([^"]*)" and role "([^"]*)":$/
18131831
*

tests/acceptance/features/apiOcm/share.feature

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1273,3 +1273,27 @@ Feature: an user shares resources using ScienceMesh application
12731273
When user "Brian" lists all available spaces via the Graph API
12741274
Then the HTTP status code should be "200"
12751275
And the json responded should not contain a space with name "folderToShare"
1276+
1277+
@issue-10213
1278+
Scenario Outline: local user removes access of federated user from a resource
1279+
Given using spaces DAV path
1280+
And using server "REMOTE"
1281+
And "Brian" has created the federation share invitation
1282+
And using server "LOCAL"
1283+
And "Alice" has accepted invitation
1284+
And user "Alice" has created a folder "FOLDER" in space "Personal"
1285+
And user "Alice" has sent the following resource share invitation to federated user:
1286+
| resource | FOLDER |
1287+
| space | Personal |
1288+
| sharee | Brian |
1289+
| shareType | user |
1290+
| permissionsRole | <permissionsRole> |
1291+
When user "Alice" removes the access of user "Brian" from resource "FOLDER" of space "Personal" using the Graph API
1292+
Then the HTTP status code should be "204"
1293+
And using server "REMOTE"
1294+
And user "Brian" should not have a federated share "FOLDER" shared by user "Alice" from space "Personal"
1295+
Examples:
1296+
| permissionsRole |
1297+
| Viewer |
1298+
| Uploader |
1299+
| Editor |

0 commit comments

Comments
 (0)