Merge pull request #8226 from owncloud/add-test-for-invite-normal-user

[full-ci] [tests-only] Modified tests so sharee can check for received shares
This commit is contained in:
Prarup Gurung
2024-01-23 12:33:51 +05:45
committed by GitHub
3 changed files with 62 additions and 0 deletions

View File

@@ -1822,4 +1822,29 @@ class GraphHelper {
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()
);
}
}

View File

@@ -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
"""
{
@@ -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
"""
{

View File

@@ -24,6 +24,7 @@ use Behat\Behat\Hook\Scope\BeforeScenarioScope;
use Psr\Http\Message\ResponseInterface;
use TestHelpers\GraphHelper;
use Behat\Gherkin\Node\TableNode;
use PHPUnit\Framework\Assert;
require_once 'bootstrap.php';
@@ -424,4 +425,34 @@ class SharingNgContext implements Context {
$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);
}
}