Added test for sending share invitation to normal user

This commit is contained in:
Prarup Gurung
2024-01-17 15:59:55 +05:45
parent cb0090e840
commit f08a9ae0d9
3 changed files with 82 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

@@ -1111,3 +1111,29 @@ Feature: Send a sharing invitations
| Co Owner | folder | FolderToShare |
| Uploader | folder | FolderToShare |
| Manager | folder | FolderToShare |
Scenario Outline: send share invitation to normal user
And user "Alice" has created folder "FolderToShare"
And user "Alice" has uploaded file "filesForUpload/textfile.txt" to "textfile.txt"
When user "Alice" sends the following share invitation using the Graph API:
| resourceType | <resource-type> |
| resource | <path> |
| space | Personal |
| sharee | Brian |
| 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> |
Examples:
| permissions-role | resource-type | path |
| Viewer | file | textfile.txt |
| File Editor | file | textfile.txt |
| Co Owner | file | textfile.txt |
| Manager | file | textfile.txt |
| Viewer | folder | FolderToShare |
| Editor | folder | FolderToShare |
| Co Owner | folder | FolderToShare |
| Uploader | folder | FolderToShare |
| Manager | folder | FolderToShare |

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_intersect(array_column($rows, 0), 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);
}
}