Skip to content

Commit

Permalink
Merge pull request #8226 from owncloud/add-test-for-invite-normal-user
Browse files Browse the repository at this point in the history
[full-ci] [tests-only] Modified tests so sharee can check for received shares
  • Loading branch information
grgprarup authored Jan 23, 2024
2 parents cb0090e + f7599b3 commit ee931c9
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/TestHelpers/GraphHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -1822,4 +1822,29 @@ public static function deleteSharePermission(
self::getRequestHeaders()
);
}

/**
* @param string $baseUrl
* @param string $xRequestId
* @param string $user
* @param string $password
*
* @return ResponseInterface
* @throws GuzzleException
*/
public static function getSharesSharedWithMe(
string $baseUrl,
string $xRequestId,
string $user,
string $password
): ResponseInterface {
$url = self::getBetaFullUrl($baseUrl, "me/drive/sharedWithMe");
return HttpRequestHelper::get(
$url,
$xRequestId,
$user,
$password,
self::getRequestHeaders()
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ Feature: Send a sharing invitations
| shareType | user |
| permissionsRole | <permissions-role> |
Then the HTTP status code should be "200"
And for user "Brian" the space Shares should contain these entries:
| <path> |
And the JSON data of the response should match
"""
{
Expand Down Expand Up @@ -115,6 +117,10 @@ Feature: Send a sharing invitations
| shareType | group |
| permissionsRole | <permissions-role> |
Then the HTTP status code should be "200"
And for user "Brian" the space Shares should contain these entries:
| <path> |
And for user "Carol" the space Shares should contain these entries:
| <path> |
And the JSON data of the response should match
"""
{
Expand Down
31 changes: 31 additions & 0 deletions tests/acceptance/features/bootstrap/SharingNgContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
use Psr\Http\Message\ResponseInterface;
use TestHelpers\GraphHelper;
use Behat\Gherkin\Node\TableNode;
use PHPUnit\Framework\Assert;

require_once 'bootstrap.php';

Expand Down Expand Up @@ -424,4 +425,34 @@ public function userRemovesSharePermissionOfAResourceInLinkShareUsingGraphAPI(
$this->removeSharePermission($sharer, 'link', $resourceType, $resource, $space)
);
}

/**
* @Then /^for user "([^"]*)" the space Shares should (not|)\s?contain these (files|entries):$/
*
* @param string $user
* @param string $shouldOrNot
* @param TableNode $table
*
* @return void
* @throws Exception
*/
public function forUserTheSpaceSharesShouldContainTheseEntries(string $user, string $shouldOrNot, TableNode $table): void {
$should = $shouldOrNot !== 'not';
$rows = $table->getRows();
$response = GraphHelper::getSharesSharedWithMe(
$this->featureContext->getBaseUrl(),
$this->featureContext->getStepLineRef(),
$user,
$this->featureContext->getPasswordForUser($user)
);
$contents = \json_decode($response->getBody()->getContents(), true);

$fileFound = empty(array_diff(array_map(fn ($row) => trim($row[0], '/'), $rows), array_column($contents['value'], 'name')));

$assertMessage = $should
? "Response does not contain the entry."
: "Response does contain the entry but should not.";

Assert::assertSame($should, $fileFound, $assertMessage);
}
}

0 comments on commit ee931c9

Please sign in to comment.