mirror of
https://github.com/owncloud/ocis
synced 2026-04-25 17:25:21 +02:00
updating lint rules for test code
This commit is contained in:
@@ -12,6 +12,20 @@ $finder = PhpCsFixer\Finder::create()
|
||||
->exclude($excludeDirs)
|
||||
->in(__DIR__);
|
||||
|
||||
$config = new OC\CodingStandard\Config();
|
||||
$ocRule = (new OC\CodingStandard\Config())->getRules();
|
||||
$config = new PhpCsFixer\Config();
|
||||
$config->setFinder($finder)
|
||||
->setIndent("\t")
|
||||
->setRules(
|
||||
array_merge(
|
||||
$ocRule,
|
||||
[
|
||||
"return_type_declaration" => [
|
||||
"space_before" => "none",
|
||||
],
|
||||
'single_space_around_construct' => true
|
||||
]
|
||||
)
|
||||
);
|
||||
$config->setFinder($finder);
|
||||
return $config;
|
||||
|
||||
18
phpcs.xml
18
phpcs.xml
@@ -19,10 +19,6 @@
|
||||
<exclude name="Generic.WhiteSpace.DisallowTabIndent.NonIndentTabsUsed" />
|
||||
</rule>
|
||||
|
||||
<rule ref="Generic.Files.LineLength">
|
||||
<exclude name="Generic.Files.LineLength.TooLong" />
|
||||
</rule>
|
||||
|
||||
<rule ref="PEAR">
|
||||
<exclude name="Generic.Commenting.DocComment.ShortNotCapital" />
|
||||
<exclude name="Generic.Commenting.DocComment.SpacingAfter" />
|
||||
@@ -77,4 +73,18 @@
|
||||
<exclude-pattern>*/lib/storagewrapper.php</exclude-pattern>
|
||||
</rule>
|
||||
|
||||
<rule ref="Generic.Commenting.Todo">
|
||||
<message>Please review this TODO comment: %s</message>
|
||||
<type>error</type>
|
||||
</rule>
|
||||
<rule ref="Squiz.PHP.NonExecutableCode" />
|
||||
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace" />
|
||||
<rule ref="Generic.Files.LineLength">
|
||||
<properties>
|
||||
<property name="ignoreComments" value="true" />
|
||||
<type>error</type>
|
||||
<property name="lineLimit" value="120" />
|
||||
<property name="absoluteLineLimit" value="120" />
|
||||
</properties>
|
||||
</rule>
|
||||
</ruleset>
|
||||
|
||||
@@ -58,7 +58,9 @@ class WebDav extends Assert {
|
||||
} elseif ($element === "reason") {
|
||||
$result = $responseXmlArray['value'][3]['value'];
|
||||
} else {
|
||||
self::fail(__METHOD__ . " element must be one of exception, response or reason. But '$element' was passed in.");
|
||||
self::fail(
|
||||
__METHOD__ . " element must be one of exception, response or reason. But '$element' was passed in."
|
||||
);
|
||||
}
|
||||
|
||||
self::assertEquals(
|
||||
|
||||
@@ -42,7 +42,11 @@ class AuthAppHelper {
|
||||
*
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
public static function listAllAppAuthTokensForUser(string $baseUrl, string $user, string $password): ResponseInterface {
|
||||
public static function listAllAppAuthTokensForUser(
|
||||
string $baseUrl,
|
||||
string $user,
|
||||
string $password
|
||||
): ResponseInterface {
|
||||
$url = $baseUrl . self::getAuthAppEndpoint();
|
||||
return HttpRequestHelper::sendRequest(
|
||||
$url,
|
||||
@@ -61,7 +65,12 @@ class AuthAppHelper {
|
||||
*
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
public static function createAppAuthToken(string $baseUrl, string $user, string $password, string $expiration): ResponseInterface {
|
||||
public static function createAppAuthToken(
|
||||
string $baseUrl,
|
||||
string $user,
|
||||
string $password,
|
||||
string $expiration
|
||||
): ResponseInterface {
|
||||
$url = $baseUrl . self::getAuthAppEndpoint() . "?expiry=$expiration";
|
||||
return HttpRequestHelper::sendRequest(
|
||||
$url,
|
||||
@@ -80,7 +89,12 @@ class AuthAppHelper {
|
||||
*
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
public static function deleteAppAuthToken(string $baseUrl, string $user, string $password, string $token): ResponseInterface {
|
||||
public static function deleteAppAuthToken(
|
||||
string $baseUrl,
|
||||
string $user,
|
||||
string $password,
|
||||
string $token
|
||||
): ResponseInterface {
|
||||
$url = $baseUrl . self::getAuthAppEndpoint() . "?token=$token";
|
||||
return HttpRequestHelper::sendRequest(
|
||||
$url,
|
||||
|
||||
@@ -38,7 +38,11 @@ class BehatHelper {
|
||||
*
|
||||
* @return Context
|
||||
*/
|
||||
public static function getContext(ScenarioScope $scope, InitializedContextEnvironment $environment, string $class): Context {
|
||||
public static function getContext(
|
||||
ScenarioScope $scope,
|
||||
InitializedContextEnvironment $environment,
|
||||
string $class
|
||||
): Context {
|
||||
try {
|
||||
return $environment->getContext($class);
|
||||
} catch (ContextNotFoundException $e) {
|
||||
|
||||
@@ -113,7 +113,11 @@ class EmailHelper {
|
||||
* @return object
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public static function getBodyOfAnEmailById(string $mailBox, string $mailboxId, ?string $xRequestId = null):object {
|
||||
public static function getBodyOfAnEmailById(
|
||||
string $mailBox,
|
||||
string $mailboxId,
|
||||
?string $xRequestId = null
|
||||
): object {
|
||||
$response = HttpRequestHelper::get(
|
||||
self::getLocalEmailUrl() . "/api/v1/mailbox/" . $mailBox . "/" . $mailboxId,
|
||||
$xRequestId,
|
||||
|
||||
@@ -110,7 +110,8 @@ class GraphHelper {
|
||||
* @return string
|
||||
*/
|
||||
public static function getShareIdRegex(): string {
|
||||
return self::getUUIDv4Regex() . '\\\$' . self::getUUIDv4Regex() . '!' . self::getUUIDv4Regex() . ':' . self::getUUIDv4Regex() . ':' . self::getUUIDv4Regex();
|
||||
return self::getUUIDv4Regex() . '\\\$' . self::getUUIDv4Regex() . '!'
|
||||
. self::getUUIDv4Regex() . ':' . self::getUUIDv4Regex() . ':' . self::getUUIDv4Regex();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1387,7 +1388,11 @@ class GraphHelper {
|
||||
string $password,
|
||||
array $groupIdArray
|
||||
): ResponseInterface {
|
||||
$url = self::getFullUrl($baseUrl, 'users' . '?$filter=memberOf/any(m:m/id ' . "eq '$groupIdArray[0]') " . "and memberOf/any(m:m/id eq '$groupIdArray[1]')");
|
||||
$url = self::getFullUrl(
|
||||
$baseUrl,
|
||||
'users' . '?$filter=memberOf/any(m:m/id ' . "eq '$groupIdArray[0]') "
|
||||
. "and memberOf/any(m:m/id eq '$groupIdArray[1]')"
|
||||
);
|
||||
return HttpRequestHelper::get(
|
||||
$url,
|
||||
$xRequestId,
|
||||
@@ -1416,7 +1421,11 @@ class GraphHelper {
|
||||
string $firstGroup,
|
||||
string $secondGroup
|
||||
): ResponseInterface {
|
||||
$url = self::getFullUrl($baseUrl, 'users' . '?$filter=memberOf/any(m:m/id ' . "eq '$firstGroup') " . "or memberOf/any(m:m/id eq '$secondGroup')");
|
||||
$url = self::getFullUrl(
|
||||
$baseUrl,
|
||||
'users' . '?$filter=memberOf/any(m:m/id '
|
||||
. "eq '$firstGroup') " . "or memberOf/any(m:m/id eq '$secondGroup')"
|
||||
);
|
||||
return HttpRequestHelper::get(
|
||||
$url,
|
||||
$xRequestId,
|
||||
@@ -1472,7 +1481,11 @@ class GraphHelper {
|
||||
string $roleId,
|
||||
string $groupId
|
||||
): ResponseInterface {
|
||||
$url = self::getFullUrl($baseUrl, 'users' . '?$filter=appRoleAssignments/any(m:m/appRoleId ' . "eq '$roleId') " . "and memberOf/any(m:m/id eq '$groupId')");
|
||||
$url = self::getFullUrl(
|
||||
$baseUrl,
|
||||
'users' . '?$filter=appRoleAssignments/any(m:m/appRoleId '
|
||||
. "eq '$roleId') " . "and memberOf/any(m:m/id eq '$groupId')"
|
||||
);
|
||||
return HttpRequestHelper::get(
|
||||
$url,
|
||||
$xRequestId,
|
||||
@@ -1669,7 +1682,15 @@ class GraphHelper {
|
||||
): ResponseInterface {
|
||||
$fullUrl = self::getFullUrl($baseUrl, 'me');
|
||||
$payload['preferredLanguage'] = $language;
|
||||
return HttpRequestHelper::sendRequest($fullUrl, $xRequestId, 'PATCH', $user, $password, null, \json_encode($payload));
|
||||
return HttpRequestHelper::sendRequest(
|
||||
$fullUrl,
|
||||
$xRequestId,
|
||||
'PATCH',
|
||||
$user,
|
||||
$password,
|
||||
null,
|
||||
\json_encode($payload)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1810,7 +1831,13 @@ class GraphHelper {
|
||||
?string $expirationDateTime
|
||||
): ResponseInterface {
|
||||
$url = self::getBetaFullUrl($baseUrl, "drives/$spaceId/items/$itemId/invite");
|
||||
$body = self::createShareInviteBody($shareeIds, $shareTypes, $permissionsRole, $permissionsAction, $expirationDateTime);
|
||||
$body = self::createShareInviteBody(
|
||||
$shareeIds,
|
||||
$shareTypes,
|
||||
$permissionsRole,
|
||||
$permissionsAction,
|
||||
$expirationDateTime
|
||||
);
|
||||
return HttpRequestHelper::post(
|
||||
$url,
|
||||
$xRequestId,
|
||||
@@ -2186,7 +2213,13 @@ class GraphHelper {
|
||||
?string $expirationDateTime
|
||||
): ResponseInterface {
|
||||
$url = self::getBetaFullUrl($baseUrl, "drives/$spaceId/root/invite");
|
||||
$body = self::createShareInviteBody($shareeIds, $shareTypes, $permissionsRole, $permissionsAction, $expirationDateTime);
|
||||
$body = self::createShareInviteBody(
|
||||
$shareeIds,
|
||||
$shareTypes,
|
||||
$permissionsRole,
|
||||
$permissionsAction,
|
||||
$expirationDateTime
|
||||
);
|
||||
|
||||
return HttpRequestHelper::post(
|
||||
$url,
|
||||
|
||||
@@ -222,7 +222,10 @@ class HttpRequestHelper {
|
||||
$client
|
||||
);
|
||||
|
||||
if ($response->getStatusCode() >= 400 && $response->getStatusCode() !== self::HTTP_TOO_EARLY && $response->getStatusCode() !== self::HTTP_CONFLICT) {
|
||||
if ($response->getStatusCode() >= 400
|
||||
&& $response->getStatusCode() !== self::HTTP_TOO_EARLY
|
||||
&& $response->getStatusCode() !== self::HTTP_CONFLICT
|
||||
) {
|
||||
$sendExceptionHappened = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -56,7 +56,11 @@ class OcisConfigHelper {
|
||||
try {
|
||||
$response = $client->send($request);
|
||||
} catch (ConnectException $e) {
|
||||
throw new \Error("Cannot connect to the ociswrapper at the moment, make sure that ociswrapper is running before proceeding with the test run.\n" . $e->getMessage());
|
||||
throw new \Error(
|
||||
"Cannot connect to the ociswrapper at the moment,"
|
||||
. "make sure that ociswrapper is running before proceeding with the test run.\n"
|
||||
. $e->getMessage()
|
||||
);
|
||||
} catch (GuzzleException $ex) {
|
||||
$response = $ex->getResponse();
|
||||
|
||||
|
||||
@@ -55,7 +55,13 @@ class SettingsHelper {
|
||||
* @throws GuzzleException
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function getBundlesList(string $baseUrl, string $user, string $password, string $xRequestId, array $headers = []): ResponseInterface {
|
||||
public static function getBundlesList(
|
||||
string $baseUrl,
|
||||
string $user,
|
||||
string $password,
|
||||
string $xRequestId,
|
||||
array $headers = []
|
||||
): ResponseInterface {
|
||||
$fullUrl = self::buildFullUrl($baseUrl, "bundles-list");
|
||||
return HttpRequestHelper::post(
|
||||
$fullUrl,
|
||||
@@ -79,7 +85,13 @@ class SettingsHelper {
|
||||
* @throws GuzzleException
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function getBundleByName(string $baseUrl, string $user, string $password, string $bundleName, string $xRequestId): array {
|
||||
public static function getBundleByName(
|
||||
string $baseUrl,
|
||||
string $user,
|
||||
string $password,
|
||||
string $bundleName,
|
||||
string $xRequestId
|
||||
): array {
|
||||
$response = self::getBundlesList($baseUrl, $user, $password, $xRequestId);
|
||||
Assert::assertEquals(201, $response->getStatusCode(), "Failed to get bundles list");
|
||||
|
||||
@@ -104,7 +116,13 @@ class SettingsHelper {
|
||||
* @throws GuzzleException
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function getRolesList(string $baseUrl, string $user, string $password, string $xRequestId, array $headers = []): ResponseInterface {
|
||||
public static function getRolesList(
|
||||
string $baseUrl,
|
||||
string $user,
|
||||
string $password,
|
||||
string $xRequestId,
|
||||
array $headers = []
|
||||
): ResponseInterface {
|
||||
$fullUrl = self::buildFullUrl($baseUrl, "roles-list");
|
||||
return HttpRequestHelper::post(
|
||||
$fullUrl,
|
||||
@@ -130,7 +148,15 @@ class SettingsHelper {
|
||||
* @throws GuzzleException
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function assignRoleToUser(string $baseUrl, string $user, string $password, string $assigneeId, string $roleId, string $xRequestId, array $headers = []): ResponseInterface {
|
||||
public static function assignRoleToUser(
|
||||
string $baseUrl,
|
||||
string $user,
|
||||
string $password,
|
||||
string $assigneeId,
|
||||
string $roleId,
|
||||
string $xRequestId,
|
||||
array $headers = []
|
||||
): ResponseInterface {
|
||||
$fullUrl = self::buildFullUrl($baseUrl, "assignments-add");
|
||||
$body = json_encode(["account_uuid" => $assigneeId, "role_id" => $roleId], JSON_THROW_ON_ERROR);
|
||||
return HttpRequestHelper::post(
|
||||
@@ -156,7 +182,14 @@ class SettingsHelper {
|
||||
* @throws GuzzleException
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function getAssignmentsList(string $baseUrl, string $user, string $password, string $userId, string $xRequestId, array $headers = []): ResponseInterface {
|
||||
public static function getAssignmentsList(
|
||||
string $baseUrl,
|
||||
string $user,
|
||||
string $password,
|
||||
string $userId,
|
||||
string $xRequestId,
|
||||
array $headers = []
|
||||
): ResponseInterface {
|
||||
$fullUrl = self::buildFullUrl($baseUrl, "assignments-list");
|
||||
$body = json_encode(["account_uuid" => $userId], JSON_THROW_ON_ERROR);
|
||||
return HttpRequestHelper::post(
|
||||
@@ -181,7 +214,13 @@ class SettingsHelper {
|
||||
* @throws GuzzleException
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function getValuesList(string $baseUrl, string $user, string $password, string $xRequestId, array $headers = []): ResponseInterface {
|
||||
public static function getValuesList(
|
||||
string $baseUrl,
|
||||
string $user,
|
||||
string $password,
|
||||
string $xRequestId,
|
||||
array $headers = []
|
||||
): ResponseInterface {
|
||||
$fullUrl = self::buildFullUrl($baseUrl, "values-list");
|
||||
$body = json_encode(["account_uuid" => "me"], JSON_THROW_ON_ERROR);
|
||||
return HttpRequestHelper::post(
|
||||
@@ -205,7 +244,12 @@ class SettingsHelper {
|
||||
* @throws GuzzleException
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function getAutoAcceptSharesSettingValue(string $baseUrl, string $user, string $password, string $xRequestId): bool {
|
||||
public static function getAutoAcceptSharesSettingValue(
|
||||
string $baseUrl,
|
||||
string $user,
|
||||
string $password,
|
||||
string $xRequestId
|
||||
): bool {
|
||||
$response = self::getValuesList($baseUrl, $user, $password, $xRequestId);
|
||||
Assert::assertEquals(201, $response->getStatusCode(), "Failed to get values list");
|
||||
|
||||
@@ -235,7 +279,12 @@ class SettingsHelper {
|
||||
* @throws GuzzleException
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function getLanguageSettingValue(string $baseUrl, string $user, string $password, string $xRequestId): string {
|
||||
public static function getLanguageSettingValue(
|
||||
string $baseUrl,
|
||||
string $user,
|
||||
string $password,
|
||||
string $xRequestId
|
||||
): string {
|
||||
$response = self::getValuesList($baseUrl, $user, $password, $xRequestId);
|
||||
Assert::assertEquals(201, $response->getStatusCode(), "Failed to get values list");
|
||||
|
||||
@@ -267,7 +316,14 @@ class SettingsHelper {
|
||||
* @throws GuzzleException
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function updateSettings(string $baseUrl, string $user, string $password, string $body, string $xRequestId, array $headers = []): ResponseInterface {
|
||||
public static function updateSettings(
|
||||
string $baseUrl,
|
||||
string $user,
|
||||
string $password,
|
||||
string $body,
|
||||
string $xRequestId,
|
||||
array $headers = []
|
||||
): ResponseInterface {
|
||||
$fullUrl = self::buildFullUrl($baseUrl, "values-save");
|
||||
return HttpRequestHelper::post(
|
||||
$fullUrl,
|
||||
|
||||
@@ -516,7 +516,12 @@ class WebDavHelper {
|
||||
* @throws GuzzleException
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function getPersonalSpaceIdForUser(string $baseUrl, string $user, string $password, string $xRequestId):string {
|
||||
public static function getPersonalSpaceIdForUser(
|
||||
string $baseUrl,
|
||||
string $user,
|
||||
string $password,
|
||||
string $xRequestId
|
||||
): string {
|
||||
if (\array_key_exists($user, self::$spacesIdRef) && \array_key_exists("personal", self::$spacesIdRef[$user])) {
|
||||
return self::$spacesIdRef[$user]["personal"];
|
||||
}
|
||||
@@ -546,14 +551,21 @@ class WebDavHelper {
|
||||
$user,
|
||||
$password
|
||||
);
|
||||
Assert::assertEquals(207, $response->getStatusCode(), "PROPFIND for user '$user' failed so the personal space id cannot be discovered");
|
||||
Assert::assertEquals(
|
||||
207,
|
||||
$response->getStatusCode(),
|
||||
"PROPFIND for user '$user' failed so the personal space id cannot be discovered"
|
||||
);
|
||||
|
||||
$responseXmlObject = HttpRequestHelper::getResponseXml(
|
||||
$response,
|
||||
__METHOD__
|
||||
);
|
||||
$xmlPart = $responseXmlObject->xpath("/d:multistatus/d:response[1]/d:propstat/d:prop/oc:spaceid");
|
||||
Assert::assertNotEmpty($xmlPart, "The 'oc:spaceid' for user '$user' was not found in the PROPFIND response");
|
||||
Assert::assertNotEmpty(
|
||||
$xmlPart,
|
||||
"The 'oc:spaceid' for user '$user' was not found in the PROPFIND response"
|
||||
);
|
||||
|
||||
$personalSpaceId = $xmlPart[0]->__toString();
|
||||
}
|
||||
@@ -577,7 +589,12 @@ class WebDavHelper {
|
||||
* @return string
|
||||
* @throws Exception|GuzzleException
|
||||
*/
|
||||
public static function getPersonalSpaceIdForUserOrFakeIfNotFound(string $baseUrl, string $user, string $password, string $xRequestId):string {
|
||||
public static function getPersonalSpaceIdForUserOrFakeIfNotFound(
|
||||
string $baseUrl,
|
||||
string $user,
|
||||
string $password,
|
||||
string $xRequestId
|
||||
): string {
|
||||
if (\str_starts_with($user, "non-exist") || \str_starts_with($user, "nonexist")) {
|
||||
return self::generateUUIDv4();
|
||||
}
|
||||
@@ -651,7 +668,9 @@ class WebDavHelper {
|
||||
}
|
||||
|
||||
// get space id if testing with spaces dav
|
||||
if ($spaceId === null && $davPathVersionToUse === self::DAV_VERSION_SPACES && !\in_array($type, ["public-files", "versions"])) {
|
||||
if ($spaceId === null && $davPathVersionToUse === self::DAV_VERSION_SPACES
|
||||
&& !\in_array($type, ["public-files", "versions"])
|
||||
) {
|
||||
$path = \ltrim($path, "/");
|
||||
if (\str_starts_with($path, "Shares/")) {
|
||||
$spaceId = GraphHelper::SHARES_SPACE_ID;
|
||||
@@ -667,7 +686,9 @@ class WebDavHelper {
|
||||
}
|
||||
|
||||
$suffixPath = $user;
|
||||
if ($davPathVersionToUse === self::DAV_VERSION_SPACES && !\in_array($type, ["archive", "versions", "public-files"])) {
|
||||
if ($davPathVersionToUse === self::DAV_VERSION_SPACES
|
||||
&& !\in_array($type, ["archive", "versions", "public-files"])
|
||||
) {
|
||||
$suffixPath = $spaceId;
|
||||
} elseif ($type === "versions") {
|
||||
// $path is file-id in case of versions
|
||||
@@ -900,7 +921,9 @@ class WebDavHelper {
|
||||
Assert::assertArrayHasKey(
|
||||
0,
|
||||
$xmlPart,
|
||||
__METHOD__ . " XML part does not have key 0. Expected a value at index 0 of 'xmlPart' but, found: " . json_encode($xmlPart)
|
||||
__METHOD__
|
||||
. " XML part does not have key 0. Expected a value at index 0 of 'xmlPart' but, found: "
|
||||
. json_encode($xmlPart)
|
||||
);
|
||||
$mtime = new DateTime($xmlPart[0]->__toString());
|
||||
return $mtime->format('U');
|
||||
|
||||
@@ -164,7 +164,9 @@ class ArchiverContext implements Context {
|
||||
foreach ($headersTable as $row) {
|
||||
$headers[$row['header']] = $row ['value'];
|
||||
}
|
||||
$this->featureContext->setResponse($this->downloadArchive($user, $resource, $addressType, $archiveType, null, $headers));
|
||||
$this->featureContext->setResponse(
|
||||
$this->downloadArchive($user, $resource, $addressType, $archiveType, null, $headers)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -156,7 +156,12 @@ class AuthContext implements Context {
|
||||
* @return void
|
||||
* @throws JsonException
|
||||
*/
|
||||
public function userRequestsEndpointsWithBodyAndNoAuthThenStatusCodeAboutUser(string $method, string $body, string $ofUser, TableNode $table): void {
|
||||
public function userRequestsEndpointsWithBodyAndNoAuthThenStatusCodeAboutUser(
|
||||
string $method,
|
||||
string $body,
|
||||
string $ofUser,
|
||||
TableNode $table
|
||||
): void {
|
||||
$ofUser = \strtolower($this->featureContext->getActualUsername($ofUser));
|
||||
$this->featureContext->verifyTableNodeColumns($table, ['endpoint']);
|
||||
foreach ($table->getHash() as $row) {
|
||||
@@ -180,7 +185,11 @@ class AuthContext implements Context {
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function userRequestsEndpointsWithoutBodyAndNoAuthAboutUser(string $method, string $ofUser, TableNode $table): void {
|
||||
public function userRequestsEndpointsWithoutBodyAndNoAuthAboutUser(
|
||||
string $method,
|
||||
string $ofUser,
|
||||
TableNode $table
|
||||
): void {
|
||||
$ofUser = \strtolower($this->featureContext->getActualUsername($ofUser));
|
||||
$this->featureContext->verifyTableNodeColumns($table, ['endpoint']);
|
||||
foreach ($table->getHash() as $row) {
|
||||
@@ -318,7 +327,12 @@ class AuthContext implements Context {
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function userRequestsURLWithUsingBasicAuthAndDepthHeader(string $user, string $url, string $method, TableNode $headersTable):void {
|
||||
public function userRequestsURLWithUsingBasicAuthAndDepthHeader(
|
||||
string $user,
|
||||
string $url,
|
||||
string $method,
|
||||
TableNode $headersTable
|
||||
): void {
|
||||
$user = $this->featureContext->getActualUsername($user);
|
||||
$url = $this->featureContext->substituteInLineCodes(
|
||||
$url,
|
||||
@@ -407,7 +421,8 @@ class AuthContext implements Context {
|
||||
$row['destination'],
|
||||
$ofUser
|
||||
);
|
||||
$headers['Destination'] = $this->featureContext->getBaseUrl() . "/" . WebdavHelper::prefixRemotePhp(\ltrim($destination, "/"));
|
||||
$headers['Destination'] = $this->featureContext->getBaseUrl()
|
||||
. "/" . WebdavHelper::prefixRemotePhp(\ltrim($destination, "/"));
|
||||
}
|
||||
$response = $this->sendRequest(
|
||||
$row['endpoint'],
|
||||
@@ -457,7 +472,8 @@ class AuthContext implements Context {
|
||||
$row['destination'],
|
||||
$ofUser
|
||||
);
|
||||
$headers['Destination'] = $this->featureContext->getBaseUrl() . "/" . WebdavHelper::prefixRemotePhp(\ltrim($destination, "/"));
|
||||
$headers['Destination'] = $this->featureContext->getBaseUrl()
|
||||
. "/" . WebdavHelper::prefixRemotePhp(\ltrim($destination, "/"));
|
||||
}
|
||||
$response = $this->sendRequest(
|
||||
$row['endpoint'],
|
||||
@@ -482,7 +498,13 @@ class AuthContext implements Context {
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function userRequestsTheseEndpointsIncludingBodyAboutUser(string $user, string $method, string $body, string $ofUser, TableNode $table):void {
|
||||
public function userRequestsTheseEndpointsIncludingBodyAboutUser(
|
||||
string $user,
|
||||
string $method,
|
||||
string $body,
|
||||
string $ofUser,
|
||||
TableNode $table
|
||||
): void {
|
||||
$user = $this->featureContext->getActualUsername($user);
|
||||
$ofUser = $this->featureContext->getActualUsername($ofUser);
|
||||
$this->featureContext->verifyTableNodeColumns($table, ['endpoint']);
|
||||
@@ -520,7 +542,12 @@ class AuthContext implements Context {
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function userRequestsTheseEndpointsWithoutBodyUsingThePasswordOfUser(string $asUser, string $method, string $ofUser, TableNode $table):void {
|
||||
public function userRequestsTheseEndpointsWithoutBodyUsingThePasswordOfUser(
|
||||
string $asUser,
|
||||
string $method,
|
||||
string $ofUser,
|
||||
TableNode $table
|
||||
): void {
|
||||
$asUser = $this->featureContext->getActualUsername($asUser);
|
||||
$ofUser = $this->featureContext->getActualUsername($ofUser);
|
||||
$this->featureContext->verifyTableNodeColumns($table, ['endpoint']);
|
||||
@@ -556,7 +583,13 @@ class AuthContext implements Context {
|
||||
* @return void
|
||||
* @throws JsonException
|
||||
*/
|
||||
public function userRequestsTheseEndpointsIncludingBodyUsingPasswordOfUser(string $asUser, string $method, ?string $body, string $ofUser, TableNode $table):void {
|
||||
public function userRequestsTheseEndpointsIncludingBodyUsingPasswordOfUser(
|
||||
string $asUser,
|
||||
string $method,
|
||||
?string $body,
|
||||
string $ofUser,
|
||||
TableNode $table
|
||||
): void {
|
||||
$asUser = $this->featureContext->getActualUsername($asUser);
|
||||
$ofUser = $this->featureContext->getActualUsername($ofUser);
|
||||
$this->featureContext->verifyTableNodeColumns($table, ['endpoint']);
|
||||
@@ -591,7 +624,12 @@ class AuthContext implements Context {
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function userRequestsTheseEndpointsAboutUser(string $user, string $method, string $ofUser, TableNode $table):void {
|
||||
public function userRequestsTheseEndpointsAboutUser(
|
||||
string $user,
|
||||
string $method,
|
||||
string $ofUser,
|
||||
TableNode $table
|
||||
): void {
|
||||
$headers = [];
|
||||
if ($method === 'MOVE' || $method === 'COPY') {
|
||||
$baseUrl = $this->featureContext->getBaseUrl();
|
||||
|
||||
@@ -76,7 +76,9 @@ class ChecksumContext implements Context {
|
||||
string $destination,
|
||||
string $checksum
|
||||
): void {
|
||||
$this->featureContext->setResponse($this->uploadFileToWithChecksumUsingTheAPI($user, $source, $destination, $checksum));
|
||||
$this->featureContext->setResponse(
|
||||
$this->uploadFileToWithChecksumUsingTheAPI($user, $source, $destination, $checksum)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -214,7 +216,11 @@ class ChecksumContext implements Context {
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function asUserTheWebdavChecksumOfPathViaPropfindShouldMatch(string $user, string $path, string $expectedChecksum):void {
|
||||
public function asUserTheWebdavChecksumOfPathViaPropfindShouldMatch(
|
||||
string $user,
|
||||
string $path,
|
||||
string $expectedChecksum
|
||||
): void {
|
||||
$user = $this->featureContext->getActualUsername($user);
|
||||
$resource = $this->propfindResourceChecksum($user, $path);
|
||||
$bodyContents = $resource->getBody()->getContents();
|
||||
@@ -243,7 +249,8 @@ class ChecksumContext implements Context {
|
||||
|
||||
Assert::assertIsArray(
|
||||
$parsed,
|
||||
__METHOD__ . " could not parse response as XML. Expected parsed XML to be an array but found " . $bodyContents
|
||||
__METHOD__
|
||||
. " could not parse response as XML. Expected parsed XML to be an array but found " . $bodyContents
|
||||
);
|
||||
Assert::assertArrayHasKey(
|
||||
0,
|
||||
@@ -360,7 +367,11 @@ class ChecksumContext implements Context {
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function theHeaderChecksumWhenUserDownloadsFileUsingTheWebdavApiShouldMatch(string $user, string $fileName, string $expectedChecksum):void {
|
||||
public function theHeaderChecksumWhenUserDownloadsFileUsingTheWebdavApiShouldMatch(
|
||||
string $user,
|
||||
string $fileName,
|
||||
string $expectedChecksum
|
||||
): void {
|
||||
$response = $this->featureContext->downloadFileAsUserUsingPassword($user, $fileName);
|
||||
$headerChecksums = $response->getHeader('OC-Checksum');
|
||||
|
||||
@@ -440,7 +451,14 @@ class ChecksumContext implements Context {
|
||||
string $destination,
|
||||
string $expectedChecksum
|
||||
): void {
|
||||
$response = $this->uploadChunkFileOfWithToWithChecksum($user, $num, $total, $data, $destination, $expectedChecksum);
|
||||
$response = $this->uploadChunkFileOfWithToWithChecksum(
|
||||
$user,
|
||||
$num,
|
||||
$total,
|
||||
$data,
|
||||
$destination,
|
||||
$expectedChecksum
|
||||
);
|
||||
$this->featureContext->setResponse($response);
|
||||
}
|
||||
|
||||
@@ -464,7 +482,14 @@ class ChecksumContext implements Context {
|
||||
string $destination,
|
||||
string $expectedChecksum
|
||||
): void {
|
||||
$response = $this->uploadChunkFileOfWithToWithChecksum($user, $num, $total, $data, $destination, $expectedChecksum);
|
||||
$response = $this->uploadChunkFileOfWithToWithChecksum(
|
||||
$user,
|
||||
$num,
|
||||
$total,
|
||||
$data,
|
||||
$destination,
|
||||
$expectedChecksum
|
||||
);
|
||||
$this->featureContext->theHTTPStatusCodeShouldBe(
|
||||
[201, 206],
|
||||
'',
|
||||
|
||||
@@ -80,7 +80,11 @@ class CliContext implements Context {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function theAdministratorResetsThePasswordOfUserUsingTheCLI(string $status, string $user, string $password): void {
|
||||
public function theAdministratorResetsThePasswordOfUserUsingTheCLI(
|
||||
string $status,
|
||||
string $user,
|
||||
string $password
|
||||
): void {
|
||||
$command = "idm resetpassword -u $user";
|
||||
$body = [
|
||||
"command" => $command,
|
||||
@@ -130,7 +134,10 @@ class CliContext implements Context {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function theAdministratorCreatesAppTokenForUserWithExpirationTimeUsingTheAuthAppCLI(string $user, string $expirationTime): void {
|
||||
public function theAdministratorCreatesAppTokenForUserWithExpirationTimeUsingTheAuthAppCLI(
|
||||
string $user,
|
||||
string $expirationTime
|
||||
): void {
|
||||
$user = $this->featureContext->getActualUserName($user);
|
||||
$command = "auth-app create --user-name=$user --expiration=$expirationTime";
|
||||
$body = [
|
||||
@@ -147,7 +154,10 @@ class CliContext implements Context {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function userHasCreatedAppTokenWithExpirationTimeUsingTheAuthAppCLI(string $user, string $expirationTime): void {
|
||||
public function userHasCreatedAppTokenWithExpirationTimeUsingTheAuthAppCLI(
|
||||
string $user,
|
||||
string $expirationTime
|
||||
): void {
|
||||
$user = $this->featureContext->getActualUserName($user);
|
||||
$command = "auth-app create --user-name=$user --expiration=$expirationTime";
|
||||
$body = [
|
||||
@@ -158,7 +168,11 @@ class CliContext implements Context {
|
||||
$this->featureContext->theHTTPStatusCodeShouldBe(200, '', $response);
|
||||
$jsonResponse = $this->featureContext->getJsonDecodedResponse($response);
|
||||
Assert::assertSame("OK", $jsonResponse["status"]);
|
||||
Assert::assertSame(0, $jsonResponse["exitCode"], "Expected exit code to be 0, but got " . $jsonResponse["exitCode"]);
|
||||
Assert::assertSame(
|
||||
0,
|
||||
$jsonResponse["exitCode"],
|
||||
"Expected exit code to be 0, but got " . $jsonResponse["exitCode"]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -253,7 +267,11 @@ class CliContext implements Context {
|
||||
$jsonResponse = $this->featureContext->getJsonDecodedResponse($response);
|
||||
|
||||
Assert::assertSame("OK", $jsonResponse["status"]);
|
||||
Assert::assertSame(0, $jsonResponse["exitCode"], "Expected exit code to be 0, but got " . $jsonResponse["exitCode"]);
|
||||
Assert::assertSame(
|
||||
0,
|
||||
$jsonResponse["exitCode"],
|
||||
"Expected exit code to be 0, but got " . $jsonResponse["exitCode"]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -86,7 +86,13 @@ class CollaborationContext implements Context {
|
||||
*
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function userChecksTheInformationOfFileOfSpaceUsingOffice(string $user, string $file, string $space, string $app, string $viewMode = null): void {
|
||||
public function userChecksTheInformationOfFileOfSpaceUsingOffice(
|
||||
string $user,
|
||||
string $file,
|
||||
string $space,
|
||||
string $app,
|
||||
string $viewMode = null
|
||||
): void {
|
||||
$fileId = $this->spacesContext->getFileId($user, $space, $file);
|
||||
$response = \json_decode(
|
||||
CollaborationHelper::sendPOSTRequestToAppOpen(
|
||||
@@ -127,7 +133,12 @@ class CollaborationContext implements Context {
|
||||
* @return void
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function userCreatesFileInsideFolderInSpaceUsingWopiEndpoint(string $user, string $file, string $folder, string $space): void {
|
||||
public function userCreatesFileInsideFolderInSpaceUsingWopiEndpoint(
|
||||
string $user,
|
||||
string $file,
|
||||
string $folder,
|
||||
string $space
|
||||
): void {
|
||||
$parentContainerId = $this->spacesContext->getResourceId($user, $space, $folder);
|
||||
$this->featureContext->setResponse(
|
||||
CollaborationHelper::createFile(
|
||||
@@ -193,7 +204,10 @@ class CollaborationContext implements Context {
|
||||
* @return void
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function thePublicCreatesAFileInsideTheLastSharedPublicLinkFolderWithPasswordUsingWopiEndpoint(string $file, string $password): void {
|
||||
public function thePublicCreatesAFileInsideTheLastSharedPublicLinkFolderWithPasswordUsingWopiEndpoint(
|
||||
string $file,
|
||||
string $password
|
||||
): void {
|
||||
$this->createFile($file, $password);
|
||||
}
|
||||
|
||||
@@ -208,7 +222,11 @@ class CollaborationContext implements Context {
|
||||
* @return void
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function thePublicCreatesAFileInsideFolderInTheLastSharedPublicLinkSpaceWithPasswordUsingWopiEndpoint(string $file, string $folder, string $password): void {
|
||||
public function thePublicCreatesAFileInsideFolderInTheLastSharedPublicLinkSpaceWithPasswordUsingWopiEndpoint(
|
||||
string $file,
|
||||
string $folder,
|
||||
string $password
|
||||
): void {
|
||||
$this->createFile($file, $password, $folder);
|
||||
}
|
||||
|
||||
@@ -225,7 +243,12 @@ class CollaborationContext implements Context {
|
||||
* @throws GuzzleException
|
||||
* @throws JsonException
|
||||
*/
|
||||
public function userTriesToCheckTheInformationOfFileOfSpaceUsingOfficeWithInvalidFileId(string $user, string $file, string $space, string $app): void {
|
||||
public function userTriesToCheckTheInformationOfFileOfSpaceUsingOfficeWithInvalidFileId(
|
||||
string $user,
|
||||
string $file,
|
||||
string $space,
|
||||
string $app
|
||||
): void {
|
||||
$response = \json_decode(
|
||||
CollaborationHelper::sendPOSTRequestToAppOpen(
|
||||
$this->spacesContext->getFileId($user, $space, $file),
|
||||
@@ -337,7 +360,9 @@ class CollaborationContext implements Context {
|
||||
*/
|
||||
public function theFollowingMimeTypesShouldExistForUser(string $shouldOrNot, TableNode $table): void {
|
||||
$rows = $table->getRows();
|
||||
$responseArray = $this->featureContext->getJsonDecodedResponse($this->featureContext->getResponse())['mime-types'];
|
||||
$responseArray = $this->featureContext->getJsonDecodedResponse(
|
||||
$this->featureContext->getResponse()
|
||||
)['mime-types'];
|
||||
$mimeTypes = \array_column($responseArray, 'mime_type');
|
||||
foreach ($rows as $row) {
|
||||
if ($shouldOrNot === "should not") {
|
||||
@@ -364,10 +389,17 @@ class CollaborationContext implements Context {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function theAppListResponseShouldContainTheFollowingTemplateInformationForOffice(string $app, TableNode $table): void {
|
||||
public function theAppListResponseShouldContainTheFollowingTemplateInformationForOffice(
|
||||
string $app,
|
||||
TableNode $table
|
||||
): void {
|
||||
$responseArray = $this->featureContext->getJsonDecodedResponse($this->featureContext->getResponse());
|
||||
|
||||
Assert::assertArrayHasKey("mime-types", $responseArray, "Expected 'mime-types' in the response but not found.\n" . print_r($responseArray, true));
|
||||
Assert::assertArrayHasKey(
|
||||
"mime-types",
|
||||
$responseArray,
|
||||
"Expected 'mime-types' in the response but not found.\n" . print_r($responseArray, true)
|
||||
);
|
||||
|
||||
$mimeTypes = $responseArray['mime-types'];
|
||||
|
||||
@@ -377,7 +409,12 @@ class CollaborationContext implements Context {
|
||||
}
|
||||
|
||||
foreach ($table->getColumnsHash() as $row) {
|
||||
Assert::assertArrayHasKey($row['mime-type'], $mimeTypeMap, "Expected mime-type '{$row['mime-type']}' to exist in the response but it doesn't.\n" . print_r($mimeTypeMap, true));
|
||||
Assert::assertArrayHasKey(
|
||||
$row['mime-type'],
|
||||
$mimeTypeMap,
|
||||
"Expected mime-type '{$row['mime-type']}' to exist in the response but it doesn't.\n"
|
||||
. print_r($mimeTypeMap, true)
|
||||
);
|
||||
|
||||
$mimeType = $mimeTypeMap[$row['mime-type']];
|
||||
$found = false;
|
||||
@@ -387,7 +424,8 @@ class CollaborationContext implements Context {
|
||||
Assert::assertSame(
|
||||
$row['target-extension'],
|
||||
$provider['target_ext'],
|
||||
"Expected 'target_ext' for $app to be '{$row['target-extension']}' but found '{$provider['target_ext']}'"
|
||||
"Expected 'target_ext' for $app to be '{$row['target-extension']}'"
|
||||
. " but found '{$provider['target_ext']}'"
|
||||
);
|
||||
$found = true;
|
||||
break;
|
||||
@@ -396,8 +434,10 @@ class CollaborationContext implements Context {
|
||||
|
||||
if (!$found) {
|
||||
Assert::fail(
|
||||
"Expected response to contain app-provider '$app' with target-extension '{$row['target-extension']}' for mime-type '{$row['mime-type']}', but no matching provider was found.\n" .
|
||||
"App Providers Found: " . print_r($mimeType['app_providers'], true)
|
||||
"Expected response to contain app-provider '$app' with target-extension "
|
||||
. "'{$row['target-extension']}' for mime-type '{$row['mime-type']}',"
|
||||
. " but no matching provider was found.\n App Providers Found: "
|
||||
. print_r($mimeType['app_providers'], true)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -176,7 +176,12 @@ class FavoritesContext implements Context {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function asUserFileOrFolderShouldBeFavorited(string $user, string $path, int $expectedValue = 1, string $spaceId = null):void {
|
||||
public function asUserFileOrFolderShouldBeFavorited(
|
||||
string $user,
|
||||
string $path,
|
||||
int $expectedValue = 1,
|
||||
string $spaceId = null
|
||||
): void {
|
||||
$property = "oc:favorite";
|
||||
$this->webDavPropertiesContext->checkPropertyOfAFolder(
|
||||
$user,
|
||||
|
||||
@@ -1034,7 +1034,11 @@ class FeatureContext extends BehatVariablesContext {
|
||||
private function checkInvalidValidator(JsonSchema $schemaObj): void {
|
||||
$validators = \array_keys((array)$schemaObj->jsonSerialize());
|
||||
foreach ($validators as $validator) {
|
||||
Assert::assertContains(\ltrim($validator, "$"), $this->jsonSchemaValidators, "Invalid schema validator: '$validator'");
|
||||
Assert::assertContains(
|
||||
\ltrim($validator, "$"),
|
||||
$this->jsonSchemaValidators,
|
||||
"Invalid schema validator: '$validator'"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1091,7 +1095,9 @@ class FeatureContext extends BehatVariablesContext {
|
||||
return;
|
||||
}
|
||||
|
||||
$hasTwoElementValidator = ($schemaObj->enum && $schemaObj->const) || ($schemaObj->enum && $schemaObj->items) || ($schemaObj->const && $schemaObj->items);
|
||||
$hasTwoElementValidator = ($schemaObj->enum && $schemaObj->const)
|
||||
|| ($schemaObj->enum && $schemaObj->items)
|
||||
|| ($schemaObj->const && $schemaObj->items);
|
||||
Assert::assertFalse($hasTwoElementValidator, "'items', 'enum' and 'const' should not be used together");
|
||||
if ($schemaObj->enum || $schemaObj->const) {
|
||||
// do not try to validate of enum or const is present
|
||||
@@ -1113,7 +1119,11 @@ class FeatureContext extends BehatVariablesContext {
|
||||
Assert::assertNotNull($schemaObj->$validator, \sprintf($errMsg, $validator));
|
||||
}
|
||||
|
||||
Assert::assertEquals($schemaObj->minItems, $schemaObj->maxItems, "'minItems' and 'maxItems' should be equal for strict assertion");
|
||||
Assert::assertEquals(
|
||||
$schemaObj->minItems,
|
||||
$schemaObj->maxItems,
|
||||
"'minItems' and 'maxItems' should be equal for strict assertion"
|
||||
);
|
||||
|
||||
// check optional validators
|
||||
foreach ($optionalValidators as $validator) {
|
||||
@@ -1127,18 +1137,34 @@ class FeatureContext extends BehatVariablesContext {
|
||||
if ($schemaObj->maxItems > 1) {
|
||||
if (\is_array($value)) {
|
||||
foreach ($value as $element) {
|
||||
Assert::assertNotNull($element->oneOf, "'oneOf' is required to assert more than one elements");
|
||||
Assert::assertNotNull(
|
||||
$element->oneOf,
|
||||
"'oneOf' is required to assert more than one elements"
|
||||
);
|
||||
}
|
||||
Assert::fail("'$validator' should be an object not an array");
|
||||
}
|
||||
Assert::assertFalse($value->allOf || $value->anyOf, "'allOf' and 'anyOf' are not allowed in array");
|
||||
Assert::assertFalse(
|
||||
$value->allOf || $value->anyOf,
|
||||
"'allOf' and 'anyOf' are not allowed in array"
|
||||
);
|
||||
if ($value->oneOf) {
|
||||
Assert::assertNotNull($value->oneOf, "'oneOf' is required to assert more than one elements");
|
||||
Assert::assertNotNull(
|
||||
$value->oneOf,
|
||||
"'oneOf' is required to assert more than one elements"
|
||||
);
|
||||
Assert::assertTrue(\is_array($value->oneOf), "'oneOf' should be an array");
|
||||
Assert::assertEquals($schemaObj->maxItems, \count($value->oneOf), "Expected " . $schemaObj->maxItems . " 'oneOf' items but got " . \count($value->oneOf));
|
||||
Assert::assertEquals(
|
||||
$schemaObj->maxItems,
|
||||
\count($value->oneOf),
|
||||
"Expected " . $schemaObj->maxItems . " 'oneOf' items but got " . \count($value->oneOf)
|
||||
);
|
||||
}
|
||||
}
|
||||
Assert::assertTrue(\is_object($value), "'$validator' should be an object when expecting 1 element");
|
||||
Assert::assertTrue(
|
||||
\is_object($value),
|
||||
"'$validator' should be an object when expecting 1 element"
|
||||
);
|
||||
break;
|
||||
case "uniqueItems":
|
||||
if ($schemaObj->minItems > 1) {
|
||||
@@ -1340,7 +1366,12 @@ class FeatureContext extends BehatVariablesContext {
|
||||
* @throws GuzzleException
|
||||
* @throws JsonException
|
||||
*/
|
||||
public function userSendsHTTPMethodToUrlWithHeaders(string $user, string $verb, string $url, TableNode $headersTable): void {
|
||||
public function userSendsHTTPMethodToUrlWithHeaders(
|
||||
string $user,
|
||||
string $verb,
|
||||
string $url,
|
||||
TableNode $headersTable
|
||||
): void {
|
||||
$this->verifyTableNodeColumns(
|
||||
$headersTable,
|
||||
['header', 'value']
|
||||
@@ -1385,7 +1416,12 @@ class FeatureContext extends BehatVariablesContext {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function userSendsHttpMethodToUrlWithContent(string $user, string $method, string $davPath, string $content): void {
|
||||
public function userSendsHttpMethodToUrlWithContent(
|
||||
string $user,
|
||||
string $method,
|
||||
string $davPath,
|
||||
string $content
|
||||
): void {
|
||||
$this->setResponse($this->sendingToWithDirectUrl($user, $method, $davPath, $content));
|
||||
}
|
||||
|
||||
@@ -1399,7 +1435,12 @@ class FeatureContext extends BehatVariablesContext {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function userSendsHTTPMethodToUrlWithPassword(string $user, string $verb, string $url, string $password): void {
|
||||
public function userSendsHTTPMethodToUrlWithPassword(
|
||||
string $user,
|
||||
string $verb,
|
||||
string $url,
|
||||
string $password
|
||||
): void {
|
||||
$this->setResponse($this->sendingToWithDirectUrl($user, $verb, $url, null, $password));
|
||||
}
|
||||
|
||||
@@ -1414,7 +1455,14 @@ class FeatureContext extends BehatVariablesContext {
|
||||
* @return ResponseInterface
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function sendingToWithDirectUrl(string $user, string $verb, string $url, ?string $body = null, ?string $password = null, ?array $headers = null): ResponseInterface {
|
||||
public function sendingToWithDirectUrl(
|
||||
string $user,
|
||||
string $verb,
|
||||
string $url,
|
||||
?string $body = null,
|
||||
?string $password = null,
|
||||
?array $headers = null
|
||||
): ResponseInterface {
|
||||
$url = \ltrim($url, '/');
|
||||
if (WebdavHelper::isDAVRequest($url)) {
|
||||
$url = WebdavHelper::prefixRemotePhp($url);
|
||||
@@ -1498,12 +1546,17 @@ class FeatureContext extends BehatVariablesContext {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function theHTTPStatusCodeShouldBe($expectedStatusCode, ?string $message = "", ?ResponseInterface $response = null): void {
|
||||
public function theHTTPStatusCodeShouldBe(
|
||||
$expectedStatusCode,
|
||||
?string $message = "",
|
||||
?ResponseInterface $response = null
|
||||
): void {
|
||||
$response = $response ?? $this->response;
|
||||
$actualStatusCode = $response->getStatusCode();
|
||||
if (\is_array($expectedStatusCode)) {
|
||||
if ($message === "") {
|
||||
$message = "HTTP status code $actualStatusCode is not one of the expected values " . \implode(" or ", $expectedStatusCode);
|
||||
$message = "HTTP status code $actualStatusCode is not one of the expected values "
|
||||
. \implode(" or ", $expectedStatusCode);
|
||||
}
|
||||
|
||||
Assert::assertContainsEquals(
|
||||
@@ -2745,7 +2798,11 @@ class FeatureContext extends BehatVariablesContext {
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function verifyTableNodeColumns(?TableNode $table, ?array $requiredHeader = [], ?array $allowedHeader = []): void {
|
||||
public function verifyTableNodeColumns(
|
||||
?TableNode $table,
|
||||
?array $requiredHeader = [],
|
||||
?array $allowedHeader = []
|
||||
): void {
|
||||
if ($table === null || \count($table->getHash()) < 1) {
|
||||
throw new Exception("Table should have at least one row.");
|
||||
}
|
||||
@@ -2830,14 +2887,17 @@ class FeatureContext extends BehatVariablesContext {
|
||||
public function getBodyForOCSRequest(string $method, string $property): ?string {
|
||||
$body = null;
|
||||
if ($method === 'PROPFIND') {
|
||||
$body = '<?xml version="1.0"?><d:propfind xmlns:d="DAV:" xmlns:oc="http://owncloud.org/ns"><d:prop><' . $property . '/></d:prop></d:propfind>';
|
||||
$body = '<?xml version="1.0"?><d:propfind xmlns:d="DAV:" xmlns:oc="http://owncloud.org/ns"><d:prop><'
|
||||
. $property . '/></d:prop></d:propfind>';
|
||||
} elseif ($method === 'LOCK') {
|
||||
$body = "<?xml version='1.0' encoding='UTF-8'?><d:lockinfo xmlns:d='DAV:'> <d:lockscope><" . $property . " /></d:lockscope></d:lockinfo>";
|
||||
$body = "<?xml version='1.0' encoding='UTF-8'?><d:lockinfo xmlns:d='DAV:'> <d:lockscope><"
|
||||
. $property . " /></d:lockscope></d:lockinfo>";
|
||||
} elseif ($method === 'PROPPATCH') {
|
||||
if ($property === 'favorite') {
|
||||
$property = '<oc:favorite xmlns:oc="http://owncloud.org/ns">1</oc:favorite>';
|
||||
}
|
||||
$body = '<?xml version="1.0"?><d:propertyupdate xmlns:d="DAV:" xmlns:oc="http://owncloud.org/ns"><d:set><d:prop>' . $property . '</d:prop></d:set></d:propertyupdate>';
|
||||
$body = '<?xml version="1.0"?><d:propertyupdate xmlns:d="DAV:" xmlns:oc="http://owncloud.org/ns"><d:set>'
|
||||
. "<d:prop>" . $property . '</d:prop></d:set></d:propertyupdate>';
|
||||
}
|
||||
if ($property === '') {
|
||||
$body = '';
|
||||
|
||||
@@ -92,7 +92,11 @@ class FilesVersionsContext implements Context {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function thePublicTriesToGetTheNumberOfVersionsOfFileWithPasswordUsingFileId(string $file, string $password, string $fileId): void {
|
||||
public function thePublicTriesToGetTheNumberOfVersionsOfFileWithPasswordUsingFileId(
|
||||
string $file,
|
||||
string $password,
|
||||
string $fileId
|
||||
): void {
|
||||
$password = $this->featureContext->getActualPassword($password);
|
||||
$this->featureContext->setResponse(
|
||||
$this->featureContext->makeDavRequest(
|
||||
@@ -129,7 +133,11 @@ class FilesVersionsContext implements Context {
|
||||
$user = $this->featureContext->getActualUsername($user);
|
||||
$fileOwner = $fileOwner ? $this->featureContext->getActualUsername($fileOwner) : $user;
|
||||
$fileId = $this->featureContext->getFileIdForPath($fileOwner, $file, $spaceId);
|
||||
Assert::assertNotNull($fileId, __METHOD__ . " fileid of file $file user $fileOwner not found (the file may not exist)");
|
||||
Assert::assertNotNull(
|
||||
$fileId,
|
||||
__METHOD__
|
||||
. " fileid of file $file user $fileOwner not found (the file may not exist)"
|
||||
);
|
||||
return $this->featureContext->makeDavRequest(
|
||||
$user,
|
||||
"PROPFIND",
|
||||
@@ -187,7 +195,11 @@ class FilesVersionsContext implements Context {
|
||||
public function getFileVersionMetadata(string $user, string $file): ResponseInterface {
|
||||
$user = $this->featureContext->getActualUsername($user);
|
||||
$fileId = $this->featureContext->getFileIdForPath($user, $file);
|
||||
Assert::assertNotNull($fileId, __METHOD__ . " fileid of file $file user $user not found (the file may not exist)");
|
||||
Assert::assertNotNull(
|
||||
$fileId,
|
||||
__METHOD__
|
||||
. " fileid of file $file user $user not found (the file may not exist)"
|
||||
);
|
||||
$body = '<?xml version="1.0"?>
|
||||
<d:propfind xmlns:d="DAV:" xmlns:oc="http://owncloud.org/ns">
|
||||
<d:prop>
|
||||
@@ -217,7 +229,11 @@ class FilesVersionsContext implements Context {
|
||||
public function restoreVersionIndexOfFile(string $user, int $versionIndex, string $path): ResponseInterface {
|
||||
$user = $this->featureContext->getActualUsername($user);
|
||||
$fileId = $this->featureContext->getFileIdForPath($user, $path);
|
||||
Assert::assertNotNull($fileId, __METHOD__ . " fileid of file $path user $user not found (the file may not exist)");
|
||||
Assert::assertNotNull(
|
||||
$fileId,
|
||||
__METHOD__
|
||||
. " fileid of file $path user $user not found (the file may not exist)"
|
||||
);
|
||||
$response = $this->listVersionFolder($user, $fileId, 1);
|
||||
$responseXmlObject = HttpRequestHelper::getResponseXml(
|
||||
$response,
|
||||
@@ -313,7 +329,11 @@ class FilesVersionsContext implements Context {
|
||||
): void {
|
||||
$user = $this->featureContext->getActualUsername($user);
|
||||
$fileId = $this->featureContext->getFileIdForPath($user, $path);
|
||||
Assert::assertNotNull($fileId, __METHOD__ . ". file '$path' for user '$user' not found (the file may not exist)");
|
||||
Assert::assertNotNull(
|
||||
$fileId,
|
||||
__METHOD__
|
||||
. ". file '$path' for user '$user' not found (the file may not exist)"
|
||||
);
|
||||
$this->assertFileVersionsCount($user, $fileId, $count);
|
||||
}
|
||||
|
||||
@@ -354,7 +374,11 @@ class FilesVersionsContext implements Context {
|
||||
): void {
|
||||
$user = $this->featureContext->getActualUsername($user);
|
||||
$fileId = $this->featureContext->getFileIdForPath($user, $path);
|
||||
Assert::assertNotNull($fileId, __METHOD__ . " fileid of file $path user $user not found (the file may not exist)");
|
||||
Assert::assertNotNull(
|
||||
$fileId,
|
||||
__METHOD__
|
||||
. " fileid of file $path user $user not found (the file may not exist)"
|
||||
);
|
||||
$response = $this->listVersionFolder($user, $fileId, 1, ['d:getcontentlength']);
|
||||
$responseXmlObject = HttpRequestHelper::getResponseXml(
|
||||
$response,
|
||||
@@ -413,10 +437,19 @@ class FilesVersionsContext implements Context {
|
||||
* @return ResponseInterface
|
||||
* @throws Exception
|
||||
*/
|
||||
public function downloadVersion(string $user, string $path, string $index, ?string $spaceId = null):ResponseInterface {
|
||||
public function downloadVersion(
|
||||
string $user,
|
||||
string $path,
|
||||
string $index,
|
||||
?string $spaceId = null
|
||||
): ResponseInterface {
|
||||
$user = $this->featureContext->getActualUsername($user);
|
||||
$fileId = $this->featureContext->getFileIdForPath($user, $path, $spaceId);
|
||||
Assert::assertNotNull($fileId, __METHOD__ . " fileid of file $path user $user not found (the file may not exist)");
|
||||
Assert::assertNotNull(
|
||||
$fileId,
|
||||
__METHOD__
|
||||
. " fileid of file $path user $user not found (the file may not exist)"
|
||||
);
|
||||
$index = (int)$index;
|
||||
$response = $this->listVersionFolder($user, $fileId, 1);
|
||||
if ($response->getStatusCode() === 403) {
|
||||
|
||||
@@ -81,7 +81,11 @@ class GraphContext implements Context {
|
||||
* @throws GuzzleException
|
||||
* @throws Exception
|
||||
*/
|
||||
public function theUserChangesTheDisplayNameOfUserToUsingTheGraphApi(string $byUser, string $user, string $displayName): void {
|
||||
public function theUserChangesTheDisplayNameOfUserToUsingTheGraphApi(
|
||||
string $byUser,
|
||||
string $user,
|
||||
string $displayName
|
||||
): void {
|
||||
$response = $this->editUserUsingTheGraphApi($byUser, $user, null, null, null, $displayName);
|
||||
$this->featureContext->setResponse($response);
|
||||
}
|
||||
@@ -98,7 +102,11 @@ class GraphContext implements Context {
|
||||
* @throws GuzzleException
|
||||
* @throws Exception
|
||||
*/
|
||||
public function theUserChangesTheUserNameOfUserToUsingTheGraphApi(string $byUser, string $user, string $userName): void {
|
||||
public function theUserChangesTheUserNameOfUserToUsingTheGraphApi(
|
||||
string $byUser,
|
||||
string $user,
|
||||
string $userName
|
||||
): void {
|
||||
$response = $this->editUserUsingTheGraphApi($byUser, $user, $userName);
|
||||
$this->featureContext->setResponse($response);
|
||||
// need to add user to list to delete him after test
|
||||
@@ -189,7 +197,16 @@ class GraphContext implements Context {
|
||||
* @return void
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function editUserUsingTheGraphApi(string $byUser, string $user, string $userName = null, string $password = null, string $email = null, string $displayName = null, bool $accountEnabled = true, string $method="PATCH"): ResponseInterface {
|
||||
public function editUserUsingTheGraphApi(
|
||||
string $byUser,
|
||||
string $user,
|
||||
string $userName = null,
|
||||
string $password = null,
|
||||
string $email = null,
|
||||
string $displayName = null,
|
||||
bool $accountEnabled = true,
|
||||
string $method="PATCH"
|
||||
): ResponseInterface {
|
||||
$user = $this->featureContext->getActualUsername($user);
|
||||
$userId = $this->featureContext->getAttributeOfCreatedUser($user, 'id') ?: $user;
|
||||
return GraphHelper::editUser(
|
||||
@@ -528,8 +545,10 @@ class GraphContext implements Context {
|
||||
* @return array
|
||||
*/
|
||||
public function getAdminOrUserCredentials(?string $user): array {
|
||||
$credentials["username"] = $user ? $this->featureContext->getActualUsername($user) : $this->featureContext->getAdminUsername();
|
||||
$credentials["password"] = $user ? $this->featureContext->getPasswordForUser($user) : $this->featureContext->getAdminPassword();
|
||||
$credentials["username"] = $user ? $this->featureContext->getActualUsername($user)
|
||||
: $this->featureContext->getAdminUsername();
|
||||
$credentials["password"] = $user ? $this->featureContext->getPasswordForUser($user)
|
||||
: $this->featureContext->getAdminPassword();
|
||||
return $credentials;
|
||||
}
|
||||
/**
|
||||
@@ -605,7 +624,10 @@ class GraphContext implements Context {
|
||||
* @return ResponseInterface
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function listSingleOrAllGroupsAlongWithAllMemberInformation(string $user, ?string $group = null): ResponseInterface {
|
||||
public function listSingleOrAllGroupsAlongWithAllMemberInformation(
|
||||
string $user,
|
||||
?string $group = null
|
||||
): ResponseInterface {
|
||||
$credentials = $this->getAdminOrUserCredentials($user);
|
||||
|
||||
return GraphHelper::getSingleOrAllGroupsAlongWithMembers(
|
||||
@@ -759,7 +781,10 @@ class GraphContext implements Context {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function theAdministratorTriesToAddNonExistentUserToGroupUsingTheGraphAPI(string $group, ?string $byUser = null): void {
|
||||
public function theAdministratorTriesToAddNonExistentUserToGroupUsingTheGraphAPI(
|
||||
string $group,
|
||||
?string $byUser = null
|
||||
): void {
|
||||
$this->featureContext->setResponse($this->addUserToGroup($group, "nonexistent", $byUser));
|
||||
}
|
||||
|
||||
@@ -774,7 +799,10 @@ class GraphContext implements Context {
|
||||
*
|
||||
* @throws GuzzleException | Exception
|
||||
*/
|
||||
public function theAdministratorTriesToAddUserToNonExistentGroupUsingTheGraphAPI(string $user, ?string $byUser = null): void {
|
||||
public function theAdministratorTriesToAddUserToNonExistentGroupUsingTheGraphAPI(
|
||||
string $user,
|
||||
?string $byUser = null
|
||||
): void {
|
||||
$this->featureContext->setResponse($this->addUserToGroup("nonexistent", $user, $byUser));
|
||||
}
|
||||
|
||||
@@ -799,7 +827,11 @@ class GraphContext implements Context {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function theUserTriesToAddAnotherUserToGroupUsingTheGraphAPI(string $byUser, string $user, string $group): void {
|
||||
public function theUserTriesToAddAnotherUserToGroupUsingTheGraphAPI(
|
||||
string $byUser,
|
||||
string $user,
|
||||
string $group
|
||||
): void {
|
||||
$this->featureContext->setResponse($this->addUserToGroup($group, $user, $byUser));
|
||||
}
|
||||
|
||||
@@ -1032,7 +1064,8 @@ class GraphContext implements Context {
|
||||
Assert::assertTrue(
|
||||
$exists,
|
||||
__METHOD__
|
||||
. "\nExpected user '" . $userGroup['username'] . "' to be in group '" . $userGroup['groupname'] . "'. But not found."
|
||||
. "\nExpected user '" . $userGroup['username'] . "' to be in group '"
|
||||
. $userGroup['groupname'] . "'. But not found."
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1098,12 +1131,16 @@ class GraphContext implements Context {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function theAdministratorRemovesTheFollowingUsersFromTheFollowingGroupsUsingTheGraphApi(TableNode $table): void {
|
||||
public function theAdministratorRemovesTheFollowingUsersFromTheFollowingGroupsUsingTheGraphApi(
|
||||
TableNode $table
|
||||
): void {
|
||||
$this->featureContext->verifyTableNodeColumns($table, ['username', 'groupname']);
|
||||
$usersGroups = $table->getColumnsHash();
|
||||
|
||||
foreach ($usersGroups as $userGroup) {
|
||||
$this->featureContext->setResponse($this->removeUserFromGroup($userGroup['groupname'], $userGroup['username']));
|
||||
$this->featureContext->setResponse(
|
||||
$this->removeUserFromGroup($userGroup['groupname'], $userGroup['username'])
|
||||
);
|
||||
$this->featureContext->pushToLastHttpStatusCodesArray();
|
||||
}
|
||||
}
|
||||
@@ -1118,7 +1155,11 @@ class GraphContext implements Context {
|
||||
* @return void
|
||||
* @throws Exception | GuzzleException
|
||||
*/
|
||||
public function theUserTriesToRemoveAnotherUserFromGroupUsingTheGraphAPI(string $user, string $group, ?string $byUser = null): void {
|
||||
public function theUserTriesToRemoveAnotherUserFromGroupUsingTheGraphAPI(
|
||||
string $user,
|
||||
string $group,
|
||||
?string $byUser = null
|
||||
): void {
|
||||
$this->featureContext->setResponse($this->removeUserFromGroup($group, $user, $byUser));
|
||||
}
|
||||
|
||||
@@ -1132,7 +1173,10 @@ class GraphContext implements Context {
|
||||
* @return void
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function theUserTriesToRemoveAnotherUserFromNonExistentGroupUsingTheGraphAPI(string $user, ?string $byUser = null): void {
|
||||
public function theUserTriesToRemoveAnotherUserFromNonExistentGroupUsingTheGraphAPI(
|
||||
string $user,
|
||||
?string $byUser = null
|
||||
): void {
|
||||
$this->featureContext->setResponse($this->removeUserFromGroup('', $user, $byUser));
|
||||
}
|
||||
|
||||
@@ -1351,7 +1395,11 @@ class GraphContext implements Context {
|
||||
* @throws GuzzleException
|
||||
* @throws Exception
|
||||
*/
|
||||
public function addMultipleUsersToGroup(string $user, array $userIds, string $groupId): ResponseInterface {
|
||||
public function addMultipleUsersToGroup(
|
||||
string $user,
|
||||
array $userIds,
|
||||
string $groupId
|
||||
): ResponseInterface {
|
||||
$credentials = $this->getAdminOrUserCredentials($user);
|
||||
|
||||
return GraphHelper::addUsersToGroup(
|
||||
@@ -1375,7 +1423,11 @@ class GraphContext implements Context {
|
||||
* @throws Exception
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function theAdministratorAddsTheFollowingUsersToAGroupInASingleRequestUsingTheGraphApi(string $user, string $group, TableNode $table): void {
|
||||
public function theAdministratorAddsTheFollowingUsersToAGroupInASingleRequestUsingTheGraphApi(
|
||||
string $user,
|
||||
string $group,
|
||||
TableNode $table
|
||||
): void {
|
||||
$userIds = [];
|
||||
$groupId = $this->featureContext->getAttributeOfCreatedGroup($group, "id");
|
||||
foreach ($table->getHash() as $row) {
|
||||
@@ -1397,7 +1449,11 @@ class GraphContext implements Context {
|
||||
* @throws Exception
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function userTriesToAddTheFollowingUsersToAGroupAtOnceWithInvalidHostUsingTheGraphApi(string $user, string $group, TableNode $table): void {
|
||||
public function userTriesToAddTheFollowingUsersToAGroupAtOnceWithInvalidHostUsingTheGraphApi(
|
||||
string $user,
|
||||
string $group,
|
||||
TableNode $table
|
||||
): void {
|
||||
$userIds = [];
|
||||
$groupId = $this->featureContext->getAttributeOfCreatedGroup($group, "id");
|
||||
$credentials = $this->getAdminOrUserCredentials($user);
|
||||
@@ -1436,7 +1492,11 @@ class GraphContext implements Context {
|
||||
* @throws Exception
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function userTriesToAddUserToGroupWithInvalidHostUsingTheGraphApi(string $adminUser, string $user, string $group): void {
|
||||
public function userTriesToAddUserToGroupWithInvalidHostUsingTheGraphApi(
|
||||
string $adminUser,
|
||||
string $user,
|
||||
string $group
|
||||
): void {
|
||||
$groupId = $this->featureContext->getAttributeOfCreatedGroup($group, "id");
|
||||
$userId = $this->featureContext->getAttributeOfCreatedUser($user, "id");
|
||||
$credentials = $this->getAdminOrUserCredentials($adminUser);
|
||||
@@ -1467,7 +1527,10 @@ class GraphContext implements Context {
|
||||
* @throws GuzzleException
|
||||
* @throws Exception
|
||||
*/
|
||||
public function theAdministratorTriesToAddsTheFollowingUsersToANonExistingGroupAtOnceUsingTheGraphApi(string $user, TableNode $table): void {
|
||||
public function theAdministratorTriesToAddsTheFollowingUsersToANonExistingGroupAtOnceUsingTheGraphApi(
|
||||
string $user,
|
||||
TableNode $table
|
||||
): void {
|
||||
$userIds = [];
|
||||
$groupId = WebDavHelper::generateUUIDv4();
|
||||
foreach ($table->getHash() as $row) {
|
||||
@@ -1489,7 +1552,11 @@ class GraphContext implements Context {
|
||||
* @throws GuzzleException
|
||||
* @throws Exception
|
||||
*/
|
||||
public function theAdministratorTriesToAddTheFollowingNonExistingUsersToAGroupAtOnceUsingTheGraphApi(string $user, string $group, TableNode $table): void {
|
||||
public function theAdministratorTriesToAddTheFollowingNonExistingUsersToAGroupAtOnceUsingTheGraphApi(
|
||||
string $user,
|
||||
string $group,
|
||||
TableNode $table
|
||||
): void {
|
||||
$userIds = [];
|
||||
$groupId = $this->featureContext->getAttributeOfCreatedGroup($group, "id");
|
||||
foreach ($table->getHash() as $row) {
|
||||
@@ -1512,7 +1579,11 @@ class GraphContext implements Context {
|
||||
* @throws GuzzleException
|
||||
* @throws Exception
|
||||
*/
|
||||
public function theAdministratorTriesToAddTheFollowingUsersToAGroupAtOnceUsingTheGraphApi(string $user, string $group, TableNode $table): void {
|
||||
public function theAdministratorTriesToAddTheFollowingUsersToAGroupAtOnceUsingTheGraphApi(
|
||||
string $user,
|
||||
string $group,
|
||||
TableNode $table
|
||||
): void {
|
||||
$userIds = [];
|
||||
$groupId = $this->featureContext->getAttributeOfCreatedGroup($group, "id");
|
||||
foreach ($table->getHash() as $row) {
|
||||
@@ -1550,7 +1621,11 @@ class GraphContext implements Context {
|
||||
* @return void
|
||||
*/
|
||||
public function theResponseShouldContainTheFollowingApplicationInformation(TableNode $table): void {
|
||||
Assert::assertIsArray($responseArray = ($this->featureContext->getJsonDecodedResponse($this->featureContext->getResponse()))['value'][0]);
|
||||
Assert::assertIsArray(
|
||||
$responseArray = (
|
||||
$this->featureContext->getJsonDecodedResponse($this->featureContext->getResponse())
|
||||
)['value'][0]
|
||||
);
|
||||
foreach ($table->getHash() as $row) {
|
||||
$key = $row["key"];
|
||||
if ($key === 'id') {
|
||||
@@ -1572,7 +1647,11 @@ class GraphContext implements Context {
|
||||
* @return void
|
||||
*/
|
||||
public function theResponseShouldContainTheFollowingAppRolesInformation(TableNode $table): void {
|
||||
Assert::assertIsArray($responseArray = ($this->featureContext->getJsonDecodedResponse($this->featureContext->getResponse()))['value'][0]);
|
||||
Assert::assertIsArray(
|
||||
$responseArray = (
|
||||
$this->featureContext->getJsonDecodedResponse($this->featureContext->getResponse())
|
||||
)['value'][0]
|
||||
);
|
||||
foreach ($table->getRows() as $row) {
|
||||
$foundRoleInResponse = false;
|
||||
foreach ($responseArray['appRoles'] as $role) {
|
||||
@@ -1640,7 +1719,11 @@ class GraphContext implements Context {
|
||||
* @return void
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function userGetsAllUsersOfFirstGroupOderSecondGroupUsingTheGraphApi(string $user, string $firstGroup, string $secondGroup) {
|
||||
public function userGetsAllUsersOfFirstGroupOderSecondGroupUsingTheGraphApi(
|
||||
string $user,
|
||||
string $firstGroup,
|
||||
string $secondGroup
|
||||
) {
|
||||
$response = GraphHelper::getUsersFromOneOrOtherGroup(
|
||||
$this->featureContext->getBaseUrl(),
|
||||
$this->featureContext->getStepLineRef(),
|
||||
@@ -1708,7 +1791,11 @@ class GraphContext implements Context {
|
||||
* @return void
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function userGetsAllUsersWithRoleAndMemberOfGroupUsingTheGraphApi(string $user, string $role, string $group) {
|
||||
public function userGetsAllUsersWithRoleAndMemberOfGroupUsingTheGraphApi(
|
||||
string $user,
|
||||
string $role,
|
||||
string $group
|
||||
) {
|
||||
$response = GraphHelper::getUsersWithFilterRolesAssignmentAndMemberOf(
|
||||
$this->featureContext->getBaseUrl(),
|
||||
$this->featureContext->getStepLineRef(),
|
||||
@@ -1841,7 +1928,8 @@ class GraphContext implements Context {
|
||||
$this->appEntity["appRoles"][$role],
|
||||
$response['appRoleId'],
|
||||
__METHOD__
|
||||
. "\nExpected rolId for role '$role'' to be '" . $this->appEntity["appRoles"][$role] . "' but got '" . $response['appRoleId'] . "'"
|
||||
. "\nExpected rolId for role '$role'' to be '" . $this->appEntity["appRoles"][$role]
|
||||
. "' but got '" . $response['appRoleId'] . "'"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1953,7 +2041,11 @@ class GraphContext implements Context {
|
||||
* @throws GuzzleException
|
||||
* @throws Exception
|
||||
*/
|
||||
public function theAdministratorHasAddedTheFollowingUsersToAGroupAtOnceUsingTheGraphApi(string $user, string $group, TableNode $table) {
|
||||
public function theAdministratorHasAddedTheFollowingUsersToAGroupAtOnceUsingTheGraphApi(
|
||||
string $user,
|
||||
string $group,
|
||||
TableNode $table
|
||||
) {
|
||||
$userIds = [];
|
||||
$groupId = $this->featureContext->getAttributeOfCreatedGroup($group, "id");
|
||||
foreach ($table->getHash() as $row) {
|
||||
@@ -1975,13 +2067,18 @@ class GraphContext implements Context {
|
||||
* @throws GuzzleException
|
||||
* @throws Exception
|
||||
*/
|
||||
public function theAdministratorTriesToAddGroupToAGroupAtOnceUsingTheGraphApi(string $user, string $groupToAdd, string $group) {
|
||||
public function theAdministratorTriesToAddGroupToAGroupAtOnceUsingTheGraphApi(
|
||||
string $user,
|
||||
string $groupToAdd,
|
||||
string $group
|
||||
) {
|
||||
$groupId = $this->featureContext->getAttributeOfCreatedGroup($group, "id");
|
||||
$groupIdToAdd = $this->featureContext->getAttributeOfCreatedGroup($groupToAdd, "id");
|
||||
$credentials = $this->getAdminOrUserCredentials($user);
|
||||
|
||||
$payload = [
|
||||
"members@odata.bind" => [GraphHelper::getFullUrl($this->featureContext->getBaseUrl(), 'groups/' . $groupIdToAdd)]
|
||||
"members@odata.bind" => [
|
||||
GraphHelper::getFullUrl($this->featureContext->getBaseUrl(), 'groups/' . $groupIdToAdd)]
|
||||
];
|
||||
|
||||
$this->featureContext->setResponse(
|
||||
@@ -2008,7 +2105,11 @@ class GraphContext implements Context {
|
||||
* @throws GuzzleException
|
||||
* @throws Exception
|
||||
*/
|
||||
public function theAdministratorTriesToAddAGroupToAGroupThroughPostRequestUsingTheGraphApi(string $user, string $groupToAdd, string $group) {
|
||||
public function theAdministratorTriesToAddAGroupToAGroupThroughPostRequestUsingTheGraphApi(
|
||||
string $user,
|
||||
string $groupToAdd,
|
||||
string $group
|
||||
) {
|
||||
$groupId = $this->featureContext->getAttributeOfCreatedGroup($group, "id");
|
||||
$groupIdToAdd = $this->featureContext->getAttributeOfCreatedGroup($groupToAdd, "id");
|
||||
$credentials = $this->getAdminOrUserCredentials($user);
|
||||
@@ -2041,7 +2142,12 @@ class GraphContext implements Context {
|
||||
* @throws Exception
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function userTriesToAddUserToGroupWithInvalidJsonUsingTheGraphApi(string $adminUser, string $user, string $group, string $invalidJSON): void {
|
||||
public function userTriesToAddUserToGroupWithInvalidJsonUsingTheGraphApi(
|
||||
string $adminUser,
|
||||
string $user,
|
||||
string $group,
|
||||
string $invalidJSON
|
||||
): void {
|
||||
$groupId = $this->featureContext->getAttributeOfCreatedGroup($group, "id");
|
||||
$credentials = $this->getAdminOrUserCredentials($adminUser);
|
||||
|
||||
@@ -2078,7 +2184,12 @@ class GraphContext implements Context {
|
||||
* @throws Exception
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function userTriesToAddTheFollowingUsersToAGroupAtOnceWithInvalidJsonUsingTheGraphApi(string $user, string $group, string $invalidJSON, TableNode $table): void {
|
||||
public function userTriesToAddTheFollowingUsersToAGroupAtOnceWithInvalidJsonUsingTheGraphApi(
|
||||
string $user,
|
||||
string $group,
|
||||
string $invalidJSON,
|
||||
TableNode $table
|
||||
): void {
|
||||
$groupId = $this->featureContext->getAttributeOfCreatedGroup($group, "id");
|
||||
$credentials = $this->getAdminOrUserCredentials($user);
|
||||
foreach ($table->getHash() as $row) {
|
||||
@@ -2116,7 +2227,11 @@ class GraphContext implements Context {
|
||||
* @throws GuzzleException
|
||||
* @throws Exception
|
||||
*/
|
||||
public function theAdministratorTriesToAddTheFollowingUserIdWithInvalidCharacterToAGroup(string $user, string $group, TableNode $table) {
|
||||
public function theAdministratorTriesToAddTheFollowingUserIdWithInvalidCharacterToAGroup(
|
||||
string $user,
|
||||
string $group,
|
||||
TableNode $table
|
||||
) {
|
||||
$userIds = [];
|
||||
$credentials = $this->getAdminOrUserCredentials($user);
|
||||
$groupId = $this->featureContext->getAttributeOfCreatedGroup($group, "id");
|
||||
@@ -2146,7 +2261,11 @@ class GraphContext implements Context {
|
||||
* @throws GuzzleException
|
||||
* @throws Exception
|
||||
*/
|
||||
public function theAdministratorTriesToAddUserIdWithInvalidCharactersToAGroup(string $user, string $userId, string $group): void {
|
||||
public function theAdministratorTriesToAddUserIdWithInvalidCharactersToAGroup(
|
||||
string $user,
|
||||
string $userId,
|
||||
string $group
|
||||
): void {
|
||||
$credentials = $this->getAdminOrUserCredentials($user);
|
||||
$groupId = $this->featureContext->getAttributeOfCreatedGroup($group, "id");
|
||||
$this->featureContext->setResponse(
|
||||
@@ -2183,7 +2302,8 @@ class GraphContext implements Context {
|
||||
Assert::assertEquals(
|
||||
1,
|
||||
$count,
|
||||
"Expected user '" . $user . "' to be added once to group '" . $group . "' but the user is listed '" . $count . "' times"
|
||||
"Expected user '" . $user . "' to be added once to group '"
|
||||
. $group . "' but the user is listed '" . $count . "' times"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2248,7 +2368,11 @@ class GraphContext implements Context {
|
||||
* @throws Exception
|
||||
*
|
||||
*/
|
||||
public function downloadedJsonContentShouldContainEventTypeInItemAndShouldMatch(string $eventType, ?string $spaceType=null, PyStringNode $schemaString=null): void {
|
||||
public function downloadedJsonContentShouldContainEventTypeInItemAndShouldMatch(
|
||||
string $eventType,
|
||||
?string $spaceType=null,
|
||||
PyStringNode $schemaString=null
|
||||
): void {
|
||||
$actualResponseToAssert = null;
|
||||
$events = $this->featureContext->getJsonDecodedResponseBodyContent()->events;
|
||||
foreach ($events as $event) {
|
||||
@@ -2307,7 +2431,11 @@ class GraphContext implements Context {
|
||||
* @return void
|
||||
*
|
||||
*/
|
||||
public function userTriesToExportGdprReportOfAnotherUserUsingGraphApi(string $user, string $ofUser, string $path): void {
|
||||
public function userTriesToExportGdprReportOfAnotherUserUsingGraphApi(
|
||||
string $user,
|
||||
string $ofUser,
|
||||
string $path
|
||||
): void {
|
||||
$credentials = $this->getAdminOrUserCredentials($user);
|
||||
$this->featureContext->setResponse(
|
||||
GraphHelper::generateGDPRReport(
|
||||
@@ -2328,7 +2456,8 @@ class GraphContext implements Context {
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function getAssignedRole(string $user): ResponseInterface {
|
||||
$userId = $this->featureContext->getAttributeOfCreatedUser($user, 'id') ?: $this->featureContext->getUserIdByUserName($user);
|
||||
$userId = $this->featureContext->getAttributeOfCreatedUser($user, 'id')
|
||||
?: $this->featureContext->getUserIdByUserName($user);
|
||||
return (
|
||||
GraphHelper::getAssignedRole(
|
||||
$this->featureContext->getBAseUrl(),
|
||||
@@ -2359,7 +2488,9 @@ class GraphContext implements Context {
|
||||
if (!$userId && $ofUser !== $this->featureContext->getAdminUsername()) {
|
||||
$appRoleAssignmentId = $this->getRoleIdByRoleName("User");
|
||||
} else {
|
||||
$appRoleAssignmentId = $this->featureContext->getJsonDecodedResponse($this->getAssignedRole($ofUser))["value"][0]["id"];
|
||||
$appRoleAssignmentId = $this->featureContext->getJsonDecodedResponse(
|
||||
$this->getAssignedRole($ofUser)
|
||||
)["value"][0]["id"];
|
||||
}
|
||||
|
||||
$userId = $userId ?: $ofUser;
|
||||
@@ -2508,7 +2639,11 @@ class GraphContext implements Context {
|
||||
* @return void
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function userListsTheResourcesSharedWithThemUsingGraphApi(string $user, string $cacheStepString, string $retryOption): void {
|
||||
public function userListsTheResourcesSharedWithThemUsingGraphApi(
|
||||
string $user,
|
||||
string $cacheStepString,
|
||||
string $retryOption
|
||||
): void {
|
||||
if ($cacheStepString !== '') {
|
||||
// ENV (GRAPH_SPACES_GROUPS_CACHE_TTL | GRAPH_SPACES_USERS_CACHE_TTL) is set default to 60 sec
|
||||
// which means 60 sec is required to clean up all the user|group cache once they are deleted
|
||||
@@ -2537,7 +2672,9 @@ class GraphContext implements Context {
|
||||
if ($retryEnabled) {
|
||||
foreach ($jsonBody->value as $share) {
|
||||
$autoSync = $this->featureContext->getUserAutoSyncSetting($credentials['username']);
|
||||
$tryAgain = !$share->{'@client.synchronize'} && $autoSync && $retried < HttpRequestHelper::numRetriesOnHttpTooEarly();
|
||||
$tryAgain = !$share->{'@client.synchronize'}
|
||||
&& $autoSync
|
||||
&& $retried < HttpRequestHelper::numRetriesOnHttpTooEarly();
|
||||
|
||||
if ($tryAgain) {
|
||||
$retried += 1;
|
||||
@@ -2676,7 +2813,11 @@ class GraphContext implements Context {
|
||||
* @throws GuzzleException
|
||||
* @throws JsonException
|
||||
*/
|
||||
public function userUsingPasswordShouldBeAbleToCreateANewUserWithDefaultAttributes(string $byUser, string $password, string $user): void {
|
||||
public function userUsingPasswordShouldBeAbleToCreateANewUserWithDefaultAttributes(
|
||||
string $byUser,
|
||||
string $password,
|
||||
string $user
|
||||
): void {
|
||||
$response = GraphHelper::createUser(
|
||||
$this->featureContext->getBaseUrl(),
|
||||
$this->featureContext->getStepLineRef(),
|
||||
@@ -2772,7 +2913,11 @@ class GraphContext implements Context {
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function userListsTheActivitiesForResourceOfSpaceUsingTheGraphAPI(string $user, string $resource, string $spaceName): void {
|
||||
public function userListsTheActivitiesForResourceOfSpaceUsingTheGraphAPI(
|
||||
string $user,
|
||||
string $resource,
|
||||
string $spaceName
|
||||
): void {
|
||||
$resourceId = $this->featureContext->spacesContext->getResourceId($user, $spaceName, $resource);
|
||||
$response = GraphHelper::getActivities(
|
||||
$this->featureContext->getBaseUrl(),
|
||||
@@ -2792,7 +2937,10 @@ class GraphContext implements Context {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function userTriesToListTheActivitiesOfFolderWithShareMountIdPointIdUsingTheGraphApi(string $user, string $folder): void {
|
||||
public function userTriesToListTheActivitiesOfFolderWithShareMountIdPointIdUsingTheGraphApi(
|
||||
string $user,
|
||||
string $folder
|
||||
): void {
|
||||
$resourceId = GraphHelper::getShareMountId(
|
||||
$this->featureContext->getBaseUrl(),
|
||||
$this->featureContext->getStepLineRef(),
|
||||
@@ -2820,7 +2968,12 @@ class GraphContext implements Context {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function userTriesToListActivitiesOfFileFromSpaceOwnedByUserUsingTheGraphApi(string $user, string $file, string $owner, string $spaceName): void {
|
||||
public function userTriesToListActivitiesOfFileFromSpaceOwnedByUserUsingTheGraphApi(
|
||||
string $user,
|
||||
string $file,
|
||||
string $owner,
|
||||
string $spaceName
|
||||
): void {
|
||||
$resourceId = $this->featureContext->spacesContext->getResourceId($owner, $spaceName, $file);
|
||||
$response = GraphHelper::getActivities(
|
||||
$this->featureContext->getBaseUrl(),
|
||||
@@ -2861,7 +3014,11 @@ class GraphContext implements Context {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function thePublicTriesToCheckTheActivitiesOfSpaceOwnedByUserWithPasswordUsingGraphApi(string $spaceName, string $user, string $password): void {
|
||||
public function thePublicTriesToCheckTheActivitiesOfSpaceOwnedByUserWithPasswordUsingGraphApi(
|
||||
string $spaceName,
|
||||
string $user,
|
||||
string $password
|
||||
): void {
|
||||
$response = GraphHelper::getActivities(
|
||||
$this->featureContext->getBaseUrl(),
|
||||
$this->featureContext->getStepLineRef(),
|
||||
@@ -2882,7 +3039,12 @@ class GraphContext implements Context {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function thePublicTriesToCheckTheActivitiesOfResourceFromSpaceOwnedByUserWithPasswordUsingGraphApi(string $resource, string $space, string $owner, string $password): void {
|
||||
public function thePublicTriesToCheckTheActivitiesOfResourceFromSpaceOwnedByUserWithPasswordUsingGraphApi(
|
||||
string $resource,
|
||||
string $space,
|
||||
string $owner,
|
||||
string $password
|
||||
): void {
|
||||
$response = GraphHelper::getActivities(
|
||||
$this->featureContext->getBaseUrl(),
|
||||
$this->featureContext->getStepLineRef(),
|
||||
@@ -2904,7 +3066,13 @@ class GraphContext implements Context {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function userListsTheActivitiesForFolderOfSpaceWithDepthOrLimitUsingTheGraphApi(string $user, string $resource, string $spaceName, string $filterType, string $filterValue): void {
|
||||
public function userListsTheActivitiesForFolderOfSpaceWithDepthOrLimitUsingTheGraphApi(
|
||||
string $user,
|
||||
string $resource,
|
||||
string $spaceName,
|
||||
string $filterType,
|
||||
string $filterValue
|
||||
): void {
|
||||
$resourceId = $this->featureContext->spacesContext->getResourceId($user, $spaceName, $resource);
|
||||
$response = GraphHelper::getActivities(
|
||||
$this->featureContext->getBaseUrl(),
|
||||
@@ -2932,7 +3100,8 @@ class GraphContext implements Context {
|
||||
foreach ($table->getHash() as $index => $expectedValue) {
|
||||
$actualActivity = $activities[$index];
|
||||
$expectedActivity = $expectedValue['resource'] . ":" . $expectedValue['message'];
|
||||
$actualActivity = $actualActivity->template->variables->resource->name . ":" . $actualActivity->template->message;
|
||||
$actualActivity = $actualActivity->template->variables->resource->name
|
||||
. ":" . $actualActivity->template->message;
|
||||
Assert::assertEquals($expectedActivity, $actualActivity, "Activity didn't match");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -324,7 +324,10 @@ class NotificationContext implements Context {
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
public function filterResponseAccordingToNotificationSubject(string $subject, ?ResponseInterface $response = null): object {
|
||||
public function filterResponseAccordingToNotificationSubject(
|
||||
string $subject,
|
||||
?ResponseInterface $response = null
|
||||
): object {
|
||||
$response = $response ?? $this->featureContext->getResponse();
|
||||
if (isset($this->featureContext->getJsonDecodedResponseBodyContent($response)->ocs->data)) {
|
||||
$responseBody = $this->featureContext->getJsonDecodedResponseBodyContent($response)->ocs->data;
|
||||
@@ -351,7 +354,11 @@ class NotificationContext implements Context {
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function filterNotificationsBySubjectAndResource(string $subject, string $resource, ?ResponseInterface $response = null): array {
|
||||
public function filterNotificationsBySubjectAndResource(
|
||||
string $subject,
|
||||
string $resource,
|
||||
?ResponseInterface $response = null
|
||||
): array {
|
||||
$filteredNotifications = [];
|
||||
$response = $response ?? $this->featureContext->getResponse();
|
||||
$responseObject = $this->featureContext->getJsonDecodedResponseBodyContent($response);
|
||||
@@ -362,7 +369,10 @@ class NotificationContext implements Context {
|
||||
|
||||
$notifications = $responseObject->ocs->data;
|
||||
foreach ($notifications as $notification) {
|
||||
if (isset($notification->subject) && $notification->subject === $subject && isset($notification->messageRichParameters->resource->name) && $notification->messageRichParameters->resource->name === $resource) {
|
||||
if (isset($notification->subject) && $notification->subject === $subject
|
||||
&& isset($notification->messageRichParameters->resource->name)
|
||||
&& $notification->messageRichParameters->resource->name === $resource
|
||||
) {
|
||||
$this->notificationIds[] = $notification->notification_id;
|
||||
$filteredNotifications[] = $notification;
|
||||
}
|
||||
@@ -392,9 +402,15 @@ class NotificationContext implements Context {
|
||||
$response = $this->listAllNotifications($user);
|
||||
$this->featureContext->theHTTPStatusCodeShouldBe(200, "", $response);
|
||||
++$count;
|
||||
} while (!isset($this->filterResponseAccordingToNotificationSubject($subject, $response)->message) && $count <= 5);
|
||||
} while (!isset($this->filterResponseAccordingToNotificationSubject($subject, $response)->message)
|
||||
&& $count <= 5
|
||||
);
|
||||
if (isset($this->filterResponseAccordingToNotificationSubject($subject, $response)->message)) {
|
||||
$actualMessage = str_replace(["\r", "\n"], " ", $this->filterResponseAccordingToNotificationSubject($subject, $response)->message);
|
||||
$actualMessage = str_replace(
|
||||
["\r", "\n"],
|
||||
" ",
|
||||
$this->filterResponseAccordingToNotificationSubject($subject, $response)->message
|
||||
);
|
||||
} else {
|
||||
throw new \Exception("Notification was not found even after retrying for 5 seconds.");
|
||||
}
|
||||
@@ -417,7 +433,12 @@ class NotificationContext implements Context {
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function userShouldGetNotificationForResourceWithMessage(string $user, string $resource, string $subject, TableNode $table):void {
|
||||
public function userShouldGetNotificationForResourceWithMessage(
|
||||
string $user,
|
||||
string $resource,
|
||||
string $subject,
|
||||
TableNode $table
|
||||
): void {
|
||||
$response = $this->listAllNotifications($user);
|
||||
$notification = $this->filterNotificationsBySubjectAndResource($subject, $resource, $response);
|
||||
|
||||
@@ -432,9 +453,15 @@ class NotificationContext implements Context {
|
||||
$response = $this->userDeletesNotification($user);
|
||||
$this->featureContext->theHTTPStatusCodeShouldBe(200, '', $response);
|
||||
} elseif (\count($notification) === 0) {
|
||||
throw new \Exception("Response doesn't contain any notification with resource '$resource' and subject '$subject'.\n" . print_r($notification, true));
|
||||
throw new \Exception(
|
||||
"Response doesn't contain any notification with resource '$resource' and subject '$subject'.\n"
|
||||
. print_r($notification, true)
|
||||
);
|
||||
} else {
|
||||
throw new \Exception("Response contains more than one notification with resource '$resource' and subject '$subject'.\n" . print_r($notification, true));
|
||||
throw new \Exception(
|
||||
"Response contains more than one notification with resource '$resource' and subject '$subject'.\n"
|
||||
. print_r($notification, true)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -447,10 +474,19 @@ class NotificationContext implements Context {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function userShouldNotHaveANotificationRelatedToResourceWithSubject(string $user, string $resource, string $subject):void {
|
||||
public function userShouldNotHaveANotificationRelatedToResourceWithSubject(
|
||||
string $user,
|
||||
string $resource,
|
||||
string $subject
|
||||
): void {
|
||||
$response = $this->listAllNotifications($user);
|
||||
$filteredResponse = $this->filterNotificationsBySubjectAndResource($subject, $resource, $response);
|
||||
Assert::assertCount(0, $filteredResponse, "Response should not contain notification related to resource '$resource' with subject '$subject' but found" . print_r($filteredResponse, true));
|
||||
Assert::assertCount(
|
||||
0,
|
||||
$filteredResponse,
|
||||
"Response should not contain notification related to resource '$resource' with subject '$subject' but found"
|
||||
. print_r($filteredResponse, true)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -464,7 +500,12 @@ class NotificationContext implements Context {
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function userShouldHaveReceivedTheFollowingEmailFromUserAboutTheShareOfProjectSpace(string $user, string $sender, string $spaceName, PyStringNode $content):void {
|
||||
public function userShouldHaveReceivedTheFollowingEmailFromUserAboutTheShareOfProjectSpace(
|
||||
string $user,
|
||||
string $sender,
|
||||
string $spaceName,
|
||||
PyStringNode $content
|
||||
): void {
|
||||
$rawExpectedEmailBodyContent = \str_replace("\r\n", "\n", $content->getRaw());
|
||||
$this->featureContext->setResponse(
|
||||
GraphHelper::getMySpaces(
|
||||
@@ -501,7 +542,11 @@ class NotificationContext implements Context {
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function userShouldHaveReceivedTheFollowingEmailFromUser(string $user, string $sender, PyStringNode $content):void {
|
||||
public function userShouldHaveReceivedTheFollowingEmailFromUser(
|
||||
string $user,
|
||||
string $sender,
|
||||
PyStringNode $content
|
||||
): void {
|
||||
$rawExpectedEmailBodyContent = \str_replace("\r\n", "\n", $content->getRaw());
|
||||
$expectedEmailBodyContent = $this->featureContext->substituteInLineCodes(
|
||||
$rawExpectedEmailBodyContent,
|
||||
@@ -520,7 +565,11 @@ class NotificationContext implements Context {
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function userShouldHaveReceivedTheFollowingEmailFromUserIgnoringWhitespaces(string $user, string $sender, PyStringNode $content):void {
|
||||
public function userShouldHaveReceivedTheFollowingEmailFromUserIgnoringWhitespaces(
|
||||
string $user,
|
||||
string $sender,
|
||||
PyStringNode $content
|
||||
): void {
|
||||
$rawExpectedEmailBodyContent = \str_replace("\r\n", "\n", $content->getRaw());
|
||||
$expectedEmailBodyContent = $this->featureContext->substituteInLineCodes(
|
||||
$rawExpectedEmailBodyContent,
|
||||
@@ -537,7 +586,11 @@ class NotificationContext implements Context {
|
||||
* @return void
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function assertEmailContains(string $user, string $expectedEmailBodyContent, $ignoreWhiteSpace = false):void {
|
||||
public function assertEmailContains(
|
||||
string $user,
|
||||
string $expectedEmailBodyContent,
|
||||
$ignoreWhiteSpace = false
|
||||
): void {
|
||||
$address = $this->featureContext->getEmailAddressForUser($user);
|
||||
$this->featureContext->pushEmailRecipientAsMailBox($address);
|
||||
$actualEmailBodyContent = EmailHelper::getBodyOfLastEmail($address, $this->featureContext->getStepLineRef());
|
||||
@@ -548,7 +601,8 @@ class NotificationContext implements Context {
|
||||
Assert::assertStringContainsString(
|
||||
$expectedEmailBodyContent,
|
||||
$actualEmailBodyContent,
|
||||
"The email address '$address' should have received an email with the body containing $expectedEmailBodyContent
|
||||
"The email address '$address' should have received an"
|
||||
. "email with the body containing $expectedEmailBodyContent
|
||||
but the received email is $actualEmailBodyContent"
|
||||
);
|
||||
}
|
||||
@@ -596,7 +650,8 @@ class NotificationContext implements Context {
|
||||
?string $deprovision_date_format= "2006-01-02T15:04:05Z07:00"
|
||||
): ResponseInterface {
|
||||
$payload["type"] = "deprovision";
|
||||
$payload["data"] = ["deprovision_date" => $deprovision_date, "deprovision_date_format" => $deprovision_date_format];
|
||||
$payload["data"] = [
|
||||
"deprovision_date" => $deprovision_date, "deprovision_date_format" => $deprovision_date_format];
|
||||
return OcsApiHelper::sendRequest(
|
||||
$this->featureContext->getBaseUrl(),
|
||||
$user ? $this->featureContext->getActualUsername($user) : $this->featureContext->getAdminUsername(),
|
||||
@@ -636,7 +691,10 @@ class NotificationContext implements Context {
|
||||
* @throws GuzzleException
|
||||
* @throws JsonException
|
||||
*/
|
||||
public function theAdministratorCreatesADeprovisioningNotificationUsingDateFormat($deprovision_date, $deprovision_date_format) {
|
||||
public function theAdministratorCreatesADeprovisioningNotificationUsingDateFormat(
|
||||
$deprovision_date,
|
||||
$deprovision_date_format
|
||||
) {
|
||||
$response = $this->userCreatesDeprovisioningNotification(null, $deprovision_date, $deprovision_date_format);
|
||||
$this->featureContext->setResponse($response);
|
||||
$this->featureContext->pushToLastHttpStatusCodesArray();
|
||||
|
||||
@@ -151,7 +151,11 @@ class OCSContext implements Context {
|
||||
*
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
public function theUserSendsToOcsApiEndpointWithBody(string $verb, string $url, ?TableNode $body = null):ResponseInterface {
|
||||
public function theUserSendsToOcsApiEndpointWithBody(
|
||||
string $verb,
|
||||
string $url,
|
||||
?TableNode $body = null
|
||||
): ResponseInterface {
|
||||
return $this->sendRequestToOcsEndpoint(
|
||||
$this->featureContext->getCurrentUser(),
|
||||
$verb,
|
||||
@@ -408,7 +412,11 @@ class OCSContext implements Context {
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function theOCSStatusCodeShouldBe(string $statusCode, string $message = "", ?ResponseInterface $response = null):void {
|
||||
public function theOCSStatusCodeShouldBe(
|
||||
string $statusCode,
|
||||
string $message = "",
|
||||
?ResponseInterface $response = null
|
||||
): void {
|
||||
$statusCodes = explode(",", $statusCode);
|
||||
$response = $response ?? $this->featureContext->getResponse();
|
||||
$responseStatusCode = $this->getOCSResponseStatusCode(
|
||||
@@ -416,7 +424,8 @@ class OCSContext implements Context {
|
||||
);
|
||||
if (\is_array($statusCodes)) {
|
||||
if ($message === "") {
|
||||
$message = "OCS status code is not any of the expected values " . \implode(",", $statusCodes) . " got " . $responseStatusCode;
|
||||
$message = "OCS status code is not any of the expected values "
|
||||
. \implode(",", $statusCodes) . " got " . $responseStatusCode;
|
||||
}
|
||||
Assert::assertContainsEquals(
|
||||
$responseStatusCode,
|
||||
@@ -455,7 +464,8 @@ class OCSContext implements Context {
|
||||
Assert::assertContainsEquals(
|
||||
$responseStatusCode,
|
||||
$statusCodes,
|
||||
"OCS status code is not any of the expected values " . \implode(",", $statusCodes) . " got " . $responseStatusCode
|
||||
"OCS status code is not any of the expected values "
|
||||
. \implode(",", $statusCodes) . " got " . $responseStatusCode
|
||||
);
|
||||
$this->featureContext->emptyLastOCSStatusCodesArray();
|
||||
}
|
||||
@@ -632,7 +642,10 @@ class OCSContext implements Context {
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function assertOCSResponseIndicatesSuccess(?string $message = "", ?ResponseInterface $response = null):void {
|
||||
public function assertOCSResponseIndicatesSuccess(
|
||||
?string $message = "",
|
||||
?ResponseInterface $response = null
|
||||
): void {
|
||||
$response = $response ?? $this->featureContext->getResponse();
|
||||
$this->featureContext->theHTTPStatusCodeShouldBe('200', $message, $response);
|
||||
if ($this->featureContext->getOcsApiVersion() === 1) {
|
||||
|
||||
@@ -286,7 +286,11 @@ class OcmContext implements Context {
|
||||
*/
|
||||
public function userHasDeletedFederatedConnectionWithUser(string $user, string $ocmUser): void {
|
||||
$response = $this->deleteConnection($user, $ocmUser);
|
||||
$this->featureContext->theHTTPStatusCodeShouldBe(200, "failed while deleting connection with user $ocmUser", $response);
|
||||
$this->featureContext->theHTTPStatusCodeShouldBe(
|
||||
200,
|
||||
"failed while deleting connection with user $ocmUser",
|
||||
$response
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -455,7 +455,11 @@ trait Provisioning {
|
||||
} catch (LdapException $e) {
|
||||
if (\str_contains($e->getMessage(), "Already exists")) {
|
||||
$this->ldap->delete(
|
||||
"uid=" . ldap_escape($entry['uid'], "", LDAP_ESCAPE_DN) . ",ou=" . $this->ldapUsersOU . "," . $this->ldapBaseDN,
|
||||
"uid=" . ldap_escape(
|
||||
$entry['uid'],
|
||||
"",
|
||||
LDAP_ESCAPE_DN
|
||||
) . ",ou=" . $this->ldapUsersOU . "," . $this->ldapBaseDN,
|
||||
);
|
||||
OcisHelper::deleteRevaUserData([$entry['uid']]);
|
||||
$this->ldap->add($newDN, $entry);
|
||||
@@ -496,7 +500,8 @@ trait Provisioning {
|
||||
} catch (LdapException $e) {
|
||||
if (\str_contains($e->getMessage(), "Already exists")) {
|
||||
$this->ldap->delete(
|
||||
"cn=" . ldap_escape($group, "", LDAP_ESCAPE_DN) . ",ou=" . $this->ldapGroupsOU . "," . $this->ldapBaseDN,
|
||||
"cn=" . ldap_escape($group, "", LDAP_ESCAPE_DN)
|
||||
. ",ou=" . $this->ldapGroupsOU . "," . $this->ldapBaseDN,
|
||||
);
|
||||
$this->ldap->add($newDN, $entry);
|
||||
}
|
||||
@@ -519,7 +524,8 @@ trait Provisioning {
|
||||
}
|
||||
foreach ($this->ldapCreatedGroups as $group) {
|
||||
$this->ldap->delete(
|
||||
"cn=" . ldap_escape($group, "", LDAP_ESCAPE_DN) . ",ou=" . $this->ldapGroupsOU . "," . $this->ldapBaseDN,
|
||||
"cn=" . ldap_escape($group, "", LDAP_ESCAPE_DN)
|
||||
. ",ou=" . $this->ldapGroupsOU . "," . $this->ldapBaseDN,
|
||||
);
|
||||
$this->rememberThatGroupIsNotExpectedToExist($group);
|
||||
}
|
||||
@@ -682,7 +688,11 @@ trait Provisioning {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function userResetUserPasswordUsingProvisioningApi(?string $user, ?string $username, ?string $password):void {
|
||||
public function userResetUserPasswordUsingProvisioningApi(
|
||||
?string $user,
|
||||
?string $username,
|
||||
?string $password
|
||||
): void {
|
||||
$targetUsername = $this->getActualUsername($username);
|
||||
$password = $this->getActualPassword($password);
|
||||
$this->userTriesToResetUserPasswordUsingTheProvisioningApi(
|
||||
@@ -700,7 +710,11 @@ trait Provisioning {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function userTriesToResetUserPasswordUsingTheProvisioningApi(?string $user, ?string $username, ?string $password):void {
|
||||
public function userTriesToResetUserPasswordUsingTheProvisioningApi(
|
||||
?string $user,
|
||||
?string $username,
|
||||
?string $password
|
||||
): void {
|
||||
$password = $this->getActualPassword($password);
|
||||
$bodyTable = new TableNode([['key', 'password'], ['value', $password]]);
|
||||
$this->ocsContext->sendRequestToOcsEndpoint(
|
||||
@@ -1737,7 +1751,15 @@ trait Provisioning {
|
||||
if (OcisHelper::isTestingOnReva()) {
|
||||
$response = $this->disableOrEnableUser($this->getAdminUsername(), $user, 'disable');
|
||||
} else {
|
||||
$response = $this->graphContext->editUserUsingTheGraphApi($this->getAdminUsername(), $user, null, null, null, null, false);
|
||||
$response = $this->graphContext->editUserUsingTheGraphApi(
|
||||
$this->getAdminUsername(),
|
||||
$user,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
false
|
||||
);
|
||||
}
|
||||
Assert::assertEquals(
|
||||
200,
|
||||
|
||||
@@ -92,7 +92,10 @@ class PublicWebDavContext implements Context {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function userTriesToDownloadFileFromPublicLinkUsingBasicAuthAndPublicWebdav(string $user, string $path): void {
|
||||
public function userTriesToDownloadFileFromPublicLinkUsingBasicAuthAndPublicWebdav(
|
||||
string $user,
|
||||
string $path
|
||||
): void {
|
||||
$response = $this->downloadFromPublicLinkAsUser($path, $user);
|
||||
$this->featureContext->setResponse($response);
|
||||
}
|
||||
@@ -104,7 +107,9 @@ class PublicWebDavContext implements Context {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function thePublicDeletesFileFolderFromTheLastPublicLinkShareUsingThePublicWebdavApi(string $fileName):void {
|
||||
public function thePublicDeletesFileFolderFromTheLastPublicLinkShareUsingThePublicWebdavApi(
|
||||
string $fileName
|
||||
): void {
|
||||
$response = $this->deleteFileFromPublicShare(
|
||||
$fileName
|
||||
);
|
||||
@@ -119,7 +124,9 @@ class PublicWebDavContext implements Context {
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
public function deleteFileFromPublicShare(string $fileName, string $password = ""): ResponseInterface {
|
||||
$token = ($this->featureContext->isUsingSharingNG()) ? $this->featureContext->shareNgGetLastCreatedLinkShareToken() : $this->featureContext->getLastCreatedPublicShareToken();
|
||||
$token = ($this->featureContext->isUsingSharingNG())
|
||||
? $this->featureContext->shareNgGetLastCreatedLinkShareToken()
|
||||
: $this->featureContext->getLastCreatedPublicShareToken();
|
||||
$davPath = WebDavHelper::getDavPath(
|
||||
WebDavHelper::DAV_VERSION_NEW,
|
||||
$token,
|
||||
@@ -151,7 +158,10 @@ class PublicWebDavContext implements Context {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function thePublicHasDeletedFileFromTheLastLinkShareWithPasswordUsingPublicWebdavApi(string $file, string $password): void {
|
||||
public function thePublicHasDeletedFileFromTheLastLinkShareWithPasswordUsingPublicWebdavApi(
|
||||
string $file,
|
||||
string $password
|
||||
): void {
|
||||
$response = $this->deleteFileFromPublicShare($file, $password);
|
||||
$this->featureContext->theHTTPStatusCodeShouldBe([201, 204], "", $response);
|
||||
}
|
||||
@@ -164,7 +174,10 @@ class PublicWebDavContext implements Context {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function thePublicDeletesFileFromTheLastLinkShareWithPasswordUsingPublicWebdavApi(string $file, string $password): void {
|
||||
public function thePublicDeletesFileFromTheLastLinkShareWithPasswordUsingPublicWebdavApi(
|
||||
string $file,
|
||||
string $password
|
||||
): void {
|
||||
$this->featureContext->setResponse(
|
||||
$this->deleteFileFromPublicShare($file, $password)
|
||||
);
|
||||
@@ -178,8 +191,14 @@ class PublicWebDavContext implements Context {
|
||||
*
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
public function renameFileFromPublicShare(string $fileName, string $toFileName, ?string $password = ""):ResponseInterface {
|
||||
$token = ($this->featureContext->isUsingSharingNG()) ? $this->featureContext->shareNgGetLastCreatedLinkShareToken() : $this->featureContext->getLastCreatedPublicShareToken();
|
||||
public function renameFileFromPublicShare(
|
||||
string $fileName,
|
||||
string $toFileName,
|
||||
?string $password = ""
|
||||
): ResponseInterface {
|
||||
$token = ($this->featureContext->isUsingSharingNG())
|
||||
? $this->featureContext->shareNgGetLastCreatedLinkShareToken()
|
||||
: $this->featureContext->getLastCreatedPublicShareToken();
|
||||
$davPath = WebDavHelper::getDavPath(
|
||||
WebDavHelper::DAV_VERSION_NEW,
|
||||
$token,
|
||||
@@ -215,7 +234,11 @@ class PublicWebDavContext implements Context {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function thePublicRenamesFileFromTheLastPublicShareUsingThePasswordPasswordAndOldPublicWebdavApi(string $fileName, string $toName, string $password):void {
|
||||
public function thePublicRenamesFileFromTheLastPublicShareUsingThePasswordPasswordAndOldPublicWebdavApi(
|
||||
string $fileName,
|
||||
string $toName,
|
||||
string $password
|
||||
): void {
|
||||
$this->featureContext->setResponse(
|
||||
$this->renameFileFromPublicShare($fileName, $toName, $password)
|
||||
);
|
||||
@@ -231,7 +254,10 @@ class PublicWebDavContext implements Context {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function publicDownloadsFileFromInsideLastPublicSharedFolderWithPassword(string $path, string $password = ""):void {
|
||||
public function publicDownloadsFileFromInsideLastPublicSharedFolderWithPassword(
|
||||
string $path,
|
||||
string $password = ""
|
||||
): void {
|
||||
$response = $this->downloadFileFromPublicFolder(
|
||||
$path,
|
||||
$password,
|
||||
@@ -249,7 +275,9 @@ class PublicWebDavContext implements Context {
|
||||
*/
|
||||
public function downloadFromPublicLinkAsUser(string $path, string $user): ResponseInterface {
|
||||
$path = \ltrim($path, "/");
|
||||
$token = ($this->featureContext->isUsingSharingNG()) ? $this->featureContext->shareNgGetLastCreatedLinkShareToken() : $this->featureContext->getLastCreatedPublicShareToken();
|
||||
$token = ($this->featureContext->isUsingSharingNG())
|
||||
? $this->featureContext->shareNgGetLastCreatedLinkShareToken()
|
||||
: $this->featureContext->getLastCreatedPublicShareToken();
|
||||
|
||||
$davPath = WebDavHelper::getDavPath(
|
||||
$this->featureContext->getDavPathVersion(),
|
||||
@@ -370,7 +398,9 @@ class PublicWebDavContext implements Context {
|
||||
* @return void
|
||||
*/
|
||||
public function thePublicCopiesFileUsingTheWebDAVApi(string $source, string $destination): void {
|
||||
$token = ($this->featureContext->isUsingSharingNG()) ? $this->featureContext->shareNgGetLastCreatedLinkShareToken() : $this->featureContext->getLastCreatedPublicShareToken();
|
||||
$token = ($this->featureContext->isUsingSharingNG())
|
||||
? $this->featureContext->shareNgGetLastCreatedLinkShareToken()
|
||||
: $this->featureContext->getLastCreatedPublicShareToken();
|
||||
$davPath = WebDavHelper::getDavPath(
|
||||
WebDavHelper::DAV_VERSION_NEW,
|
||||
$token,
|
||||
@@ -420,7 +450,10 @@ class PublicWebDavContext implements Context {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function thePublicHasUploadedFileWithContentWithAutoRenameMode(string $filename, string $body = 'test'):void {
|
||||
public function thePublicHasUploadedFileWithContentWithAutoRenameMode(
|
||||
string $filename,
|
||||
string $body = 'test'
|
||||
): void {
|
||||
$response = $this->publiclyUploadingContentAutoRename($filename, $body);
|
||||
$this->featureContext->theHTTPStatusCodeShouldBe([201, 204], "", $response);
|
||||
}
|
||||
@@ -455,7 +488,11 @@ class PublicWebDavContext implements Context {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function thePublicHasUploadedFileWithContentAndPasswordToLastLinkShareUsingPublicWebdavApi(string $filename, string $content = 'test', string $password = ''): void {
|
||||
public function thePublicHasUploadedFileWithContentAndPasswordToLastLinkShareUsingPublicWebdavApi(
|
||||
string $filename,
|
||||
string $content = 'test',
|
||||
string $password = ''
|
||||
): void {
|
||||
$response = $this->publiclyUploadingContentWithPassword(
|
||||
$filename,
|
||||
$password,
|
||||
@@ -956,7 +993,9 @@ class PublicWebDavContext implements Context {
|
||||
string $destination,
|
||||
string $password
|
||||
): ResponseInterface {
|
||||
$token = ($this->featureContext->isUsingSharingNG()) ? $this->featureContext->shareNgGetLastCreatedLinkShareToken() : $this->featureContext->getLastCreatedPublicShareToken();
|
||||
$token = ($this->featureContext->isUsingSharingNG())
|
||||
? $this->featureContext->shareNgGetLastCreatedLinkShareToken()
|
||||
: $this->featureContext->getLastCreatedPublicShareToken();
|
||||
$davPath = WebDavHelper::getDavPath(
|
||||
$this->featureContext->getDavPathVersion(),
|
||||
$token,
|
||||
@@ -1046,7 +1085,9 @@ class PublicWebDavContext implements Context {
|
||||
string $fileName,
|
||||
string $mtime
|
||||
): void {
|
||||
$token = ($this->featureContext->isUsingSharingNG()) ? $this->featureContext->shareNgGetLastCreatedLinkShareToken() : $this->featureContext->getLastCreatedPublicShareToken();
|
||||
$token = ($this->featureContext->isUsingSharingNG())
|
||||
? $this->featureContext->shareNgGetLastCreatedLinkShareToken()
|
||||
: $this->featureContext->getLastCreatedPublicShareToken();
|
||||
$baseUrl = $this->featureContext->getBaseUrl();
|
||||
$mtime = \explode(" ", $mtime);
|
||||
\array_pop($mtime);
|
||||
@@ -1205,7 +1246,9 @@ class PublicWebDavContext implements Context {
|
||||
} else {
|
||||
$body = null;
|
||||
}
|
||||
$token = ($this->featureContext->isUsingSharingNG()) ? $this->featureContext->shareNgGetLastCreatedLinkShareToken() : $this->featureContext->getLastCreatedPublicShareToken();
|
||||
$token = ($this->featureContext->isUsingSharingNG())
|
||||
? $this->featureContext->shareNgGetLastCreatedLinkShareToken()
|
||||
: $this->featureContext->getLastCreatedPublicShareToken();
|
||||
$davPath = WebDavHelper::getDavPath(
|
||||
WebDavHelper::DAV_VERSION_NEW,
|
||||
$token,
|
||||
|
||||
@@ -84,7 +84,11 @@ class SearchContext implements Context {
|
||||
$spaceId = $this->featureContext->spacesContext->getSpaceIdByName($user, $scope);
|
||||
$pattern .= " scope:$spaceId";
|
||||
} else {
|
||||
$resourceID = $this->featureContext->spacesContext->getResourceId($user, $spaceName ?? "Personal", $scope);
|
||||
$resourceID = $this->featureContext->spacesContext->getResourceId(
|
||||
$user,
|
||||
$spaceName ?? "Personal",
|
||||
$scope
|
||||
);
|
||||
$pattern .= " scope:$resourceID";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -263,7 +263,11 @@ class SettingsContext implements Context {
|
||||
$assignmentResponse = $this->featureContext->getJsonDecodedResponseBodyContent($response);
|
||||
if (isset($assignmentResponse->assignments[0]->roleId)) {
|
||||
$actualRoleId = $assignmentResponse->assignments[0]->roleId;
|
||||
Assert::assertEquals($this->getRoleIdByRoleName($this->featureContext->getAdminUserName(), $role), $actualRoleId, "user $user has no role $role");
|
||||
Assert::assertEquals(
|
||||
$this->getRoleIdByRoleName($this->featureContext->getAdminUserName(), $role),
|
||||
$actualRoleId,
|
||||
"user $user has no role $role"
|
||||
);
|
||||
} else {
|
||||
Assert::fail("Response should contain user role but not found.\n" . json_encode($assignmentResponse));
|
||||
}
|
||||
@@ -279,8 +283,14 @@ class SettingsContext implements Context {
|
||||
* @throws Exception
|
||||
*/
|
||||
public function theSettingApiResponseShouldHaveTheRole(string $role): void {
|
||||
$assignmentRoleId = $this->featureContext->getJsonDecodedResponse($this->featureContext->getResponse())["assignments"][0]["roleId"];
|
||||
Assert::assertEquals($this->getRoleIdByRoleName($this->featureContext->getAdminUserName(), $role), $assignmentRoleId, "user has no role $role");
|
||||
$assignmentRoleId = $this->featureContext->getJsonDecodedResponse(
|
||||
$this->featureContext->getResponse()
|
||||
)["assignments"][0]["roleId"];
|
||||
Assert::assertEquals(
|
||||
$this->getRoleIdByRoleName($this->featureContext->getAdminUserName(), $role),
|
||||
$assignmentRoleId,
|
||||
"user has no role $role"
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -213,7 +213,11 @@ trait Sharing {
|
||||
public function shareNgGetLastCreatedLinkShareToken(): string {
|
||||
$lastResponse = $this->shareNgGetLastCreatedLinkShare();
|
||||
if (!isset($this->getJsonDecodedResponse($lastResponse)['link']['webUrl'])) {
|
||||
throw new Error('Response did not contain share id ' . $this->getJsonDecodedResponse($lastResponse)['link']['webUrl'] . ' for the created public link');
|
||||
throw new Error(
|
||||
'Response did not contain share id '
|
||||
. $this->getJsonDecodedResponse($lastResponse)['link']['webUrl']
|
||||
. ' for the created public link'
|
||||
);
|
||||
}
|
||||
$last_created_link_webURL = $this->getJsonDecodedResponse($lastResponse)['link']['webUrl'];
|
||||
return substr(strrchr($last_created_link_webURL, "/"), 1);
|
||||
@@ -341,8 +345,14 @@ trait Sharing {
|
||||
$bodyRows['name'] = \array_key_exists('name', $bodyRows) ? $bodyRows['name'] : null;
|
||||
$bodyRows['shareWith'] = \array_key_exists('shareWith', $bodyRows) ? $bodyRows['shareWith'] : null;
|
||||
$bodyRows['shareWith'] = $this->getActualUsername($bodyRows['shareWith']);
|
||||
$bodyRows['publicUpload'] = \array_key_exists('publicUpload', $bodyRows) ? $bodyRows['publicUpload'] === 'true' : null;
|
||||
$bodyRows['password'] = \array_key_exists('password', $bodyRows) ? $this->getActualPassword($bodyRows['password']) : null;
|
||||
$bodyRows['publicUpload'] = \array_key_exists(
|
||||
'publicUpload',
|
||||
$bodyRows
|
||||
) ? $bodyRows['publicUpload'] === 'true' : null;
|
||||
$bodyRows['password'] = \array_key_exists(
|
||||
'password',
|
||||
$bodyRows
|
||||
) ? $this->getActualPassword($bodyRows['password']) : null;
|
||||
|
||||
if (\array_key_exists('permissions', $bodyRows)) {
|
||||
if (\is_numeric($bodyRows['permissions'])) {
|
||||
@@ -718,7 +728,8 @@ trait Sharing {
|
||||
*/
|
||||
public function getLastCreatedUserGroupShareId(?string $user = null): string {
|
||||
if ($user === null) {
|
||||
$shareId = $this->isUsingSharingNG() ? $this->shareNgGetLastCreatedUserGroupShareID() : $this->getLastCreatedUserGroupShare()->id;
|
||||
$shareId = $this->isUsingSharingNG()
|
||||
? $this->shareNgGetLastCreatedUserGroupShareID() : $this->getLastCreatedUserGroupShare()->id;
|
||||
return (string) $shareId;
|
||||
}
|
||||
$createdShares = $this->getCreatedUserGroupShares();
|
||||
@@ -746,10 +757,12 @@ trait Sharing {
|
||||
$user = $this->getActualUsername($user);
|
||||
|
||||
if ($updateLastPublicLink) {
|
||||
$share_id = ($this->isUsingSharingNG()) ? $this->shareNgGetLastCreatedLinkShareID() : (string) $this->getLastCreatedPublicShare()->id;
|
||||
$share_id = ($this->isUsingSharingNG())
|
||||
? $this->shareNgGetLastCreatedLinkShareID() : (string) $this->getLastCreatedPublicShare()->id;
|
||||
} else {
|
||||
if ($shareOwner === null) {
|
||||
$share_id = ($this->isUsingSharingNG()) ? $this->shareNgGetLastCreatedUserGroupShareID() : $this->getLastCreatedUserGroupShareId();
|
||||
$share_id = ($this->isUsingSharingNG())
|
||||
? $this->shareNgGetLastCreatedUserGroupShareID() : $this->getLastCreatedUserGroupShareId();
|
||||
} else {
|
||||
$share_id = $this->getLastCreatedUserGroupShareId($shareOwner);
|
||||
}
|
||||
@@ -979,7 +992,12 @@ trait Sharing {
|
||||
* @return bool
|
||||
* @throws Exception
|
||||
*/
|
||||
public function isFieldInResponse(string $field, ?string $contentExpected, bool $expectSuccess = true, ?SimpleXMLElement $data = null):bool {
|
||||
public function isFieldInResponse(
|
||||
string $field,
|
||||
?string $contentExpected,
|
||||
bool $expectSuccess = true,
|
||||
?SimpleXMLElement $data = null
|
||||
): bool {
|
||||
if ($data === null) {
|
||||
$data = HttpRequestHelper::getResponseXml($this->response, __METHOD__)->data[0];
|
||||
}
|
||||
@@ -1547,7 +1565,10 @@ trait Sharing {
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function userTriesToUpdateTheLastPublicLinkShareUsingTheSharingApiWith(string $user, ?TableNode $body):void {
|
||||
public function userTriesToUpdateTheLastPublicLinkShareUsingTheSharingApiWith(
|
||||
string $user,
|
||||
?TableNode $body
|
||||
): void {
|
||||
$this->response = $this->updateLastShareWithSettings($user, $body, null, true);
|
||||
}
|
||||
|
||||
@@ -1652,15 +1673,21 @@ trait Sharing {
|
||||
*
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
public function deleteLastShareUsingSharingApi(string $user, string $sharer = null, bool $deleteLastPublicLink = false):ResponseInterface {
|
||||
public function deleteLastShareUsingSharingApi(
|
||||
string $user,
|
||||
string $sharer = null,
|
||||
bool $deleteLastPublicLink = false
|
||||
): ResponseInterface {
|
||||
$user = $this->getActualUsername($user);
|
||||
if ($deleteLastPublicLink) {
|
||||
$shareId = (string) $this->getLastCreatedPublicShare()->id;
|
||||
} else {
|
||||
if ($sharer === null) {
|
||||
$shareId = ($this->isUsingSharingNG()) ? $this->shareNgGetLastCreatedUserGroupShareID() : $this->getLastCreatedUserGroupShareId();
|
||||
$shareId = ($this->isUsingSharingNG())
|
||||
? $this->shareNgGetLastCreatedUserGroupShareID() : $this->getLastCreatedUserGroupShareId();
|
||||
} else {
|
||||
$shareId = ($this->isUsingSharingNG()) ? $this->shareNgGetLastCreatedUserGroupShareID() : $this->getLastCreatedUserGroupShareId($sharer);
|
||||
$shareId = ($this->isUsingSharingNG())
|
||||
? $this->shareNgGetLastCreatedUserGroupShareID() : $this->getLastCreatedUserGroupShareId($sharer);
|
||||
}
|
||||
}
|
||||
$url = $this->getSharesEndpointPath("/$shareId");
|
||||
@@ -1739,9 +1766,11 @@ trait Sharing {
|
||||
*/
|
||||
public function getLastShareInfo(string $user, string $shareType, ?string $language = null): ResponseInterface {
|
||||
if ($shareType !== "link") {
|
||||
$shareId = $this->isUsingSharingNg() ? $this->shareNgGetLastCreatedUserGroupShareID() : $this->getLastCreatedUserGroupShareId();
|
||||
$shareId = $this->isUsingSharingNg()
|
||||
? $this->shareNgGetLastCreatedUserGroupShareID() : $this->getLastCreatedUserGroupShareId();
|
||||
} else {
|
||||
$shareId = ($this->isUsingSharingNG()) ? $this->shareNgGetLastCreatedLinkShareID() : (string) $this->getLastCreatedPublicShare()->id;
|
||||
$shareId = ($this->isUsingSharingNG())
|
||||
? $this->shareNgGetLastCreatedLinkShareID() : (string) $this->getLastCreatedPublicShare()->id;
|
||||
}
|
||||
if ($shareId === null) {
|
||||
throw new Exception(
|
||||
@@ -1869,7 +1898,8 @@ trait Sharing {
|
||||
public function userGetsTheLastShareSharedWithHimUsingTheSharingApi(string $user, TableNode $table): void {
|
||||
$user = $this->getActualUsername($user);
|
||||
$this->verifyTableNodeRows($table, [], $this->shareResponseFields);
|
||||
$share_id = ($this->isUsingSharingNG()) ? $this->shareNgGetLastCreatedUserGroupShareID() : $this->getLastCreatedUserGroupShareId();
|
||||
$share_id = ($this->isUsingSharingNG())
|
||||
? $this->shareNgGetLastCreatedUserGroupShareID() : $this->getLastCreatedUserGroupShareId();
|
||||
|
||||
$response = $this->getShareData($user, $share_id);
|
||||
$this->theHTTPStatusCodeShouldBe(
|
||||
@@ -1898,7 +1928,11 @@ trait Sharing {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function userGetsFilteredSharesSharedWithHimUsingTheSharingApi(string $user, string $pending, string $shareType):void {
|
||||
public function userGetsFilteredSharesSharedWithHimUsingTheSharingApi(
|
||||
string $user,
|
||||
string $pending,
|
||||
string $shareType
|
||||
): void {
|
||||
$user = $this->getActualUsername($user);
|
||||
if ($pending === "pending") {
|
||||
$pendingClause = "&state=" . SharingHelper::SHARE_STATES['pending'];
|
||||
@@ -1931,7 +1965,10 @@ trait Sharing {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function userGetsAllSharesSharedWithHimFromFileOrFolderUsingTheProvisioningApi(string $user, string $path):void {
|
||||
public function userGetsAllSharesSharedWithHimFromFileOrFolderUsingTheProvisioningApi(
|
||||
string $user,
|
||||
string $path
|
||||
): void {
|
||||
$user = $this->getActualUsername($user);
|
||||
$url = "/apps/files_sharing/api/"
|
||||
. "v$this->sharingApiVersion/shares?shared_with_me=true&path=$path";
|
||||
@@ -2167,7 +2204,8 @@ trait Sharing {
|
||||
* @throws Exception
|
||||
*/
|
||||
public function checkingLastShareIDIsIncluded(): void {
|
||||
$shareId = ($this->isUsingSharingNG()) ? $this->shareNgGetLastCreatedUserGroupShareID() : $this->getLastCreatedUserGroupShareId();
|
||||
$shareId = ($this->isUsingSharingNG())
|
||||
? $this->shareNgGetLastCreatedUserGroupShareID() : $this->getLastCreatedUserGroupShareId();
|
||||
if (!$this->isFieldInResponse('id', $shareId)) {
|
||||
Assert::fail(
|
||||
"Share id $shareId not found in response"
|
||||
@@ -2182,7 +2220,8 @@ trait Sharing {
|
||||
* @throws Exception
|
||||
*/
|
||||
public function checkLastShareIDIsNotIncluded(): void {
|
||||
$shareId = $this->isUsingSharingNG() ? $this->shareNgGetLastCreatedUserGroupShareID() : $this->getLastCreatedUserGroupShareId();
|
||||
$shareId = $this->isUsingSharingNG()
|
||||
? $this->shareNgGetLastCreatedUserGroupShareID() : $this->getLastCreatedUserGroupShareId();
|
||||
if ($this->isFieldInResponse('id', $shareId, false)) {
|
||||
Assert::fail(
|
||||
"Share id $shareId has been found in response"
|
||||
@@ -2246,7 +2285,8 @@ trait Sharing {
|
||||
public function userShouldNotSeeShareIdOfLastShare(string $user): void {
|
||||
$response = $this->getSharedWithMeShares($user);
|
||||
$this->theHTTPStatusCodeShouldBe(200, "", $response);
|
||||
$shareId = $this->isUsingSharingNG() ? $this->shareNgGetLastCreatedUserGroupShareID() : $this->getLastCreatedUserGroupShareId();
|
||||
$shareId = $this->isUsingSharingNG()
|
||||
? $this->shareNgGetLastCreatedUserGroupShareID() : $this->getLastCreatedUserGroupShareId();
|
||||
if ($this->isFieldInResponse('id', $shareId, false)) {
|
||||
Assert::fail(
|
||||
"Share id $shareId has been found in response"
|
||||
@@ -2421,9 +2461,25 @@ trait Sharing {
|
||||
$this->verifyTableNodeColumnsCount($body, 2);
|
||||
$bodyRows = $body->getRowsHash();
|
||||
foreach ($bodyRows as $field => $value) {
|
||||
if (\in_array($field, ["displayname_owner", "displayname_file_owner", "owner", "uid_owner", "uid_file_owner", "additional_info_owner", "additional_info_file_owner"])) {
|
||||
if (\in_array(
|
||||
$field,
|
||||
[
|
||||
"displayname_owner",
|
||||
"displayname_file_owner",
|
||||
"owner",
|
||||
"uid_owner",
|
||||
"uid_file_owner",
|
||||
"additional_info_owner",
|
||||
"additional_info_file_owner"
|
||||
]
|
||||
)
|
||||
) {
|
||||
$value = $this->substituteInLineCodes($value, $sharer);
|
||||
} elseif (\in_array($field, ["share_with", "share_with_displayname", "user", "share_with_additional_info"])) {
|
||||
} elseif (\in_array(
|
||||
$field,
|
||||
["share_with", "share_with_displayname", "user", "share_with_additional_info"]
|
||||
)
|
||||
) {
|
||||
$value = $this->substituteInLineCodes($value, $sharee);
|
||||
}
|
||||
$value = $this->replaceValuesFromTable($field, $value);
|
||||
@@ -2768,7 +2824,13 @@ trait Sharing {
|
||||
*
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
public function reactToShareOfferedBy(string $user, string $action, string $share, string $offeredBy, ?string $state = ''):ResponseInterface {
|
||||
public function reactToShareOfferedBy(
|
||||
string $user,
|
||||
string $action,
|
||||
string $share,
|
||||
string $offeredBy,
|
||||
?string $state = ''
|
||||
): ResponseInterface {
|
||||
$user = $this->getActualUsername($user);
|
||||
$offeredBy = $this->getActualUsername($offeredBy);
|
||||
|
||||
@@ -2830,7 +2892,13 @@ trait Sharing {
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function userReactsToShareOfferedBy(string $user, string $action, string $share, string $offeredBy, ?string $state = ''):void {
|
||||
public function userReactsToShareOfferedBy(
|
||||
string $user,
|
||||
string $action,
|
||||
string $share,
|
||||
string $offeredBy,
|
||||
?string $state = ''
|
||||
): void {
|
||||
$response = $this->reactToShareOfferedBy(
|
||||
$user,
|
||||
$action,
|
||||
@@ -2853,7 +2921,13 @@ trait Sharing {
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function userAcceptsTheAlreadyAcceptedShareOfferedByUsingTheSharingApi(string $user, string $action, string $share, string $offeredBy, ?string $state = ''):void {
|
||||
public function userAcceptsTheAlreadyAcceptedShareOfferedByUsingTheSharingApi(
|
||||
string $user,
|
||||
string $action,
|
||||
string $share,
|
||||
string $offeredBy,
|
||||
?string $state = ''
|
||||
): void {
|
||||
$response = $this->reactToShareOfferedBy(
|
||||
$user,
|
||||
$action,
|
||||
@@ -2875,7 +2949,12 @@ trait Sharing {
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function userReactsToTheFollowingSharesOfferedBy(string $user, string $action, string $offeredBy, TableNode $table):void {
|
||||
public function userReactsToTheFollowingSharesOfferedBy(
|
||||
string $user,
|
||||
string $action,
|
||||
string $offeredBy,
|
||||
TableNode $table
|
||||
): void {
|
||||
$this->verifyTableNodeColumns($table, ["path"]);
|
||||
$paths = $table->getHash();
|
||||
|
||||
@@ -2935,7 +3014,12 @@ trait Sharing {
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function userHasReactedToShareOfferedBy(string $user, string $action, string $share, string $offeredBy):void {
|
||||
public function userHasReactedToShareOfferedBy(
|
||||
string $user,
|
||||
string $action,
|
||||
string $share,
|
||||
string $offeredBy
|
||||
): void {
|
||||
$response = $this->reactToShareOfferedBy(
|
||||
$user,
|
||||
$action,
|
||||
@@ -3157,7 +3241,10 @@ trait Sharing {
|
||||
*
|
||||
* @return ResponseInterface|null
|
||||
*/
|
||||
public function userGetsTheLastShareWithTheShareIdUsingTheSharingApi(string $user, string $share_id): ?ResponseInterface {
|
||||
public function userGetsTheLastShareWithTheShareIdUsingTheSharingApi(
|
||||
string $user,
|
||||
string $share_id
|
||||
): ?ResponseInterface {
|
||||
$user = $this->getActualUsername($user);
|
||||
$share_id = $this->substituteInLineCodes($share_id, $user);
|
||||
$url = $this->getSharesEndpointPath("/$share_id");
|
||||
@@ -3246,7 +3333,8 @@ trait Sharing {
|
||||
* @return void
|
||||
*/
|
||||
public function thePublicAccessesThePreviewOfTheSharedFileUsingTheSharingApi(string $path): void {
|
||||
$token = ($this->isUsingSharingNG()) ? $this->shareNgGetLastCreatedLinkShareToken() : $this->getLastCreatedPublicShareToken();
|
||||
$token = ($this->isUsingSharingNG())
|
||||
? $this->shareNgGetLastCreatedLinkShareToken() : $this->getLastCreatedPublicShareToken();
|
||||
$response = $this->getPublicPreviewOfFile($path, $token);
|
||||
$this->setResponse($response);
|
||||
$this->pushToLastStatusCodesArrays();
|
||||
@@ -3268,7 +3356,8 @@ trait Sharing {
|
||||
$this->emptyLastHTTPStatusCodesArray();
|
||||
$this->emptyLastOCSStatusCodesArray();
|
||||
foreach ($paths as $path) {
|
||||
$token = ($this->isUsingSharingNG()) ? $this->shareNgGetLastCreatedLinkShareToken() : $this->getLastCreatedPublicShareToken();
|
||||
$token = ($this->isUsingSharingNG())
|
||||
? $this->shareNgGetLastCreatedLinkShareToken() : $this->getLastCreatedPublicShareToken();
|
||||
$response = $this->getPublicPreviewOfFile($path["path"], $token);
|
||||
$this->setResponse($response);
|
||||
$this->pushToLastStatusCodesArrays();
|
||||
@@ -3371,7 +3460,12 @@ trait Sharing {
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function preparePublicQuickLinkPayload(string $user, string $path, string $type, int $permissions = 1): array {
|
||||
public function preparePublicQuickLinkPayload(
|
||||
string $user,
|
||||
string $path,
|
||||
string $type,
|
||||
int $permissions = 1
|
||||
): array {
|
||||
return [
|
||||
"permissions" => $permissions,
|
||||
"expireDate" => "",
|
||||
|
||||
@@ -87,7 +87,8 @@ class SharingNgContext implements Context {
|
||||
|
||||
$bodyRows['quickLink'] = $bodyRows['quickLink'] ?? false;
|
||||
$bodyRows['displayName'] = $bodyRows['displayName'] ?? null;
|
||||
$bodyRows['expirationDateTime'] = \array_key_exists('expirationDateTime', $bodyRows) ? \date('Y-m-d', \strtotime($bodyRows['expirationDateTime'])) . 'T14:00:00.000Z' : null;
|
||||
$bodyRows['expirationDateTime'] = \array_key_exists('expirationDateTime', $bodyRows)
|
||||
? \date('Y-m-d', \strtotime($bodyRows['expirationDateTime'])) . 'T14:00:00.000Z' : null;
|
||||
$bodyRows['password'] = $bodyRows['password'] ?? null;
|
||||
$body = [
|
||||
'type' => $bodyRows['permissionsRole'],
|
||||
@@ -154,7 +155,12 @@ class SharingNgContext implements Context {
|
||||
* @return ResponseInterface
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function getPermissionsList(string $user, string $fileOrFolder, string $space, ?string $resource = ''):ResponseInterface {
|
||||
public function getPermissionsList(
|
||||
string $user,
|
||||
string $fileOrFolder,
|
||||
string $space,
|
||||
?string $resource = ''
|
||||
): ResponseInterface {
|
||||
$spaceId = ($this->spacesContext->getSpaceByName($user, $space))["id"];
|
||||
|
||||
if ($fileOrFolder === 'folder') {
|
||||
@@ -184,7 +190,12 @@ class SharingNgContext implements Context {
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function userGetsPermissionsListForResourceOfTheSpaceUsingTheGraphAPI(string $user, string $fileOrFolder, string $resource, string $space):void {
|
||||
public function userGetsPermissionsListForResourceOfTheSpaceUsingTheGraphAPI(
|
||||
string $user,
|
||||
string $fileOrFolder,
|
||||
string $resource,
|
||||
string $space
|
||||
): void {
|
||||
$this->featureContext->setResponse(
|
||||
$this->getPermissionsList($user, $fileOrFolder, $space, $resource)
|
||||
);
|
||||
@@ -215,7 +226,11 @@ class SharingNgContext implements Context {
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function userTriesToListThePermissionsOfSpaceUsingPermissionsEndpointOfTheGraphApi(string $user, string $space, string $spaceOwner):void {
|
||||
public function userTriesToListThePermissionsOfSpaceUsingPermissionsEndpointOfTheGraphApi(
|
||||
string $user,
|
||||
string $space,
|
||||
string $spaceOwner
|
||||
): void {
|
||||
$spaceId = ($this->spacesContext->getSpaceByName($spaceOwner, $space))["id"];
|
||||
$itemId = $this->spacesContext->getResourceId($spaceOwner, $space, '');
|
||||
|
||||
@@ -287,7 +302,12 @@ class SharingNgContext implements Context {
|
||||
if ($shareType === "user") {
|
||||
$shareeId = $this->featureContext->getAttributeOfCreatedUser($sharee, 'id');
|
||||
if ($federatedShare) {
|
||||
$shareeId = ($this->featureContext->ocmContext->getAcceptedUserByName($user, $sharee))['user_id'];
|
||||
$shareeId = (
|
||||
$this->featureContext->ocmContext->getAcceptedUserByName(
|
||||
$user,
|
||||
$sharee
|
||||
)
|
||||
)['user_id'];
|
||||
}
|
||||
} elseif ($shareType === "group") {
|
||||
$shareeId = $this->featureContext->getAttributeOfCreatedGroup($sharee, 'id');
|
||||
@@ -333,7 +353,11 @@ class SharingNgContext implements Context {
|
||||
* @throws GuzzleException
|
||||
* @throws Exception
|
||||
*/
|
||||
public function sendDriveShareInvitation(string $user, TableNode $table, bool $federatedShare = false): ResponseInterface {
|
||||
public function sendDriveShareInvitation(
|
||||
string $user,
|
||||
TableNode $table,
|
||||
bool $federatedShare = false
|
||||
): ResponseInterface {
|
||||
$shareeIds = [];
|
||||
$rows = $table->getRowsHash();
|
||||
if ($rows['space'] === 'Personal' || $rows['space'] === 'Shares') {
|
||||
@@ -396,7 +420,11 @@ class SharingNgContext implements Context {
|
||||
*/
|
||||
public function userHasSentTheFollowingResourceShareInvitation(string $user, TableNode $table): void {
|
||||
$rows = $table->getRowsHash();
|
||||
Assert::assertArrayHasKey("resource", $rows, "'resource' should be provided in the data-table while sharing a resource");
|
||||
Assert::assertArrayHasKey(
|
||||
"resource",
|
||||
$rows,
|
||||
"'resource' should be provided in the data-table while sharing a resource"
|
||||
);
|
||||
$response = $this->sendShareInvitation($user, $rows);
|
||||
$this->featureContext->theHTTPStatusCodeShouldBe(200, "", $response);
|
||||
}
|
||||
@@ -411,9 +439,16 @@ class SharingNgContext implements Context {
|
||||
* @throws Exception
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function userHasSentTheFollowingResourceShareInvitationToFederatedUser(string $user, TableNode $table): void {
|
||||
public function userHasSentTheFollowingResourceShareInvitationToFederatedUser(
|
||||
string $user,
|
||||
TableNode $table
|
||||
): void {
|
||||
$rows = $table->getRowsHash();
|
||||
Assert::assertArrayHasKey("resource", $rows, "'resource' should be provided in the data-table while sharing a resource");
|
||||
Assert::assertArrayHasKey(
|
||||
"resource",
|
||||
$rows,
|
||||
"'resource' should be provided in the data-table while sharing a resource"
|
||||
);
|
||||
$response = $this->sendShareInvitation($user, $rows, null, true);
|
||||
$this->featureContext->theHTTPStatusCodeShouldBe(200, "", $response);
|
||||
}
|
||||
@@ -430,7 +465,11 @@ class SharingNgContext implements Context {
|
||||
*/
|
||||
public function userHasSentTheFollowingShareShareInvitation(string $user, TableNode $table): void {
|
||||
$rows = $table->getRowsHash();
|
||||
Assert::assertArrayNotHasKey("resource", $rows, "'resource' should not be provided in the data-table while sharing a space");
|
||||
Assert::assertArrayNotHasKey(
|
||||
"resource",
|
||||
$rows,
|
||||
"'resource' should not be provided in the data-table while sharing a space"
|
||||
);
|
||||
$response = $this->sendDriveShareInvitation($user, $table);
|
||||
$this->featureContext->theHTTPStatusCodeShouldBe(200, "", $response);
|
||||
}
|
||||
@@ -448,7 +487,11 @@ class SharingNgContext implements Context {
|
||||
*/
|
||||
public function userSendsTheFollowingResourceShareInvitationUsingTheGraphApi(string $user, TableNode $table): void {
|
||||
$rows = $table->getRowsHash();
|
||||
Assert::assertArrayHasKey("resource", $rows, "'resource' should be provided in the data-table while sharing a resource");
|
||||
Assert::assertArrayHasKey(
|
||||
"resource",
|
||||
$rows,
|
||||
"'resource' should be provided in the data-table while sharing a resource"
|
||||
);
|
||||
$this->featureContext->setResponse(
|
||||
$this->sendShareInvitation($user, $rows)
|
||||
);
|
||||
@@ -464,9 +507,16 @@ class SharingNgContext implements Context {
|
||||
* @throws Exception
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function userSendsTheFollowingResourceShareInvitationToFederatedUserUsingTheGraphApi(string $user, TableNode $table): void {
|
||||
public function userSendsTheFollowingResourceShareInvitationToFederatedUserUsingTheGraphApi(
|
||||
string $user,
|
||||
TableNode $table
|
||||
): void {
|
||||
$rows = $table->getRowsHash();
|
||||
Assert::assertArrayHasKey("resource", $rows, "'resource' should be provided in the data-table while sharing a resource");
|
||||
Assert::assertArrayHasKey(
|
||||
"resource",
|
||||
$rows,
|
||||
"'resource' should be provided in the data-table while sharing a resource"
|
||||
);
|
||||
$this->featureContext->setResponse(
|
||||
$this->sendShareInvitation($user, $rows, null, true)
|
||||
);
|
||||
@@ -482,9 +532,16 @@ class SharingNgContext implements Context {
|
||||
* @throws Exception
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function userSendsTheFollowingSpaceShareInvitationUsingPermissionsEndpointOfTheGraphApi(string $user, TableNode $table): void {
|
||||
public function userSendsTheFollowingSpaceShareInvitationUsingPermissionsEndpointOfTheGraphApi(
|
||||
string $user,
|
||||
TableNode $table
|
||||
): void {
|
||||
$rows = $table->getRowsHash();
|
||||
Assert::assertArrayNotHasKey("resource", $rows, "'resource' should not be provided in the data-table while sharing a space");
|
||||
Assert::assertArrayNotHasKey(
|
||||
"resource",
|
||||
$rows,
|
||||
"'resource' should not be provided in the data-table while sharing a space"
|
||||
);
|
||||
$this->featureContext->setResponse(
|
||||
$this->sendShareInvitation($user, $rows)
|
||||
);
|
||||
@@ -500,9 +557,16 @@ class SharingNgContext implements Context {
|
||||
* @throws Exception
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function userSendsTheFollowingSpaceShareInvitationToFederatedUserUsingPermissionsEndpointOfTheGraphApi(string $user, TableNode $table): void {
|
||||
public function userSendsTheFollowingSpaceShareInvitationToFederatedUserUsingPermissionsEndpointOfTheGraphApi(
|
||||
string $user,
|
||||
TableNode $table
|
||||
): void {
|
||||
$rows = $table->getRowsHash();
|
||||
Assert::assertArrayNotHasKey("resource", $rows, "'resource' should not be provided in the data-table while sharing a space");
|
||||
Assert::assertArrayNotHasKey(
|
||||
"resource",
|
||||
$rows,
|
||||
"'resource' should not be provided in the data-table while sharing a space"
|
||||
);
|
||||
$this->featureContext->setResponse(
|
||||
$this->sendShareInvitation($user, $rows, null, true)
|
||||
);
|
||||
@@ -555,7 +619,12 @@ class SharingNgContext implements Context {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function userUpdatesTheSpaceShareForUserOrGroupWithFollowingUsingGraphApi(string $user, string $shareType, string $sharee, TableNode $table) {
|
||||
public function userUpdatesTheSpaceShareForUserOrGroupWithFollowingUsingGraphApi(
|
||||
string $user,
|
||||
string $shareType,
|
||||
string $sharee,
|
||||
TableNode $table
|
||||
) {
|
||||
$permissionID = "";
|
||||
if ($shareType === "user") {
|
||||
$permissionID = "u:" . $this->featureContext->getAttributeOfCreatedUser($sharee, 'id');
|
||||
@@ -600,7 +669,8 @@ class SharingNgContext implements Context {
|
||||
}
|
||||
|
||||
if (\array_key_exists('expirationDateTime', $bodyRows)) {
|
||||
$body['expirationDateTime'] = empty($bodyRows['expirationDateTime']) ? null : $bodyRows['expirationDateTime'];
|
||||
$body['expirationDateTime'] = empty($bodyRows['expirationDateTime'])
|
||||
? null : $bodyRows['expirationDateTime'];
|
||||
}
|
||||
|
||||
return GraphHelper::updateShare(
|
||||
@@ -626,7 +696,11 @@ class SharingNgContext implements Context {
|
||||
* @throws JsonException
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function userSendsTheFollowingShareInvitationWithFileIdUsingTheGraphApi(string $user, string $fileId, TableNode $table): void {
|
||||
public function userSendsTheFollowingShareInvitationWithFileIdUsingTheGraphApi(
|
||||
string $user,
|
||||
string $fileId,
|
||||
TableNode $table
|
||||
): void {
|
||||
$rows = $table->getRowsHash();
|
||||
$this->featureContext->setResponse(
|
||||
$this->sendShareInvitation($user, $rows, $fileId)
|
||||
@@ -656,7 +730,10 @@ class SharingNgContext implements Context {
|
||||
* @return void
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function userCreatesTheFollowingSpaceLinkShareUsingPermissionsEndpointOfTheGraphApi(string $user, TableNode $body):void {
|
||||
public function userCreatesTheFollowingSpaceLinkShareUsingPermissionsEndpointOfTheGraphApi(
|
||||
string $user,
|
||||
TableNode $body
|
||||
): void {
|
||||
$this->featureContext->setResponse($this->createLinkShare($user, $body));
|
||||
}
|
||||
|
||||
@@ -671,7 +748,11 @@ class SharingNgContext implements Context {
|
||||
*/
|
||||
public function userHasCreatedTheFollowingResourceLinkShare(string $user, TableNode $body): void {
|
||||
$rows = $body->getRowsHash();
|
||||
Assert::assertArrayHasKey("resource", $rows, "'resource' should be provided in the data-table while sharing a resource");
|
||||
Assert::assertArrayHasKey(
|
||||
"resource",
|
||||
$rows,
|
||||
"'resource' should be provided in the data-table while sharing a resource"
|
||||
);
|
||||
$response = $this->createLinkShare($user, $body);
|
||||
$this->featureContext->theHTTPStatusCodeShouldBe(200, "Failed while creating public share link!", $response);
|
||||
$this->featureContext->shareNgAddToCreatedLinkShares($response);
|
||||
@@ -688,7 +769,11 @@ class SharingNgContext implements Context {
|
||||
*/
|
||||
public function userHasCreatedTheFollowingLinkShare(string $user, TableNode $body): void {
|
||||
$rows = $body->getRowsHash();
|
||||
Assert::assertArrayNotHasKey("resource", $rows, "'resource' should not be provided in the data-table while sharing a space");
|
||||
Assert::assertArrayNotHasKey(
|
||||
"resource",
|
||||
$rows,
|
||||
"'resource' should not be provided in the data-table while sharing a space"
|
||||
);
|
||||
$response = $this->createDriveLinkShare($user, $body);
|
||||
$this->featureContext->theHTTPStatusCodeShouldBe(200, "Failed while creating public share link!", $response);
|
||||
$this->featureContext->shareNgAddToCreatedLinkShares($response);
|
||||
@@ -721,7 +806,10 @@ class SharingNgContext implements Context {
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function userUpdatesTheLastPublicLinkShareUsingThePermissionsEndpointOfTheGraphApi(string $user, TableNode $body):void {
|
||||
public function userUpdatesTheLastPublicLinkShareUsingThePermissionsEndpointOfTheGraphApi(
|
||||
string $user,
|
||||
TableNode $body
|
||||
): void {
|
||||
$this->featureContext->setResponse(
|
||||
$this->updateLinkShare(
|
||||
$user,
|
||||
@@ -755,7 +843,8 @@ class SharingNgContext implements Context {
|
||||
}
|
||||
|
||||
if (\array_key_exists('expirationDateTime', $bodyRows)) {
|
||||
$body['expirationDateTime'] = empty($bodyRows['expirationDateTime']) ? null : $bodyRows['expirationDateTime'];
|
||||
$body['expirationDateTime'] = empty($bodyRows['expirationDateTime'])
|
||||
? null : $bodyRows['expirationDateTime'];
|
||||
}
|
||||
|
||||
if (\array_key_exists('displayName', $bodyRows)) {
|
||||
@@ -824,7 +913,11 @@ class SharingNgContext implements Context {
|
||||
$body,
|
||||
$this->featureContext->shareNgGetLastCreatedLinkShareID()
|
||||
);
|
||||
$this->featureContext->theHTTPStatusCodeShouldBe(200, "Failed while setting public share link password!", $response);
|
||||
$this->featureContext->theHTTPStatusCodeShouldBe(
|
||||
200,
|
||||
"Failed while setting public share link password!",
|
||||
$response
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -836,7 +929,10 @@ class SharingNgContext implements Context {
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function userSetsOrUpdatesFollowingPasswordForLastLinkShareUsingTheGraphApi(string $user, TableNode $body):void {
|
||||
public function userSetsOrUpdatesFollowingPasswordForLastLinkShareUsingTheGraphApi(
|
||||
string $user,
|
||||
TableNode $body
|
||||
): void {
|
||||
$this->featureContext->setResponse(
|
||||
$this->setLinkSharePassword(
|
||||
$user,
|
||||
@@ -867,7 +963,8 @@ class SharingNgContext implements Context {
|
||||
?string $recipient = null
|
||||
): ResponseInterface {
|
||||
$spaceId = ($this->spacesContext->getSpaceByName($sharer, $space))["id"];
|
||||
$itemId = (isset($resource)) ? $this->spacesContext->getResourceId($sharer, $space, $resource) : $this->spacesContext->getResourceId($sharer, $space, $space);
|
||||
$itemId = (isset($resource)) ? $this->spacesContext->getResourceId($sharer, $space, $resource)
|
||||
: $this->spacesContext->getResourceId($sharer, $space, $space);
|
||||
|
||||
$permissionID = "";
|
||||
|
||||
@@ -1158,7 +1255,11 @@ class SharingNgContext implements Context {
|
||||
$itemId,
|
||||
$shareSpaceId,
|
||||
);
|
||||
$this->featureContext->theHTTPStatusCodeShouldBe(204, __METHOD__ . " could not disable sync of last share", $response);
|
||||
$this->featureContext->theHTTPStatusCodeShouldBe(
|
||||
204,
|
||||
__METHOD__ . " could not disable sync of last share",
|
||||
$response
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1244,7 +1345,12 @@ class SharingNgContext implements Context {
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function userEnablesSyncOfShareUsingTheGraphApi(string $user, string $share, string $offeredBy, string $space):void {
|
||||
public function userEnablesSyncOfShareUsingTheGraphApi(
|
||||
string $user,
|
||||
string $share,
|
||||
string $offeredBy,
|
||||
string $space
|
||||
): void {
|
||||
$share = ltrim($share, '/');
|
||||
$itemId = $this->spacesContext->getResourceId($offeredBy, $space, $share);
|
||||
$shareSpaceId = GraphHelper::SHARES_SPACE_ID;
|
||||
@@ -1406,11 +1512,15 @@ class SharingNgContext implements Context {
|
||||
* @throws Exception
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function userShouldBeAbleToSendShareTheFollowingInvitationWithAllAllowedPermissionRoles(string $user, TableNode $table): void {
|
||||
public function userShouldBeAbleToSendShareTheFollowingInvitationWithAllAllowedPermissionRoles(
|
||||
string $user,
|
||||
TableNode $table
|
||||
): void {
|
||||
$listPermissionResponse = $this->featureContext->getJsonDecodedResponseBodyContent();
|
||||
if (!isset($listPermissionResponse->{'@libre.graph.permissions.roles.allowedValues'})) {
|
||||
Assert::fail(
|
||||
"The following response does not contain '@libre.graph.permissions.roles.allowedValues' property:\n" . $listPermissionResponse
|
||||
"The following response does not contain '@libre.graph.permissions.roles.allowedValues' property:\n"
|
||||
. $listPermissionResponse
|
||||
);
|
||||
}
|
||||
Assert::assertNotEmpty(
|
||||
@@ -1431,8 +1541,13 @@ class SharingNgContext implements Context {
|
||||
foreach ($allowedPermissionRoles as $role) {
|
||||
//we should be able to send share invitation for each of the role allowed for the files/folders which are listed in permissions (allowed)
|
||||
$roleAllowed = GraphHelper::getPermissionNameByPermissionRoleId($role->id);
|
||||
$responseSendInvitation = $this->sendShareInvitation($user, array_merge($rows, ['permissionsRole' => $roleAllowed]));
|
||||
$jsonResponseSendInvitation = $this->featureContext->getJsonDecodedResponseBodyContent($responseSendInvitation);
|
||||
$responseSendInvitation = $this->sendShareInvitation(
|
||||
$user,
|
||||
array_merge($rows, ['permissionsRole' => $roleAllowed])
|
||||
);
|
||||
$jsonResponseSendInvitation = $this->featureContext->getJsonDecodedResponseBodyContent(
|
||||
$responseSendInvitation
|
||||
);
|
||||
$httpsStatusCode = $responseSendInvitation->getStatusCode();
|
||||
if ($httpsStatusCode === 200 && !empty($jsonResponseSendInvitation->value)) {
|
||||
// remove the share so that the same user can be share for the next allowed roles
|
||||
@@ -1440,7 +1555,8 @@ class SharingNgContext implements Context {
|
||||
Assert::assertEquals(204, $removePermissionsResponse->getStatusCode());
|
||||
} else {
|
||||
$areAllSendInvitationSuccessFullForAllowedRoles = false;
|
||||
$shareInvitationRequestResult .= "\tShare invitation for " . $resourceDetail . "' with role '" . $roleAllowed . "' failed and was not allowed.\n";
|
||||
$shareInvitationRequestResult .= "\tShare invitation for " . $resourceDetail
|
||||
. "' with role '" . $roleAllowed . "' failed and was not allowed.\n";
|
||||
}
|
||||
}
|
||||
Assert::assertTrue($areAllSendInvitationSuccessFullForAllowedRoles, $shareInvitationRequestResult);
|
||||
@@ -1479,7 +1595,10 @@ class SharingNgContext implements Context {
|
||||
* @return void
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function userSendsTheFollowingShareInvitationUsingRootEndPointTheGraphApi(string $user, TableNode $table):void {
|
||||
public function userSendsTheFollowingShareInvitationUsingRootEndPointTheGraphApi(
|
||||
string $user,
|
||||
TableNode $table
|
||||
): void {
|
||||
$response = $this->sendDriveShareInvitation($user, $table);
|
||||
$this->featureContext->setResponse($response);
|
||||
}
|
||||
@@ -1493,7 +1612,10 @@ class SharingNgContext implements Context {
|
||||
* @return void
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function userSendsTheFollowingShareInvitationToFederatedUserUsingRootEndPointTheGraphApi(string $user, TableNode $table):void {
|
||||
public function userSendsTheFollowingShareInvitationToFederatedUserUsingRootEndPointTheGraphApi(
|
||||
string $user,
|
||||
TableNode $table
|
||||
): void {
|
||||
$response = $this->sendDriveShareInvitation($user, $table, true);
|
||||
$this->featureContext->setResponse($response);
|
||||
}
|
||||
@@ -1507,7 +1629,10 @@ class SharingNgContext implements Context {
|
||||
* @return void
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function userUpdatesTheLastDriveShareWithTheFollowingUsingRootEndpointOfTheGraphApi(string $user, TableNode $table): void {
|
||||
public function userUpdatesTheLastDriveShareWithTheFollowingUsingRootEndpointOfTheGraphApi(
|
||||
string $user,
|
||||
TableNode $table
|
||||
): void {
|
||||
$bodyRows = $table->getRowsHash();
|
||||
$permissionID = match ($bodyRows['shareType']) {
|
||||
'user' => 'u:' . $this->featureContext->getAttributeOfCreatedUser($bodyRows['sharee'], 'id'),
|
||||
@@ -1523,7 +1648,8 @@ class SharingNgContext implements Context {
|
||||
}
|
||||
|
||||
if (\array_key_exists('expirationDateTime', $bodyRows)) {
|
||||
$body['expirationDateTime'] = empty($bodyRows['expirationDateTime']) ? null : $bodyRows['expirationDateTime'];
|
||||
$body['expirationDateTime'] = empty($bodyRows['expirationDateTime'])
|
||||
? null : $bodyRows['expirationDateTime'];
|
||||
}
|
||||
|
||||
$this->featureContext->setResponse(
|
||||
@@ -1548,9 +1674,16 @@ class SharingNgContext implements Context {
|
||||
* @return void
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function userCreatesTheFollowingSpaceLinkShareUsingRootEndpointOfTheGraphApi(string $user, TableNode $body): void {
|
||||
public function userCreatesTheFollowingSpaceLinkShareUsingRootEndpointOfTheGraphApi(
|
||||
string $user,
|
||||
TableNode $body
|
||||
): void {
|
||||
$rows = $body->getRowsHash();
|
||||
Assert::assertArrayNotHasKey("resource", $rows, "'resource' should not be provided in the data-table while sharing a space");
|
||||
Assert::assertArrayNotHasKey(
|
||||
"resource",
|
||||
$rows,
|
||||
"'resource' should not be provided in the data-table while sharing a space"
|
||||
);
|
||||
$response = $this->createDriveLinkShare($user, $body);
|
||||
|
||||
$this->featureContext->setResponse($response);
|
||||
@@ -1565,9 +1698,16 @@ class SharingNgContext implements Context {
|
||||
* @return void
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function userSetsTheFollowingPasswordForTheLastSpaceLinkShareUsingRootEndpointOfTheGraphAPI(string $user, TableNode $body): void {
|
||||
public function userSetsTheFollowingPasswordForTheLastSpaceLinkShareUsingRootEndpointOfTheGraphAPI(
|
||||
string $user,
|
||||
TableNode $body
|
||||
): void {
|
||||
$rows = $body->getRowsHash();
|
||||
Assert::assertArrayNotHasKey("resource", $rows, "'resource' should not be provided in the data-table while setting password in space shared link");
|
||||
Assert::assertArrayNotHasKey(
|
||||
"resource",
|
||||
$rows,
|
||||
"'resource' should not be provided in the data-table while setting password in space shared link"
|
||||
);
|
||||
|
||||
Assert::assertArrayHasKey("password", $rows, "'password' is missing in the data-table");
|
||||
$body = [
|
||||
@@ -1599,7 +1739,11 @@ class SharingNgContext implements Context {
|
||||
* @return void
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function userTriesToRemoveShareLinkOfSpaceOwnedByUsingRootEndpointOfTheGraphApi(string $user, string $space, string $spaceOwner): void {
|
||||
public function userTriesToRemoveShareLinkOfSpaceOwnedByUsingRootEndpointOfTheGraphApi(
|
||||
string $user,
|
||||
string $space,
|
||||
string $spaceOwner
|
||||
): void {
|
||||
$permissionID = $this->featureContext->shareNgGetLastCreatedLinkShareID();
|
||||
$spaceId = ($this->spacesContext->getSpaceByName($spaceOwner, $space))["id"];
|
||||
|
||||
@@ -1638,10 +1782,18 @@ class SharingNgContext implements Context {
|
||||
foreach ($responseBody['value'] as $value) {
|
||||
switch ($shareType) {
|
||||
case $shareType === 'link':
|
||||
Assert::assertArrayNotHasKey('link', $value, $space . ' space should not have any link permissions but found ' . print_r($value, true));
|
||||
Assert::assertArrayNotHasKey(
|
||||
'link',
|
||||
$value,
|
||||
$space . ' space should not have any link permissions but found ' . print_r($value, true)
|
||||
);
|
||||
break;
|
||||
case $shareType === "share":
|
||||
Assert::assertArrayNotHasKey('grantedToV2', $value, $space . ' space should not have any share permissions but found ' . print_r($value, true));
|
||||
Assert::assertArrayNotHasKey(
|
||||
'grantedToV2',
|
||||
$value,
|
||||
$space . ' space should not have any share permissions but found ' . print_r($value, true)
|
||||
);
|
||||
break;
|
||||
default:
|
||||
Assert::fail('Invalid share type has been specified');
|
||||
@@ -1657,12 +1809,18 @@ class SharingNgContext implements Context {
|
||||
*
|
||||
* @return void
|
||||
* @throws GuzzleException
|
||||
* @codingStandardsIgnoreStart
|
||||
*/
|
||||
public function userShouldBeAbleToSendTheFollowingSpaceShareInvitationWithAllAllowedPermissionRolesUsingRootEndpointOFTheGraphApi(string $user, TableNode $table): void {
|
||||
public function userShouldBeAbleToSendTheFollowingSpaceShareInvitationWithAllAllowedPermissionRolesUsingRootEndpointOFTheGraphApi(
|
||||
// @codingStandardsIgnoreEnd
|
||||
string $user,
|
||||
TableNode $table
|
||||
): void {
|
||||
$listPermissionResponse = $this->featureContext->getJsonDecodedResponseBodyContent();
|
||||
if (!isset($listPermissionResponse->{'@libre.graph.permissions.roles.allowedValues'})) {
|
||||
Assert::fail(
|
||||
"The following response does not contain '@libre.graph.permissions.roles.allowedValues' property:\n" . $listPermissionResponse
|
||||
"The following response does not contain '@libre.graph.permissions.roles.allowedValues' property:\n"
|
||||
. $listPermissionResponse
|
||||
);
|
||||
}
|
||||
Assert::assertNotEmpty(
|
||||
@@ -1682,8 +1840,13 @@ class SharingNgContext implements Context {
|
||||
foreach ($allowedPermissionRoles as $role) {
|
||||
// we should be able to send share invitation for each of the roles allowed which are listed in permissions (allowed)
|
||||
$roleAllowed = GraphHelper::getPermissionNameByPermissionRoleId($role->id);
|
||||
$responseSendInvitation = $this->sendDriveShareInvitation($user, new TableNode(array_merge($table->getTable(), [['permissionsRole', $roleAllowed]])));
|
||||
$jsonResponseSendInvitation = $this->featureContext->getJsonDecodedResponseBodyContent($responseSendInvitation);
|
||||
$responseSendInvitation = $this->sendDriveShareInvitation(
|
||||
$user,
|
||||
new TableNode(array_merge($table->getTable(), [['permissionsRole', $roleAllowed]]))
|
||||
);
|
||||
$jsonResponseSendInvitation = $this->featureContext->getJsonDecodedResponseBodyContent(
|
||||
$responseSendInvitation
|
||||
);
|
||||
$httpsStatusCode = $responseSendInvitation->getStatusCode();
|
||||
if ($httpsStatusCode === 200 && !empty($jsonResponseSendInvitation->value)) {
|
||||
// remove the share so that the same user can be share for the next allowed roles
|
||||
@@ -1691,7 +1854,8 @@ class SharingNgContext implements Context {
|
||||
Assert::assertEquals(204, $removePermissionsResponse->getStatusCode());
|
||||
} else {
|
||||
$areAllSendInvitationSuccessFullForAllowedRoles = false;
|
||||
$shareInvitationRequestResult .= "\tShare invitation for " . $space . "' with role '" . $roleAllowed . "' failed and was not allowed.\n";
|
||||
$shareInvitationRequestResult .= "\tShare invitation for " . $space . "' with role '"
|
||||
. $roleAllowed . "' failed and was not allowed.\n";
|
||||
}
|
||||
}
|
||||
Assert::assertTrue($areAllSendInvitationSuccessFullForAllowedRoles, $shareInvitationRequestResult);
|
||||
@@ -1707,7 +1871,11 @@ class SharingNgContext implements Context {
|
||||
* @return void
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function userTriesToListThePermissionsOfSpaceOwnedByUsingRootEndpointOfTheGraphApi(string $user, string $space, string $spaceOwner): void {
|
||||
public function userTriesToListThePermissionsOfSpaceOwnedByUsingRootEndpointOfTheGraphApi(
|
||||
string $user,
|
||||
string $space,
|
||||
string $spaceOwner
|
||||
): void {
|
||||
$spaceId = ($this->spacesContext->getSpaceByName($spaceOwner, $space))["id"];
|
||||
|
||||
$response = GraphHelper::getDrivePermissionsList(
|
||||
@@ -1728,8 +1896,13 @@ class SharingNgContext implements Context {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function userRemovesTheLastLinkShareOfSpaceUsingPermissionsEndpointOfGraphApi(string $user, string $space):void {
|
||||
$this->featureContext->setResponse($this->removeAccessToSpaceItem($user, 'link', $space, ''));
|
||||
public function userRemovesTheLastLinkShareOfSpaceUsingPermissionsEndpointOfGraphApi(
|
||||
string $user,
|
||||
string $space
|
||||
): void {
|
||||
$this->featureContext->setResponse(
|
||||
$this->removeAccessToSpaceItem($user, 'link', $space, '')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1745,7 +1918,14 @@ class SharingNgContext implements Context {
|
||||
* @throws JsonException
|
||||
* @throws Exception
|
||||
*/
|
||||
public function checkIfShareExists(string $share, string $sharee, string $sharer, string $space, bool $shouldExist = true, bool $federatedShare = false): void {
|
||||
public function checkIfShareExists(
|
||||
string $share,
|
||||
string $sharee,
|
||||
string $sharer,
|
||||
string $space,
|
||||
bool $shouldExist = true,
|
||||
bool $federatedShare = false
|
||||
): void {
|
||||
$share = \ltrim($share, "/");
|
||||
if (\strtolower($space) === "personal") {
|
||||
$remoteDriveAlias = "personal/" . \strtolower($sharer);
|
||||
@@ -1765,11 +1945,18 @@ class SharingNgContext implements Context {
|
||||
$driveList = HttpRequestHelper::getJsonDecodedResponseBodyContent($response)->value;
|
||||
$foundShareMountpoint = false;
|
||||
foreach ($driveList as $drive) {
|
||||
if ($drive->driveType === "mountpoint" && $drive->name === $share && $drive->root->remoteItem->driveAlias === $remoteDriveAlias) {
|
||||
if ($drive->driveType === "mountpoint"
|
||||
&& $drive->name === $share
|
||||
&& $drive->root->remoteItem->driveAlias === $remoteDriveAlias
|
||||
) {
|
||||
$foundShareMountpoint = true;
|
||||
}
|
||||
}
|
||||
Assert::assertSame($shouldExist, $foundShareMountpoint, "Share mountpoint '$share' was not found in the drives list.");
|
||||
Assert::assertSame(
|
||||
$shouldExist,
|
||||
$foundShareMountpoint,
|
||||
"Share mountpoint '$share' was not found in the drives list."
|
||||
);
|
||||
}
|
||||
|
||||
// check share in shared-with-me list
|
||||
@@ -1793,7 +1980,11 @@ class SharingNgContext implements Context {
|
||||
break;
|
||||
}
|
||||
}
|
||||
Assert::assertSame($shouldExist, $foundShareInSharedWithMe, "Share '$share' was not found in the shared-with-me list");
|
||||
Assert::assertSame(
|
||||
$shouldExist,
|
||||
$foundShareInSharedWithMe,
|
||||
"Share '$share' was not found in the shared-with-me list"
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1807,7 +1998,13 @@ class SharingNgContext implements Context {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function userShouldHaveShareSharedByUserFromSpace(string $sharee, string $shouldOrNot, string $share, string $sharer, string $space): void {
|
||||
public function userShouldHaveShareSharedByUserFromSpace(
|
||||
string $sharee,
|
||||
string $shouldOrNot,
|
||||
string $share,
|
||||
string $sharer,
|
||||
string $space
|
||||
): void {
|
||||
$this->checkIfShareExists($share, $sharee, $sharer, $space, $shouldOrNot === "should");
|
||||
}
|
||||
|
||||
@@ -1822,7 +2019,13 @@ class SharingNgContext implements Context {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function userShouldOrShouldNotHaveFederatedShareSharedByUserFromSpace(string $sharee, string $shouldOrNot, string $share, string $sharer, string $space): void {
|
||||
public function userShouldOrShouldNotHaveFederatedShareSharedByUserFromSpace(
|
||||
string $sharee,
|
||||
string $shouldOrNot,
|
||||
string $share,
|
||||
string $sharer,
|
||||
string $space
|
||||
): void {
|
||||
$this->checkIfShareExists($share, $sharee, $sharer, $space, $shouldOrNot === "should", true);
|
||||
}
|
||||
|
||||
@@ -1837,7 +2040,13 @@ class SharingNgContext implements Context {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function userHasSharedTheFollowingFilesFromSpaceWithUserAndRole(string $sharer, string $space, string $sharee, string $role, TableNode $table):void {
|
||||
public function userHasSharedTheFollowingFilesFromSpaceWithUserAndRole(
|
||||
string $sharer,
|
||||
string $space,
|
||||
string $sharee,
|
||||
string $role,
|
||||
TableNode $table
|
||||
): void {
|
||||
$rows = $table->getRows();
|
||||
foreach ($rows as $row) {
|
||||
if (isset($row[0])) {
|
||||
|
||||
@@ -203,7 +203,8 @@ class SpacesContext implements Context {
|
||||
$this->$listSpacesFn($user);
|
||||
$spaces = $this->getAvailableSpaces();
|
||||
|
||||
$tryAgain = !\array_key_exists($spaceName, $spaces) && $retried < HttpRequestHelper::numRetriesOnHttpTooEarly();
|
||||
$tryAgain = !\array_key_exists($spaceName, $spaces)
|
||||
&& $retried < HttpRequestHelper::numRetriesOnHttpTooEarly();
|
||||
if ($tryAgain) {
|
||||
$retried += 1;
|
||||
echo "Space '$spaceName' not found for user '$user', retrying ($retried)...\n";
|
||||
@@ -213,7 +214,10 @@ class SpacesContext implements Context {
|
||||
} while ($tryAgain);
|
||||
|
||||
Assert::assertArrayHasKey($spaceName, $spaces, "Space with name '$spaceName' for user '$user' not found");
|
||||
Assert::assertNotEmpty($spaces[$spaceName]["root"]["webDavUrl"], "WebDavUrl for space with name '$spaceName' for user '$user' not found");
|
||||
Assert::assertNotEmpty(
|
||||
$spaces[$spaceName]["root"]["webDavUrl"],
|
||||
"WebDavUrl for space with name '$spaceName' for user '$user' not found"
|
||||
);
|
||||
return $spaces[$spaceName];
|
||||
}
|
||||
|
||||
@@ -275,7 +279,12 @@ class SpacesContext implements Context {
|
||||
* @return ResponseInterface
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function getFileData(string $user, string $spaceName, string $fileName, bool $federatedShare = false): ResponseInterface {
|
||||
public function getFileData(
|
||||
string $user,
|
||||
string $spaceName,
|
||||
string $fileName,
|
||||
bool $federatedShare = false
|
||||
): ResponseInterface {
|
||||
$baseUrl = $this->featureContext->getBaseUrl();
|
||||
|
||||
if ($federatedShare) {
|
||||
@@ -373,7 +382,15 @@ class SpacesContext implements Context {
|
||||
"files",
|
||||
WebDavHelper::DAV_VERSION_SPACES
|
||||
);
|
||||
$responseArray = json_decode(json_encode(HttpRequestHelper::getResponseXml($response, __METHOD__)->xpath("//d:response/d:propstat/d:prop/oc:privatelink")), true, 512, JSON_THROW_ON_ERROR);
|
||||
$responseArray = json_decode(
|
||||
json_encode(
|
||||
HttpRequestHelper::getResponseXml($response, __METHOD__)
|
||||
->xpath("//d:response/d:propstat/d:prop/oc:privatelink")
|
||||
),
|
||||
true,
|
||||
512,
|
||||
JSON_THROW_ON_ERROR
|
||||
);
|
||||
Assert::assertNotEmpty($responseArray, "the PROPFIND response for $spaceName is empty");
|
||||
return $responseArray[0][0];
|
||||
}
|
||||
@@ -539,7 +556,11 @@ class SpacesContext implements Context {
|
||||
* @throws GuzzleException
|
||||
* @throws Exception
|
||||
*/
|
||||
public function listAllAvailableSpacesOfUser(string $user, string $query = '', array $headers = []): ResponseInterface {
|
||||
public function listAllAvailableSpacesOfUser(
|
||||
string $user,
|
||||
string $query = '',
|
||||
array $headers = []
|
||||
): ResponseInterface {
|
||||
$response = GraphHelper::getMySpaces(
|
||||
$this->featureContext->getBaseUrl(),
|
||||
$user,
|
||||
@@ -580,7 +601,10 @@ class SpacesContext implements Context {
|
||||
* @throws GuzzleException
|
||||
* @throws Exception
|
||||
*/
|
||||
public function theUserListsAllHisAvailableSpacesWithHeadersUsingTheGraphApi(string $user, TableNode $headersTable): void {
|
||||
public function theUserListsAllHisAvailableSpacesWithHeadersUsingTheGraphApi(
|
||||
string $user,
|
||||
TableNode $headersTable
|
||||
): void {
|
||||
$this->featureContext->verifyTableNodeColumns(
|
||||
$headersTable,
|
||||
['header', 'value']
|
||||
@@ -645,7 +669,11 @@ class SpacesContext implements Context {
|
||||
* @return void
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function theUserLooksUpTheSingleSpaceUsingTheGraphApiByUsingItsId(string $user, string $spaceName, string $ownerUser = ''): void {
|
||||
public function theUserLooksUpTheSingleSpaceUsingTheGraphApiByUsingItsId(
|
||||
string $user,
|
||||
string $spaceName,
|
||||
string $ownerUser = ''
|
||||
): void {
|
||||
$space = $this->getSpaceByName(($ownerUser !== "") ? $ownerUser : $user, $spaceName);
|
||||
Assert::assertIsArray($space);
|
||||
Assert::assertNotEmpty($space["id"]);
|
||||
@@ -777,7 +805,12 @@ class SpacesContext implements Context {
|
||||
* @return void
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function userSendsPatchRequestToTheSpaceOfUserWithData(string $user, string $spaceName, string $owner, string $data): void {
|
||||
public function userSendsPatchRequestToTheSpaceOfUserWithData(
|
||||
string $user,
|
||||
string $spaceName,
|
||||
string $owner,
|
||||
string $data
|
||||
): void {
|
||||
$space = $this->getSpaceByName($owner, $spaceName);
|
||||
Assert::assertIsArray($space);
|
||||
Assert::assertNotEmpty($spaceId = $space["id"]);
|
||||
@@ -835,7 +868,14 @@ class SpacesContext implements Context {
|
||||
): void {
|
||||
$space = $this->getSpaceByName($user, $spaceName);
|
||||
$this->featureContext->setResponse($this->propfindSpace($user, $spaceName));
|
||||
$this->featureContext->propfindResultShouldContainEntries($shouldOrNot, $expectedFiles, $user, 'PROPFIND', '', $space['id']);
|
||||
$this->featureContext->propfindResultShouldContainEntries(
|
||||
$shouldOrNot,
|
||||
$expectedFiles,
|
||||
$user,
|
||||
'PROPFIND',
|
||||
'',
|
||||
$space['id']
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -910,7 +950,12 @@ class SpacesContext implements Context {
|
||||
string $share,
|
||||
string $fileContent
|
||||
): void {
|
||||
$actualFileContent = $this->getFileData($user, $share, $file, true)->getBody()->getContents();
|
||||
$actualFileContent = $this->getFileData(
|
||||
$user,
|
||||
$share,
|
||||
$file,
|
||||
true
|
||||
)->getBody()->getContents();
|
||||
Assert::assertEquals($fileContent, $actualFileContent, "File content did not match");
|
||||
}
|
||||
|
||||
@@ -1010,7 +1055,10 @@ class SpacesContext implements Context {
|
||||
"Expected response status code should be 200",
|
||||
$response
|
||||
);
|
||||
Assert::assertIsArray($spaceAsArray = $this->getSpaceByNameFromResponse($spaceName, $response), "No space with name $spaceName found");
|
||||
Assert::assertIsArray(
|
||||
$spaceAsArray = $this->getSpaceByNameFromResponse($spaceName, $response),
|
||||
"No space with name $spaceName found"
|
||||
);
|
||||
$permissions = $spaceAsArray["root"]["permissions"];
|
||||
$userId = $this->featureContext->getUserIdByUserName($grantedUser);
|
||||
|
||||
@@ -1036,7 +1084,10 @@ class SpacesContext implements Context {
|
||||
public function jsonRespondedShouldNotContain(
|
||||
string $spaceName
|
||||
): void {
|
||||
Assert::assertEmpty($this->getSpaceByNameFromResponse($spaceName), "space $spaceName should not be available for a user");
|
||||
Assert::assertEmpty(
|
||||
$this->getSpaceByNameFromResponse($spaceName),
|
||||
"space $spaceName should not be available for a user"
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1061,9 +1112,15 @@ class SpacesContext implements Context {
|
||||
$response
|
||||
);
|
||||
if (\trim($shouldOrNot) === "not") {
|
||||
Assert::assertEmpty($this->getSpaceByNameFromResponse($spaceName, $response), "space $spaceName should not be available for a user");
|
||||
Assert::assertEmpty(
|
||||
$this->getSpaceByNameFromResponse($spaceName, $response),
|
||||
"space $spaceName should not be available for a user"
|
||||
);
|
||||
} else {
|
||||
Assert::assertNotEmpty($this->getSpaceByNameFromResponse($spaceName, $response), "space '$spaceName' should be available for a user '$user' but not found");
|
||||
Assert::assertNotEmpty(
|
||||
$this->getSpaceByNameFromResponse($spaceName, $response),
|
||||
"space '$spaceName' should be available for a user '$user' but not found"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1384,7 +1441,12 @@ class SpacesContext implements Context {
|
||||
* @throws GuzzleException
|
||||
* @throws Exception
|
||||
*/
|
||||
public function userHasUploadedAFileToInSpaceUsingTheWebdavApi(string $user, string $source, string $destination, string $spaceName): void {
|
||||
public function userHasUploadedAFileToInSpaceUsingTheWebdavApi(
|
||||
string $user,
|
||||
string $source,
|
||||
string $destination,
|
||||
string $spaceName
|
||||
): void {
|
||||
$spaceId = $this->getSpaceIdByName($user, $spaceName);
|
||||
$response = $this->featureContext->uploadFile($user, $source, $destination, $spaceId);
|
||||
$this->featureContext->theHTTPStatusCodeShouldBe(
|
||||
@@ -1415,7 +1477,12 @@ class SpacesContext implements Context {
|
||||
string $destination
|
||||
): void {
|
||||
$spaceId = $this->getSpaceIdByName($ownerUser, $spaceName);
|
||||
$response = $this->featureContext->uploadFileWithContent($user, $content, $destination, $spaceId);
|
||||
$response = $this->featureContext->uploadFileWithContent(
|
||||
$user,
|
||||
$content,
|
||||
$destination,
|
||||
$spaceId
|
||||
);
|
||||
$this->featureContext->setResponse($response);
|
||||
}
|
||||
|
||||
@@ -1475,7 +1542,9 @@ class SpacesContext implements Context {
|
||||
string $owner = ''
|
||||
): void {
|
||||
$bodyData = ["Name" => $newName];
|
||||
$this->featureContext->setResponse($this->updateSpace($user, $spaceName, $bodyData, $owner));
|
||||
$this->featureContext->setResponse(
|
||||
$this->updateSpace($user, $spaceName, $bodyData, $owner)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1498,7 +1567,9 @@ class SpacesContext implements Context {
|
||||
string $owner = ''
|
||||
): void {
|
||||
$bodyData = ["description" => $newDescription];
|
||||
$this->featureContext->setResponse($this->updateSpace($user, $spaceName, $bodyData, $owner));
|
||||
$this->featureContext->setResponse(
|
||||
$this->updateSpace($user, $spaceName, $bodyData, $owner)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1546,7 +1617,9 @@ class SpacesContext implements Context {
|
||||
string $owner = ''
|
||||
): void {
|
||||
$bodyData = ["quota" => ["total" => $newQuota]];
|
||||
$this->featureContext->setResponse($this->updateSpace($user, $spaceName, $bodyData, $owner));
|
||||
$this->featureContext->setResponse(
|
||||
$this->updateSpace($user, $spaceName, $bodyData, $owner)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1821,7 +1894,14 @@ class SpacesContext implements Context {
|
||||
string $fileDestination,
|
||||
string $spaceName
|
||||
): void {
|
||||
$this->featureContext->setResponse($this->moveFileWithinSpace($user, $fileSource, $fileDestination, $spaceName));
|
||||
$this->featureContext->setResponse(
|
||||
$this->moveFileWithinSpace(
|
||||
$user,
|
||||
$fileSource,
|
||||
$fileDestination,
|
||||
$spaceName
|
||||
)
|
||||
);
|
||||
$this->featureContext->pushToLastHttpStatusCodesArray();
|
||||
}
|
||||
|
||||
@@ -1901,7 +1981,11 @@ class SpacesContext implements Context {
|
||||
TableNode $table = null
|
||||
): void {
|
||||
$space = $this->getSpaceByName($user, $fromSpaceName);
|
||||
$headers['Destination'] = $this->destinationHeaderValueWithSpaceName($user, $fileDestination, $toSpaceName);
|
||||
$headers['Destination'] = $this->destinationHeaderValueWithSpaceName(
|
||||
$user,
|
||||
$fileDestination,
|
||||
$toSpaceName
|
||||
);
|
||||
|
||||
if ($table !== null) {
|
||||
$this->featureContext->verifyTableNodeColumns(
|
||||
@@ -1943,7 +2027,11 @@ class SpacesContext implements Context {
|
||||
string $action
|
||||
): void {
|
||||
$space = $this->getSpaceByName($user, $fromSpaceName);
|
||||
$headers['Destination'] = $this->destinationHeaderValueWithSpaceName($user, $fileDestination, $toSpaceName);
|
||||
$headers['Destination'] = $this->destinationHeaderValueWithSpaceName(
|
||||
$user,
|
||||
$fileDestination,
|
||||
$toSpaceName
|
||||
);
|
||||
$headers['Overwrite'] = 'T';
|
||||
|
||||
$encodedName = \rawurlencode(ltrim($fileSource, "/"));
|
||||
@@ -1975,7 +2063,11 @@ class SpacesContext implements Context {
|
||||
string $fileName,
|
||||
string $spaceName
|
||||
): void {
|
||||
$response = $this->featureContext->downloadFileAsUserUsingPassword($user, $fileName, $this->featureContext->getPasswordForUser($user));
|
||||
$response = $this->featureContext->downloadFileAsUserUsingPassword(
|
||||
$user,
|
||||
$fileName,
|
||||
$this->featureContext->getPasswordForUser($user)
|
||||
);
|
||||
Assert::assertGreaterThanOrEqual(
|
||||
400,
|
||||
$response->getStatusCode(),
|
||||
@@ -2011,7 +2103,11 @@ class SpacesContext implements Context {
|
||||
string $toSpaceName
|
||||
): void {
|
||||
$space = $this->getSpaceByName($user, $fromSpaceName);
|
||||
$headers['Destination'] = $this->destinationHeaderValueWithSpaceName($user, $fileDestination, $toSpaceName);
|
||||
$headers['Destination'] = $this->destinationHeaderValueWithSpaceName(
|
||||
$user,
|
||||
$fileDestination,
|
||||
$toSpaceName
|
||||
);
|
||||
|
||||
$encodedName = \rawurlencode(ltrim($fileSource, "/"));
|
||||
$baseUrl = $this->featureContext->getBaseUrl();
|
||||
@@ -2033,7 +2129,12 @@ class SpacesContext implements Context {
|
||||
* @return string
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function destinationHeaderValueWithSpaceName(string $user, string $fileDestination, string $spaceName, string $endPath = null):string {
|
||||
public function destinationHeaderValueWithSpaceName(
|
||||
string $user,
|
||||
string $fileDestination,
|
||||
string $spaceName,
|
||||
string $endPath = null
|
||||
): string {
|
||||
$space = $this->getSpaceByName($user, $spaceName);
|
||||
$fileDestination = $this->escapePath(\ltrim($fileDestination, "/"));
|
||||
$baseUrl = $this->featureContext->getBaseUrl();
|
||||
@@ -2075,7 +2176,14 @@ class SpacesContext implements Context {
|
||||
* @throws GuzzleException
|
||||
* @return void
|
||||
*/
|
||||
public function userCopiesOrMovesFileWithIdAsIntoFolderInsideSpace(string $user, string $actionType, string $fileId, string $destinationFile, string $destinationFolder, string $toSpaceName): void {
|
||||
public function userCopiesOrMovesFileWithIdAsIntoFolderInsideSpace(
|
||||
string $user,
|
||||
string $actionType,
|
||||
string $fileId,
|
||||
string $destinationFile,
|
||||
string $destinationFolder,
|
||||
string $toSpaceName
|
||||
): void {
|
||||
$destinationFile = \trim($destinationFile, "/");
|
||||
$destinationFolder = \trim($destinationFolder, "/");
|
||||
$fileDestination = $destinationFolder . '/' . $this->escapePath($destinationFile);
|
||||
@@ -2086,13 +2194,22 @@ class SpacesContext implements Context {
|
||||
$davPath = WebDavHelper::getDavPath($this->featureContext->getDavPathVersion());
|
||||
$headers['Destination'] = "$baseUrl/$davPath/$sharesPath";
|
||||
} else {
|
||||
$headers['Destination'] = $this->destinationHeaderValueWithSpaceName($user, $fileDestination, $toSpaceName, $fileId);
|
||||
$headers['Destination'] = $this->destinationHeaderValueWithSpaceName(
|
||||
$user,
|
||||
$fileDestination,
|
||||
$toSpaceName,
|
||||
$fileId
|
||||
);
|
||||
}
|
||||
$fullUrl = "$baseUrl/$sourceDavPath/$fileId";
|
||||
if ($actionType === 'copies') {
|
||||
$this->featureContext->setResponse($this->copyFilesAndFoldersRequest($user, $fullUrl, $headers));
|
||||
$this->featureContext->setResponse(
|
||||
$this->copyFilesAndFoldersRequest($user, $fullUrl, $headers)
|
||||
);
|
||||
} else {
|
||||
$this->featureContext->setResponse($this->moveFilesAndFoldersRequest($user, $fullUrl, $headers));
|
||||
$this->featureContext->setResponse(
|
||||
$this->moveFilesAndFoldersRequest($user, $fullUrl, $headers)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2124,7 +2241,12 @@ class SpacesContext implements Context {
|
||||
$davPath = WebDavHelper::getDavPath($this->featureContext->getDavPathVersion());
|
||||
$headers['Destination'] = "$baseUrl/$davPath/$sharesPath";
|
||||
} else {
|
||||
$headers['Destination'] = $this->destinationHeaderValueWithSpaceName($user, $fileDestination, $spaceName, $fileId);
|
||||
$headers['Destination'] = $this->destinationHeaderValueWithSpaceName(
|
||||
$user,
|
||||
$fileDestination,
|
||||
$spaceName,
|
||||
$fileId
|
||||
);
|
||||
}
|
||||
$fullUrl = "$baseUrl/$sourceDavPath/$fileId";
|
||||
$this->featureContext->setResponse($this->moveFilesAndFoldersRequest($user, $fullUrl, $headers));
|
||||
@@ -2163,7 +2285,12 @@ class SpacesContext implements Context {
|
||||
$davPath = WebDavHelper::getDavPath($this->featureContext->getDavPathVersion());
|
||||
$headers['Destination'] = "$baseUrl/$davPath/$sharesPath";
|
||||
} else {
|
||||
$headers['Destination'] = $this->destinationHeaderValueWithSpaceName($user, $fileDestination, $spaceName, $fileId);
|
||||
$headers['Destination'] = $this->destinationHeaderValueWithSpaceName(
|
||||
$user,
|
||||
$fileDestination,
|
||||
$spaceName,
|
||||
$fileId
|
||||
);
|
||||
}
|
||||
$fullUrl = "$baseUrl/$sourceDavPath/$fileId";
|
||||
if ($actionType === 'copied') {
|
||||
@@ -2206,7 +2333,12 @@ class SpacesContext implements Context {
|
||||
$davPath = WebDavHelper::getDavPath($this->featureContext->getDavPathVersion());
|
||||
$headers['Destination'] = "$baseUrl/$davPath/$sharesPath";
|
||||
} else {
|
||||
$headers['Destination'] = $this->destinationHeaderValueWithSpaceName($user, $fileDestination, $spaceName, $fileId);
|
||||
$headers['Destination'] = $this->destinationHeaderValueWithSpaceName(
|
||||
$user,
|
||||
$fileDestination,
|
||||
$spaceName,
|
||||
$fileId
|
||||
);
|
||||
}
|
||||
$fullUrl = "$baseUrl/$sourceDavPath/$fileId";
|
||||
$response = $this->moveFilesAndFoldersRequest($user, $fullUrl, $headers);
|
||||
@@ -2279,7 +2411,13 @@ class SpacesContext implements Context {
|
||||
$response = $this->listAllAvailableSpacesOfUser($user);
|
||||
$this->featureContext->theHTTPStatusCodeShouldBe(200, "", $response);
|
||||
$spaceId = $this->getSpaceIdByName($user, $spaceName);
|
||||
$response = $this->featureContext->uploadFileWithContent($user, $fileContent, $destination, $spaceId, true);
|
||||
$response = $this->featureContext->uploadFileWithContent(
|
||||
$user,
|
||||
$fileContent,
|
||||
$destination,
|
||||
$spaceId,
|
||||
true
|
||||
);
|
||||
$this->featureContext->theHTTPStatusCodeShouldBe(['201', '204'], "", $response);
|
||||
return $response->getHeader('oc-fileid');
|
||||
}
|
||||
@@ -2353,7 +2491,12 @@ class SpacesContext implements Context {
|
||||
* @return void
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function userExpiresTheShareOfSpaceForUser(string $user, string $shareType, string $spaceName, string $memberUser) {
|
||||
public function userExpiresTheShareOfSpaceForUser(
|
||||
string $user,
|
||||
string $shareType,
|
||||
string $spaceName,
|
||||
string $memberUser
|
||||
) {
|
||||
$dateTime = new DateTime('yesterday');
|
||||
$rows['expireDate'] = $dateTime->format('Y-m-d\\TH:i:sP');
|
||||
$rows['shareWith'] = $memberUser;
|
||||
@@ -2473,7 +2616,9 @@ class SpacesContext implements Context {
|
||||
* @throws JsonException
|
||||
*/
|
||||
public function updateSharedResource(string $user, array $rows): ResponseInterface {
|
||||
$shareId = ($this->featureContext->isUsingSharingNG()) ? $this->featureContext->shareNgGetLastCreatedUserGroupShareID() : $this->featureContext->getLastCreatedUserGroupShareId();
|
||||
$shareId = ($this->featureContext->isUsingSharingNG())
|
||||
? $this->featureContext->shareNgGetLastCreatedUserGroupShareID()
|
||||
: $this->featureContext->getLastCreatedUserGroupShareId();
|
||||
$fullUrl = $this->featureContext->getBaseUrl() . $this->ocsApiUrl . '/' . $shareId;
|
||||
return HttpRequestHelper::sendRequest(
|
||||
$fullUrl,
|
||||
@@ -2496,7 +2641,11 @@ class SpacesContext implements Context {
|
||||
* @return void
|
||||
* @throws GuzzleException|JsonException
|
||||
*/
|
||||
public function userExpiresTheLastShareOfResourceInsideOfTheSpace(string $user, string $resource, string $spaceName): void {
|
||||
public function userExpiresTheLastShareOfResourceInsideOfTheSpace(
|
||||
string $user,
|
||||
string $resource,
|
||||
string $spaceName
|
||||
): void {
|
||||
$dateTime = new DateTime('yesterday');
|
||||
$rows['expireDate'] = $dateTime->format('Y-m-d\\TH:i:sP');
|
||||
if ($this->featureContext->isUsingSharingNG()) {
|
||||
@@ -2541,7 +2690,8 @@ class SpacesContext implements Context {
|
||||
$rows["path"] = \array_key_exists("path", $rows) ? $rows["path"] : null;
|
||||
$rows["shareType"] = \array_key_exists("shareType", $rows) ? $rows["shareType"] : 3;
|
||||
$rows["permissions"] = \array_key_exists("permissions", $rows) ? $rows["permissions"] : null;
|
||||
$rows['password'] = \array_key_exists('password', $rows) ? $this->featureContext->getActualPassword($rows['password']) : null;
|
||||
$rows['password'] = \array_key_exists('password', $rows)
|
||||
? $this->featureContext->getActualPassword($rows['password']) : null;
|
||||
$rows["name"] = \array_key_exists("name", $rows) ? $rows["name"] : null;
|
||||
$rows["expireDate"] = \array_key_exists("expireDate", $rows) ? $rows["expireDate"] : null;
|
||||
|
||||
@@ -2683,7 +2833,8 @@ class SpacesContext implements Context {
|
||||
string $recipient
|
||||
): ResponseInterface {
|
||||
$space = $this->getSpaceByName($user, $spaceName);
|
||||
$fullUrl = $this->featureContext->getBaseUrl() . $this->ocsApiUrl . "/" . $space['id'] . "?shareWith=" . $recipient;
|
||||
$fullUrl = $this->featureContext->getBaseUrl()
|
||||
. $this->ocsApiUrl . "/" . $space['id'] . "?shareWith=" . $recipient;
|
||||
|
||||
return HttpRequestHelper::delete(
|
||||
$fullUrl,
|
||||
@@ -2996,7 +3147,11 @@ class SpacesContext implements Context {
|
||||
): ResponseInterface {
|
||||
$space = $this->getSpaceByName($user, $spaceName);
|
||||
$baseUrl = $this->featureContext->getBaseUrl();
|
||||
$davPath = WebDavHelper::getDavPath(WebDavHelper::DAV_VERSION_SPACES, $space["id"], "trash-bin");
|
||||
$davPath = WebDavHelper::getDavPath(
|
||||
WebDavHelper::DAV_VERSION_SPACES,
|
||||
$space["id"],
|
||||
"trash-bin"
|
||||
);
|
||||
$fullUrl = "$baseUrl/$davPath";
|
||||
return HttpRequestHelper::sendRequest(
|
||||
$fullUrl,
|
||||
@@ -3041,10 +3196,20 @@ class SpacesContext implements Context {
|
||||
// get space by admin user
|
||||
$space = $this->getSpaceByName($this->featureContext->getAdminUserName(), $spaceName);
|
||||
$baseUrl = $this->featureContext->getBaseUrl();
|
||||
$davPath = WebDavHelper::getDavPath(WebDavHelper::DAV_VERSION_SPACES, $space["id"], "trash-bin");
|
||||
$davPath = WebDavHelper::getDavPath(
|
||||
WebDavHelper::DAV_VERSION_SPACES,
|
||||
$space["id"],
|
||||
"trash-bin"
|
||||
);
|
||||
$fullUrl = "$baseUrl/$davPath";
|
||||
$this->featureContext->setResponse(
|
||||
HttpRequestHelper::sendRequest($fullUrl, $this->featureContext->getStepLineRef(), 'PROPFIND', $user, $this->featureContext->getPasswordForUser($user))
|
||||
HttpRequestHelper::sendRequest(
|
||||
$fullUrl,
|
||||
$this->featureContext->getStepLineRef(),
|
||||
'PROPFIND',
|
||||
$user,
|
||||
$this->featureContext->getPasswordForUser($user)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -3144,7 +3309,9 @@ class SpacesContext implements Context {
|
||||
}
|
||||
|
||||
if ($pathToDeletedObject === "") {
|
||||
throw new Exception(__METHOD__ . " Object '$object' was not found in the trashbin of space '$spaceName' by user '$user'");
|
||||
throw new Exception(
|
||||
__METHOD__ . " Object '$object' was not found in the trashbin of space '$spaceName' by user '$user'"
|
||||
);
|
||||
}
|
||||
|
||||
$baseUrl = $this->featureContext->getBaseUrl();
|
||||
@@ -3193,7 +3360,9 @@ class SpacesContext implements Context {
|
||||
}
|
||||
|
||||
if ($pathToDeletedObject === "") {
|
||||
throw new Exception(__METHOD__ . " Object '$object' was not found in the trashbin of space '$spaceName' by user '$user'");
|
||||
throw new Exception(
|
||||
__METHOD__ . " Object '$object' was not found in the trashbin of space '$spaceName' by user '$user'"
|
||||
);
|
||||
}
|
||||
|
||||
$fullUrl = $this->featureContext->getBaseUrl() . $pathToDeletedObject;
|
||||
@@ -3272,7 +3441,13 @@ class SpacesContext implements Context {
|
||||
string $spaceName
|
||||
): void {
|
||||
$spaceId = $this->getSpaceIdByName($user, $spaceName);
|
||||
$response = $this->featureContext->downloadFileAsUserUsingPassword($user, $fileName, $this->featureContext->getPasswordForUser($user), [], $spaceId);
|
||||
$response = $this->featureContext->downloadFileAsUserUsingPassword(
|
||||
$user,
|
||||
$fileName,
|
||||
$this->featureContext->getPasswordForUser($user),
|
||||
[],
|
||||
$spaceId
|
||||
);
|
||||
$this->featureContext->setResponse($response);
|
||||
}
|
||||
|
||||
@@ -3292,7 +3467,9 @@ class SpacesContext implements Context {
|
||||
string $spaceName
|
||||
): void {
|
||||
$spaceId = $this->getSpaceIdByName($user, $spaceName);
|
||||
$this->featureContext->setResponse($this->checksumContext->propfindResourceChecksum($user, $path, $spaceId));
|
||||
$this->featureContext->setResponse(
|
||||
$this->checksumContext->propfindResourceChecksum($user, $path, $spaceId)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3316,7 +3493,14 @@ class SpacesContext implements Context {
|
||||
): void {
|
||||
$spaceId = $this->getSpaceIdByName($user, $spaceName);
|
||||
$this->featureContext->setResponse(
|
||||
$this->featureContext->uploadFileWithChecksumAndContent($user, $checksum, $content, $destination, false, $spaceId)
|
||||
$this->featureContext->uploadFileWithChecksumAndContent(
|
||||
$user,
|
||||
$checksum,
|
||||
$content,
|
||||
$destination,
|
||||
false,
|
||||
$spaceId
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -3339,7 +3523,9 @@ class SpacesContext implements Context {
|
||||
string $spaceName
|
||||
): void {
|
||||
$spaceId = $this->getSpaceIdByName($user, $spaceName);
|
||||
$this->featureContext->setResponse($this->filesVersionsContext->downloadVersion($user, $fileName, $index, $spaceId));
|
||||
$this->featureContext->setResponse(
|
||||
$this->filesVersionsContext->downloadVersion($user, $fileName, $index, $spaceId)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3386,7 +3572,12 @@ class SpacesContext implements Context {
|
||||
* @return void
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function storeEtagOfElementInSpaceForUser(string $user, string $space, string $path, ?string $storePath = ""): void {
|
||||
public function storeEtagOfElementInSpaceForUser(
|
||||
string $user,
|
||||
string $space,
|
||||
string $path,
|
||||
?string $storePath = ""
|
||||
): void {
|
||||
if ($storePath === "") {
|
||||
$storePath = $path;
|
||||
}
|
||||
@@ -3451,11 +3642,13 @@ class SpacesContext implements Context {
|
||||
$storedEtag = $this->getStoredEtagForPathInSpaceOfAUser($user, $space, $path);
|
||||
if ($action === 'should' && $etag === $storedEtag) {
|
||||
$changedEtagCount++;
|
||||
$changedEtagMessage .= "\nExpected etag of element '$path' for user '$user' in space '$space' to change, but it did not.";
|
||||
$changedEtagMessage .=
|
||||
"\nExpected etag of element '$path' for user '$user' in space '$space' to change, but it did not.";
|
||||
}
|
||||
if ($action === 'should not' && $etag !== $storedEtag) {
|
||||
$changedEtagCount++;
|
||||
$changedEtagMessage .= "\nExpected etag of element '$path' for user '$user' in space '$space' to change, but it did not.";
|
||||
$changedEtagMessage .=
|
||||
"\nExpected etag of element '$path' for user '$user' in space '$space' to change, but it did not.";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3495,7 +3688,12 @@ class SpacesContext implements Context {
|
||||
* @return void
|
||||
* @throws Exception | GuzzleException
|
||||
*/
|
||||
public function userHasStoredEtagOfElementOnPathFromSpace(string $user, string $path, string $storePath, string $space):void {
|
||||
public function userHasStoredEtagOfElementOnPathFromSpace(
|
||||
string $user,
|
||||
string $path,
|
||||
string $storePath,
|
||||
string $space
|
||||
): void {
|
||||
$user = $this->featureContext->getActualUsername($user);
|
||||
$this->storeEtagOfElementInSpaceForUser(
|
||||
$user,
|
||||
@@ -3503,7 +3701,9 @@ class SpacesContext implements Context {
|
||||
$path,
|
||||
$storePath
|
||||
);
|
||||
if ($this->storedEtags[$user][$space][$storePath] === "" || $this->storedEtags[$user][$space][$storePath] === null) {
|
||||
if ($this->storedEtags[$user][$space][$storePath] === ""
|
||||
|| $this->storedEtags[$user][$space][$storePath] === null
|
||||
) {
|
||||
throw new Exception("Expected stored etag to be some string but found null!");
|
||||
}
|
||||
}
|
||||
@@ -3526,7 +3726,8 @@ class SpacesContext implements Context {
|
||||
|
||||
$rows["shareType"] = \array_key_exists("shareType", $rows) ? $rows["shareType"] : 3;
|
||||
$rows["permissions"] = \array_key_exists("permissions", $rows) ? $rows["permissions"] : null;
|
||||
$rows['password'] = \array_key_exists('password', $rows) ? $this->featureContext->getActualPassword($rows['password']) : null;
|
||||
$rows['password'] = \array_key_exists('password', $rows)
|
||||
? $this->featureContext->getActualPassword($rows['password']) : null;
|
||||
$rows["name"] = \array_key_exists("name", $rows) ? $rows["name"] : null;
|
||||
$rows["expireDate"] = \array_key_exists("expireDate", $rows) ? $rows["expireDate"] : null;
|
||||
|
||||
@@ -3549,7 +3750,9 @@ class SpacesContext implements Context {
|
||||
$this->featureContext->getStepLineRef()
|
||||
);
|
||||
|
||||
$this->featureContext->addToCreatedPublicShares(HttpRequestHelper::getResponseXml($response, __METHOD__)->data);
|
||||
$this->featureContext->addToCreatedPublicShares(
|
||||
HttpRequestHelper::getResponseXml($response, __METHOD__)->data
|
||||
);
|
||||
return $response;
|
||||
}
|
||||
|
||||
@@ -3639,16 +3842,25 @@ class SpacesContext implements Context {
|
||||
);
|
||||
|
||||
$should = ($shouldOrNot !== "not");
|
||||
$responseArray = json_decode(json_encode(HttpRequestHelper::getResponseXml($response, __METHOD__)->data), true, 512, JSON_THROW_ON_ERROR);
|
||||
$responseArray = json_decode(
|
||||
json_encode(HttpRequestHelper::getResponseXml($response, __METHOD__)->data),
|
||||
true,
|
||||
512,
|
||||
JSON_THROW_ON_ERROR
|
||||
);
|
||||
|
||||
if ($should) {
|
||||
Assert::assertNotEmpty($responseArray, __METHOD__ . ' Response should contain a link, but it is empty');
|
||||
foreach ($responseArray as $element) {
|
||||
if ($shareType === 'public link') {
|
||||
$expectedLinkId = ($this->featureContext->isUsingSharingNG()) ? $this->featureContext->shareNgGetLastCreatedLinkShareID() : (string) $this->featureContext->getLastCreatedPublicShare()->id;
|
||||
$expectedLinkId = ($this->featureContext->isUsingSharingNG())
|
||||
? $this->featureContext->shareNgGetLastCreatedLinkShareID() :
|
||||
(string) $this->featureContext->getLastCreatedPublicShare()->id;
|
||||
Assert::assertEquals($element["id"], $expectedLinkId, "link IDs are different");
|
||||
} else {
|
||||
$expectedShareId = ($this->featureContext->isUsingSharingNG()) ? $this->featureContext->shareNgGetLastCreatedUserGroupShareID() : (string)$this->featureContext->getLastCreatedUserGroupShareId();
|
||||
$expectedShareId = ($this->featureContext->isUsingSharingNG())
|
||||
? $this->featureContext->shareNgGetLastCreatedUserGroupShareID()
|
||||
: (string)$this->featureContext->getLastCreatedUserGroupShareId();
|
||||
Assert::assertEquals($element["id"], $expectedShareId, "share IDs are different");
|
||||
}
|
||||
}
|
||||
@@ -3676,7 +3888,12 @@ class SpacesContext implements Context {
|
||||
TableNode $propertiesTable
|
||||
): void {
|
||||
$spaceId = $this->getSpaceIdByName($user, $spaceName);
|
||||
$response = $this->webDavPropertiesContext->getPropertiesOfFolder($user, $resourceName, $spaceId, $propertiesTable);
|
||||
$response = $this->webDavPropertiesContext->getPropertiesOfFolder(
|
||||
$user,
|
||||
$resourceName,
|
||||
$spaceId,
|
||||
$propertiesTable
|
||||
);
|
||||
$this->featureContext->setResponse($response);
|
||||
}
|
||||
|
||||
@@ -3702,7 +3919,12 @@ class SpacesContext implements Context {
|
||||
// short wait is necessary before getting those properties
|
||||
sleep(2);
|
||||
$spaceId = $this->getSpaceIdByName($user, $spaceName);
|
||||
$response = $this->webDavPropertiesContext->getPropertiesOfFolder($user, $resourceName, $spaceId, $propertiesTable);
|
||||
$response = $this->webDavPropertiesContext->getPropertiesOfFolder(
|
||||
$user,
|
||||
$resourceName,
|
||||
$spaceId,
|
||||
$propertiesTable
|
||||
);
|
||||
$this->featureContext->setResponse($response);
|
||||
}
|
||||
|
||||
@@ -3727,7 +3949,14 @@ class SpacesContext implements Context {
|
||||
string $value
|
||||
): void {
|
||||
$spaceId = $this->getSpaceIdByName($user, $spaceName);
|
||||
$this->webDavPropertiesContext->checkPropertyOfAFolder($user, $resourceName, $property, $value, null, $spaceId);
|
||||
$this->webDavPropertiesContext->checkPropertyOfAFolder(
|
||||
$user,
|
||||
$resourceName,
|
||||
$property,
|
||||
$value,
|
||||
null,
|
||||
$spaceId
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3740,9 +3969,19 @@ class SpacesContext implements Context {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function asUserFileOrFolderInsideSpaceShouldOrNotBeFavorited(string $user, string $path, string $spaceName, string $shouldOrNot):void {
|
||||
public function asUserFileOrFolderInsideSpaceShouldOrNotBeFavorited(
|
||||
string $user,
|
||||
string $path,
|
||||
string $spaceName,
|
||||
string $shouldOrNot
|
||||
): void {
|
||||
$spaceId = $this->getSpaceIdByName($user, $spaceName);
|
||||
$this->favoritesContext->asUserFileOrFolderShouldBeFavorited($user, $path, ($shouldOrNot === 'should') ? 1 : 0, $spaceId);
|
||||
$this->favoritesContext->asUserFileOrFolderShouldBeFavorited(
|
||||
$user,
|
||||
$path,
|
||||
($shouldOrNot === 'should') ? 1 : 0,
|
||||
$spaceId
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3789,7 +4028,12 @@ class SpacesContext implements Context {
|
||||
* @throws GuzzleException
|
||||
* @throws JsonException
|
||||
*/
|
||||
public function userFolderOfTheSpaceShouldHaveThePreviouslyStoredId(string $user, string $fileOrFolder, string $path, string $spaceName): void {
|
||||
public function userFolderOfTheSpaceShouldHaveThePreviouslyStoredId(
|
||||
string $user,
|
||||
string $fileOrFolder,
|
||||
string $path,
|
||||
string $spaceName
|
||||
): void {
|
||||
$this->getSpaceIdByName($user, $spaceName);
|
||||
$user = $this->featureContext->getActualUsername($user);
|
||||
$currentFileID = $this->featureContext->getFileIdForPath($user, $path);
|
||||
@@ -3798,7 +4042,8 @@ class SpacesContext implements Context {
|
||||
$currentFileID,
|
||||
$storedFileID,
|
||||
__METHOD__
|
||||
. " User '$user' $fileOrFolder '$path' does not have the previously stored id '$storedFileID', but has '$currentFileID'."
|
||||
. " User '$user' $fileOrFolder '$path' does not have the previously stored id '"
|
||||
. $storedFileID . "', but has '$currentFileID'."
|
||||
);
|
||||
}
|
||||
|
||||
@@ -3813,7 +4058,14 @@ class SpacesContext implements Context {
|
||||
*/
|
||||
public function searchResultShouldContainSpace(string $user, string $spaceName): void {
|
||||
// get a response after a Report request (called in the core)
|
||||
$responseArray = json_decode(json_encode(HttpRequestHelper::getResponseXml($this->featureContext->getResponse())->xpath("//d:response/d:href")), true, 512, JSON_THROW_ON_ERROR);
|
||||
$responseArray = json_decode(
|
||||
json_encode(
|
||||
HttpRequestHelper::getResponseXml($this->featureContext->getResponse())->xpath("//d:response/d:href")
|
||||
),
|
||||
true,
|
||||
512,
|
||||
JSON_THROW_ON_ERROR
|
||||
);
|
||||
Assert::assertNotEmpty($responseArray, "search result is empty");
|
||||
|
||||
// for mountpoint, id looks a little different than for project space
|
||||
@@ -3857,7 +4109,11 @@ class SpacesContext implements Context {
|
||||
*
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function userSendsPropfindRequestToSpaceUsingTheWebdavApi(string $user, string $spaceName, ?string $folderDepth = "1"): void {
|
||||
public function userSendsPropfindRequestToSpaceUsingTheWebdavApi(
|
||||
string $user,
|
||||
string $spaceName,
|
||||
?string $folderDepth = "1"
|
||||
): void {
|
||||
$this->featureContext->setResponse(
|
||||
$this->sendPropfindRequestToSpace($user, $spaceName, "", null, $folderDepth)
|
||||
);
|
||||
@@ -3878,7 +4134,12 @@ class SpacesContext implements Context {
|
||||
*
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function userSendsPropfindRequestFromTheSpaceToTheResourceWithDepthUsingTheWebdavApi(string $user, string $spaceName, string $resource, ?string $folderDepth = "1"): void {
|
||||
public function userSendsPropfindRequestFromTheSpaceToTheResourceWithDepthUsingTheWebdavApi(
|
||||
string $user,
|
||||
string $spaceName,
|
||||
string $resource,
|
||||
?string $folderDepth = "1"
|
||||
): void {
|
||||
$response = $this->sendPropfindRequestToSpace($user, $spaceName, $resource, null, $folderDepth);
|
||||
$this->featureContext->setResponse($response);
|
||||
}
|
||||
@@ -3896,7 +4157,11 @@ class SpacesContext implements Context {
|
||||
*
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function userSendsPropfindRequestToSpaceWithHeaders(string $user, string $spaceName, TableNode $headersTable): void {
|
||||
public function userSendsPropfindRequestToSpaceWithHeaders(
|
||||
string $user,
|
||||
string $spaceName,
|
||||
TableNode $headersTable
|
||||
): void {
|
||||
$this->featureContext->verifyTableNodeColumns(
|
||||
$headersTable,
|
||||
['header', 'value']
|
||||
@@ -3922,7 +4187,13 @@ class SpacesContext implements Context {
|
||||
*
|
||||
* @throws JsonException
|
||||
*/
|
||||
public function sendPropfindRequestToSpace(string $user, string $spaceName, ?string $resource = "", ?array $headers = [], ?string $folderDepth = "1"): ResponseInterface {
|
||||
public function sendPropfindRequestToSpace(
|
||||
string $user,
|
||||
string $spaceName,
|
||||
?string $resource = "",
|
||||
?array $headers = [],
|
||||
?string $folderDepth = "1"
|
||||
): ResponseInterface {
|
||||
$spaceId = $this->getSpaceIdByName($user, $spaceName);
|
||||
$properties = [
|
||||
'oc:id',
|
||||
@@ -3984,7 +4255,12 @@ class SpacesContext implements Context {
|
||||
* @throws GuzzleException
|
||||
* @throws JsonException
|
||||
*/
|
||||
public function asUsertheXMLResponseShouldContainMountpointWithTheseKeyAndValuePair(string $user, string $type, string $resource, TableNode $table): void {
|
||||
public function asUsertheXMLResponseShouldContainMountpointWithTheseKeyAndValuePair(
|
||||
string $user,
|
||||
string $type,
|
||||
string $resource,
|
||||
TableNode $table
|
||||
): void {
|
||||
$this->featureContext->verifyTableNodeColumns($table, ['key', 'value']);
|
||||
if ($this->featureContext->getDavPathVersion() === WebDavHelper::DAV_VERSION_SPACES && $type === 'space') {
|
||||
$space = $this->getSpaceByName($user, $resource);
|
||||
@@ -4006,7 +4282,11 @@ class SpacesContext implements Context {
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function buildXpathErrorMessage(SimpleXMLElement $responseXmlObject, array $xpaths, string $message): string {
|
||||
public function buildXpathErrorMessage(
|
||||
SimpleXMLElement $responseXmlObject,
|
||||
array $xpaths,
|
||||
string $message
|
||||
): string {
|
||||
return "Using xpaths:\n\t- " . \join("\n\t- ", $xpaths)
|
||||
. "\n"
|
||||
. $message
|
||||
@@ -4022,7 +4302,11 @@ class SpacesContext implements Context {
|
||||
* @return string
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getXpathSiblingValue(SimpleXMLElement $responseXmlObject, string $siblingXpath, string $siblingToFind): string {
|
||||
public function getXpathSiblingValue(
|
||||
SimpleXMLElement $responseXmlObject,
|
||||
string $siblingXpath,
|
||||
string $siblingToFind
|
||||
): string {
|
||||
$xpaths[] = $siblingXpath . "/preceding-sibling::$siblingToFind";
|
||||
$xpaths[] = $siblingXpath . "/following-sibling::$siblingToFind";
|
||||
|
||||
@@ -4032,7 +4316,11 @@ class SpacesContext implements Context {
|
||||
break;
|
||||
}
|
||||
}
|
||||
$errorMessage = $this->buildXpathErrorMessage($responseXmlObject, $xpaths, "Could not find sibling '<$siblingToFind>' element in the XML response");
|
||||
$errorMessage = $this->buildXpathErrorMessage(
|
||||
$responseXmlObject,
|
||||
$xpaths,
|
||||
"Could not find sibling '<$siblingToFind>' element in the XML response"
|
||||
);
|
||||
Assert::assertNotEmpty($foundSibling, $errorMessage);
|
||||
return \preg_quote($foundSibling[0]->__toString(), "/");
|
||||
}
|
||||
@@ -4067,10 +4355,15 @@ class SpacesContext implements Context {
|
||||
if ($property['key'] === 'oc:name') {
|
||||
$xpath = "//oc:name[text()='$decodedResource']";
|
||||
} elseif (\array_key_exists('oc:shareroot', $properties)) {
|
||||
$xpaths[] = "//oc:name[text()='$resource']/preceding-sibling::oc:shareroot[text()='" . $properties['oc:shareroot'] . "'/preceding-sibling::/";
|
||||
$xpaths[] = "//oc:name[text()='$resource']/preceding-sibling::oc:shareroot[text()='" . $properties['oc:shareroot'] . "'/following-sibling::/";
|
||||
$xpaths[] = "//oc:name[text()='$resource']/following-sibling::oc:shareroot[text()='" . $properties['oc:shareroot'] . "'/preceding-sibling::/";
|
||||
$xpaths[] = "//oc:name[text()='$resource']/following-sibling::oc:shareroot[text()='" . $properties['oc:shareroot'] . "'/following-sibling::/";
|
||||
$xpaths[] = "//oc:name[text()='$resource']/preceding-sibling::oc:shareroot[text()='"
|
||||
. $properties['oc:shareroot'] . "'/preceding-sibling::/";
|
||||
$xpaths[] = "//oc:name[text()='$resource']/preceding-sibling::oc:shareroot[text()='"
|
||||
. $properties['oc:shareroot'] . "'/following-sibling::/";
|
||||
$xpaths[] = "//oc:name[text()='$resource']/following-sibling::oc:shareroot[text()='"
|
||||
|
||||
. $properties['oc:shareroot'] . "'/preceding-sibling::/";
|
||||
$xpaths[] = "//oc:name[text()='$resource']/following-sibling::oc:shareroot[text()='"
|
||||
. $properties['oc:shareroot'] . "'/following-sibling::/";
|
||||
} else {
|
||||
$xpaths[] = "//oc:name[text()='$decodedResource']/preceding-sibling::";
|
||||
$xpaths[] = "//oc:name[text()='$decodedResource']/following-sibling::";
|
||||
@@ -4097,11 +4390,19 @@ class SpacesContext implements Context {
|
||||
Assert::assertCount(
|
||||
1,
|
||||
$foundXmlItem,
|
||||
$this->buildXpathErrorMessage($responseXmlObject, $xpaths, "Found multiple elements for '<$itemToFind>' in the XML response")
|
||||
$this->buildXpathErrorMessage(
|
||||
$responseXmlObject,
|
||||
$xpaths,
|
||||
"Found multiple elements for '<$itemToFind>' in the XML response"
|
||||
)
|
||||
);
|
||||
Assert::assertNotEmpty(
|
||||
$foundXmlItem,
|
||||
$this->buildXpathErrorMessage($responseXmlObject, $xpaths, "Could not find '<$itemToFind>' element in the XML response")
|
||||
$this->buildXpathErrorMessage(
|
||||
$responseXmlObject,
|
||||
$xpaths,
|
||||
"Could not find '<$itemToFind>' element in the XML response"
|
||||
)
|
||||
);
|
||||
|
||||
$actualValue = $foundXmlItem[0]->__toString();
|
||||
@@ -4131,15 +4432,27 @@ class SpacesContext implements Context {
|
||||
switch ($itemToFind) {
|
||||
case "oc:fileid":
|
||||
$expectedValue = GraphHelper::jsonSchemaRegexToPureRegex($expectedValue);
|
||||
Assert::assertMatchesRegularExpression($expectedValue, $actualValue, 'wrong "fileid" in the response');
|
||||
Assert::assertMatchesRegularExpression(
|
||||
$expectedValue,
|
||||
$actualValue,
|
||||
'wrong "fileid" in the response'
|
||||
);
|
||||
break;
|
||||
case "oc:file-parent":
|
||||
$expectedValue = GraphHelper::jsonSchemaRegexToPureRegex($expectedValue);
|
||||
Assert::assertMatchesRegularExpression($expectedValue, $actualValue, 'wrong "file-parent" in the response');
|
||||
Assert::assertMatchesRegularExpression(
|
||||
$expectedValue,
|
||||
$actualValue,
|
||||
'wrong "file-parent" in the response'
|
||||
);
|
||||
break;
|
||||
case "oc:privatelink":
|
||||
$expectedValue = GraphHelper::jsonSchemaRegexToPureRegex($expectedValue);
|
||||
Assert::assertMatchesRegularExpression($expectedValue, $actualValue, 'wrong "privatelink" in the response');
|
||||
Assert::assertMatchesRegularExpression(
|
||||
$expectedValue,
|
||||
$actualValue,
|
||||
'wrong "privatelink" in the response'
|
||||
);
|
||||
break;
|
||||
case "oc:tags":
|
||||
// The value should be a comma-separated string of tag names.
|
||||
@@ -4167,7 +4480,11 @@ class SpacesContext implements Context {
|
||||
break;
|
||||
case "oc:remote-item-id":
|
||||
$expectedValue = GraphHelper::jsonSchemaRegexToPureRegex($expectedValue);
|
||||
Assert::assertMatchesRegularExpression($expectedValue, $actualValue, 'wrong "remote-item-id" in the response');
|
||||
Assert::assertMatchesRegularExpression(
|
||||
$expectedValue,
|
||||
$actualValue,
|
||||
'wrong "remote-item-id" in the response'
|
||||
);
|
||||
break;
|
||||
default:
|
||||
Assert::assertEquals($expectedValue, $actualValue, "wrong '$itemToFind' in the response");
|
||||
@@ -4186,7 +4503,11 @@ class SpacesContext implements Context {
|
||||
* @return void
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function asUserTheKeyFromPropfindResponseShouldMatchWithSharedwithmeDriveitemidOfShare(string $user, string $key, string $resource): void {
|
||||
public function asUserTheKeyFromPropfindResponseShouldMatchWithSharedwithmeDriveitemidOfShare(
|
||||
string $user,
|
||||
string $key,
|
||||
string $resource
|
||||
): void {
|
||||
$responseXmlObject = HttpRequestHelper::getResponseXml($this->featureContext->getResponse(), __METHOD__);
|
||||
$fileId = $responseXmlObject->xpath("//oc:name[text()='$resource']/preceding-sibling::$key")[0]->__toString();
|
||||
|
||||
@@ -4219,7 +4540,9 @@ class SpacesContext implements Context {
|
||||
* @throws Exception
|
||||
*/
|
||||
public function publicDownloadsTheFolderFromTheLastCreatedPublicLink(string $resource) {
|
||||
$token = ($this->featureContext->isUsingSharingNG()) ? $this->featureContext->shareNgGetLastCreatedLinkShareToken() : $this->featureContext->getLastCreatedPublicShareToken();
|
||||
$token = ($this->featureContext->isUsingSharingNG())
|
||||
? $this->featureContext->shareNgGetLastCreatedLinkShareToken()
|
||||
: $this->featureContext->getLastCreatedPublicShareToken();
|
||||
|
||||
$responseXmlObject = HttpRequestHelper::getResponseXml(
|
||||
$this->featureContext->listFolder(
|
||||
@@ -4293,14 +4616,26 @@ class SpacesContext implements Context {
|
||||
"Expected response status code should be 200",
|
||||
$response
|
||||
);
|
||||
Assert::assertIsArray($spaceAsArray = $this->getSpaceByNameFromResponse($spaceName, $response), "No space with name $spaceName found");
|
||||
$recipientType === 'user' ? $recipientId = $this->featureContext->getUserIdByUserName($recipient) : $recipientId = $this->featureContext->getGroupIdByGroupName($recipient);
|
||||
Assert::assertIsArray(
|
||||
$spaceAsArray = $this->getSpaceByNameFromResponse($spaceName, $response),
|
||||
"No space with name $spaceName found"
|
||||
);
|
||||
$recipientType === 'user' ?
|
||||
$recipientId = $this->featureContext->getUserIdByUserName($recipient)
|
||||
: $recipientId = $this->featureContext->getGroupIdByGroupName($recipient);
|
||||
$foundRoleInResponse = false;
|
||||
foreach ($spaceAsArray['root']['permissions'] as $permission) {
|
||||
if (isset($permission['grantedToIdentities'][0][$recipientType]) && $permission['roles'][0] === $role && $permission['grantedToIdentities'][0][$recipientType]['id'] === $recipientId) {
|
||||
if (isset($permission['grantedToIdentities'][0][$recipientType])
|
||||
&& $permission['roles'][0] === $role
|
||||
&& $permission['grantedToIdentities'][0][$recipientType]['id'] === $recipientId
|
||||
) {
|
||||
$foundRoleInResponse = true;
|
||||
if ($expirationDate !== null && isset($permission['expirationDateTime'])) {
|
||||
Assert::assertEquals($expirationDate, (preg_split("/[\sT]+/", $permission['expirationDateTime']))[0], "$expirationDate is different in the response");
|
||||
Assert::assertEquals(
|
||||
$expirationDate,
|
||||
(preg_split("/[\sT]+/", $permission['expirationDateTime']))[0],
|
||||
"$expirationDate is different in the response"
|
||||
);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -4344,7 +4679,12 @@ class SpacesContext implements Context {
|
||||
* @return void
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function userHasSharedResourceInsideSpaceWithUser(string $sharer, string $path, string $space, string $sharee): void {
|
||||
public function userHasSharedResourceInsideSpaceWithUser(
|
||||
string $sharer,
|
||||
string $path,
|
||||
string $space,
|
||||
string $sharee
|
||||
): void {
|
||||
$sharer = $this->featureContext->getActualUsername($sharer);
|
||||
$resource_id = $this->getResourceId($sharer, $space, $path);
|
||||
$response = $this->featureContext->createShare(
|
||||
@@ -4367,7 +4707,8 @@ class SpacesContext implements Context {
|
||||
Assert::assertContainsEquals(
|
||||
$responseStatusCode,
|
||||
$statusCodes,
|
||||
"OCS status code is not any of the expected values " . \implode(",", $statusCodes) . " got " . $responseStatusCode
|
||||
"OCS status code is not any of the expected values "
|
||||
. \implode(",", $statusCodes) . " got " . $responseStatusCode
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -61,7 +61,12 @@ class SpacesTUSContext implements Context {
|
||||
* @throws Exception
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function userHasUploadedFileViaTusInSpace(string $user, string $source, string $destination, string $spaceName): void {
|
||||
public function userHasUploadedFileViaTusInSpace(
|
||||
string $user,
|
||||
string $source,
|
||||
string $destination,
|
||||
string $spaceName
|
||||
): void {
|
||||
$spaceId = $this->spacesContext->getSpaceIdByName($user, $spaceName);
|
||||
$this->tusContext->uploadFileUsingTus($user, $source, $destination, $spaceId);
|
||||
$this->featureContext->setLastUploadDeleteTime(\time());
|
||||
@@ -175,7 +180,12 @@ class SpacesTUSContext implements Context {
|
||||
* @return void
|
||||
* @throws Exception|GuzzleException
|
||||
*/
|
||||
public function userUploadsAFileWithContentToInsideFederatedShareViaTusUsingTheWebdavApi(string $user, string $content, string $file, string $destination): void {
|
||||
public function userUploadsAFileWithContentToInsideFederatedShareViaTusUsingTheWebdavApi(
|
||||
string $user,
|
||||
string $content,
|
||||
string $file,
|
||||
string $destination
|
||||
): void {
|
||||
$remoteItemId = $this->spacesContext->getSharesRemoteItemId($user, $destination);
|
||||
$remoteItemId = \rawurlencode($remoteItemId);
|
||||
$tmpFile = $this->tusContext->writeDataToTempFile($content);
|
||||
@@ -293,8 +303,10 @@ class SpacesTUSContext implements Context {
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception|GuzzleException
|
||||
* @codingStandardsIgnoreStart
|
||||
*/
|
||||
public function userHasUploadedFileWithChecksumToTheLastCreatedTusLocationWithOffsetAndContentViaTusInsideOfTheSpaceUsingTheWebdavApi(
|
||||
// @codingStandardsIgnoreEnd
|
||||
string $user,
|
||||
string $checksum,
|
||||
string $offset,
|
||||
@@ -317,8 +329,10 @@ class SpacesTUSContext implements Context {
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception|GuzzleException
|
||||
* @codingStandardsIgnoreStart
|
||||
*/
|
||||
public function userUploadsFileWithChecksumToTheLastCreatedTusLocationWithOffsetAndContentViaTusInsideOfTheSpaceUsingTheWebdavApi(
|
||||
// @codingStandardsIgnoreEnd
|
||||
string $user,
|
||||
string $checksum,
|
||||
string $offset,
|
||||
@@ -341,8 +355,10 @@ class SpacesTUSContext implements Context {
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception|GuzzleException
|
||||
* @codingStandardsIgnoreStart
|
||||
*/
|
||||
public function userSendsAChunkToTheLastCreatedTusLocationWithOffsetAndDataWithChecksumViaTusInsideOfTheSpaceUsingTheWebdavApi(
|
||||
// @codingStandardsIgnoreEnd
|
||||
string $user,
|
||||
string $offset,
|
||||
string $data,
|
||||
@@ -371,7 +387,14 @@ class SpacesTUSContext implements Context {
|
||||
): void {
|
||||
$rows = $headers->getRowsHash();
|
||||
$resourceLocation = $this->tusContext->getLastTusResourceLocation();
|
||||
$response = $this->tusContext->uploadChunkToTUSLocation($user, $resourceLocation, $rows['Upload-Offset'], $data, $rows['Upload-Checksum'], ['Origin' => $rows['Origin']]);
|
||||
$response = $this->tusContext->uploadChunkToTUSLocation(
|
||||
$user,
|
||||
$resourceLocation,
|
||||
$rows['Upload-Offset'],
|
||||
$data,
|
||||
$rows['Upload-Checksum'],
|
||||
['Origin' => $rows['Origin']]
|
||||
);
|
||||
$this->featureContext->setResponse($response);
|
||||
}
|
||||
|
||||
@@ -387,8 +410,10 @@ class SpacesTUSContext implements Context {
|
||||
*
|
||||
* @return void
|
||||
* @throws GuzzleException
|
||||
* @codingStandardsIgnoreStart
|
||||
*/
|
||||
public function userOverwritesRecentlySharedFileWithOffsetAndDataWithChecksumViaTusInsideOfTheSpaceUsingTheWebdavApiWithTheseHeaders(
|
||||
// @codingStandardsIgnoreEnd
|
||||
string $user,
|
||||
string $offset,
|
||||
string $data,
|
||||
|
||||
@@ -97,7 +97,12 @@ class TUSContext implements Context {
|
||||
* @throws Exception
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function createNewTUSResourceWithHeaders(string $user, TableNode $headersTable, string $content = '', ?string $spaceId = null): ResponseInterface {
|
||||
public function createNewTUSResourceWithHeaders(
|
||||
string $user,
|
||||
TableNode $headersTable,
|
||||
string $content = '',
|
||||
?string $spaceId = null
|
||||
): ResponseInterface {
|
||||
$this->featureContext->verifyTableNodeColumnsCount($headersTable, 2);
|
||||
$user = $this->featureContext->getActualUsername($user);
|
||||
$password = $this->featureContext->getUserPassword($user);
|
||||
@@ -182,7 +187,14 @@ class TUSContext implements Context {
|
||||
* @throws GuzzleException
|
||||
* @throws JsonException
|
||||
*/
|
||||
public function uploadChunkToTUSLocation(string $user, string $resourceLocation, string $offset, string $data, string $checksum = '', ?array $extraHeaders = null): ResponseInterface {
|
||||
public function uploadChunkToTUSLocation(
|
||||
string $user,
|
||||
string $resourceLocation,
|
||||
string $offset,
|
||||
string $data,
|
||||
string $checksum = '',
|
||||
?array $extraHeaders = null
|
||||
): ResponseInterface {
|
||||
$user = $this->featureContext->getActualUsername($user);
|
||||
$password = $this->featureContext->getUserPassword($user);
|
||||
$headers = [
|
||||
@@ -631,7 +643,12 @@ class TUSContext implements Context {
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function userUploadsChunkFileWithChecksum(string $user, string $offset, string $data, string $checksum): void {
|
||||
public function userUploadsChunkFileWithChecksum(
|
||||
string $user,
|
||||
string $offset,
|
||||
string $data,
|
||||
string $checksum
|
||||
): void {
|
||||
$resourceLocation = $this->getLastTusResourceLocation();
|
||||
$response = $this->uploadChunkToTUSLocation($user, $resourceLocation, $offset, $data, $checksum);
|
||||
$this->featureContext->setResponse($response);
|
||||
@@ -648,7 +665,12 @@ class TUSContext implements Context {
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function userHasUploadedChunkFileWithChecksum(string $user, string $offset, string $data, string $checksum): void {
|
||||
public function userHasUploadedChunkFileWithChecksum(
|
||||
string $user,
|
||||
string $offset,
|
||||
string $data,
|
||||
string $checksum
|
||||
): void {
|
||||
$resourceLocation = $this->getLastTusResourceLocation();
|
||||
$response = $this->uploadChunkToTUSLocation($user, $resourceLocation, $offset, $data, $checksum);
|
||||
$this->featureContext->theHTTPStatusCodeShouldBe(204, "", $response);
|
||||
@@ -669,7 +691,13 @@ class TUSContext implements Context {
|
||||
* @throws GuzzleException
|
||||
* @throws Exception
|
||||
*/
|
||||
public function userOverwritesFileWithChecksum(string $user, string $offset, string $data, string $checksum, TableNode $headers): void {
|
||||
public function userOverwritesFileWithChecksum(
|
||||
string $user,
|
||||
string $offset,
|
||||
string $data,
|
||||
string $checksum,
|
||||
TableNode $headers
|
||||
): void {
|
||||
$createResponse = $this->createNewTUSResource($user, $headers);
|
||||
$this->featureContext->theHTTPStatusCodeShouldBe(201, "", $createResponse);
|
||||
$resourceLocation = $this->getLastTusResourceLocation();
|
||||
|
||||
@@ -64,7 +64,13 @@ class TagContext implements Context {
|
||||
* @return ResponseInterface
|
||||
* @throws Exception
|
||||
*/
|
||||
public function createTags(string $user, string $fileOrFolder, string $resource, string $space, TableNode $table):ResponseInterface {
|
||||
public function createTags(
|
||||
string $user,
|
||||
string $fileOrFolder,
|
||||
string $resource,
|
||||
string $space,
|
||||
TableNode $table
|
||||
): ResponseInterface {
|
||||
$tagNameArray = [];
|
||||
foreach ($table->getRows() as $value) {
|
||||
$tagNameArray[] = $value[0];
|
||||
@@ -97,7 +103,13 @@ class TagContext implements Context {
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function theUserCreatesFollowingTags(string $user, string $fileOrFolder, string $resource, string $space, TableNode $table):void {
|
||||
public function theUserCreatesFollowingTags(
|
||||
string $user,
|
||||
string $fileOrFolder,
|
||||
string $resource,
|
||||
string $space,
|
||||
TableNode $table
|
||||
): void {
|
||||
$response = $this->createTags($user, $fileOrFolder, $resource, $space, $table);
|
||||
$this->featureContext->setResponse($response);
|
||||
}
|
||||
@@ -114,7 +126,13 @@ class TagContext implements Context {
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function theUserHasCreatedFollowingTags(string $user, string $fileOrFolder, string $resource, string $space, TableNode $table):void {
|
||||
public function theUserHasCreatedFollowingTags(
|
||||
string $user,
|
||||
string $fileOrFolder,
|
||||
string $resource,
|
||||
string $space,
|
||||
TableNode $table
|
||||
): void {
|
||||
$response = $this->createTags($user, $fileOrFolder, $resource, $space, $table);
|
||||
$this->featureContext->theHttpStatusCodeShouldBe(200, "", $response);
|
||||
}
|
||||
@@ -130,7 +148,12 @@ class TagContext implements Context {
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function userHasCreatedTheFollowingTagsForFilesOfTheSpace(string $user, string $filesOrFolders, string $space, TableNode $table):void {
|
||||
public function userHasCreatedTheFollowingTagsForFilesOfTheSpace(
|
||||
string $user,
|
||||
string $filesOrFolders,
|
||||
string $space,
|
||||
TableNode $table
|
||||
): void {
|
||||
$this->featureContext->verifyTableNodeColumns($table, ["path", "tagName"]);
|
||||
$rows = $table->getHash();
|
||||
foreach ($rows as $row) {
|
||||
@@ -174,7 +197,9 @@ class TagContext implements Context {
|
||||
public function theFollowingTagsShouldExistForUser(string $shouldOrNot, TableNode $table): void {
|
||||
$rows = $table->getRows();
|
||||
foreach ($rows as $row) {
|
||||
$responseArray = $this->featureContext->getJsonDecodedResponse($this->featureContext->getResponse())['value'];
|
||||
$responseArray = $this->featureContext->getJsonDecodedResponse(
|
||||
$this->featureContext->getResponse()
|
||||
)['value'];
|
||||
if ($shouldOrNot === "not") {
|
||||
Assert::assertFalse(
|
||||
\in_array($row[0], $responseArray),
|
||||
@@ -201,7 +226,13 @@ class TagContext implements Context {
|
||||
* @return ResponseInterface
|
||||
* @throws Exception
|
||||
*/
|
||||
public function removeTagsFromResourceOfTheSpace(string $user, string $fileOrFolder, string $resource, string $space, TableNode $table):ResponseInterface {
|
||||
public function removeTagsFromResourceOfTheSpace(
|
||||
string $user,
|
||||
string $fileOrFolder,
|
||||
string $resource,
|
||||
string $space,
|
||||
TableNode $table
|
||||
): ResponseInterface {
|
||||
$tagNameArray = [];
|
||||
foreach ($table->getRows() as $value) {
|
||||
$tagNameArray[] = $value[0];
|
||||
@@ -235,8 +266,20 @@ class TagContext implements Context {
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function userRemovesTagsFromResourceOfTheSpace(string $user, string $fileOrFolder, string $resource, string $space, TableNode $table):void {
|
||||
$response = $this->removeTagsFromResourceOfTheSpace($user, $fileOrFolder, $resource, $space, $table);
|
||||
public function userRemovesTagsFromResourceOfTheSpace(
|
||||
string $user,
|
||||
string $fileOrFolder,
|
||||
string $resource,
|
||||
string $space,
|
||||
TableNode $table
|
||||
): void {
|
||||
$response = $this->removeTagsFromResourceOfTheSpace(
|
||||
$user,
|
||||
$fileOrFolder,
|
||||
$resource,
|
||||
$space,
|
||||
$table
|
||||
);
|
||||
$this->featureContext->setResponse($response);
|
||||
}
|
||||
|
||||
@@ -252,7 +295,13 @@ class TagContext implements Context {
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function userHAsRemovedTheFollowingTagsForFileOfSpace(string $user, string $fileOrFolder, string $resource, string $space, TableNode $table):void {
|
||||
public function userHAsRemovedTheFollowingTagsForFileOfSpace(
|
||||
string $user,
|
||||
string $fileOrFolder,
|
||||
string $resource,
|
||||
string $space,
|
||||
TableNode $table
|
||||
): void {
|
||||
$response = $this->removeTagsFromResourceOfTheSpace($user, $fileOrFolder, $resource, $space, $table);
|
||||
$this->featureContext->theHttpStatusCodeShouldBe(200, "", $response);
|
||||
}
|
||||
|
||||
@@ -109,7 +109,9 @@ class TrashbinContext implements Context {
|
||||
$name = $successPropStat->xpath('./d:prop/oc:trashbin-original-filename');
|
||||
$mtime = $successPropStat->xpath('./d:prop/oc:trashbin-delete-timestamp');
|
||||
$resourcetype = $successPropStat->xpath('./d:prop/d:resourcetype');
|
||||
if (\array_key_exists(0, $resourcetype) && ($resourcetype[0]->asXML() === "<d:resourcetype><d:collection/></d:resourcetype>")) {
|
||||
if (\array_key_exists(0, $resourcetype)
|
||||
&& ($resourcetype[0]->asXML() === "<d:resourcetype><d:collection/></d:resourcetype>")
|
||||
) {
|
||||
$collection[0] = true;
|
||||
} else {
|
||||
$collection[0] = false;
|
||||
@@ -224,7 +226,12 @@ class TrashbinContext implements Context {
|
||||
* @return array response
|
||||
* @throws Exception
|
||||
*/
|
||||
public function listTrashbinFolderCollection(?string $user, ?string $collectionPath = "", string $depth = "1", int $level = 1):array {
|
||||
public function listTrashbinFolderCollection(
|
||||
?string $user,
|
||||
?string $collectionPath = "",
|
||||
string $depth = "1",
|
||||
int $level = 1
|
||||
): array {
|
||||
// $collectionPath should be some list of file-ids like 2147497661/2147497662
|
||||
// or the empty string, which will list the whole trashbin from the top.
|
||||
$collectionPath = \trim($collectionPath, "/");
|
||||
@@ -251,7 +258,11 @@ class TrashbinContext implements Context {
|
||||
$response->getBody()->rewind();
|
||||
$statusCode = $response->getStatusCode();
|
||||
$respBody = $response->getBody()->getContents();
|
||||
Assert::assertEquals("207", $statusCode, "Expected status code to be '207' but got $statusCode \nResponse\n$respBody");
|
||||
Assert::assertEquals(
|
||||
"207",
|
||||
$statusCode,
|
||||
"Expected status code to be '207' but got $statusCode \nResponse\n$respBody"
|
||||
);
|
||||
|
||||
$files = $this->getTrashbinContentFromResponseXml(
|
||||
HttpRequestHelper::getResponseXml(
|
||||
@@ -345,7 +356,9 @@ class TrashbinContext implements Context {
|
||||
*/
|
||||
public function theTrashbinDavResponseShouldNotContainTheseNodes(TableNode $table): void {
|
||||
$this->featureContext->verifyTableNodeColumns($table, ['name']);
|
||||
$files = $this->getTrashbinContentFromResponseXml(HttpRequestHelper::getResponseXml($this->featureContext->getResponse(), __METHOD__));
|
||||
$files = $this->getTrashbinContentFromResponseXml(
|
||||
HttpRequestHelper::getResponseXml($this->featureContext->getResponse(), __METHOD__)
|
||||
);
|
||||
|
||||
foreach ($table->getHash() as $row) {
|
||||
$path = trim((string)$row['name'], "/");
|
||||
@@ -368,7 +381,9 @@ class TrashbinContext implements Context {
|
||||
public function theTrashbinDavResponseShouldContainTheseNodes(TableNode $table): void {
|
||||
$this->featureContext->verifyTableNodeColumns($table, ['name']);
|
||||
|
||||
$files = $this->getTrashbinContentFromResponseXml(HttpRequestHelper::getResponseXml($this->featureContext->getResponse(), __METHOD__));
|
||||
$files = $this->getTrashbinContentFromResponseXml(
|
||||
HttpRequestHelper::getResponseXml($this->featureContext->getResponse(), __METHOD__)
|
||||
);
|
||||
|
||||
foreach ($table->getHash() as $row) {
|
||||
$path = trim($row['name'], "/");
|
||||
@@ -395,7 +410,11 @@ class TrashbinContext implements Context {
|
||||
* @return ResponseInterface
|
||||
* @throws Exception
|
||||
*/
|
||||
public function sendTrashbinListRequest(string $user, ?string $asUser = null, ?string $password = null): ResponseInterface {
|
||||
public function sendTrashbinListRequest(
|
||||
string $user,
|
||||
?string $asUser = null,
|
||||
?string $password = null
|
||||
): ResponseInterface {
|
||||
$asUser = $asUser ?? $user;
|
||||
$password = $password ?? $this->featureContext->getPasswordForUser($asUser);
|
||||
|
||||
@@ -445,7 +464,11 @@ class TrashbinContext implements Context {
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function userTriesToListTheTrashbinContentForUserUsingPassword(string $asUser, string $user, string $password):void {
|
||||
public function userTriesToListTheTrashbinContentForUserUsingPassword(
|
||||
string $asUser,
|
||||
string $user,
|
||||
string $password
|
||||
): void {
|
||||
$response = $this->sendTrashbinListRequest($user, $asUser, $password);
|
||||
$this->featureContext->setResponse($response);
|
||||
}
|
||||
@@ -482,7 +505,9 @@ class TrashbinContext implements Context {
|
||||
* @throws Exception
|
||||
*/
|
||||
public function theLastWebdavResponseShouldNotContainFollowingElements(TableNode $elements): void {
|
||||
$files = $this->getTrashbinContentFromResponseXml(HttpRequestHelper::getResponseXml($this->featureContext->getResponse()));
|
||||
$files = $this->getTrashbinContentFromResponseXml(
|
||||
HttpRequestHelper::getResponseXml($this->featureContext->getResponse())
|
||||
);
|
||||
|
||||
// 'user' is also allowed in the table even though it is not used anywhere
|
||||
// This for better readability in feature files
|
||||
@@ -530,7 +555,12 @@ class TrashbinContext implements Context {
|
||||
* @throws JsonException
|
||||
* @throws Exception
|
||||
*/
|
||||
public function userTriesToDeleteFromTrashbinOfUserUsingPassword(string $user, string $path, string $ofUser, string $password):void {
|
||||
public function userTriesToDeleteFromTrashbinOfUserUsingPassword(
|
||||
string $user,
|
||||
string $path,
|
||||
string $ofUser,
|
||||
string $password
|
||||
): void {
|
||||
$response = $this->deleteItemFromTrashbin($user, $path, $ofUser, $password);
|
||||
$this->featureContext->setResponse($response);
|
||||
}
|
||||
@@ -565,7 +595,12 @@ class TrashbinContext implements Context {
|
||||
* @throws JsonException
|
||||
* @throws Exception
|
||||
*/
|
||||
public function userTriesToRestoreFromTrashbinOfUserUsingPassword(?string $asUser, ?string $path, ?string $user, ?string $password):void {
|
||||
public function userTriesToRestoreFromTrashbinOfUserUsingPassword(
|
||||
?string $asUser,
|
||||
?string $path,
|
||||
?string $user,
|
||||
?string $password
|
||||
): void {
|
||||
$asUser = $this->featureContext->getActualUsername($asUser);
|
||||
$user = $this->featureContext->getActualUsername($user);
|
||||
$response = $this->restoreElement($user, $path, null, $asUser, $password);
|
||||
@@ -596,7 +631,10 @@ class TrashbinContext implements Context {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function userTriesToDeleteFileWithOriginalPathFromTrashbinUsingTrashbinAPI(string $user, string $originalPath):void {
|
||||
public function userTriesToDeleteFileWithOriginalPathFromTrashbinUsingTrashbinAPI(
|
||||
string $user,
|
||||
string $originalPath
|
||||
): void {
|
||||
$response = $this->deleteItemFromTrashbin($user, $originalPath);
|
||||
$this->featureContext->setResponse($response);
|
||||
}
|
||||
@@ -609,7 +647,12 @@ class TrashbinContext implements Context {
|
||||
*
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
public function deleteItemFromTrashbin(string $user, string $originalPath, ?string $ofUser = null, ?string $password = null): ResponseInterface {
|
||||
public function deleteItemFromTrashbin(
|
||||
string $user,
|
||||
string $originalPath,
|
||||
?string $ofUser = null,
|
||||
?string $password = null
|
||||
): ResponseInterface {
|
||||
$ofUser = $ofUser ?? $user;
|
||||
$user = $this->featureContext->getActualUsername($user);
|
||||
$ofUser = $this->featureContext->getActualUsername($ofUser);
|
||||
@@ -781,7 +824,13 @@ class TrashbinContext implements Context {
|
||||
* @throws JsonException
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
private function sendUndeleteRequest(string $user, string $trashItemHRef, string $destinationPath, ?string $asUser = null, ?string $password = null):ResponseInterface {
|
||||
private function sendUndeleteRequest(
|
||||
string $user,
|
||||
string $trashItemHRef,
|
||||
string $destinationPath,
|
||||
?string $asUser = null,
|
||||
?string $password = null
|
||||
): ResponseInterface {
|
||||
$asUser = $asUser ?? $user;
|
||||
$password = $password ?? $this->featureContext->getPasswordForUser($asUser);
|
||||
$destinationPath = \trim($destinationPath, '/');
|
||||
@@ -834,7 +883,13 @@ class TrashbinContext implements Context {
|
||||
* @throws JsonException
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
private function restoreElement(string $user, string $originalPath, ?string $destinationPath = null, ?string $asUser = null, ?string $password = null):ResponseInterface {
|
||||
private function restoreElement(
|
||||
string $user,
|
||||
string $originalPath,
|
||||
?string $destinationPath = null,
|
||||
?string $asUser = null,
|
||||
?string $password = null
|
||||
): ResponseInterface {
|
||||
$asUser = $asUser ?? $user;
|
||||
$listing = $this->listTrashbinFolder($user);
|
||||
$originalPath = \trim($originalPath, '/');
|
||||
@@ -870,7 +925,10 @@ class TrashbinContext implements Context {
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function userRestoresResourceWithOriginalPathWithoutSpecifyingDestinationUsingTrashbinApi(string $user, string $originalPath):void {
|
||||
public function userRestoresResourceWithOriginalPathWithoutSpecifyingDestinationUsingTrashbinApi(
|
||||
string $user,
|
||||
string $originalPath
|
||||
): void {
|
||||
$listing = $this->listTrashbinFolder($user);
|
||||
$originalPath = \trim($originalPath, '/');
|
||||
|
||||
|
||||
@@ -198,7 +198,6 @@ trait WebDav {
|
||||
break;
|
||||
default:
|
||||
throw new Exception("Invalid DAV path: $davChoice");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -349,7 +348,13 @@ trait WebDav {
|
||||
* @throws JsonException | GuzzleException
|
||||
* @throws GuzzleException | JsonException
|
||||
*/
|
||||
public function createFolder(string $user, string $folder, ?bool $isGivenStep = false, ?string $password = null, ?string $spaceId=null): ResponseInterface {
|
||||
public function createFolder(
|
||||
string $user,
|
||||
string $folder,
|
||||
?bool $isGivenStep = false,
|
||||
?string $password = null,
|
||||
?string $spaceId=null
|
||||
): ResponseInterface {
|
||||
return $this->makeDavRequest(
|
||||
$user,
|
||||
"MKCOL",
|
||||
@@ -377,7 +382,13 @@ trait WebDav {
|
||||
* @return ResponseInterface
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function downloadPreviews(string $user, ?string $path, ?string $doDavRequestAsUser, ?string $width, ?string $height):ResponseInterface {
|
||||
public function downloadPreviews(
|
||||
string $user,
|
||||
?string $path,
|
||||
?string $doDavRequestAsUser,
|
||||
?string $width,
|
||||
?string $height
|
||||
): ResponseInterface {
|
||||
$user = $this->getActualUsername($user);
|
||||
$doDavRequestAsUser = $this->getActualUsername($doDavRequestAsUser);
|
||||
$doDavRequestAsUser = $doDavRequestAsUser ?? $user;
|
||||
@@ -595,7 +606,12 @@ trait WebDav {
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function theUserShouldBeAbleToRenameEntryTo(string $user, string $entry, string $source, string $destination):void {
|
||||
public function theUserShouldBeAbleToRenameEntryTo(
|
||||
string $user,
|
||||
string $entry,
|
||||
string $source,
|
||||
string $destination
|
||||
): void {
|
||||
$user = $this->getActualUsername($user);
|
||||
$this->checkFileOrFolderExistsForUser($user, $entry, $source);
|
||||
$response = $this->moveResource($user, $source, $destination);
|
||||
@@ -615,7 +631,12 @@ trait WebDav {
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function theUserShouldNotBeAbleToRenameEntryTo(string $user, string $entry, string $source, string $destination):void {
|
||||
public function theUserShouldNotBeAbleToRenameEntryTo(
|
||||
string $user,
|
||||
string $entry,
|
||||
string $source,
|
||||
string $destination
|
||||
): void {
|
||||
$this->checkFileOrFolderExistsForUser($user, $entry, $source);
|
||||
$response = $this->moveResource($user, $source, $destination);
|
||||
$this->theHTTPStatusCodeShouldBeBetween(400, 499, $response);
|
||||
@@ -684,7 +705,8 @@ trait WebDav {
|
||||
$response = $this->copyFile($user, $fileSource, $fileDestination);
|
||||
$this->theHTTPStatusCodeShouldBe(
|
||||
["201", "204"],
|
||||
"HTTP status code was not 201 or 204 while trying to copy resource '$fileSource' to '$fileDestination' for user '$user'",
|
||||
"HTTP status code was not 201 or 204 while trying to copy resource "
|
||||
. "'$fileSource' to '$fileDestination' for user '$user'",
|
||||
$response
|
||||
);
|
||||
}
|
||||
@@ -851,7 +873,8 @@ trait WebDav {
|
||||
Assert::assertEquals(
|
||||
$expectedContent,
|
||||
$actualContent,
|
||||
$extraErrorText . "The content was expected to be '$expectedContent', but actually is '$actualContent'. HTTP status was $actualStatus"
|
||||
$extraErrorText . "The content was expected to be '$expectedContent', but actually is "
|
||||
. "'$actualContent'. HTTP status was $actualStatus"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -899,7 +922,8 @@ trait WebDav {
|
||||
Assert::assertEquals(
|
||||
$content,
|
||||
$actualContent,
|
||||
"The downloaded content was expected to be '$content', but actually is '$actualContent'. HTTP status was $actualStatusCode"
|
||||
"The downloaded content was expected to be '$content', but actually is "
|
||||
. "'$actualContent'. HTTP status was $actualStatusCode"
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1068,7 +1092,8 @@ trait WebDav {
|
||||
* @throws Exception
|
||||
*/
|
||||
public function publicGetsSizeOfLastSharedPublicLinkUsingTheWebdavApi(): void {
|
||||
$token = ($this->isUsingSharingNG()) ? $this->shareNgGetLastCreatedLinkShareToken() : $this->getLastCreatedPublicShareToken();
|
||||
$token = ($this->isUsingSharingNG())
|
||||
? $this->shareNgGetLastCreatedLinkShareToken() : $this->getLastCreatedPublicShareToken();
|
||||
$davPath = WebDavHelper::getDavPath($this->getDavPathVersion(), $token, "public-files");
|
||||
$url = "{$this->getBaseUrl()}/$davPath";
|
||||
$this->response = HttpRequestHelper::sendRequest(
|
||||
@@ -1609,7 +1634,8 @@ trait WebDav {
|
||||
$response = $this->uploadFile($user, $source, $destination, null, true);
|
||||
$this->theHTTPStatusCodeShouldBe(
|
||||
["201", "204"],
|
||||
"HTTP status code was not 201 or 204 while trying to upload file '$source' to '$destination' for user '$user'",
|
||||
"HTTP status code was not 201 or 204 while trying to upload file "
|
||||
. "'$source' to '$destination' for user '$user'",
|
||||
$response
|
||||
);
|
||||
return $response->getHeader('oc-fileid');
|
||||
@@ -1791,7 +1817,10 @@ trait WebDav {
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function theHTTPStatusCodeOfResponsesOnEachEndpointShouldBeOcisReva(string $ocisStatusCodes, string $revaStatusCodes):void {
|
||||
public function theHTTPStatusCodeOfResponsesOnEachEndpointShouldBeOcisReva(
|
||||
string $ocisStatusCodes,
|
||||
string $revaStatusCodes
|
||||
): void {
|
||||
if (OcisHelper::isTestingOnReva()) {
|
||||
$expectedStatusCodes = $revaStatusCodes;
|
||||
} else {
|
||||
@@ -1897,7 +1926,8 @@ trait WebDav {
|
||||
Assert::assertSame(
|
||||
$initialContent,
|
||||
$currentContent,
|
||||
__METHOD__ . " user $user was unexpectedly able to upload $source to $destination - the content has changed:"
|
||||
__METHOD__
|
||||
. " user $user was unexpectedly able to upload $source to $destination - the content has changed:"
|
||||
);
|
||||
} else {
|
||||
$this->checkFileOrFolderDoesNotExistsForUser($user, "file", $destination);
|
||||
@@ -1989,7 +2019,12 @@ trait WebDav {
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function userHasUploadedFileToEndingWithOfSizeBytes(string $user, string $destination, string $text, string $bytes):void {
|
||||
public function userHasUploadedFileToEndingWithOfSizeBytes(
|
||||
string $user,
|
||||
string $destination,
|
||||
string $text,
|
||||
string $bytes
|
||||
): void {
|
||||
$filename = "filespecificSize.txt";
|
||||
$this->createLocalFileOfSpecificSize($filename, $bytes, $text);
|
||||
Assert::assertFileExists($this->workStorageDirLocation() . $filename);
|
||||
@@ -2021,7 +2056,9 @@ trait WebDav {
|
||||
$user = $this->getActualUsername($user);
|
||||
$this->pauseUploadDelete();
|
||||
|
||||
if (\str_starts_with($destination, "Shares/") && $this->getDavPathVersion() === WebDavHelper::DAV_VERSION_SPACES) {
|
||||
if (\str_starts_with($destination, "Shares/")
|
||||
&& $this->getDavPathVersion() === WebDavHelper::DAV_VERSION_SPACES
|
||||
) {
|
||||
$spaceId = $this->spacesContext->getSpaceIdByName($user, "Shares");
|
||||
$destination = \str_replace("Shares/", "", $destination);
|
||||
}
|
||||
@@ -2392,7 +2429,8 @@ trait WebDav {
|
||||
);
|
||||
$this->theHTTPStatusCodeShouldBe(
|
||||
["201", "204"],
|
||||
"HTTP status code was not 201 or 204 while trying to upload file with checksum '$checksum' to '$destination' for user '$user'",
|
||||
"HTTP status code was not 201 or 204 while trying to upload file with checksum "
|
||||
. "'$checksum' to '$destination' for user '$user'",
|
||||
$response
|
||||
);
|
||||
}
|
||||
@@ -2468,7 +2506,12 @@ trait WebDav {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function userDeletesFileFromSpaceUsingFileIdPath(string $user, string $filename, string $space, string $fileId):void {
|
||||
public function userDeletesFileFromSpaceUsingFileIdPath(
|
||||
string $user,
|
||||
string $filename,
|
||||
string $space,
|
||||
string $fileId
|
||||
): void {
|
||||
$baseUrl = $this->getBaseUrl();
|
||||
$davPath = WebDavHelper::getDavPath($this->getDavPathVersion());
|
||||
$user = $this->getActualUsername($user);
|
||||
@@ -2722,7 +2765,11 @@ trait WebDav {
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function userShouldBeAbleToCreateFolderUsingPassword(string $user, string $destination, string $password):void {
|
||||
public function userShouldBeAbleToCreateFolderUsingPassword(
|
||||
string $user,
|
||||
string $destination,
|
||||
string $password
|
||||
): void {
|
||||
$user = $this->getActualUsername($user);
|
||||
$response = $this->createFolder($user, $destination, true, $password);
|
||||
$this->theHTTPStatusCodeShouldBe(
|
||||
@@ -2767,7 +2814,11 @@ trait WebDav {
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function userShouldNotBeAbleToCreateFolderUsingPassword(string $user, string $destination, string $password):void {
|
||||
public function userShouldNotBeAbleToCreateFolderUsingPassword(
|
||||
string $user,
|
||||
string $destination,
|
||||
string $password
|
||||
): void {
|
||||
$user = $this->getActualUsername($user);
|
||||
$response = $this->createFolder($user, $destination, false, $password);
|
||||
$this->theHTTPStatusCodeShouldBeBetween(400, 499, $response);
|
||||
@@ -2958,7 +3009,13 @@ trait WebDav {
|
||||
$chunkNumber = (int)$chunkDetail['number'];
|
||||
$chunkContent = $chunkDetail['content'];
|
||||
if ($isGivenStep) {
|
||||
$response = $this->userUploadNewChunkFileOfWithToId($user, $chunkNumber, $chunkContent, $chunkingId, true);
|
||||
$response = $this->userUploadNewChunkFileOfWithToId(
|
||||
$user,
|
||||
$chunkNumber,
|
||||
$chunkContent,
|
||||
$chunkingId,
|
||||
true
|
||||
);
|
||||
$this->theHTTPStatusCodeShouldBeBetween(200, 299, $response);
|
||||
} else {
|
||||
$response = $this->userUploadNewChunkFileOfWithToId($user, $chunkNumber, $chunkContent, $chunkingId);
|
||||
@@ -3488,7 +3545,12 @@ trait WebDav {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function userDownloadsThePreviewOfWithPreviewZero(string $user, string $path, string $width, string $height) {
|
||||
public function userDownloadsThePreviewOfWithPreviewZero(
|
||||
string $user,
|
||||
string $path,
|
||||
string $width,
|
||||
string $height
|
||||
) {
|
||||
$user = $this->getActualUsername($user);
|
||||
$urlParameter = [
|
||||
'x' => $width,
|
||||
@@ -3521,7 +3583,12 @@ trait WebDav {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function userDownloadsThePreviewOfSharedResourceWithWidthAndHeightUsingTheWebdavApi(string $user, string $path, string $width, string $height): void {
|
||||
public function userDownloadsThePreviewOfSharedResourceWithWidthAndHeightUsingTheWebdavApi(
|
||||
string $user,
|
||||
string $path,
|
||||
string $width,
|
||||
string $height
|
||||
): void {
|
||||
if ($this->getDavPathVersion() === WebDavHelper::DAV_VERSION_SPACES) {
|
||||
$this->setResponse($this->downloadSharedFilePreview($user, $path, $width, $height));
|
||||
} else {
|
||||
@@ -3540,7 +3607,13 @@ trait WebDav {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function userDownloadsThePreviewOfWithWidthHeightProcessorUsingWebDAVAPI(string $user, string $path, string $width, string $height, string $processor): void {
|
||||
public function userDownloadsThePreviewOfWithWidthHeightProcessorUsingWebDAVAPI(
|
||||
string $user,
|
||||
string $path,
|
||||
string $width,
|
||||
string $height,
|
||||
string $processor
|
||||
): void {
|
||||
$user = $this->getActualUsername($user);
|
||||
$urlParameter = [
|
||||
'x' => $width,
|
||||
@@ -3574,7 +3647,12 @@ trait WebDav {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function userDownloadsThePreviewOfFederatedShareImageWithWidthHeightUsingWebDAVAPI(string $user, string $path, string $width, string $height): void {
|
||||
public function userDownloadsThePreviewOfFederatedShareImageWithWidthHeightUsingWebDAVAPI(
|
||||
string $user,
|
||||
string $path,
|
||||
string $width,
|
||||
string $height
|
||||
): void {
|
||||
$user = $this->getActualUsername($user);
|
||||
$urlParameter = [
|
||||
'x' => $width,
|
||||
@@ -3609,7 +3687,12 @@ trait WebDav {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function userHasDownloadedThePreviewOfSharedResourceWithWidthAndHeight(string $user, string $path, string $width, string $height): void {
|
||||
public function userHasDownloadedThePreviewOfSharedResourceWithWidthAndHeight(
|
||||
string $user,
|
||||
string $path,
|
||||
string $width,
|
||||
string $height
|
||||
): void {
|
||||
if ($this->getDavPathVersion() === WebDavHelper::DAV_VERSION_SPACES) {
|
||||
$response = $this->downloadSharedFilePreview($user, $path, $width, $height);
|
||||
} else {
|
||||
@@ -3633,7 +3716,12 @@ trait WebDav {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function asUserThePreviewOfSharedResourceWithWidthAndHeightShouldHaveBeenChanged(string $user, string $path, string $width, string $height):void {
|
||||
public function asUserThePreviewOfSharedResourceWithWidthAndHeightShouldHaveBeenChanged(
|
||||
string $user,
|
||||
string $path,
|
||||
string $width,
|
||||
string $height
|
||||
): void {
|
||||
if ($this->getDavPathVersion() === WebDavHelper::DAV_VERSION_SPACES) {
|
||||
$response = $this->downloadSharedFilePreview($user, $path, $width, $height);
|
||||
} else {
|
||||
@@ -3662,7 +3750,11 @@ trait WebDav {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function userUploadsFileWithContentSharedResourceToUsingTheWebdavApi(string $user, string $content, string $destination): void {
|
||||
public function userUploadsFileWithContentSharedResourceToUsingTheWebdavApi(
|
||||
string $user,
|
||||
string $content,
|
||||
string $destination
|
||||
): void {
|
||||
$this->setResponse($this->uploadFileWithContent($user, $content, $destination));
|
||||
}
|
||||
|
||||
@@ -3754,7 +3846,13 @@ trait WebDav {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function downloadPreviewOfOtherUser(string $user, string $path, string $ofUser, string $width, string $height):void {
|
||||
public function downloadPreviewOfOtherUser(
|
||||
string $user,
|
||||
string $path,
|
||||
string $ofUser,
|
||||
string $width,
|
||||
string $height
|
||||
): void {
|
||||
$response = $this->downloadPreviews(
|
||||
$ofUser,
|
||||
$path,
|
||||
@@ -3819,7 +3917,12 @@ trait WebDav {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function userDownloadsThePreviewOfWithWidthAndHeight(string $user, string $path, string $width, string $height):void {
|
||||
public function userDownloadsThePreviewOfWithWidthAndHeight(
|
||||
string $user,
|
||||
string $path,
|
||||
string $width,
|
||||
string $height
|
||||
): void {
|
||||
$response = $this->downloadPreviews(
|
||||
$user,
|
||||
$path,
|
||||
@@ -3844,7 +3947,12 @@ trait WebDav {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function asUserThePreviewOfPathWithHeightAndWidthShouldHaveBeenChanged(string $user, string $path, string $width, string $height):void {
|
||||
public function asUserThePreviewOfPathWithHeightAndWidthShouldHaveBeenChanged(
|
||||
string $user,
|
||||
string $path,
|
||||
string $width,
|
||||
string $height
|
||||
): void {
|
||||
$response = $this->downloadPreviews(
|
||||
$user,
|
||||
$path,
|
||||
@@ -3917,7 +4025,8 @@ trait WebDav {
|
||||
$currentFileID,
|
||||
$this->storedFileID,
|
||||
__METHOD__
|
||||
. " User '$user' $fileOrFolder '$path' does not have the previously stored id '$this->storedFileID', but has '$currentFileID'."
|
||||
. " User '$user' $fileOrFolder '$path' does not have the previously stored id " .
|
||||
"'$this->storedFileID', but has '$currentFileID'."
|
||||
);
|
||||
}
|
||||
|
||||
@@ -4180,7 +4289,11 @@ trait WebDav {
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function userListsTheResourcesInPathWithDepthUsingTheWebdavApi(string $user, string $path, string $depth):void {
|
||||
public function userListsTheResourcesInPathWithDepthUsingTheWebdavApi(
|
||||
string $user,
|
||||
string $path,
|
||||
string $depth
|
||||
): void {
|
||||
$response = $this->listFolder(
|
||||
$user,
|
||||
$path,
|
||||
@@ -4234,7 +4347,8 @@ trait WebDav {
|
||||
* @throws Exception
|
||||
*/
|
||||
public function theLastPublicDavResponseShouldContainTheseNodes(TableNode $table): void {
|
||||
$token = ($this->isUsingSharingNG()) ? $this->shareNgGetLastCreatedLinkShareToken() : $this->getLastCreatedPublicShareToken();
|
||||
$token = ($this->isUsingSharingNG())
|
||||
? $this->shareNgGetLastCreatedLinkShareToken() : $this->getLastCreatedPublicShareToken();
|
||||
$this->verifyTableNodeColumns($table, ["name"]);
|
||||
|
||||
foreach ($table->getHash() as $row) {
|
||||
@@ -4253,7 +4367,8 @@ trait WebDav {
|
||||
* @throws Exception
|
||||
*/
|
||||
public function theLastPublicDavResponseShouldNotContainTheseNodes(TableNode $table): void {
|
||||
$token = ($this->isUsingSharingNG()) ? $this->shareNgGetLastCreatedLinkShareToken() : $this->getLastCreatedPublicShareToken();
|
||||
$token = ($this->isUsingSharingNG())
|
||||
? $this->shareNgGetLastCreatedLinkShareToken() : $this->getLastCreatedPublicShareToken();
|
||||
$this->verifyTableNodeColumns($table, ["name"]);
|
||||
|
||||
foreach ($table->getHash() as $row) {
|
||||
@@ -4271,8 +4386,11 @@ trait WebDav {
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function thePublicListsTheResourcesInTheLastCreatedPublicLinkWithDepthUsingTheWebdavApi(string $depth):void {
|
||||
$token = ($this->isUsingSharingNG()) ? $this->shareNgGetLastCreatedLinkShareToken() : $this->getLastCreatedPublicShareToken();
|
||||
public function thePublicListsTheResourcesInTheLastCreatedPublicLinkWithDepthUsingTheWebdavApi(
|
||||
string $depth
|
||||
): void {
|
||||
$token = ($this->isUsingSharingNG())
|
||||
? $this->shareNgGetLastCreatedLinkShareToken() : $this->getLastCreatedPublicShareToken();
|
||||
$this->setResponse(
|
||||
$this->listFolder(
|
||||
$token,
|
||||
@@ -4565,14 +4683,16 @@ trait WebDav {
|
||||
}
|
||||
if (!isset($authors[$index - 1])) {
|
||||
Assert::fail(
|
||||
'could not find version with index "' . $index . '" for oc:meta-version-edited-by property in response to user "' . $this->responseUser . '"'
|
||||
'could not find version with index "' . $index
|
||||
. '" for oc:meta-version-edited-by property in response to user "' . $this->responseUser . '"'
|
||||
);
|
||||
}
|
||||
$actualUser = $authors[$index - 1];
|
||||
Assert::assertEquals(
|
||||
$expectedUsername,
|
||||
$actualUser,
|
||||
"Expected user of version with index $index in response to user '$this->responseUser' was '$expectedUsername', but got '$actualUser'"
|
||||
"Expected user of version with index $index in response to user '$this->responseUser'"
|
||||
. " was '$expectedUsername', but got '$actualUser'"
|
||||
);
|
||||
|
||||
// the user's display name should be in oc:meta-version-edited-by-name
|
||||
@@ -4587,14 +4707,16 @@ trait WebDav {
|
||||
}
|
||||
if (!isset($displaynames[$index - 1])) {
|
||||
Assert::fail(
|
||||
'could not find version with index "' . $index . '" for oc:meta-version-edited-by-name property in response to user "' . $this->responseUser . '"'
|
||||
'could not find version with index "' . $index
|
||||
. '" for oc:meta-version-edited-by-name property in response to user "' . $this->responseUser . '"'
|
||||
);
|
||||
}
|
||||
$actualUserDisplayName = $displaynames[$index - 1];
|
||||
Assert::assertEquals(
|
||||
$expectedUserDisplayName,
|
||||
$actualUserDisplayName,
|
||||
"Expected display name of version with index $index in response to user '$this->responseUser' was '$expectedUserDisplayName', but got '$actualUserDisplayName'"
|
||||
"Expected display name of version with index $index in response to user '$this->responseUser'"
|
||||
. " was '$expectedUserDisplayName', but got '$actualUserDisplayName'"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -146,7 +146,9 @@ class WebDavLockingContext implements Context {
|
||||
*/
|
||||
public function userLocksFileSettingPropertiesUsingWebDavAPI(string $user, string $file, TableNode $properties) {
|
||||
$spaceId = null;
|
||||
if (\str_starts_with($file, "Shares/") && $this->featureContext->getDavPathVersion() === WebDavHelper::DAV_VERSION_SPACES) {
|
||||
if (\str_starts_with($file, "Shares/")
|
||||
&& $this->featureContext->getDavPathVersion() === WebDavHelper::DAV_VERSION_SPACES
|
||||
) {
|
||||
$spaceId = $this->spacesContext->getSpaceIdByName($user, "Shares");
|
||||
$file = \str_replace("Shares/", "", $file);
|
||||
}
|
||||
@@ -163,7 +165,11 @@ class WebDavLockingContext implements Context {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function userTriesToLockFileSettingPropertiesUsingWebDavAPI(string $user, string $file, TableNode $properties) {
|
||||
public function userTriesToLockFileSettingPropertiesUsingWebDavAPI(
|
||||
string $user,
|
||||
string $file,
|
||||
TableNode $properties
|
||||
) {
|
||||
$response = $this->lockFile($user, $file, $properties, null, false, false);
|
||||
$this->featureContext->setResponse($response);
|
||||
}
|
||||
@@ -179,7 +185,12 @@ class WebDavLockingContext implements Context {
|
||||
* @return void
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function userLocksFileInProjectSpaceUsingWebDavAPI(string $user, string $file, string $space, TableNode $properties) {
|
||||
public function userLocksFileInProjectSpaceUsingWebDavAPI(
|
||||
string $user,
|
||||
string $file,
|
||||
string $space,
|
||||
TableNode $properties
|
||||
) {
|
||||
$this->featureContext->setResponse($this->userLocksFileInProjectSpace($user, $file, $space, $properties));
|
||||
}
|
||||
|
||||
@@ -193,7 +204,12 @@ class WebDavLockingContext implements Context {
|
||||
*
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function userLocksFileInProjectSpace(string $user, string $file, string $space, TableNode $properties): ?ResponseInterface {
|
||||
public function userLocksFileInProjectSpace(
|
||||
string $user,
|
||||
string $file,
|
||||
string $space,
|
||||
TableNode $properties
|
||||
): ?ResponseInterface {
|
||||
$spaceId = $this->spacesContext->getSpaceIdByName($user, $space);
|
||||
$baseUrl = $this->featureContext->getBaseUrl();
|
||||
$davPathVersion = $this->featureContext->getDavPathVersion();
|
||||
@@ -218,7 +234,12 @@ class WebDavLockingContext implements Context {
|
||||
* @return void
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function userHasLockedFileInProjectSpaceUsingWebDavAPI(string $user, string $file, string $space, TableNode $properties): void {
|
||||
public function userHasLockedFileInProjectSpaceUsingWebDavAPI(
|
||||
string $user,
|
||||
string $file,
|
||||
string $space,
|
||||
TableNode $properties
|
||||
): void {
|
||||
$response = $this->userLocksFileInProjectSpace($user, $file, $space, $properties);
|
||||
$this->featureContext->theHTTPStatusCodeShouldBe(200, '', $response);
|
||||
}
|
||||
@@ -233,7 +254,12 @@ class WebDavLockingContext implements Context {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function userTriesToLockFileInProjectSpaceUsingWebDavAPI(string $user, string $file, string $space, TableNode $properties) {
|
||||
public function userTriesToLockFileInProjectSpaceUsingWebDavAPI(
|
||||
string $user,
|
||||
string $file,
|
||||
string $space,
|
||||
TableNode $properties
|
||||
) {
|
||||
$spaceId = $this->spacesContext->getSpaceIdByName($user, $space);
|
||||
$davPathVersion = $this->featureContext->getDavPathVersion();
|
||||
$suffixPath = $user;
|
||||
@@ -257,7 +283,12 @@ class WebDavLockingContext implements Context {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function userLocksFileUsingFileIdUsingWebDavAPISettingFollowingProperties(string $user, string $file, string $fileId, TableNode $properties) {
|
||||
public function userLocksFileUsingFileIdUsingWebDavAPISettingFollowingProperties(
|
||||
string $user,
|
||||
string $file,
|
||||
string $fileId,
|
||||
TableNode $properties
|
||||
) {
|
||||
$davPath = WebdavHelper::getDavPath($this->featureContext->getDavPathVersion());
|
||||
$davPath = \rtrim($davPath, '/');
|
||||
$fullUrl = $this->featureContext->getBaseUrl() . "/$davPath/$fileId";
|
||||
@@ -275,7 +306,12 @@ class WebDavLockingContext implements Context {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function userTriesToLockFileUsingFileIdUsingWebDavAPI(string $user, string $file, string $fileId, TableNode $properties) {
|
||||
public function userTriesToLockFileUsingFileIdUsingWebDavAPI(
|
||||
string $user,
|
||||
string $file,
|
||||
string $fileId,
|
||||
TableNode $properties
|
||||
) {
|
||||
$davPath = WebdavHelper::getDavPath($this->featureContext->getDavPathVersion());
|
||||
$davPath = \rtrim($davPath, '/');
|
||||
$fullUrl = $this->featureContext->getBaseUrl() . "/$davPath/$fileId";
|
||||
@@ -307,7 +343,12 @@ class WebDavLockingContext implements Context {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function userHasLockedFileInsideSpaceSettingTheFollowingProperties(string $user, string $file, string $spaceName, TableNode $properties) {
|
||||
public function userHasLockedFileInsideSpaceSettingTheFollowingProperties(
|
||||
string $user,
|
||||
string $file,
|
||||
string $spaceName,
|
||||
TableNode $properties
|
||||
) {
|
||||
$spaceId = $this->spacesContext->getSpaceIdByName($this->featureContext->getActualUsername($user), $spaceName);
|
||||
$response = $this->lockFile($user, $file, $properties, null, false, true, $spaceId);
|
||||
$this->featureContext->theHTTPStatusCodeShouldBe(200, '', $response);
|
||||
@@ -358,7 +399,9 @@ class WebDavLockingContext implements Context {
|
||||
* @return void
|
||||
*/
|
||||
public function publicLocksLastSharedFile(TableNode $properties) {
|
||||
$token = ($this->featureContext->isUsingSharingNG()) ? $this->featureContext->shareNgGetLastCreatedLinkShareToken() : $this->featureContext->getLastCreatedPublicShareToken();
|
||||
$token = ($this->featureContext->isUsingSharingNG())
|
||||
? $this->featureContext->shareNgGetLastCreatedLinkShareToken()
|
||||
: $this->featureContext->getLastCreatedPublicShareToken();
|
||||
$response = $this->lockFile(
|
||||
$token,
|
||||
"/",
|
||||
@@ -382,7 +425,9 @@ class WebDavLockingContext implements Context {
|
||||
string $file,
|
||||
TableNode $properties
|
||||
) {
|
||||
$token = ($this->featureContext->isUsingSharingNG()) ? $this->featureContext->shareNgGetLastCreatedLinkShareToken() : $this->featureContext->getLastCreatedPublicShareToken();
|
||||
$token = ($this->featureContext->isUsingSharingNG())
|
||||
? $this->featureContext->shareNgGetLastCreatedLinkShareToken()
|
||||
: $this->featureContext->getLastCreatedPublicShareToken();
|
||||
$response = $this->lockFile(
|
||||
$token,
|
||||
$file,
|
||||
@@ -406,7 +451,9 @@ class WebDavLockingContext implements Context {
|
||||
string $file,
|
||||
TableNode $properties
|
||||
) {
|
||||
$token = ($this->featureContext->isUsingSharingNG()) ? $this->featureContext->shareNgGetLastCreatedLinkShareToken() : $this->featureContext->getLastCreatedPublicShareToken();
|
||||
$token = ($this->featureContext->isUsingSharingNG())
|
||||
? $this->featureContext->shareNgGetLastCreatedLinkShareToken()
|
||||
: $this->featureContext->getLastCreatedPublicShareToken();
|
||||
$response = $this->lockFile(
|
||||
$token,
|
||||
$file,
|
||||
@@ -445,7 +492,11 @@ class WebDavLockingContext implements Context {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function userUnlocksTheLastCreatedLockOfFileInsideSpaceUsingTheWebdavApi(string $user, string $spaceName, string $file) {
|
||||
public function userUnlocksTheLastCreatedLockOfFileInsideSpaceUsingTheWebdavApi(
|
||||
string $user,
|
||||
string $spaceName,
|
||||
string $file
|
||||
) {
|
||||
$spaceId = $this->spacesContext->getSpaceIdByName($this->featureContext->getActualUsername($user), $spaceName);
|
||||
$response = $this->unlockItemWithLastLockOfUserAndItemUsingWebDavAPI(
|
||||
$user,
|
||||
@@ -468,11 +519,22 @@ class WebDavLockingContext implements Context {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function userUnlocksTheLastCreatedLockOfFileWithFileIdPathUsingTheWebdavApi(string $user, string $itemToUnlock, string $fileId) {
|
||||
public function userUnlocksTheLastCreatedLockOfFileWithFileIdPathUsingTheWebdavApi(
|
||||
string $user,
|
||||
string $itemToUnlock,
|
||||
string $fileId
|
||||
) {
|
||||
$davPath = WebdavHelper::getDavPath($this->featureContext->getDavPathVersion());
|
||||
$davPath = \rtrim($davPath, '/');
|
||||
$fullUrl = $this->featureContext->getBaseUrl() . "/$davPath/$fileId";
|
||||
$response = $this->unlockItemWithLastLockOfUserAndItemUsingWebDavAPI($user, $itemToUnlock, $user, $itemToUnlock, false, $fullUrl);
|
||||
$response = $this->unlockItemWithLastLockOfUserAndItemUsingWebDavAPI(
|
||||
$user,
|
||||
$itemToUnlock,
|
||||
$user,
|
||||
$itemToUnlock,
|
||||
false,
|
||||
$fullUrl
|
||||
);
|
||||
$this->featureContext->setResponse($response);
|
||||
}
|
||||
|
||||
@@ -711,7 +773,9 @@ class WebDavLockingContext implements Context {
|
||||
string $lockOwner,
|
||||
string $itemToUseLockOf
|
||||
) {
|
||||
$token = ($this->featureContext->isUsingSharingNG()) ? $this->featureContext->shareNgGetLastCreatedLinkShareToken() : $this->featureContext->getLastCreatedPublicShareToken();
|
||||
$token = ($this->featureContext->isUsingSharingNG())
|
||||
? $this->featureContext->shareNgGetLastCreatedLinkShareToken()
|
||||
: $this->featureContext->getLastCreatedPublicShareToken();
|
||||
$response = $this->unlockItemWithLastLockOfUserAndItemUsingWebDavAPI(
|
||||
$token,
|
||||
$itemToUnlock,
|
||||
@@ -730,7 +794,9 @@ class WebDavLockingContext implements Context {
|
||||
* @return void
|
||||
*/
|
||||
public function unlockItemAsPublicUsingWebDavAPI(string $itemToUnlock) {
|
||||
$token = ($this->featureContext->isUsingSharingNG()) ? $this->featureContext->shareNgGetLastCreatedLinkShareToken() : $this->featureContext->getLastCreatedPublicShareToken();
|
||||
$token = ($this->featureContext->isUsingSharingNG())
|
||||
? $this->featureContext->shareNgGetLastCreatedLinkShareToken()
|
||||
: $this->featureContext->getLastCreatedPublicShareToken();
|
||||
$response = $this->unlockItemWithLastLockOfUserAndItemUsingWebDavAPI(
|
||||
$token,
|
||||
$itemToUnlock,
|
||||
@@ -901,7 +967,12 @@ class WebDavLockingContext implements Context {
|
||||
* @return void
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function numberOfLockShouldBeReportedInProjectSpace(int $count, string $file, string $spaceName, string $user) {
|
||||
public function numberOfLockShouldBeReportedInProjectSpace(
|
||||
int $count,
|
||||
string $file,
|
||||
string $spaceName,
|
||||
string $user
|
||||
) {
|
||||
$response = $this->spacesContext->sendPropfindRequestToSpace($user, $spaceName, $file, null, '0');
|
||||
$this->featureContext->theHTTPStatusCodeShouldBe(207, "", $response);
|
||||
$responseXmlObject = HttpRequestHelper::getResponseXml($response, __METHOD__);
|
||||
|
||||
@@ -170,7 +170,11 @@ class WebDavPropertiesContext implements Context {
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function userHasSetFollowingPropertiesUsingProppatch(string $username, string $path, TableNode $propertiesTable) {
|
||||
public function userHasSetFollowingPropertiesUsingProppatch(
|
||||
string $username,
|
||||
string $path,
|
||||
TableNode $propertiesTable
|
||||
) {
|
||||
$username = $this->featureContext->getActualUsername($username);
|
||||
$this->featureContext->verifyTableNodeColumns($propertiesTable, ['propertyName', 'propertyValue']);
|
||||
$properties = $propertiesTable->getColumnsHash();
|
||||
@@ -262,7 +266,9 @@ class WebDavPropertiesContext implements Context {
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getPropertiesOfEntryFromLastLinkShare(string $path, TableNode $propertiesTable): ResponseInterface {
|
||||
$token = ($this->featureContext->isUsingSharingNG()) ? $this->featureContext->shareNgGetLastCreatedLinkShareToken() : $this->featureContext->getLastCreatedPublicShareToken();
|
||||
$token = ($this->featureContext->isUsingSharingNG())
|
||||
? $this->featureContext->shareNgGetLastCreatedLinkShareToken()
|
||||
: $this->featureContext->getLastCreatedPublicShareToken();
|
||||
$properties = null;
|
||||
foreach ($propertiesTable->getRows() as $row) {
|
||||
$properties[] = $row[0];
|
||||
@@ -286,7 +292,10 @@ class WebDavPropertiesContext implements Context {
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function thePublicGetsFollowingPropertiesOfEntryFromLastLinkShare(string $path, TableNode $propertiesTable):void {
|
||||
public function thePublicGetsFollowingPropertiesOfEntryFromLastLinkShare(
|
||||
string $path,
|
||||
TableNode $propertiesTable
|
||||
): void {
|
||||
$response = $this->getPropertiesOfEntryFromLastLinkShare($path, $propertiesTable);
|
||||
$this->featureContext->setResponse($response);
|
||||
}
|
||||
@@ -636,7 +645,11 @@ class WebDavPropertiesContext implements Context {
|
||||
* @return SimpleXMLElement
|
||||
* @throws Exception
|
||||
*/
|
||||
public function checkResponseContainsProperty(ResponseInterface $response, string $key, string $namespaceString = null): SimpleXMLElement {
|
||||
public function checkResponseContainsProperty(
|
||||
ResponseInterface $response,
|
||||
string $key,
|
||||
string $namespaceString = null
|
||||
): SimpleXMLElement {
|
||||
$xmlPart = HttpRequestHelper::getResponseXml($response, __METHOD__);
|
||||
;
|
||||
|
||||
@@ -749,7 +762,11 @@ class WebDavPropertiesContext implements Context {
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function theValueOfTheItemInTheResponseAboutUserShouldBe(string $xpath, string $user, string $expectedValue):void {
|
||||
public function theValueOfTheItemInTheResponseAboutUserShouldBe(
|
||||
string $xpath,
|
||||
string $user,
|
||||
string $expectedValue
|
||||
): void {
|
||||
$this->assertValueOfItemInResponseAboutUserIs($xpath, $user, $expectedValue);
|
||||
}
|
||||
|
||||
@@ -794,7 +811,12 @@ class WebDavPropertiesContext implements Context {
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function assertValueOfItemInResponseAboutUserIsEitherOr(string $xpath, ?string $user, string $expectedValue1, string $expectedValue2):void {
|
||||
public function assertValueOfItemInResponseAboutUserIsEitherOr(
|
||||
string $xpath,
|
||||
?string $user,
|
||||
string $expectedValue1,
|
||||
string $expectedValue2
|
||||
): void {
|
||||
if (!$expectedValue2) {
|
||||
$expectedValue2 = $expectedValue1;
|
||||
}
|
||||
@@ -820,7 +842,10 @@ class WebDavPropertiesContext implements Context {
|
||||
$expectedValue2 = preg_replace("/^\/\//i", "/", $expectedValue2);
|
||||
$expectedValues = [$expectedValue1, $expectedValue2];
|
||||
$isExpectedValueInMessage = \in_array($value, $expectedValues);
|
||||
Assert::assertTrue($isExpectedValueInMessage, "The actual value \"$value\" is not one of the expected values: \"$expectedValue1\" or \"$expectedValue2\"");
|
||||
Assert::assertTrue(
|
||||
$isExpectedValueInMessage,
|
||||
"The actual value \"$value\" is not one of the expected values: \"$expectedValue1\" or \"$expectedValue2\""
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -868,7 +893,11 @@ class WebDavPropertiesContext implements Context {
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function publicGetsThePropertiesOfFolderAndAssertValueOfItemInResponseRegExp(string $xpath, string $path, string $pattern):void {
|
||||
public function publicGetsThePropertiesOfFolderAndAssertValueOfItemInResponseRegExp(
|
||||
string $xpath,
|
||||
string $path,
|
||||
string $pattern
|
||||
): void {
|
||||
$propertiesTable = new TableNode([['propertyName'],['d:lockdiscovery']]);
|
||||
$response = $this->getPropertiesOfEntryFromLastLinkShare($path, $propertiesTable);
|
||||
$this->featureContext->theHTTPStatusCodeShouldBe('207', "", $response);
|
||||
@@ -947,7 +976,12 @@ class WebDavPropertiesContext implements Context {
|
||||
* @return void
|
||||
* @throws JsonException
|
||||
*/
|
||||
public function assertXpathValueMatchesPattern(SimpleXMLElement $responseXmlObject, string $xpath, string $pattern, ?string $user = null): void {
|
||||
public function assertXpathValueMatchesPattern(
|
||||
SimpleXMLElement $responseXmlObject,
|
||||
string $xpath,
|
||||
string $pattern,
|
||||
?string $user = null
|
||||
): void {
|
||||
$xmlPart = $responseXmlObject->xpath($xpath);
|
||||
Assert::assertTrue(
|
||||
isset($xmlPart[0]),
|
||||
@@ -955,7 +989,8 @@ class WebDavPropertiesContext implements Context {
|
||||
);
|
||||
$user = $this->featureContext->getActualUsername($user);
|
||||
$value = $xmlPart[0]->__toString();
|
||||
$callback = ($this->featureContext->isUsingSharingNG()) ? "shareNgGetLastCreatedLinkShareToken" : "getLastCreatedPublicShareToken";
|
||||
$callback = ($this->featureContext->isUsingSharingNG())
|
||||
? "shareNgGetLastCreatedLinkShareToken" : "getLastCreatedPublicShareToken";
|
||||
|
||||
if (\str_ends_with($xpath, "d:href")) {
|
||||
$pattern = \preg_replace("/^\//", "", $pattern);
|
||||
@@ -996,7 +1031,12 @@ class WebDavPropertiesContext implements Context {
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function userGetsPropertiesOfFolderAndAssertValueOfItemInResponseToUserRegExp(string $user, string $xpath, string $path, string $pattern):void {
|
||||
public function userGetsPropertiesOfFolderAndAssertValueOfItemInResponseToUserRegExp(
|
||||
string $user,
|
||||
string $xpath,
|
||||
string $path,
|
||||
string $pattern
|
||||
): void {
|
||||
$propertiesTable = new TableNode([['propertyName'],['d:lockdiscovery']]);
|
||||
$response = $this->getPropertiesOfFolder(
|
||||
$user,
|
||||
@@ -1163,7 +1203,12 @@ class WebDavPropertiesContext implements Context {
|
||||
* @return SimpleXMLElement
|
||||
* @throws Exception
|
||||
*/
|
||||
public function storeEtagOfElement(string $user, string $path, ?string $storePath = "", ?string $spaceId = null):SimpleXMLElement {
|
||||
public function storeEtagOfElement(
|
||||
string $user,
|
||||
string $path,
|
||||
?string $storePath = "",
|
||||
?string $spaceId = null
|
||||
): SimpleXMLElement {
|
||||
if ($storePath === "") {
|
||||
$storePath = $path;
|
||||
}
|
||||
@@ -1288,7 +1333,10 @@ class WebDavPropertiesContext implements Context {
|
||||
* @throws Exception
|
||||
*/
|
||||
public function theResponseShouldHavePropertyWithValue(string $username, TableNode $expectedPropTable): void {
|
||||
$this->featureContext->verifyTableNodeColumns($expectedPropTable, ['resource', 'propertyName', 'propertyValue']);
|
||||
$this->featureContext->verifyTableNodeColumns(
|
||||
$expectedPropTable,
|
||||
['resource', 'propertyName', 'propertyValue']
|
||||
);
|
||||
$responseXmlObject = HttpRequestHelper::getResponseXml($this->featureContext->getResponse());
|
||||
|
||||
$href = (string)$responseXmlObject->xpath("//d:href")[0];
|
||||
@@ -1324,7 +1372,9 @@ class WebDavPropertiesContext implements Context {
|
||||
null,
|
||||
$propertiesTable
|
||||
);
|
||||
return $this->featureContext->getEtagFromResponseXmlObject(HttpRequestHelper::getResponseXml($response, __METHOD__));
|
||||
return $this->featureContext->getEtagFromResponseXmlObject(
|
||||
HttpRequestHelper::getResponseXml($response, __METHOD__)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1348,7 +1398,8 @@ class WebDavPropertiesContext implements Context {
|
||||
$path,
|
||||
$this->storedETAG[$user],
|
||||
$messageStart
|
||||
. " Trying to check etag of element $path of user $user but the user does not have a stored etag for the element"
|
||||
. " Trying to check etag of element $path of user "
|
||||
. "$user but the user does not have a stored etag for the element"
|
||||
);
|
||||
return $this->storedETAG[$user][$path];
|
||||
}
|
||||
@@ -1419,7 +1470,11 @@ class WebDavPropertiesContext implements Context {
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function etagOfElementOfUserShouldOrShouldNotHaveChanged(string $path, string $user, string $shouldShouldNot):void {
|
||||
public function etagOfElementOfUserShouldOrShouldNotHaveChanged(
|
||||
string $path,
|
||||
string $user,
|
||||
string $shouldShouldNot
|
||||
): void {
|
||||
$user = $this->featureContext->getActualUsername($user);
|
||||
$actualEtag = $this->getCurrentEtagOfElement($path, $user);
|
||||
$storedEtag = $this->getStoredEtagOfElement($path, $user, __METHOD__);
|
||||
|
||||
Reference in New Issue
Block a user