updating lint rules for test code

This commit is contained in:
Niraj Acharya
2024-12-30 09:18:45 +05:45
parent 24798a80d1
commit 089ccc1ca3
45 changed files with 2914 additions and 1151 deletions
+15 -1
View File
@@ -12,6 +12,20 @@ $finder = PhpCsFixer\Finder::create()
->exclude($excludeDirs) ->exclude($excludeDirs)
->in(__DIR__); ->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); $config->setFinder($finder);
return $config; return $config;
+14 -4
View File
@@ -19,10 +19,6 @@
<exclude name="Generic.WhiteSpace.DisallowTabIndent.NonIndentTabsUsed" /> <exclude name="Generic.WhiteSpace.DisallowTabIndent.NonIndentTabsUsed" />
</rule> </rule>
<rule ref="Generic.Files.LineLength">
<exclude name="Generic.Files.LineLength.TooLong" />
</rule>
<rule ref="PEAR"> <rule ref="PEAR">
<exclude name="Generic.Commenting.DocComment.ShortNotCapital" /> <exclude name="Generic.Commenting.DocComment.ShortNotCapital" />
<exclude name="Generic.Commenting.DocComment.SpacingAfter" /> <exclude name="Generic.Commenting.DocComment.SpacingAfter" />
@@ -77,4 +73,18 @@
<exclude-pattern>*/lib/storagewrapper.php</exclude-pattern> <exclude-pattern>*/lib/storagewrapper.php</exclude-pattern>
</rule> </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> </ruleset>
@@ -58,7 +58,9 @@ class WebDav extends Assert {
} elseif ($element === "reason") { } elseif ($element === "reason") {
$result = $responseXmlArray['value'][3]['value']; $result = $responseXmlArray['value'][3]['value'];
} else { } 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( self::assertEquals(
+17 -3
View File
@@ -42,7 +42,11 @@ class AuthAppHelper {
* *
* @return ResponseInterface * @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(); $url = $baseUrl . self::getAuthAppEndpoint();
return HttpRequestHelper::sendRequest( return HttpRequestHelper::sendRequest(
$url, $url,
@@ -61,7 +65,12 @@ class AuthAppHelper {
* *
* @return ResponseInterface * @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"; $url = $baseUrl . self::getAuthAppEndpoint() . "?expiry=$expiration";
return HttpRequestHelper::sendRequest( return HttpRequestHelper::sendRequest(
$url, $url,
@@ -80,7 +89,12 @@ class AuthAppHelper {
* *
* @return ResponseInterface * @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"; $url = $baseUrl . self::getAuthAppEndpoint() . "?token=$token";
return HttpRequestHelper::sendRequest( return HttpRequestHelper::sendRequest(
$url, $url,
+5 -1
View File
@@ -38,7 +38,11 @@ class BehatHelper {
* *
* @return Context * @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 { try {
return $environment->getContext($class); return $environment->getContext($class);
} catch (ContextNotFoundException $e) { } catch (ContextNotFoundException $e) {
+5 -1
View File
@@ -113,7 +113,11 @@ class EmailHelper {
* @return object * @return object
* @throws GuzzleException * @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( $response = HttpRequestHelper::get(
self::getLocalEmailUrl() . "/api/v1/mailbox/" . $mailBox . "/" . $mailboxId, self::getLocalEmailUrl() . "/api/v1/mailbox/" . $mailBox . "/" . $mailboxId,
$xRequestId, $xRequestId,
+40 -7
View File
@@ -110,7 +110,8 @@ class GraphHelper {
* @return string * @return string
*/ */
public static function getShareIdRegex(): 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, string $password,
array $groupIdArray array $groupIdArray
): ResponseInterface { ): 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( return HttpRequestHelper::get(
$url, $url,
$xRequestId, $xRequestId,
@@ -1416,7 +1421,11 @@ class GraphHelper {
string $firstGroup, string $firstGroup,
string $secondGroup string $secondGroup
): ResponseInterface { ): 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( return HttpRequestHelper::get(
$url, $url,
$xRequestId, $xRequestId,
@@ -1472,7 +1481,11 @@ class GraphHelper {
string $roleId, string $roleId,
string $groupId string $groupId
): ResponseInterface { ): 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( return HttpRequestHelper::get(
$url, $url,
$xRequestId, $xRequestId,
@@ -1669,7 +1682,15 @@ class GraphHelper {
): ResponseInterface { ): ResponseInterface {
$fullUrl = self::getFullUrl($baseUrl, 'me'); $fullUrl = self::getFullUrl($baseUrl, 'me');
$payload['preferredLanguage'] = $language; $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 ?string $expirationDateTime
): ResponseInterface { ): ResponseInterface {
$url = self::getBetaFullUrl($baseUrl, "drives/$spaceId/items/$itemId/invite"); $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( return HttpRequestHelper::post(
$url, $url,
$xRequestId, $xRequestId,
@@ -2186,7 +2213,13 @@ class GraphHelper {
?string $expirationDateTime ?string $expirationDateTime
): ResponseInterface { ): ResponseInterface {
$url = self::getBetaFullUrl($baseUrl, "drives/$spaceId/root/invite"); $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( return HttpRequestHelper::post(
$url, $url,
@@ -222,7 +222,10 @@ class HttpRequestHelper {
$client $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; $sendExceptionHappened = true;
} }
@@ -56,7 +56,11 @@ class OcisConfigHelper {
try { try {
$response = $client->send($request); $response = $client->send($request);
} catch (ConnectException $e) { } 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) { } catch (GuzzleException $ex) {
$response = $ex->getResponse(); $response = $ex->getResponse();
@@ -55,7 +55,13 @@ class SettingsHelper {
* @throws GuzzleException * @throws GuzzleException
* @throws Exception * @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"); $fullUrl = self::buildFullUrl($baseUrl, "bundles-list");
return HttpRequestHelper::post( return HttpRequestHelper::post(
$fullUrl, $fullUrl,
@@ -79,7 +85,13 @@ class SettingsHelper {
* @throws GuzzleException * @throws GuzzleException
* @throws Exception * @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); $response = self::getBundlesList($baseUrl, $user, $password, $xRequestId);
Assert::assertEquals(201, $response->getStatusCode(), "Failed to get bundles list"); Assert::assertEquals(201, $response->getStatusCode(), "Failed to get bundles list");
@@ -104,7 +116,13 @@ class SettingsHelper {
* @throws GuzzleException * @throws GuzzleException
* @throws Exception * @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"); $fullUrl = self::buildFullUrl($baseUrl, "roles-list");
return HttpRequestHelper::post( return HttpRequestHelper::post(
$fullUrl, $fullUrl,
@@ -130,7 +148,15 @@ class SettingsHelper {
* @throws GuzzleException * @throws GuzzleException
* @throws Exception * @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"); $fullUrl = self::buildFullUrl($baseUrl, "assignments-add");
$body = json_encode(["account_uuid" => $assigneeId, "role_id" => $roleId], JSON_THROW_ON_ERROR); $body = json_encode(["account_uuid" => $assigneeId, "role_id" => $roleId], JSON_THROW_ON_ERROR);
return HttpRequestHelper::post( return HttpRequestHelper::post(
@@ -156,7 +182,14 @@ class SettingsHelper {
* @throws GuzzleException * @throws GuzzleException
* @throws Exception * @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"); $fullUrl = self::buildFullUrl($baseUrl, "assignments-list");
$body = json_encode(["account_uuid" => $userId], JSON_THROW_ON_ERROR); $body = json_encode(["account_uuid" => $userId], JSON_THROW_ON_ERROR);
return HttpRequestHelper::post( return HttpRequestHelper::post(
@@ -181,7 +214,13 @@ class SettingsHelper {
* @throws GuzzleException * @throws GuzzleException
* @throws Exception * @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"); $fullUrl = self::buildFullUrl($baseUrl, "values-list");
$body = json_encode(["account_uuid" => "me"], JSON_THROW_ON_ERROR); $body = json_encode(["account_uuid" => "me"], JSON_THROW_ON_ERROR);
return HttpRequestHelper::post( return HttpRequestHelper::post(
@@ -205,7 +244,12 @@ class SettingsHelper {
* @throws GuzzleException * @throws GuzzleException
* @throws Exception * @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); $response = self::getValuesList($baseUrl, $user, $password, $xRequestId);
Assert::assertEquals(201, $response->getStatusCode(), "Failed to get values list"); Assert::assertEquals(201, $response->getStatusCode(), "Failed to get values list");
@@ -235,7 +279,12 @@ class SettingsHelper {
* @throws GuzzleException * @throws GuzzleException
* @throws Exception * @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); $response = self::getValuesList($baseUrl, $user, $password, $xRequestId);
Assert::assertEquals(201, $response->getStatusCode(), "Failed to get values list"); Assert::assertEquals(201, $response->getStatusCode(), "Failed to get values list");
@@ -267,7 +316,14 @@ class SettingsHelper {
* @throws GuzzleException * @throws GuzzleException
* @throws Exception * @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"); $fullUrl = self::buildFullUrl($baseUrl, "values-save");
return HttpRequestHelper::post( return HttpRequestHelper::post(
$fullUrl, $fullUrl,
+30 -7
View File
@@ -516,7 +516,12 @@ class WebDavHelper {
* @throws GuzzleException * @throws GuzzleException
* @throws Exception * @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])) { if (\array_key_exists($user, self::$spacesIdRef) && \array_key_exists("personal", self::$spacesIdRef[$user])) {
return self::$spacesIdRef[$user]["personal"]; return self::$spacesIdRef[$user]["personal"];
} }
@@ -546,14 +551,21 @@ class WebDavHelper {
$user, $user,
$password $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( $responseXmlObject = HttpRequestHelper::getResponseXml(
$response, $response,
__METHOD__ __METHOD__
); );
$xmlPart = $responseXmlObject->xpath("/d:multistatus/d:response[1]/d:propstat/d:prop/oc:spaceid"); $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(); $personalSpaceId = $xmlPart[0]->__toString();
} }
@@ -577,7 +589,12 @@ class WebDavHelper {
* @return string * @return string
* @throws Exception|GuzzleException * @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")) { if (\str_starts_with($user, "non-exist") || \str_starts_with($user, "nonexist")) {
return self::generateUUIDv4(); return self::generateUUIDv4();
} }
@@ -651,7 +668,9 @@ class WebDavHelper {
} }
// get space id if testing with spaces dav // 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, "/"); $path = \ltrim($path, "/");
if (\str_starts_with($path, "Shares/")) { if (\str_starts_with($path, "Shares/")) {
$spaceId = GraphHelper::SHARES_SPACE_ID; $spaceId = GraphHelper::SHARES_SPACE_ID;
@@ -667,7 +686,9 @@ class WebDavHelper {
} }
$suffixPath = $user; $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; $suffixPath = $spaceId;
} elseif ($type === "versions") { } elseif ($type === "versions") {
// $path is file-id in case of versions // $path is file-id in case of versions
@@ -900,7 +921,9 @@ class WebDavHelper {
Assert::assertArrayHasKey( Assert::assertArrayHasKey(
0, 0,
$xmlPart, $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()); $mtime = new DateTime($xmlPart[0]->__toString());
return $mtime->format('U'); return $mtime->format('U');
@@ -164,7 +164,9 @@ class ArchiverContext implements Context {
foreach ($headersTable as $row) { foreach ($headersTable as $row) {
$headers[$row['header']] = $row ['value']; $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)
);
} }
/** /**
+47 -9
View File
@@ -156,7 +156,12 @@ class AuthContext implements Context {
* @return void * @return void
* @throws JsonException * @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)); $ofUser = \strtolower($this->featureContext->getActualUsername($ofUser));
$this->featureContext->verifyTableNodeColumns($table, ['endpoint']); $this->featureContext->verifyTableNodeColumns($table, ['endpoint']);
foreach ($table->getHash() as $row) { foreach ($table->getHash() as $row) {
@@ -180,7 +185,11 @@ class AuthContext implements Context {
* @return void * @return void
* @throws Exception * @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)); $ofUser = \strtolower($this->featureContext->getActualUsername($ofUser));
$this->featureContext->verifyTableNodeColumns($table, ['endpoint']); $this->featureContext->verifyTableNodeColumns($table, ['endpoint']);
foreach ($table->getHash() as $row) { foreach ($table->getHash() as $row) {
@@ -318,7 +327,12 @@ class AuthContext implements Context {
* @return void * @return void
* @throws Exception * @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); $user = $this->featureContext->getActualUsername($user);
$url = $this->featureContext->substituteInLineCodes( $url = $this->featureContext->substituteInLineCodes(
$url, $url,
@@ -407,7 +421,8 @@ class AuthContext implements Context {
$row['destination'], $row['destination'],
$ofUser $ofUser
); );
$headers['Destination'] = $this->featureContext->getBaseUrl() . "/" . WebdavHelper::prefixRemotePhp(\ltrim($destination, "/")); $headers['Destination'] = $this->featureContext->getBaseUrl()
. "/" . WebdavHelper::prefixRemotePhp(\ltrim($destination, "/"));
} }
$response = $this->sendRequest( $response = $this->sendRequest(
$row['endpoint'], $row['endpoint'],
@@ -457,7 +472,8 @@ class AuthContext implements Context {
$row['destination'], $row['destination'],
$ofUser $ofUser
); );
$headers['Destination'] = $this->featureContext->getBaseUrl() . "/" . WebdavHelper::prefixRemotePhp(\ltrim($destination, "/")); $headers['Destination'] = $this->featureContext->getBaseUrl()
. "/" . WebdavHelper::prefixRemotePhp(\ltrim($destination, "/"));
} }
$response = $this->sendRequest( $response = $this->sendRequest(
$row['endpoint'], $row['endpoint'],
@@ -482,7 +498,13 @@ class AuthContext implements Context {
* @return void * @return void
* @throws Exception * @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); $user = $this->featureContext->getActualUsername($user);
$ofUser = $this->featureContext->getActualUsername($ofUser); $ofUser = $this->featureContext->getActualUsername($ofUser);
$this->featureContext->verifyTableNodeColumns($table, ['endpoint']); $this->featureContext->verifyTableNodeColumns($table, ['endpoint']);
@@ -520,7 +542,12 @@ class AuthContext implements Context {
* @return void * @return void
* @throws Exception * @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); $asUser = $this->featureContext->getActualUsername($asUser);
$ofUser = $this->featureContext->getActualUsername($ofUser); $ofUser = $this->featureContext->getActualUsername($ofUser);
$this->featureContext->verifyTableNodeColumns($table, ['endpoint']); $this->featureContext->verifyTableNodeColumns($table, ['endpoint']);
@@ -556,7 +583,13 @@ class AuthContext implements Context {
* @return void * @return void
* @throws JsonException * @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); $asUser = $this->featureContext->getActualUsername($asUser);
$ofUser = $this->featureContext->getActualUsername($ofUser); $ofUser = $this->featureContext->getActualUsername($ofUser);
$this->featureContext->verifyTableNodeColumns($table, ['endpoint']); $this->featureContext->verifyTableNodeColumns($table, ['endpoint']);
@@ -591,7 +624,12 @@ class AuthContext implements Context {
* @return void * @return void
* @throws Exception * @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 = []; $headers = [];
if ($method === 'MOVE' || $method === 'COPY') { if ($method === 'MOVE' || $method === 'COPY') {
$baseUrl = $this->featureContext->getBaseUrl(); $baseUrl = $this->featureContext->getBaseUrl();
+31 -6
View File
@@ -76,7 +76,9 @@ class ChecksumContext implements Context {
string $destination, string $destination,
string $checksum string $checksum
): void { ): 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 * @return void
* @throws Exception * @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); $user = $this->featureContext->getActualUsername($user);
$resource = $this->propfindResourceChecksum($user, $path); $resource = $this->propfindResourceChecksum($user, $path);
$bodyContents = $resource->getBody()->getContents(); $bodyContents = $resource->getBody()->getContents();
@@ -243,7 +249,8 @@ class ChecksumContext implements Context {
Assert::assertIsArray( Assert::assertIsArray(
$parsed, $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( Assert::assertArrayHasKey(
0, 0,
@@ -360,7 +367,11 @@ class ChecksumContext implements Context {
* @return void * @return void
* @throws Exception * @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); $response = $this->featureContext->downloadFileAsUserUsingPassword($user, $fileName);
$headerChecksums = $response->getHeader('OC-Checksum'); $headerChecksums = $response->getHeader('OC-Checksum');
@@ -440,7 +451,14 @@ class ChecksumContext implements Context {
string $destination, string $destination,
string $expectedChecksum string $expectedChecksum
): void { ): void {
$response = $this->uploadChunkFileOfWithToWithChecksum($user, $num, $total, $data, $destination, $expectedChecksum); $response = $this->uploadChunkFileOfWithToWithChecksum(
$user,
$num,
$total,
$data,
$destination,
$expectedChecksum
);
$this->featureContext->setResponse($response); $this->featureContext->setResponse($response);
} }
@@ -464,7 +482,14 @@ class ChecksumContext implements Context {
string $destination, string $destination,
string $expectedChecksum string $expectedChecksum
): void { ): void {
$response = $this->uploadChunkFileOfWithToWithChecksum($user, $num, $total, $data, $destination, $expectedChecksum); $response = $this->uploadChunkFileOfWithToWithChecksum(
$user,
$num,
$total,
$data,
$destination,
$expectedChecksum
);
$this->featureContext->theHTTPStatusCodeShouldBe( $this->featureContext->theHTTPStatusCodeShouldBe(
[201, 206], [201, 206],
'', '',
+23 -5
View File
@@ -80,7 +80,11 @@ class CliContext implements Context {
* *
* @return void * @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"; $command = "idm resetpassword -u $user";
$body = [ $body = [
"command" => $command, "command" => $command,
@@ -130,7 +134,10 @@ class CliContext implements Context {
* *
* @return void * @return void
*/ */
public function theAdministratorCreatesAppTokenForUserWithExpirationTimeUsingTheAuthAppCLI(string $user, string $expirationTime): void { public function theAdministratorCreatesAppTokenForUserWithExpirationTimeUsingTheAuthAppCLI(
string $user,
string $expirationTime
): void {
$user = $this->featureContext->getActualUserName($user); $user = $this->featureContext->getActualUserName($user);
$command = "auth-app create --user-name=$user --expiration=$expirationTime"; $command = "auth-app create --user-name=$user --expiration=$expirationTime";
$body = [ $body = [
@@ -147,7 +154,10 @@ class CliContext implements Context {
* *
* @return void * @return void
*/ */
public function userHasCreatedAppTokenWithExpirationTimeUsingTheAuthAppCLI(string $user, string $expirationTime): void { public function userHasCreatedAppTokenWithExpirationTimeUsingTheAuthAppCLI(
string $user,
string $expirationTime
): void {
$user = $this->featureContext->getActualUserName($user); $user = $this->featureContext->getActualUserName($user);
$command = "auth-app create --user-name=$user --expiration=$expirationTime"; $command = "auth-app create --user-name=$user --expiration=$expirationTime";
$body = [ $body = [
@@ -158,7 +168,11 @@ class CliContext implements Context {
$this->featureContext->theHTTPStatusCodeShouldBe(200, '', $response); $this->featureContext->theHTTPStatusCodeShouldBe(200, '', $response);
$jsonResponse = $this->featureContext->getJsonDecodedResponse($response); $jsonResponse = $this->featureContext->getJsonDecodedResponse($response);
Assert::assertSame("OK", $jsonResponse["status"]); 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); $jsonResponse = $this->featureContext->getJsonDecodedResponse($response);
Assert::assertSame("OK", $jsonResponse["status"]); 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 * @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); $fileId = $this->spacesContext->getFileId($user, $space, $file);
$response = \json_decode( $response = \json_decode(
CollaborationHelper::sendPOSTRequestToAppOpen( CollaborationHelper::sendPOSTRequestToAppOpen(
@@ -127,7 +133,12 @@ class CollaborationContext implements Context {
* @return void * @return void
* @throws GuzzleException * @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); $parentContainerId = $this->spacesContext->getResourceId($user, $space, $folder);
$this->featureContext->setResponse( $this->featureContext->setResponse(
CollaborationHelper::createFile( CollaborationHelper::createFile(
@@ -193,7 +204,10 @@ class CollaborationContext implements Context {
* @return void * @return void
* @throws GuzzleException * @throws GuzzleException
*/ */
public function thePublicCreatesAFileInsideTheLastSharedPublicLinkFolderWithPasswordUsingWopiEndpoint(string $file, string $password): void { public function thePublicCreatesAFileInsideTheLastSharedPublicLinkFolderWithPasswordUsingWopiEndpoint(
string $file,
string $password
): void {
$this->createFile($file, $password); $this->createFile($file, $password);
} }
@@ -208,7 +222,11 @@ class CollaborationContext implements Context {
* @return void * @return void
* @throws GuzzleException * @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); $this->createFile($file, $password, $folder);
} }
@@ -225,7 +243,12 @@ class CollaborationContext implements Context {
* @throws GuzzleException * @throws GuzzleException
* @throws JsonException * @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( $response = \json_decode(
CollaborationHelper::sendPOSTRequestToAppOpen( CollaborationHelper::sendPOSTRequestToAppOpen(
$this->spacesContext->getFileId($user, $space, $file), $this->spacesContext->getFileId($user, $space, $file),
@@ -337,7 +360,9 @@ class CollaborationContext implements Context {
*/ */
public function theFollowingMimeTypesShouldExistForUser(string $shouldOrNot, TableNode $table): void { public function theFollowingMimeTypesShouldExistForUser(string $shouldOrNot, TableNode $table): void {
$rows = $table->getRows(); $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'); $mimeTypes = \array_column($responseArray, 'mime_type');
foreach ($rows as $row) { foreach ($rows as $row) {
if ($shouldOrNot === "should not") { if ($shouldOrNot === "should not") {
@@ -364,10 +389,17 @@ class CollaborationContext implements Context {
* *
* @return void * @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()); $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']; $mimeTypes = $responseArray['mime-types'];
@@ -377,7 +409,12 @@ class CollaborationContext implements Context {
} }
foreach ($table->getColumnsHash() as $row) { 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']]; $mimeType = $mimeTypeMap[$row['mime-type']];
$found = false; $found = false;
@@ -387,7 +424,8 @@ class CollaborationContext implements Context {
Assert::assertSame( Assert::assertSame(
$row['target-extension'], $row['target-extension'],
$provider['target_ext'], $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; $found = true;
break; break;
@@ -396,8 +434,10 @@ class CollaborationContext implements Context {
if (!$found) { if (!$found) {
Assert::fail( 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" . "Expected response to contain app-provider '$app' with target-extension "
"App Providers Found: " . print_r($mimeType['app_providers'], true) . "'{$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 * @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"; $property = "oc:favorite";
$this->webDavPropertiesContext->checkPropertyOfAFolder( $this->webDavPropertiesContext->checkPropertyOfAFolder(
$user, $user,
+78 -18
View File
@@ -1034,7 +1034,11 @@ class FeatureContext extends BehatVariablesContext {
private function checkInvalidValidator(JsonSchema $schemaObj): void { private function checkInvalidValidator(JsonSchema $schemaObj): void {
$validators = \array_keys((array)$schemaObj->jsonSerialize()); $validators = \array_keys((array)$schemaObj->jsonSerialize());
foreach ($validators as $validator) { 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; 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"); Assert::assertFalse($hasTwoElementValidator, "'items', 'enum' and 'const' should not be used together");
if ($schemaObj->enum || $schemaObj->const) { if ($schemaObj->enum || $schemaObj->const) {
// do not try to validate of enum or const is present // 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::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 // check optional validators
foreach ($optionalValidators as $validator) { foreach ($optionalValidators as $validator) {
@@ -1127,18 +1137,34 @@ class FeatureContext extends BehatVariablesContext {
if ($schemaObj->maxItems > 1) { if ($schemaObj->maxItems > 1) {
if (\is_array($value)) { if (\is_array($value)) {
foreach ($value as $element) { 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::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) { 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::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; break;
case "uniqueItems": case "uniqueItems":
if ($schemaObj->minItems > 1) { if ($schemaObj->minItems > 1) {
@@ -1340,7 +1366,12 @@ class FeatureContext extends BehatVariablesContext {
* @throws GuzzleException * @throws GuzzleException
* @throws JsonException * @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( $this->verifyTableNodeColumns(
$headersTable, $headersTable,
['header', 'value'] ['header', 'value']
@@ -1385,7 +1416,12 @@ class FeatureContext extends BehatVariablesContext {
* *
* @return void * @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)); $this->setResponse($this->sendingToWithDirectUrl($user, $method, $davPath, $content));
} }
@@ -1399,7 +1435,12 @@ class FeatureContext extends BehatVariablesContext {
* *
* @return void * @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)); $this->setResponse($this->sendingToWithDirectUrl($user, $verb, $url, null, $password));
} }
@@ -1414,7 +1455,14 @@ class FeatureContext extends BehatVariablesContext {
* @return ResponseInterface * @return ResponseInterface
* @throws GuzzleException * @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, '/'); $url = \ltrim($url, '/');
if (WebdavHelper::isDAVRequest($url)) { if (WebdavHelper::isDAVRequest($url)) {
$url = WebdavHelper::prefixRemotePhp($url); $url = WebdavHelper::prefixRemotePhp($url);
@@ -1498,12 +1546,17 @@ class FeatureContext extends BehatVariablesContext {
* *
* @return void * @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; $response = $response ?? $this->response;
$actualStatusCode = $response->getStatusCode(); $actualStatusCode = $response->getStatusCode();
if (\is_array($expectedStatusCode)) { if (\is_array($expectedStatusCode)) {
if ($message === "") { 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( Assert::assertContainsEquals(
@@ -2745,7 +2798,11 @@ class FeatureContext extends BehatVariablesContext {
* @return void * @return void
* @throws Exception * @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) { if ($table === null || \count($table->getHash()) < 1) {
throw new Exception("Table should have at least one row."); 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 { public function getBodyForOCSRequest(string $method, string $property): ?string {
$body = null; $body = null;
if ($method === 'PROPFIND') { 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') { } 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') { } elseif ($method === 'PROPPATCH') {
if ($property === 'favorite') { if ($property === 'favorite') {
$property = '<oc:favorite xmlns:oc="http://owncloud.org/ns">1</oc: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 === '') { if ($property === '') {
$body = ''; $body = '';
@@ -92,7 +92,11 @@ class FilesVersionsContext implements Context {
* *
* @return void * @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); $password = $this->featureContext->getActualPassword($password);
$this->featureContext->setResponse( $this->featureContext->setResponse(
$this->featureContext->makeDavRequest( $this->featureContext->makeDavRequest(
@@ -129,7 +133,11 @@ class FilesVersionsContext implements Context {
$user = $this->featureContext->getActualUsername($user); $user = $this->featureContext->getActualUsername($user);
$fileOwner = $fileOwner ? $this->featureContext->getActualUsername($fileOwner) : $user; $fileOwner = $fileOwner ? $this->featureContext->getActualUsername($fileOwner) : $user;
$fileId = $this->featureContext->getFileIdForPath($fileOwner, $file, $spaceId); $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( return $this->featureContext->makeDavRequest(
$user, $user,
"PROPFIND", "PROPFIND",
@@ -187,7 +195,11 @@ class FilesVersionsContext implements Context {
public function getFileVersionMetadata(string $user, string $file): ResponseInterface { public function getFileVersionMetadata(string $user, string $file): ResponseInterface {
$user = $this->featureContext->getActualUsername($user); $user = $this->featureContext->getActualUsername($user);
$fileId = $this->featureContext->getFileIdForPath($user, $file); $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"?> $body = '<?xml version="1.0"?>
<d:propfind xmlns:d="DAV:" xmlns:oc="http://owncloud.org/ns"> <d:propfind xmlns:d="DAV:" xmlns:oc="http://owncloud.org/ns">
<d:prop> <d:prop>
@@ -217,7 +229,11 @@ class FilesVersionsContext implements Context {
public function restoreVersionIndexOfFile(string $user, int $versionIndex, string $path): ResponseInterface { public function restoreVersionIndexOfFile(string $user, int $versionIndex, string $path): ResponseInterface {
$user = $this->featureContext->getActualUsername($user); $user = $this->featureContext->getActualUsername($user);
$fileId = $this->featureContext->getFileIdForPath($user, $path); $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); $response = $this->listVersionFolder($user, $fileId, 1);
$responseXmlObject = HttpRequestHelper::getResponseXml( $responseXmlObject = HttpRequestHelper::getResponseXml(
$response, $response,
@@ -313,7 +329,11 @@ class FilesVersionsContext implements Context {
): void { ): void {
$user = $this->featureContext->getActualUsername($user); $user = $this->featureContext->getActualUsername($user);
$fileId = $this->featureContext->getFileIdForPath($user, $path); $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); $this->assertFileVersionsCount($user, $fileId, $count);
} }
@@ -354,7 +374,11 @@ class FilesVersionsContext implements Context {
): void { ): void {
$user = $this->featureContext->getActualUsername($user); $user = $this->featureContext->getActualUsername($user);
$fileId = $this->featureContext->getFileIdForPath($user, $path); $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']); $response = $this->listVersionFolder($user, $fileId, 1, ['d:getcontentlength']);
$responseXmlObject = HttpRequestHelper::getResponseXml( $responseXmlObject = HttpRequestHelper::getResponseXml(
$response, $response,
@@ -413,10 +437,19 @@ class FilesVersionsContext implements Context {
* @return ResponseInterface * @return ResponseInterface
* @throws Exception * @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); $user = $this->featureContext->getActualUsername($user);
$fileId = $this->featureContext->getFileIdForPath($user, $path, $spaceId); $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; $index = (int)$index;
$response = $this->listVersionFolder($user, $fileId, 1); $response = $this->listVersionFolder($user, $fileId, 1);
if ($response->getStatusCode() === 403) { if ($response->getStatusCode() === 403) {
+218 -49
View File
@@ -81,7 +81,11 @@ class GraphContext implements Context {
* @throws GuzzleException * @throws GuzzleException
* @throws Exception * @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); $response = $this->editUserUsingTheGraphApi($byUser, $user, null, null, null, $displayName);
$this->featureContext->setResponse($response); $this->featureContext->setResponse($response);
} }
@@ -98,7 +102,11 @@ class GraphContext implements Context {
* @throws GuzzleException * @throws GuzzleException
* @throws Exception * @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); $response = $this->editUserUsingTheGraphApi($byUser, $user, $userName);
$this->featureContext->setResponse($response); $this->featureContext->setResponse($response);
// need to add user to list to delete him after test // need to add user to list to delete him after test
@@ -189,7 +197,16 @@ class GraphContext implements Context {
* @return void * @return void
* @throws GuzzleException * @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); $user = $this->featureContext->getActualUsername($user);
$userId = $this->featureContext->getAttributeOfCreatedUser($user, 'id') ?: $user; $userId = $this->featureContext->getAttributeOfCreatedUser($user, 'id') ?: $user;
return GraphHelper::editUser( return GraphHelper::editUser(
@@ -528,8 +545,10 @@ class GraphContext implements Context {
* @return array * @return array
*/ */
public function getAdminOrUserCredentials(?string $user): array { public function getAdminOrUserCredentials(?string $user): array {
$credentials["username"] = $user ? $this->featureContext->getActualUsername($user) : $this->featureContext->getAdminUsername(); $credentials["username"] = $user ? $this->featureContext->getActualUsername($user)
$credentials["password"] = $user ? $this->featureContext->getPasswordForUser($user) : $this->featureContext->getAdminPassword(); : $this->featureContext->getAdminUsername();
$credentials["password"] = $user ? $this->featureContext->getPasswordForUser($user)
: $this->featureContext->getAdminPassword();
return $credentials; return $credentials;
} }
/** /**
@@ -605,7 +624,10 @@ class GraphContext implements Context {
* @return ResponseInterface * @return ResponseInterface
* @throws GuzzleException * @throws GuzzleException
*/ */
public function listSingleOrAllGroupsAlongWithAllMemberInformation(string $user, ?string $group = null): ResponseInterface { public function listSingleOrAllGroupsAlongWithAllMemberInformation(
string $user,
?string $group = null
): ResponseInterface {
$credentials = $this->getAdminOrUserCredentials($user); $credentials = $this->getAdminOrUserCredentials($user);
return GraphHelper::getSingleOrAllGroupsAlongWithMembers( return GraphHelper::getSingleOrAllGroupsAlongWithMembers(
@@ -759,7 +781,10 @@ class GraphContext implements Context {
* *
* @return void * @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)); $this->featureContext->setResponse($this->addUserToGroup($group, "nonexistent", $byUser));
} }
@@ -774,7 +799,10 @@ class GraphContext implements Context {
* *
* @throws GuzzleException | Exception * @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)); $this->featureContext->setResponse($this->addUserToGroup("nonexistent", $user, $byUser));
} }
@@ -799,7 +827,11 @@ class GraphContext implements Context {
* *
* @return void * @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)); $this->featureContext->setResponse($this->addUserToGroup($group, $user, $byUser));
} }
@@ -1032,7 +1064,8 @@ class GraphContext implements Context {
Assert::assertTrue( Assert::assertTrue(
$exists, $exists,
__METHOD__ __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 * @return void
*/ */
public function theAdministratorRemovesTheFollowingUsersFromTheFollowingGroupsUsingTheGraphApi(TableNode $table): void { public function theAdministratorRemovesTheFollowingUsersFromTheFollowingGroupsUsingTheGraphApi(
TableNode $table
): void {
$this->featureContext->verifyTableNodeColumns($table, ['username', 'groupname']); $this->featureContext->verifyTableNodeColumns($table, ['username', 'groupname']);
$usersGroups = $table->getColumnsHash(); $usersGroups = $table->getColumnsHash();
foreach ($usersGroups as $userGroup) { 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(); $this->featureContext->pushToLastHttpStatusCodesArray();
} }
} }
@@ -1118,7 +1155,11 @@ class GraphContext implements Context {
* @return void * @return void
* @throws Exception | GuzzleException * @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)); $this->featureContext->setResponse($this->removeUserFromGroup($group, $user, $byUser));
} }
@@ -1132,7 +1173,10 @@ class GraphContext implements Context {
* @return void * @return void
* @throws GuzzleException * @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)); $this->featureContext->setResponse($this->removeUserFromGroup('', $user, $byUser));
} }
@@ -1351,7 +1395,11 @@ class GraphContext implements Context {
* @throws GuzzleException * @throws GuzzleException
* @throws Exception * @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); $credentials = $this->getAdminOrUserCredentials($user);
return GraphHelper::addUsersToGroup( return GraphHelper::addUsersToGroup(
@@ -1375,7 +1423,11 @@ class GraphContext implements Context {
* @throws Exception * @throws Exception
* @throws GuzzleException * @throws GuzzleException
*/ */
public function theAdministratorAddsTheFollowingUsersToAGroupInASingleRequestUsingTheGraphApi(string $user, string $group, TableNode $table): void { public function theAdministratorAddsTheFollowingUsersToAGroupInASingleRequestUsingTheGraphApi(
string $user,
string $group,
TableNode $table
): void {
$userIds = []; $userIds = [];
$groupId = $this->featureContext->getAttributeOfCreatedGroup($group, "id"); $groupId = $this->featureContext->getAttributeOfCreatedGroup($group, "id");
foreach ($table->getHash() as $row) { foreach ($table->getHash() as $row) {
@@ -1397,7 +1449,11 @@ class GraphContext implements Context {
* @throws Exception * @throws Exception
* @throws GuzzleException * @throws GuzzleException
*/ */
public function userTriesToAddTheFollowingUsersToAGroupAtOnceWithInvalidHostUsingTheGraphApi(string $user, string $group, TableNode $table): void { public function userTriesToAddTheFollowingUsersToAGroupAtOnceWithInvalidHostUsingTheGraphApi(
string $user,
string $group,
TableNode $table
): void {
$userIds = []; $userIds = [];
$groupId = $this->featureContext->getAttributeOfCreatedGroup($group, "id"); $groupId = $this->featureContext->getAttributeOfCreatedGroup($group, "id");
$credentials = $this->getAdminOrUserCredentials($user); $credentials = $this->getAdminOrUserCredentials($user);
@@ -1436,7 +1492,11 @@ class GraphContext implements Context {
* @throws Exception * @throws Exception
* @throws GuzzleException * @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"); $groupId = $this->featureContext->getAttributeOfCreatedGroup($group, "id");
$userId = $this->featureContext->getAttributeOfCreatedUser($user, "id"); $userId = $this->featureContext->getAttributeOfCreatedUser($user, "id");
$credentials = $this->getAdminOrUserCredentials($adminUser); $credentials = $this->getAdminOrUserCredentials($adminUser);
@@ -1467,7 +1527,10 @@ class GraphContext implements Context {
* @throws GuzzleException * @throws GuzzleException
* @throws Exception * @throws Exception
*/ */
public function theAdministratorTriesToAddsTheFollowingUsersToANonExistingGroupAtOnceUsingTheGraphApi(string $user, TableNode $table): void { public function theAdministratorTriesToAddsTheFollowingUsersToANonExistingGroupAtOnceUsingTheGraphApi(
string $user,
TableNode $table
): void {
$userIds = []; $userIds = [];
$groupId = WebDavHelper::generateUUIDv4(); $groupId = WebDavHelper::generateUUIDv4();
foreach ($table->getHash() as $row) { foreach ($table->getHash() as $row) {
@@ -1489,7 +1552,11 @@ class GraphContext implements Context {
* @throws GuzzleException * @throws GuzzleException
* @throws Exception * @throws Exception
*/ */
public function theAdministratorTriesToAddTheFollowingNonExistingUsersToAGroupAtOnceUsingTheGraphApi(string $user, string $group, TableNode $table): void { public function theAdministratorTriesToAddTheFollowingNonExistingUsersToAGroupAtOnceUsingTheGraphApi(
string $user,
string $group,
TableNode $table
): void {
$userIds = []; $userIds = [];
$groupId = $this->featureContext->getAttributeOfCreatedGroup($group, "id"); $groupId = $this->featureContext->getAttributeOfCreatedGroup($group, "id");
foreach ($table->getHash() as $row) { foreach ($table->getHash() as $row) {
@@ -1512,7 +1579,11 @@ class GraphContext implements Context {
* @throws GuzzleException * @throws GuzzleException
* @throws Exception * @throws Exception
*/ */
public function theAdministratorTriesToAddTheFollowingUsersToAGroupAtOnceUsingTheGraphApi(string $user, string $group, TableNode $table): void { public function theAdministratorTriesToAddTheFollowingUsersToAGroupAtOnceUsingTheGraphApi(
string $user,
string $group,
TableNode $table
): void {
$userIds = []; $userIds = [];
$groupId = $this->featureContext->getAttributeOfCreatedGroup($group, "id"); $groupId = $this->featureContext->getAttributeOfCreatedGroup($group, "id");
foreach ($table->getHash() as $row) { foreach ($table->getHash() as $row) {
@@ -1550,7 +1621,11 @@ class GraphContext implements Context {
* @return void * @return void
*/ */
public function theResponseShouldContainTheFollowingApplicationInformation(TableNode $table): 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) { foreach ($table->getHash() as $row) {
$key = $row["key"]; $key = $row["key"];
if ($key === 'id') { if ($key === 'id') {
@@ -1572,7 +1647,11 @@ class GraphContext implements Context {
* @return void * @return void
*/ */
public function theResponseShouldContainTheFollowingAppRolesInformation(TableNode $table): 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) { foreach ($table->getRows() as $row) {
$foundRoleInResponse = false; $foundRoleInResponse = false;
foreach ($responseArray['appRoles'] as $role) { foreach ($responseArray['appRoles'] as $role) {
@@ -1640,7 +1719,11 @@ class GraphContext implements Context {
* @return void * @return void
* @throws GuzzleException * @throws GuzzleException
*/ */
public function userGetsAllUsersOfFirstGroupOderSecondGroupUsingTheGraphApi(string $user, string $firstGroup, string $secondGroup) { public function userGetsAllUsersOfFirstGroupOderSecondGroupUsingTheGraphApi(
string $user,
string $firstGroup,
string $secondGroup
) {
$response = GraphHelper::getUsersFromOneOrOtherGroup( $response = GraphHelper::getUsersFromOneOrOtherGroup(
$this->featureContext->getBaseUrl(), $this->featureContext->getBaseUrl(),
$this->featureContext->getStepLineRef(), $this->featureContext->getStepLineRef(),
@@ -1708,7 +1791,11 @@ class GraphContext implements Context {
* @return void * @return void
* @throws GuzzleException * @throws GuzzleException
*/ */
public function userGetsAllUsersWithRoleAndMemberOfGroupUsingTheGraphApi(string $user, string $role, string $group) { public function userGetsAllUsersWithRoleAndMemberOfGroupUsingTheGraphApi(
string $user,
string $role,
string $group
) {
$response = GraphHelper::getUsersWithFilterRolesAssignmentAndMemberOf( $response = GraphHelper::getUsersWithFilterRolesAssignmentAndMemberOf(
$this->featureContext->getBaseUrl(), $this->featureContext->getBaseUrl(),
$this->featureContext->getStepLineRef(), $this->featureContext->getStepLineRef(),
@@ -1841,7 +1928,8 @@ class GraphContext implements Context {
$this->appEntity["appRoles"][$role], $this->appEntity["appRoles"][$role],
$response['appRoleId'], $response['appRoleId'],
__METHOD__ __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 GuzzleException
* @throws Exception * @throws Exception
*/ */
public function theAdministratorHasAddedTheFollowingUsersToAGroupAtOnceUsingTheGraphApi(string $user, string $group, TableNode $table) { public function theAdministratorHasAddedTheFollowingUsersToAGroupAtOnceUsingTheGraphApi(
string $user,
string $group,
TableNode $table
) {
$userIds = []; $userIds = [];
$groupId = $this->featureContext->getAttributeOfCreatedGroup($group, "id"); $groupId = $this->featureContext->getAttributeOfCreatedGroup($group, "id");
foreach ($table->getHash() as $row) { foreach ($table->getHash() as $row) {
@@ -1975,13 +2067,18 @@ class GraphContext implements Context {
* @throws GuzzleException * @throws GuzzleException
* @throws Exception * @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"); $groupId = $this->featureContext->getAttributeOfCreatedGroup($group, "id");
$groupIdToAdd = $this->featureContext->getAttributeOfCreatedGroup($groupToAdd, "id"); $groupIdToAdd = $this->featureContext->getAttributeOfCreatedGroup($groupToAdd, "id");
$credentials = $this->getAdminOrUserCredentials($user); $credentials = $this->getAdminOrUserCredentials($user);
$payload = [ $payload = [
"members@odata.bind" => [GraphHelper::getFullUrl($this->featureContext->getBaseUrl(), 'groups/' . $groupIdToAdd)] "members@odata.bind" => [
GraphHelper::getFullUrl($this->featureContext->getBaseUrl(), 'groups/' . $groupIdToAdd)]
]; ];
$this->featureContext->setResponse( $this->featureContext->setResponse(
@@ -2008,7 +2105,11 @@ class GraphContext implements Context {
* @throws GuzzleException * @throws GuzzleException
* @throws Exception * @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"); $groupId = $this->featureContext->getAttributeOfCreatedGroup($group, "id");
$groupIdToAdd = $this->featureContext->getAttributeOfCreatedGroup($groupToAdd, "id"); $groupIdToAdd = $this->featureContext->getAttributeOfCreatedGroup($groupToAdd, "id");
$credentials = $this->getAdminOrUserCredentials($user); $credentials = $this->getAdminOrUserCredentials($user);
@@ -2041,7 +2142,12 @@ class GraphContext implements Context {
* @throws Exception * @throws Exception
* @throws GuzzleException * @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"); $groupId = $this->featureContext->getAttributeOfCreatedGroup($group, "id");
$credentials = $this->getAdminOrUserCredentials($adminUser); $credentials = $this->getAdminOrUserCredentials($adminUser);
@@ -2078,7 +2184,12 @@ class GraphContext implements Context {
* @throws Exception * @throws Exception
* @throws GuzzleException * @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"); $groupId = $this->featureContext->getAttributeOfCreatedGroup($group, "id");
$credentials = $this->getAdminOrUserCredentials($user); $credentials = $this->getAdminOrUserCredentials($user);
foreach ($table->getHash() as $row) { foreach ($table->getHash() as $row) {
@@ -2116,7 +2227,11 @@ class GraphContext implements Context {
* @throws GuzzleException * @throws GuzzleException
* @throws Exception * @throws Exception
*/ */
public function theAdministratorTriesToAddTheFollowingUserIdWithInvalidCharacterToAGroup(string $user, string $group, TableNode $table) { public function theAdministratorTriesToAddTheFollowingUserIdWithInvalidCharacterToAGroup(
string $user,
string $group,
TableNode $table
) {
$userIds = []; $userIds = [];
$credentials = $this->getAdminOrUserCredentials($user); $credentials = $this->getAdminOrUserCredentials($user);
$groupId = $this->featureContext->getAttributeOfCreatedGroup($group, "id"); $groupId = $this->featureContext->getAttributeOfCreatedGroup($group, "id");
@@ -2146,7 +2261,11 @@ class GraphContext implements Context {
* @throws GuzzleException * @throws GuzzleException
* @throws Exception * @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); $credentials = $this->getAdminOrUserCredentials($user);
$groupId = $this->featureContext->getAttributeOfCreatedGroup($group, "id"); $groupId = $this->featureContext->getAttributeOfCreatedGroup($group, "id");
$this->featureContext->setResponse( $this->featureContext->setResponse(
@@ -2183,7 +2302,8 @@ class GraphContext implements Context {
Assert::assertEquals( Assert::assertEquals(
1, 1,
$count, $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 * @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; $actualResponseToAssert = null;
$events = $this->featureContext->getJsonDecodedResponseBodyContent()->events; $events = $this->featureContext->getJsonDecodedResponseBodyContent()->events;
foreach ($events as $event) { foreach ($events as $event) {
@@ -2307,7 +2431,11 @@ class GraphContext implements Context {
* @return void * @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); $credentials = $this->getAdminOrUserCredentials($user);
$this->featureContext->setResponse( $this->featureContext->setResponse(
GraphHelper::generateGDPRReport( GraphHelper::generateGDPRReport(
@@ -2328,7 +2456,8 @@ class GraphContext implements Context {
* @throws GuzzleException * @throws GuzzleException
*/ */
public function getAssignedRole(string $user): ResponseInterface { 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 ( return (
GraphHelper::getAssignedRole( GraphHelper::getAssignedRole(
$this->featureContext->getBAseUrl(), $this->featureContext->getBAseUrl(),
@@ -2359,7 +2488,9 @@ class GraphContext implements Context {
if (!$userId && $ofUser !== $this->featureContext->getAdminUsername()) { if (!$userId && $ofUser !== $this->featureContext->getAdminUsername()) {
$appRoleAssignmentId = $this->getRoleIdByRoleName("User"); $appRoleAssignmentId = $this->getRoleIdByRoleName("User");
} else { } else {
$appRoleAssignmentId = $this->featureContext->getJsonDecodedResponse($this->getAssignedRole($ofUser))["value"][0]["id"]; $appRoleAssignmentId = $this->featureContext->getJsonDecodedResponse(
$this->getAssignedRole($ofUser)
)["value"][0]["id"];
} }
$userId = $userId ?: $ofUser; $userId = $userId ?: $ofUser;
@@ -2508,7 +2639,11 @@ class GraphContext implements Context {
* @return void * @return void
* @throws GuzzleException * @throws GuzzleException
*/ */
public function userListsTheResourcesSharedWithThemUsingGraphApi(string $user, string $cacheStepString, string $retryOption): void { public function userListsTheResourcesSharedWithThemUsingGraphApi(
string $user,
string $cacheStepString,
string $retryOption
): void {
if ($cacheStepString !== '') { if ($cacheStepString !== '') {
// ENV (GRAPH_SPACES_GROUPS_CACHE_TTL | GRAPH_SPACES_USERS_CACHE_TTL) is set default to 60 sec // 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 // 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) { if ($retryEnabled) {
foreach ($jsonBody->value as $share) { foreach ($jsonBody->value as $share) {
$autoSync = $this->featureContext->getUserAutoSyncSetting($credentials['username']); $autoSync = $this->featureContext->getUserAutoSyncSetting($credentials['username']);
$tryAgain = !$share->{'@client.synchronize'} && $autoSync && $retried < HttpRequestHelper::numRetriesOnHttpTooEarly(); $tryAgain = !$share->{'@client.synchronize'}
&& $autoSync
&& $retried < HttpRequestHelper::numRetriesOnHttpTooEarly();
if ($tryAgain) { if ($tryAgain) {
$retried += 1; $retried += 1;
@@ -2676,7 +2813,11 @@ class GraphContext implements Context {
* @throws GuzzleException * @throws GuzzleException
* @throws JsonException * @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( $response = GraphHelper::createUser(
$this->featureContext->getBaseUrl(), $this->featureContext->getBaseUrl(),
$this->featureContext->getStepLineRef(), $this->featureContext->getStepLineRef(),
@@ -2772,7 +2913,11 @@ class GraphContext implements Context {
* @return void * @return void
* @throws Exception * @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); $resourceId = $this->featureContext->spacesContext->getResourceId($user, $spaceName, $resource);
$response = GraphHelper::getActivities( $response = GraphHelper::getActivities(
$this->featureContext->getBaseUrl(), $this->featureContext->getBaseUrl(),
@@ -2792,7 +2937,10 @@ class GraphContext implements Context {
* *
* @return void * @return void
*/ */
public function userTriesToListTheActivitiesOfFolderWithShareMountIdPointIdUsingTheGraphApi(string $user, string $folder): void { public function userTriesToListTheActivitiesOfFolderWithShareMountIdPointIdUsingTheGraphApi(
string $user,
string $folder
): void {
$resourceId = GraphHelper::getShareMountId( $resourceId = GraphHelper::getShareMountId(
$this->featureContext->getBaseUrl(), $this->featureContext->getBaseUrl(),
$this->featureContext->getStepLineRef(), $this->featureContext->getStepLineRef(),
@@ -2820,7 +2968,12 @@ class GraphContext implements Context {
* *
* @return void * @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); $resourceId = $this->featureContext->spacesContext->getResourceId($owner, $spaceName, $file);
$response = GraphHelper::getActivities( $response = GraphHelper::getActivities(
$this->featureContext->getBaseUrl(), $this->featureContext->getBaseUrl(),
@@ -2861,7 +3014,11 @@ class GraphContext implements Context {
* *
* @return void * @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( $response = GraphHelper::getActivities(
$this->featureContext->getBaseUrl(), $this->featureContext->getBaseUrl(),
$this->featureContext->getStepLineRef(), $this->featureContext->getStepLineRef(),
@@ -2882,7 +3039,12 @@ class GraphContext implements Context {
* *
* @return void * @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( $response = GraphHelper::getActivities(
$this->featureContext->getBaseUrl(), $this->featureContext->getBaseUrl(),
$this->featureContext->getStepLineRef(), $this->featureContext->getStepLineRef(),
@@ -2904,7 +3066,13 @@ class GraphContext implements Context {
* *
* @return void * @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); $resourceId = $this->featureContext->spacesContext->getResourceId($user, $spaceName, $resource);
$response = GraphHelper::getActivities( $response = GraphHelper::getActivities(
$this->featureContext->getBaseUrl(), $this->featureContext->getBaseUrl(),
@@ -2932,7 +3100,8 @@ class GraphContext implements Context {
foreach ($table->getHash() as $index => $expectedValue) { foreach ($table->getHash() as $index => $expectedValue) {
$actualActivity = $activities[$index]; $actualActivity = $activities[$index];
$expectedActivity = $expectedValue['resource'] . ":" . $expectedValue['message']; $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"); Assert::assertEquals($expectedActivity, $actualActivity, "Activity didn't match");
} }
} }
@@ -324,7 +324,10 @@ class NotificationContext implements Context {
* *
* @return object * @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(); $response = $response ?? $this->featureContext->getResponse();
if (isset($this->featureContext->getJsonDecodedResponseBodyContent($response)->ocs->data)) { if (isset($this->featureContext->getJsonDecodedResponseBodyContent($response)->ocs->data)) {
$responseBody = $this->featureContext->getJsonDecodedResponseBodyContent($response)->ocs->data; $responseBody = $this->featureContext->getJsonDecodedResponseBodyContent($response)->ocs->data;
@@ -351,7 +354,11 @@ class NotificationContext implements Context {
* *
* @return array * @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 = []; $filteredNotifications = [];
$response = $response ?? $this->featureContext->getResponse(); $response = $response ?? $this->featureContext->getResponse();
$responseObject = $this->featureContext->getJsonDecodedResponseBodyContent($response); $responseObject = $this->featureContext->getJsonDecodedResponseBodyContent($response);
@@ -362,7 +369,10 @@ class NotificationContext implements Context {
$notifications = $responseObject->ocs->data; $notifications = $responseObject->ocs->data;
foreach ($notifications as $notification) { 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; $this->notificationIds[] = $notification->notification_id;
$filteredNotifications[] = $notification; $filteredNotifications[] = $notification;
} }
@@ -392,9 +402,15 @@ class NotificationContext implements Context {
$response = $this->listAllNotifications($user); $response = $this->listAllNotifications($user);
$this->featureContext->theHTTPStatusCodeShouldBe(200, "", $response); $this->featureContext->theHTTPStatusCodeShouldBe(200, "", $response);
++$count; ++$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)) { 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 { } else {
throw new \Exception("Notification was not found even after retrying for 5 seconds."); throw new \Exception("Notification was not found even after retrying for 5 seconds.");
} }
@@ -417,7 +433,12 @@ class NotificationContext implements Context {
* @return void * @return void
* @throws Exception * @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); $response = $this->listAllNotifications($user);
$notification = $this->filterNotificationsBySubjectAndResource($subject, $resource, $response); $notification = $this->filterNotificationsBySubjectAndResource($subject, $resource, $response);
@@ -432,9 +453,15 @@ class NotificationContext implements Context {
$response = $this->userDeletesNotification($user); $response = $this->userDeletesNotification($user);
$this->featureContext->theHTTPStatusCodeShouldBe(200, '', $response); $this->featureContext->theHTTPStatusCodeShouldBe(200, '', $response);
} elseif (\count($notification) === 0) { } 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 { } 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 * @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); $response = $this->listAllNotifications($user);
$filteredResponse = $this->filterNotificationsBySubjectAndResource($subject, $resource, $response); $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 * @return void
* @throws Exception * @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()); $rawExpectedEmailBodyContent = \str_replace("\r\n", "\n", $content->getRaw());
$this->featureContext->setResponse( $this->featureContext->setResponse(
GraphHelper::getMySpaces( GraphHelper::getMySpaces(
@@ -501,7 +542,11 @@ class NotificationContext implements Context {
* @return void * @return void
* @throws Exception * @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()); $rawExpectedEmailBodyContent = \str_replace("\r\n", "\n", $content->getRaw());
$expectedEmailBodyContent = $this->featureContext->substituteInLineCodes( $expectedEmailBodyContent = $this->featureContext->substituteInLineCodes(
$rawExpectedEmailBodyContent, $rawExpectedEmailBodyContent,
@@ -520,7 +565,11 @@ class NotificationContext implements Context {
* @return void * @return void
* @throws Exception * @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()); $rawExpectedEmailBodyContent = \str_replace("\r\n", "\n", $content->getRaw());
$expectedEmailBodyContent = $this->featureContext->substituteInLineCodes( $expectedEmailBodyContent = $this->featureContext->substituteInLineCodes(
$rawExpectedEmailBodyContent, $rawExpectedEmailBodyContent,
@@ -537,7 +586,11 @@ class NotificationContext implements Context {
* @return void * @return void
* @throws GuzzleException * @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); $address = $this->featureContext->getEmailAddressForUser($user);
$this->featureContext->pushEmailRecipientAsMailBox($address); $this->featureContext->pushEmailRecipientAsMailBox($address);
$actualEmailBodyContent = EmailHelper::getBodyOfLastEmail($address, $this->featureContext->getStepLineRef()); $actualEmailBodyContent = EmailHelper::getBodyOfLastEmail($address, $this->featureContext->getStepLineRef());
@@ -548,7 +601,8 @@ class NotificationContext implements Context {
Assert::assertStringContainsString( Assert::assertStringContainsString(
$expectedEmailBodyContent, $expectedEmailBodyContent,
$actualEmailBodyContent, $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" but the received email is $actualEmailBodyContent"
); );
} }
@@ -596,7 +650,8 @@ class NotificationContext implements Context {
?string $deprovision_date_format= "2006-01-02T15:04:05Z07:00" ?string $deprovision_date_format= "2006-01-02T15:04:05Z07:00"
): ResponseInterface { ): ResponseInterface {
$payload["type"] = "deprovision"; $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( return OcsApiHelper::sendRequest(
$this->featureContext->getBaseUrl(), $this->featureContext->getBaseUrl(),
$user ? $this->featureContext->getActualUsername($user) : $this->featureContext->getAdminUsername(), $user ? $this->featureContext->getActualUsername($user) : $this->featureContext->getAdminUsername(),
@@ -636,7 +691,10 @@ class NotificationContext implements Context {
* @throws GuzzleException * @throws GuzzleException
* @throws JsonException * @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); $response = $this->userCreatesDeprovisioningNotification(null, $deprovision_date, $deprovision_date_format);
$this->featureContext->setResponse($response); $this->featureContext->setResponse($response);
$this->featureContext->pushToLastHttpStatusCodesArray(); $this->featureContext->pushToLastHttpStatusCodesArray();
+18 -5
View File
@@ -151,7 +151,11 @@ class OCSContext implements Context {
* *
* @return ResponseInterface * @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( return $this->sendRequestToOcsEndpoint(
$this->featureContext->getCurrentUser(), $this->featureContext->getCurrentUser(),
$verb, $verb,
@@ -408,7 +412,11 @@ class OCSContext implements Context {
* @return void * @return void
* @throws Exception * @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); $statusCodes = explode(",", $statusCode);
$response = $response ?? $this->featureContext->getResponse(); $response = $response ?? $this->featureContext->getResponse();
$responseStatusCode = $this->getOCSResponseStatusCode( $responseStatusCode = $this->getOCSResponseStatusCode(
@@ -416,7 +424,8 @@ class OCSContext implements Context {
); );
if (\is_array($statusCodes)) { if (\is_array($statusCodes)) {
if ($message === "") { 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( Assert::assertContainsEquals(
$responseStatusCode, $responseStatusCode,
@@ -455,7 +464,8 @@ class OCSContext implements Context {
Assert::assertContainsEquals( Assert::assertContainsEquals(
$responseStatusCode, $responseStatusCode,
$statusCodes, $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(); $this->featureContext->emptyLastOCSStatusCodesArray();
} }
@@ -632,7 +642,10 @@ class OCSContext implements Context {
* @return void * @return void
* @throws Exception * @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(); $response = $response ?? $this->featureContext->getResponse();
$this->featureContext->theHTTPStatusCodeShouldBe('200', $message, $response); $this->featureContext->theHTTPStatusCodeShouldBe('200', $message, $response);
if ($this->featureContext->getOcsApiVersion() === 1) { if ($this->featureContext->getOcsApiVersion() === 1) {
+5 -1
View File
@@ -286,7 +286,11 @@ class OcmContext implements Context {
*/ */
public function userHasDeletedFederatedConnectionWithUser(string $user, string $ocmUser): void { public function userHasDeletedFederatedConnectionWithUser(string $user, string $ocmUser): void {
$response = $this->deleteConnection($user, $ocmUser); $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
);
} }
/** /**
+28 -6
View File
@@ -455,7 +455,11 @@ trait Provisioning {
} catch (LdapException $e) { } catch (LdapException $e) {
if (\str_contains($e->getMessage(), "Already exists")) { if (\str_contains($e->getMessage(), "Already exists")) {
$this->ldap->delete( $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']]); OcisHelper::deleteRevaUserData([$entry['uid']]);
$this->ldap->add($newDN, $entry); $this->ldap->add($newDN, $entry);
@@ -496,7 +500,8 @@ trait Provisioning {
} catch (LdapException $e) { } catch (LdapException $e) {
if (\str_contains($e->getMessage(), "Already exists")) { if (\str_contains($e->getMessage(), "Already exists")) {
$this->ldap->delete( $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); $this->ldap->add($newDN, $entry);
} }
@@ -519,7 +524,8 @@ trait Provisioning {
} }
foreach ($this->ldapCreatedGroups as $group) { foreach ($this->ldapCreatedGroups as $group) {
$this->ldap->delete( $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); $this->rememberThatGroupIsNotExpectedToExist($group);
} }
@@ -682,7 +688,11 @@ trait Provisioning {
* *
* @return void * @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); $targetUsername = $this->getActualUsername($username);
$password = $this->getActualPassword($password); $password = $this->getActualPassword($password);
$this->userTriesToResetUserPasswordUsingTheProvisioningApi( $this->userTriesToResetUserPasswordUsingTheProvisioningApi(
@@ -700,7 +710,11 @@ trait Provisioning {
* *
* @return void * @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); $password = $this->getActualPassword($password);
$bodyTable = new TableNode([['key', 'password'], ['value', $password]]); $bodyTable = new TableNode([['key', 'password'], ['value', $password]]);
$this->ocsContext->sendRequestToOcsEndpoint( $this->ocsContext->sendRequestToOcsEndpoint(
@@ -1737,7 +1751,15 @@ trait Provisioning {
if (OcisHelper::isTestingOnReva()) { if (OcisHelper::isTestingOnReva()) {
$response = $this->disableOrEnableUser($this->getAdminUsername(), $user, 'disable'); $response = $this->disableOrEnableUser($this->getAdminUsername(), $user, 'disable');
} else { } 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( Assert::assertEquals(
200, 200,
@@ -92,7 +92,10 @@ class PublicWebDavContext implements Context {
* *
* @return void * @return void
*/ */
public function userTriesToDownloadFileFromPublicLinkUsingBasicAuthAndPublicWebdav(string $user, string $path): void { public function userTriesToDownloadFileFromPublicLinkUsingBasicAuthAndPublicWebdav(
string $user,
string $path
): void {
$response = $this->downloadFromPublicLinkAsUser($path, $user); $response = $this->downloadFromPublicLinkAsUser($path, $user);
$this->featureContext->setResponse($response); $this->featureContext->setResponse($response);
} }
@@ -104,7 +107,9 @@ class PublicWebDavContext implements Context {
* *
* @return void * @return void
*/ */
public function thePublicDeletesFileFolderFromTheLastPublicLinkShareUsingThePublicWebdavApi(string $fileName):void { public function thePublicDeletesFileFolderFromTheLastPublicLinkShareUsingThePublicWebdavApi(
string $fileName
): void {
$response = $this->deleteFileFromPublicShare( $response = $this->deleteFileFromPublicShare(
$fileName $fileName
); );
@@ -119,7 +124,9 @@ class PublicWebDavContext implements Context {
* @return ResponseInterface * @return ResponseInterface
*/ */
public function deleteFileFromPublicShare(string $fileName, string $password = ""): 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( $davPath = WebDavHelper::getDavPath(
WebDavHelper::DAV_VERSION_NEW, WebDavHelper::DAV_VERSION_NEW,
$token, $token,
@@ -151,7 +158,10 @@ class PublicWebDavContext implements Context {
* *
* @return void * @return void
*/ */
public function thePublicHasDeletedFileFromTheLastLinkShareWithPasswordUsingPublicWebdavApi(string $file, string $password): void { public function thePublicHasDeletedFileFromTheLastLinkShareWithPasswordUsingPublicWebdavApi(
string $file,
string $password
): void {
$response = $this->deleteFileFromPublicShare($file, $password); $response = $this->deleteFileFromPublicShare($file, $password);
$this->featureContext->theHTTPStatusCodeShouldBe([201, 204], "", $response); $this->featureContext->theHTTPStatusCodeShouldBe([201, 204], "", $response);
} }
@@ -164,7 +174,10 @@ class PublicWebDavContext implements Context {
* *
* @return void * @return void
*/ */
public function thePublicDeletesFileFromTheLastLinkShareWithPasswordUsingPublicWebdavApi(string $file, string $password): void { public function thePublicDeletesFileFromTheLastLinkShareWithPasswordUsingPublicWebdavApi(
string $file,
string $password
): void {
$this->featureContext->setResponse( $this->featureContext->setResponse(
$this->deleteFileFromPublicShare($file, $password) $this->deleteFileFromPublicShare($file, $password)
); );
@@ -178,8 +191,14 @@ class PublicWebDavContext implements Context {
* *
* @return ResponseInterface * @return ResponseInterface
*/ */
public function renameFileFromPublicShare(string $fileName, string $toFileName, ?string $password = ""):ResponseInterface { public function renameFileFromPublicShare(
$token = ($this->featureContext->isUsingSharingNG()) ? $this->featureContext->shareNgGetLastCreatedLinkShareToken() : $this->featureContext->getLastCreatedPublicShareToken(); string $fileName,
string $toFileName,
?string $password = ""
): ResponseInterface {
$token = ($this->featureContext->isUsingSharingNG())
? $this->featureContext->shareNgGetLastCreatedLinkShareToken()
: $this->featureContext->getLastCreatedPublicShareToken();
$davPath = WebDavHelper::getDavPath( $davPath = WebDavHelper::getDavPath(
WebDavHelper::DAV_VERSION_NEW, WebDavHelper::DAV_VERSION_NEW,
$token, $token,
@@ -215,7 +234,11 @@ class PublicWebDavContext implements Context {
* *
* @return void * @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->featureContext->setResponse(
$this->renameFileFromPublicShare($fileName, $toName, $password) $this->renameFileFromPublicShare($fileName, $toName, $password)
); );
@@ -231,7 +254,10 @@ class PublicWebDavContext implements Context {
* *
* @return void * @return void
*/ */
public function publicDownloadsFileFromInsideLastPublicSharedFolderWithPassword(string $path, string $password = ""):void { public function publicDownloadsFileFromInsideLastPublicSharedFolderWithPassword(
string $path,
string $password = ""
): void {
$response = $this->downloadFileFromPublicFolder( $response = $this->downloadFileFromPublicFolder(
$path, $path,
$password, $password,
@@ -249,7 +275,9 @@ class PublicWebDavContext implements Context {
*/ */
public function downloadFromPublicLinkAsUser(string $path, string $user): ResponseInterface { public function downloadFromPublicLinkAsUser(string $path, string $user): ResponseInterface {
$path = \ltrim($path, "/"); $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( $davPath = WebDavHelper::getDavPath(
$this->featureContext->getDavPathVersion(), $this->featureContext->getDavPathVersion(),
@@ -370,7 +398,9 @@ class PublicWebDavContext implements Context {
* @return void * @return void
*/ */
public function thePublicCopiesFileUsingTheWebDAVApi(string $source, string $destination): 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( $davPath = WebDavHelper::getDavPath(
WebDavHelper::DAV_VERSION_NEW, WebDavHelper::DAV_VERSION_NEW,
$token, $token,
@@ -420,7 +450,10 @@ class PublicWebDavContext implements Context {
* *
* @return void * @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); $response = $this->publiclyUploadingContentAutoRename($filename, $body);
$this->featureContext->theHTTPStatusCodeShouldBe([201, 204], "", $response); $this->featureContext->theHTTPStatusCodeShouldBe([201, 204], "", $response);
} }
@@ -455,7 +488,11 @@ class PublicWebDavContext implements Context {
* *
* @return void * @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( $response = $this->publiclyUploadingContentWithPassword(
$filename, $filename,
$password, $password,
@@ -956,7 +993,9 @@ class PublicWebDavContext implements Context {
string $destination, string $destination,
string $password string $password
): ResponseInterface { ): ResponseInterface {
$token = ($this->featureContext->isUsingSharingNG()) ? $this->featureContext->shareNgGetLastCreatedLinkShareToken() : $this->featureContext->getLastCreatedPublicShareToken(); $token = ($this->featureContext->isUsingSharingNG())
? $this->featureContext->shareNgGetLastCreatedLinkShareToken()
: $this->featureContext->getLastCreatedPublicShareToken();
$davPath = WebDavHelper::getDavPath( $davPath = WebDavHelper::getDavPath(
$this->featureContext->getDavPathVersion(), $this->featureContext->getDavPathVersion(),
$token, $token,
@@ -1046,7 +1085,9 @@ class PublicWebDavContext implements Context {
string $fileName, string $fileName,
string $mtime string $mtime
): void { ): 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(); $baseUrl = $this->featureContext->getBaseUrl();
$mtime = \explode(" ", $mtime); $mtime = \explode(" ", $mtime);
\array_pop($mtime); \array_pop($mtime);
@@ -1205,7 +1246,9 @@ class PublicWebDavContext implements Context {
} else { } else {
$body = null; $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( $davPath = WebDavHelper::getDavPath(
WebDavHelper::DAV_VERSION_NEW, WebDavHelper::DAV_VERSION_NEW,
$token, $token,
+5 -1
View File
@@ -84,7 +84,11 @@ class SearchContext implements Context {
$spaceId = $this->featureContext->spacesContext->getSpaceIdByName($user, $scope); $spaceId = $this->featureContext->spacesContext->getSpaceIdByName($user, $scope);
$pattern .= " scope:$spaceId"; $pattern .= " scope:$spaceId";
} else { } else {
$resourceID = $this->featureContext->spacesContext->getResourceId($user, $spaceName ?? "Personal", $scope); $resourceID = $this->featureContext->spacesContext->getResourceId(
$user,
$spaceName ?? "Personal",
$scope
);
$pattern .= " scope:$resourceID"; $pattern .= " scope:$resourceID";
} }
} }
+13 -3
View File
@@ -263,7 +263,11 @@ class SettingsContext implements Context {
$assignmentResponse = $this->featureContext->getJsonDecodedResponseBodyContent($response); $assignmentResponse = $this->featureContext->getJsonDecodedResponseBodyContent($response);
if (isset($assignmentResponse->assignments[0]->roleId)) { if (isset($assignmentResponse->assignments[0]->roleId)) {
$actualRoleId = $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 { } else {
Assert::fail("Response should contain user role but not found.\n" . json_encode($assignmentResponse)); Assert::fail("Response should contain user role but not found.\n" . json_encode($assignmentResponse));
} }
@@ -279,8 +283,14 @@ class SettingsContext implements Context {
* @throws Exception * @throws Exception
*/ */
public function theSettingApiResponseShouldHaveTheRole(string $role): void { public function theSettingApiResponseShouldHaveTheRole(string $role): void {
$assignmentRoleId = $this->featureContext->getJsonDecodedResponse($this->featureContext->getResponse())["assignments"][0]["roleId"]; $assignmentRoleId = $this->featureContext->getJsonDecodedResponse(
Assert::assertEquals($this->getRoleIdByRoleName($this->featureContext->getAdminUserName(), $role), $assignmentRoleId, "user has no role $role"); $this->featureContext->getResponse()
)["assignments"][0]["roleId"];
Assert::assertEquals(
$this->getRoleIdByRoleName($this->featureContext->getAdminUserName(), $role),
$assignmentRoleId,
"user has no role $role"
);
} }
/** /**
+124 -30
View File
@@ -213,7 +213,11 @@ trait Sharing {
public function shareNgGetLastCreatedLinkShareToken(): string { public function shareNgGetLastCreatedLinkShareToken(): string {
$lastResponse = $this->shareNgGetLastCreatedLinkShare(); $lastResponse = $this->shareNgGetLastCreatedLinkShare();
if (!isset($this->getJsonDecodedResponse($lastResponse)['link']['webUrl'])) { 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']; $last_created_link_webURL = $this->getJsonDecodedResponse($lastResponse)['link']['webUrl'];
return substr(strrchr($last_created_link_webURL, "/"), 1); 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['name'] = \array_key_exists('name', $bodyRows) ? $bodyRows['name'] : null;
$bodyRows['shareWith'] = \array_key_exists('shareWith', $bodyRows) ? $bodyRows['shareWith'] : null; $bodyRows['shareWith'] = \array_key_exists('shareWith', $bodyRows) ? $bodyRows['shareWith'] : null;
$bodyRows['shareWith'] = $this->getActualUsername($bodyRows['shareWith']); $bodyRows['shareWith'] = $this->getActualUsername($bodyRows['shareWith']);
$bodyRows['publicUpload'] = \array_key_exists('publicUpload', $bodyRows) ? $bodyRows['publicUpload'] === 'true' : null; $bodyRows['publicUpload'] = \array_key_exists(
$bodyRows['password'] = \array_key_exists('password', $bodyRows) ? $this->getActualPassword($bodyRows['password']) : null; '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 (\array_key_exists('permissions', $bodyRows)) {
if (\is_numeric($bodyRows['permissions'])) { if (\is_numeric($bodyRows['permissions'])) {
@@ -718,7 +728,8 @@ trait Sharing {
*/ */
public function getLastCreatedUserGroupShareId(?string $user = null): string { public function getLastCreatedUserGroupShareId(?string $user = null): string {
if ($user === null) { if ($user === null) {
$shareId = $this->isUsingSharingNG() ? $this->shareNgGetLastCreatedUserGroupShareID() : $this->getLastCreatedUserGroupShare()->id; $shareId = $this->isUsingSharingNG()
? $this->shareNgGetLastCreatedUserGroupShareID() : $this->getLastCreatedUserGroupShare()->id;
return (string) $shareId; return (string) $shareId;
} }
$createdShares = $this->getCreatedUserGroupShares(); $createdShares = $this->getCreatedUserGroupShares();
@@ -746,10 +757,12 @@ trait Sharing {
$user = $this->getActualUsername($user); $user = $this->getActualUsername($user);
if ($updateLastPublicLink) { if ($updateLastPublicLink) {
$share_id = ($this->isUsingSharingNG()) ? $this->shareNgGetLastCreatedLinkShareID() : (string) $this->getLastCreatedPublicShare()->id; $share_id = ($this->isUsingSharingNG())
? $this->shareNgGetLastCreatedLinkShareID() : (string) $this->getLastCreatedPublicShare()->id;
} else { } else {
if ($shareOwner === null) { if ($shareOwner === null) {
$share_id = ($this->isUsingSharingNG()) ? $this->shareNgGetLastCreatedUserGroupShareID() : $this->getLastCreatedUserGroupShareId(); $share_id = ($this->isUsingSharingNG())
? $this->shareNgGetLastCreatedUserGroupShareID() : $this->getLastCreatedUserGroupShareId();
} else { } else {
$share_id = $this->getLastCreatedUserGroupShareId($shareOwner); $share_id = $this->getLastCreatedUserGroupShareId($shareOwner);
} }
@@ -979,7 +992,12 @@ trait Sharing {
* @return bool * @return bool
* @throws Exception * @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) { if ($data === null) {
$data = HttpRequestHelper::getResponseXml($this->response, __METHOD__)->data[0]; $data = HttpRequestHelper::getResponseXml($this->response, __METHOD__)->data[0];
} }
@@ -1547,7 +1565,10 @@ trait Sharing {
* @return void * @return void
* @throws Exception * @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); $this->response = $this->updateLastShareWithSettings($user, $body, null, true);
} }
@@ -1652,15 +1673,21 @@ trait Sharing {
* *
* @return ResponseInterface * @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); $user = $this->getActualUsername($user);
if ($deleteLastPublicLink) { if ($deleteLastPublicLink) {
$shareId = (string) $this->getLastCreatedPublicShare()->id; $shareId = (string) $this->getLastCreatedPublicShare()->id;
} else { } else {
if ($sharer === null) { if ($sharer === null) {
$shareId = ($this->isUsingSharingNG()) ? $this->shareNgGetLastCreatedUserGroupShareID() : $this->getLastCreatedUserGroupShareId(); $shareId = ($this->isUsingSharingNG())
? $this->shareNgGetLastCreatedUserGroupShareID() : $this->getLastCreatedUserGroupShareId();
} else { } else {
$shareId = ($this->isUsingSharingNG()) ? $this->shareNgGetLastCreatedUserGroupShareID() : $this->getLastCreatedUserGroupShareId($sharer); $shareId = ($this->isUsingSharingNG())
? $this->shareNgGetLastCreatedUserGroupShareID() : $this->getLastCreatedUserGroupShareId($sharer);
} }
} }
$url = $this->getSharesEndpointPath("/$shareId"); $url = $this->getSharesEndpointPath("/$shareId");
@@ -1739,9 +1766,11 @@ trait Sharing {
*/ */
public function getLastShareInfo(string $user, string $shareType, ?string $language = null): ResponseInterface { public function getLastShareInfo(string $user, string $shareType, ?string $language = null): ResponseInterface {
if ($shareType !== "link") { if ($shareType !== "link") {
$shareId = $this->isUsingSharingNg() ? $this->shareNgGetLastCreatedUserGroupShareID() : $this->getLastCreatedUserGroupShareId(); $shareId = $this->isUsingSharingNg()
? $this->shareNgGetLastCreatedUserGroupShareID() : $this->getLastCreatedUserGroupShareId();
} else { } else {
$shareId = ($this->isUsingSharingNG()) ? $this->shareNgGetLastCreatedLinkShareID() : (string) $this->getLastCreatedPublicShare()->id; $shareId = ($this->isUsingSharingNG())
? $this->shareNgGetLastCreatedLinkShareID() : (string) $this->getLastCreatedPublicShare()->id;
} }
if ($shareId === null) { if ($shareId === null) {
throw new Exception( throw new Exception(
@@ -1869,7 +1898,8 @@ trait Sharing {
public function userGetsTheLastShareSharedWithHimUsingTheSharingApi(string $user, TableNode $table): void { public function userGetsTheLastShareSharedWithHimUsingTheSharingApi(string $user, TableNode $table): void {
$user = $this->getActualUsername($user); $user = $this->getActualUsername($user);
$this->verifyTableNodeRows($table, [], $this->shareResponseFields); $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); $response = $this->getShareData($user, $share_id);
$this->theHTTPStatusCodeShouldBe( $this->theHTTPStatusCodeShouldBe(
@@ -1898,7 +1928,11 @@ trait Sharing {
* *
* @return void * @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); $user = $this->getActualUsername($user);
if ($pending === "pending") { if ($pending === "pending") {
$pendingClause = "&state=" . SharingHelper::SHARE_STATES['pending']; $pendingClause = "&state=" . SharingHelper::SHARE_STATES['pending'];
@@ -1931,7 +1965,10 @@ trait Sharing {
* *
* @return void * @return void
*/ */
public function userGetsAllSharesSharedWithHimFromFileOrFolderUsingTheProvisioningApi(string $user, string $path):void { public function userGetsAllSharesSharedWithHimFromFileOrFolderUsingTheProvisioningApi(
string $user,
string $path
): void {
$user = $this->getActualUsername($user); $user = $this->getActualUsername($user);
$url = "/apps/files_sharing/api/" $url = "/apps/files_sharing/api/"
. "v$this->sharingApiVersion/shares?shared_with_me=true&path=$path"; . "v$this->sharingApiVersion/shares?shared_with_me=true&path=$path";
@@ -2167,7 +2204,8 @@ trait Sharing {
* @throws Exception * @throws Exception
*/ */
public function checkingLastShareIDIsIncluded(): void { public function checkingLastShareIDIsIncluded(): void {
$shareId = ($this->isUsingSharingNG()) ? $this->shareNgGetLastCreatedUserGroupShareID() : $this->getLastCreatedUserGroupShareId(); $shareId = ($this->isUsingSharingNG())
? $this->shareNgGetLastCreatedUserGroupShareID() : $this->getLastCreatedUserGroupShareId();
if (!$this->isFieldInResponse('id', $shareId)) { if (!$this->isFieldInResponse('id', $shareId)) {
Assert::fail( Assert::fail(
"Share id $shareId not found in response" "Share id $shareId not found in response"
@@ -2182,7 +2220,8 @@ trait Sharing {
* @throws Exception * @throws Exception
*/ */
public function checkLastShareIDIsNotIncluded(): void { public function checkLastShareIDIsNotIncluded(): void {
$shareId = $this->isUsingSharingNG() ? $this->shareNgGetLastCreatedUserGroupShareID() : $this->getLastCreatedUserGroupShareId(); $shareId = $this->isUsingSharingNG()
? $this->shareNgGetLastCreatedUserGroupShareID() : $this->getLastCreatedUserGroupShareId();
if ($this->isFieldInResponse('id', $shareId, false)) { if ($this->isFieldInResponse('id', $shareId, false)) {
Assert::fail( Assert::fail(
"Share id $shareId has been found in response" "Share id $shareId has been found in response"
@@ -2246,7 +2285,8 @@ trait Sharing {
public function userShouldNotSeeShareIdOfLastShare(string $user): void { public function userShouldNotSeeShareIdOfLastShare(string $user): void {
$response = $this->getSharedWithMeShares($user); $response = $this->getSharedWithMeShares($user);
$this->theHTTPStatusCodeShouldBe(200, "", $response); $this->theHTTPStatusCodeShouldBe(200, "", $response);
$shareId = $this->isUsingSharingNG() ? $this->shareNgGetLastCreatedUserGroupShareID() : $this->getLastCreatedUserGroupShareId(); $shareId = $this->isUsingSharingNG()
? $this->shareNgGetLastCreatedUserGroupShareID() : $this->getLastCreatedUserGroupShareId();
if ($this->isFieldInResponse('id', $shareId, false)) { if ($this->isFieldInResponse('id', $shareId, false)) {
Assert::fail( Assert::fail(
"Share id $shareId has been found in response" "Share id $shareId has been found in response"
@@ -2421,9 +2461,25 @@ trait Sharing {
$this->verifyTableNodeColumnsCount($body, 2); $this->verifyTableNodeColumnsCount($body, 2);
$bodyRows = $body->getRowsHash(); $bodyRows = $body->getRowsHash();
foreach ($bodyRows as $field => $value) { 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); $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->substituteInLineCodes($value, $sharee);
} }
$value = $this->replaceValuesFromTable($field, $value); $value = $this->replaceValuesFromTable($field, $value);
@@ -2768,7 +2824,13 @@ trait Sharing {
* *
* @return ResponseInterface * @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); $user = $this->getActualUsername($user);
$offeredBy = $this->getActualUsername($offeredBy); $offeredBy = $this->getActualUsername($offeredBy);
@@ -2830,7 +2892,13 @@ trait Sharing {
* @return void * @return void
* @throws Exception * @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( $response = $this->reactToShareOfferedBy(
$user, $user,
$action, $action,
@@ -2853,7 +2921,13 @@ trait Sharing {
* @return void * @return void
* @throws Exception * @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( $response = $this->reactToShareOfferedBy(
$user, $user,
$action, $action,
@@ -2875,7 +2949,12 @@ trait Sharing {
* @return void * @return void
* @throws Exception * @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"]); $this->verifyTableNodeColumns($table, ["path"]);
$paths = $table->getHash(); $paths = $table->getHash();
@@ -2935,7 +3014,12 @@ trait Sharing {
* @return void * @return void
* @throws Exception * @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( $response = $this->reactToShareOfferedBy(
$user, $user,
$action, $action,
@@ -3157,7 +3241,10 @@ trait Sharing {
* *
* @return ResponseInterface|null * @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); $user = $this->getActualUsername($user);
$share_id = $this->substituteInLineCodes($share_id, $user); $share_id = $this->substituteInLineCodes($share_id, $user);
$url = $this->getSharesEndpointPath("/$share_id"); $url = $this->getSharesEndpointPath("/$share_id");
@@ -3246,7 +3333,8 @@ trait Sharing {
* @return void * @return void
*/ */
public function thePublicAccessesThePreviewOfTheSharedFileUsingTheSharingApi(string $path): 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); $response = $this->getPublicPreviewOfFile($path, $token);
$this->setResponse($response); $this->setResponse($response);
$this->pushToLastStatusCodesArrays(); $this->pushToLastStatusCodesArrays();
@@ -3268,7 +3356,8 @@ trait Sharing {
$this->emptyLastHTTPStatusCodesArray(); $this->emptyLastHTTPStatusCodesArray();
$this->emptyLastOCSStatusCodesArray(); $this->emptyLastOCSStatusCodesArray();
foreach ($paths as $path) { foreach ($paths as $path) {
$token = ($this->isUsingSharingNG()) ? $this->shareNgGetLastCreatedLinkShareToken() : $this->getLastCreatedPublicShareToken(); $token = ($this->isUsingSharingNG())
? $this->shareNgGetLastCreatedLinkShareToken() : $this->getLastCreatedPublicShareToken();
$response = $this->getPublicPreviewOfFile($path["path"], $token); $response = $this->getPublicPreviewOfFile($path["path"], $token);
$this->setResponse($response); $this->setResponse($response);
$this->pushToLastStatusCodesArrays(); $this->pushToLastStatusCodesArrays();
@@ -3371,7 +3460,12 @@ trait Sharing {
* *
* @return array * @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 [ return [
"permissions" => $permissions, "permissions" => $permissions,
"expireDate" => "", "expireDate" => "",
+270 -61
View File
@@ -87,7 +87,8 @@ class SharingNgContext implements Context {
$bodyRows['quickLink'] = $bodyRows['quickLink'] ?? false; $bodyRows['quickLink'] = $bodyRows['quickLink'] ?? false;
$bodyRows['displayName'] = $bodyRows['displayName'] ?? null; $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; $bodyRows['password'] = $bodyRows['password'] ?? null;
$body = [ $body = [
'type' => $bodyRows['permissionsRole'], 'type' => $bodyRows['permissionsRole'],
@@ -154,7 +155,12 @@ class SharingNgContext implements Context {
* @return ResponseInterface * @return ResponseInterface
* @throws GuzzleException * @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"]; $spaceId = ($this->spacesContext->getSpaceByName($user, $space))["id"];
if ($fileOrFolder === 'folder') { if ($fileOrFolder === 'folder') {
@@ -184,7 +190,12 @@ class SharingNgContext implements Context {
* @return void * @return void
* @throws Exception * @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->featureContext->setResponse(
$this->getPermissionsList($user, $fileOrFolder, $space, $resource) $this->getPermissionsList($user, $fileOrFolder, $space, $resource)
); );
@@ -215,7 +226,11 @@ class SharingNgContext implements Context {
* @return void * @return void
* @throws Exception * @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"]; $spaceId = ($this->spacesContext->getSpaceByName($spaceOwner, $space))["id"];
$itemId = $this->spacesContext->getResourceId($spaceOwner, $space, ''); $itemId = $this->spacesContext->getResourceId($spaceOwner, $space, '');
@@ -287,7 +302,12 @@ class SharingNgContext implements Context {
if ($shareType === "user") { if ($shareType === "user") {
$shareeId = $this->featureContext->getAttributeOfCreatedUser($sharee, 'id'); $shareeId = $this->featureContext->getAttributeOfCreatedUser($sharee, 'id');
if ($federatedShare) { if ($federatedShare) {
$shareeId = ($this->featureContext->ocmContext->getAcceptedUserByName($user, $sharee))['user_id']; $shareeId = (
$this->featureContext->ocmContext->getAcceptedUserByName(
$user,
$sharee
)
)['user_id'];
} }
} elseif ($shareType === "group") { } elseif ($shareType === "group") {
$shareeId = $this->featureContext->getAttributeOfCreatedGroup($sharee, 'id'); $shareeId = $this->featureContext->getAttributeOfCreatedGroup($sharee, 'id');
@@ -333,7 +353,11 @@ class SharingNgContext implements Context {
* @throws GuzzleException * @throws GuzzleException
* @throws Exception * @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 = []; $shareeIds = [];
$rows = $table->getRowsHash(); $rows = $table->getRowsHash();
if ($rows['space'] === 'Personal' || $rows['space'] === 'Shares') { if ($rows['space'] === 'Personal' || $rows['space'] === 'Shares') {
@@ -396,7 +420,11 @@ class SharingNgContext implements Context {
*/ */
public function userHasSentTheFollowingResourceShareInvitation(string $user, TableNode $table): void { public function userHasSentTheFollowingResourceShareInvitation(string $user, TableNode $table): void {
$rows = $table->getRowsHash(); $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); $response = $this->sendShareInvitation($user, $rows);
$this->featureContext->theHTTPStatusCodeShouldBe(200, "", $response); $this->featureContext->theHTTPStatusCodeShouldBe(200, "", $response);
} }
@@ -411,9 +439,16 @@ class SharingNgContext implements Context {
* @throws Exception * @throws Exception
* @throws GuzzleException * @throws GuzzleException
*/ */
public function userHasSentTheFollowingResourceShareInvitationToFederatedUser(string $user, TableNode $table): void { public function userHasSentTheFollowingResourceShareInvitationToFederatedUser(
string $user,
TableNode $table
): void {
$rows = $table->getRowsHash(); $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); $response = $this->sendShareInvitation($user, $rows, null, true);
$this->featureContext->theHTTPStatusCodeShouldBe(200, "", $response); $this->featureContext->theHTTPStatusCodeShouldBe(200, "", $response);
} }
@@ -430,7 +465,11 @@ class SharingNgContext implements Context {
*/ */
public function userHasSentTheFollowingShareShareInvitation(string $user, TableNode $table): void { public function userHasSentTheFollowingShareShareInvitation(string $user, TableNode $table): void {
$rows = $table->getRowsHash(); $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); $response = $this->sendDriveShareInvitation($user, $table);
$this->featureContext->theHTTPStatusCodeShouldBe(200, "", $response); $this->featureContext->theHTTPStatusCodeShouldBe(200, "", $response);
} }
@@ -448,7 +487,11 @@ class SharingNgContext implements Context {
*/ */
public function userSendsTheFollowingResourceShareInvitationUsingTheGraphApi(string $user, TableNode $table): void { public function userSendsTheFollowingResourceShareInvitationUsingTheGraphApi(string $user, TableNode $table): void {
$rows = $table->getRowsHash(); $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->featureContext->setResponse(
$this->sendShareInvitation($user, $rows) $this->sendShareInvitation($user, $rows)
); );
@@ -464,9 +507,16 @@ class SharingNgContext implements Context {
* @throws Exception * @throws Exception
* @throws GuzzleException * @throws GuzzleException
*/ */
public function userSendsTheFollowingResourceShareInvitationToFederatedUserUsingTheGraphApi(string $user, TableNode $table): void { public function userSendsTheFollowingResourceShareInvitationToFederatedUserUsingTheGraphApi(
string $user,
TableNode $table
): void {
$rows = $table->getRowsHash(); $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->featureContext->setResponse(
$this->sendShareInvitation($user, $rows, null, true) $this->sendShareInvitation($user, $rows, null, true)
); );
@@ -482,9 +532,16 @@ class SharingNgContext implements Context {
* @throws Exception * @throws Exception
* @throws GuzzleException * @throws GuzzleException
*/ */
public function userSendsTheFollowingSpaceShareInvitationUsingPermissionsEndpointOfTheGraphApi(string $user, TableNode $table): void { public function userSendsTheFollowingSpaceShareInvitationUsingPermissionsEndpointOfTheGraphApi(
string $user,
TableNode $table
): void {
$rows = $table->getRowsHash(); $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->featureContext->setResponse(
$this->sendShareInvitation($user, $rows) $this->sendShareInvitation($user, $rows)
); );
@@ -500,9 +557,16 @@ class SharingNgContext implements Context {
* @throws Exception * @throws Exception
* @throws GuzzleException * @throws GuzzleException
*/ */
public function userSendsTheFollowingSpaceShareInvitationToFederatedUserUsingPermissionsEndpointOfTheGraphApi(string $user, TableNode $table): void { public function userSendsTheFollowingSpaceShareInvitationToFederatedUserUsingPermissionsEndpointOfTheGraphApi(
string $user,
TableNode $table
): void {
$rows = $table->getRowsHash(); $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->featureContext->setResponse(
$this->sendShareInvitation($user, $rows, null, true) $this->sendShareInvitation($user, $rows, null, true)
); );
@@ -555,7 +619,12 @@ class SharingNgContext implements Context {
* *
* @return void * @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 = ""; $permissionID = "";
if ($shareType === "user") { if ($shareType === "user") {
$permissionID = "u:" . $this->featureContext->getAttributeOfCreatedUser($sharee, 'id'); $permissionID = "u:" . $this->featureContext->getAttributeOfCreatedUser($sharee, 'id');
@@ -600,7 +669,8 @@ class SharingNgContext implements Context {
} }
if (\array_key_exists('expirationDateTime', $bodyRows)) { 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( return GraphHelper::updateShare(
@@ -626,7 +696,11 @@ class SharingNgContext implements Context {
* @throws JsonException * @throws JsonException
* @throws GuzzleException * @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(); $rows = $table->getRowsHash();
$this->featureContext->setResponse( $this->featureContext->setResponse(
$this->sendShareInvitation($user, $rows, $fileId) $this->sendShareInvitation($user, $rows, $fileId)
@@ -656,7 +730,10 @@ class SharingNgContext implements Context {
* @return void * @return void
* @throws GuzzleException * @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)); $this->featureContext->setResponse($this->createLinkShare($user, $body));
} }
@@ -671,7 +748,11 @@ class SharingNgContext implements Context {
*/ */
public function userHasCreatedTheFollowingResourceLinkShare(string $user, TableNode $body): void { public function userHasCreatedTheFollowingResourceLinkShare(string $user, TableNode $body): void {
$rows = $body->getRowsHash(); $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); $response = $this->createLinkShare($user, $body);
$this->featureContext->theHTTPStatusCodeShouldBe(200, "Failed while creating public share link!", $response); $this->featureContext->theHTTPStatusCodeShouldBe(200, "Failed while creating public share link!", $response);
$this->featureContext->shareNgAddToCreatedLinkShares($response); $this->featureContext->shareNgAddToCreatedLinkShares($response);
@@ -688,7 +769,11 @@ class SharingNgContext implements Context {
*/ */
public function userHasCreatedTheFollowingLinkShare(string $user, TableNode $body): void { public function userHasCreatedTheFollowingLinkShare(string $user, TableNode $body): void {
$rows = $body->getRowsHash(); $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); $response = $this->createDriveLinkShare($user, $body);
$this->featureContext->theHTTPStatusCodeShouldBe(200, "Failed while creating public share link!", $response); $this->featureContext->theHTTPStatusCodeShouldBe(200, "Failed while creating public share link!", $response);
$this->featureContext->shareNgAddToCreatedLinkShares($response); $this->featureContext->shareNgAddToCreatedLinkShares($response);
@@ -721,7 +806,10 @@ class SharingNgContext implements Context {
* @return void * @return void
* @throws Exception * @throws Exception
*/ */
public function userUpdatesTheLastPublicLinkShareUsingThePermissionsEndpointOfTheGraphApi(string $user, TableNode $body):void { public function userUpdatesTheLastPublicLinkShareUsingThePermissionsEndpointOfTheGraphApi(
string $user,
TableNode $body
): void {
$this->featureContext->setResponse( $this->featureContext->setResponse(
$this->updateLinkShare( $this->updateLinkShare(
$user, $user,
@@ -755,7 +843,8 @@ class SharingNgContext implements Context {
} }
if (\array_key_exists('expirationDateTime', $bodyRows)) { 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)) { if (\array_key_exists('displayName', $bodyRows)) {
@@ -824,7 +913,11 @@ class SharingNgContext implements Context {
$body, $body,
$this->featureContext->shareNgGetLastCreatedLinkShareID() $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 * @return void
* @throws Exception * @throws Exception
*/ */
public function userSetsOrUpdatesFollowingPasswordForLastLinkShareUsingTheGraphApi(string $user, TableNode $body):void { public function userSetsOrUpdatesFollowingPasswordForLastLinkShareUsingTheGraphApi(
string $user,
TableNode $body
): void {
$this->featureContext->setResponse( $this->featureContext->setResponse(
$this->setLinkSharePassword( $this->setLinkSharePassword(
$user, $user,
@@ -867,7 +963,8 @@ class SharingNgContext implements Context {
?string $recipient = null ?string $recipient = null
): ResponseInterface { ): ResponseInterface {
$spaceId = ($this->spacesContext->getSpaceByName($sharer, $space))["id"]; $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 = ""; $permissionID = "";
@@ -1158,7 +1255,11 @@ class SharingNgContext implements Context {
$itemId, $itemId,
$shareSpaceId, $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 * @return void
* @throws Exception * @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, '/'); $share = ltrim($share, '/');
$itemId = $this->spacesContext->getResourceId($offeredBy, $space, $share); $itemId = $this->spacesContext->getResourceId($offeredBy, $space, $share);
$shareSpaceId = GraphHelper::SHARES_SPACE_ID; $shareSpaceId = GraphHelper::SHARES_SPACE_ID;
@@ -1406,11 +1512,15 @@ class SharingNgContext implements Context {
* @throws Exception * @throws Exception
* @throws GuzzleException * @throws GuzzleException
*/ */
public function userShouldBeAbleToSendShareTheFollowingInvitationWithAllAllowedPermissionRoles(string $user, TableNode $table): void { public function userShouldBeAbleToSendShareTheFollowingInvitationWithAllAllowedPermissionRoles(
string $user,
TableNode $table
): void {
$listPermissionResponse = $this->featureContext->getJsonDecodedResponseBodyContent(); $listPermissionResponse = $this->featureContext->getJsonDecodedResponseBodyContent();
if (!isset($listPermissionResponse->{'@libre.graph.permissions.roles.allowedValues'})) { if (!isset($listPermissionResponse->{'@libre.graph.permissions.roles.allowedValues'})) {
Assert::fail( 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( Assert::assertNotEmpty(
@@ -1431,8 +1541,13 @@ class SharingNgContext implements Context {
foreach ($allowedPermissionRoles as $role) { 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) //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); $roleAllowed = GraphHelper::getPermissionNameByPermissionRoleId($role->id);
$responseSendInvitation = $this->sendShareInvitation($user, array_merge($rows, ['permissionsRole' => $roleAllowed])); $responseSendInvitation = $this->sendShareInvitation(
$jsonResponseSendInvitation = $this->featureContext->getJsonDecodedResponseBodyContent($responseSendInvitation); $user,
array_merge($rows, ['permissionsRole' => $roleAllowed])
);
$jsonResponseSendInvitation = $this->featureContext->getJsonDecodedResponseBodyContent(
$responseSendInvitation
);
$httpsStatusCode = $responseSendInvitation->getStatusCode(); $httpsStatusCode = $responseSendInvitation->getStatusCode();
if ($httpsStatusCode === 200 && !empty($jsonResponseSendInvitation->value)) { if ($httpsStatusCode === 200 && !empty($jsonResponseSendInvitation->value)) {
// remove the share so that the same user can be share for the next allowed roles // 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()); Assert::assertEquals(204, $removePermissionsResponse->getStatusCode());
} else { } else {
$areAllSendInvitationSuccessFullForAllowedRoles = false; $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); Assert::assertTrue($areAllSendInvitationSuccessFullForAllowedRoles, $shareInvitationRequestResult);
@@ -1479,7 +1595,10 @@ class SharingNgContext implements Context {
* @return void * @return void
* @throws GuzzleException * @throws GuzzleException
*/ */
public function userSendsTheFollowingShareInvitationUsingRootEndPointTheGraphApi(string $user, TableNode $table):void { public function userSendsTheFollowingShareInvitationUsingRootEndPointTheGraphApi(
string $user,
TableNode $table
): void {
$response = $this->sendDriveShareInvitation($user, $table); $response = $this->sendDriveShareInvitation($user, $table);
$this->featureContext->setResponse($response); $this->featureContext->setResponse($response);
} }
@@ -1493,7 +1612,10 @@ class SharingNgContext implements Context {
* @return void * @return void
* @throws GuzzleException * @throws GuzzleException
*/ */
public function userSendsTheFollowingShareInvitationToFederatedUserUsingRootEndPointTheGraphApi(string $user, TableNode $table):void { public function userSendsTheFollowingShareInvitationToFederatedUserUsingRootEndPointTheGraphApi(
string $user,
TableNode $table
): void {
$response = $this->sendDriveShareInvitation($user, $table, true); $response = $this->sendDriveShareInvitation($user, $table, true);
$this->featureContext->setResponse($response); $this->featureContext->setResponse($response);
} }
@@ -1507,7 +1629,10 @@ class SharingNgContext implements Context {
* @return void * @return void
* @throws GuzzleException * @throws GuzzleException
*/ */
public function userUpdatesTheLastDriveShareWithTheFollowingUsingRootEndpointOfTheGraphApi(string $user, TableNode $table): void { public function userUpdatesTheLastDriveShareWithTheFollowingUsingRootEndpointOfTheGraphApi(
string $user,
TableNode $table
): void {
$bodyRows = $table->getRowsHash(); $bodyRows = $table->getRowsHash();
$permissionID = match ($bodyRows['shareType']) { $permissionID = match ($bodyRows['shareType']) {
'user' => 'u:' . $this->featureContext->getAttributeOfCreatedUser($bodyRows['sharee'], 'id'), 'user' => 'u:' . $this->featureContext->getAttributeOfCreatedUser($bodyRows['sharee'], 'id'),
@@ -1523,7 +1648,8 @@ class SharingNgContext implements Context {
} }
if (\array_key_exists('expirationDateTime', $bodyRows)) { 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( $this->featureContext->setResponse(
@@ -1548,9 +1674,16 @@ class SharingNgContext implements Context {
* @return void * @return void
* @throws GuzzleException * @throws GuzzleException
*/ */
public function userCreatesTheFollowingSpaceLinkShareUsingRootEndpointOfTheGraphApi(string $user, TableNode $body): void { public function userCreatesTheFollowingSpaceLinkShareUsingRootEndpointOfTheGraphApi(
string $user,
TableNode $body
): void {
$rows = $body->getRowsHash(); $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); $response = $this->createDriveLinkShare($user, $body);
$this->featureContext->setResponse($response); $this->featureContext->setResponse($response);
@@ -1565,9 +1698,16 @@ class SharingNgContext implements Context {
* @return void * @return void
* @throws GuzzleException * @throws GuzzleException
*/ */
public function userSetsTheFollowingPasswordForTheLastSpaceLinkShareUsingRootEndpointOfTheGraphAPI(string $user, TableNode $body): void { public function userSetsTheFollowingPasswordForTheLastSpaceLinkShareUsingRootEndpointOfTheGraphAPI(
string $user,
TableNode $body
): void {
$rows = $body->getRowsHash(); $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"); Assert::assertArrayHasKey("password", $rows, "'password' is missing in the data-table");
$body = [ $body = [
@@ -1599,7 +1739,11 @@ class SharingNgContext implements Context {
* @return void * @return void
* @throws GuzzleException * @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(); $permissionID = $this->featureContext->shareNgGetLastCreatedLinkShareID();
$spaceId = ($this->spacesContext->getSpaceByName($spaceOwner, $space))["id"]; $spaceId = ($this->spacesContext->getSpaceByName($spaceOwner, $space))["id"];
@@ -1638,10 +1782,18 @@ class SharingNgContext implements Context {
foreach ($responseBody['value'] as $value) { foreach ($responseBody['value'] as $value) {
switch ($shareType) { switch ($shareType) {
case $shareType === 'link': 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; break;
case $shareType === "share": 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; break;
default: default:
Assert::fail('Invalid share type has been specified'); Assert::fail('Invalid share type has been specified');
@@ -1657,12 +1809,18 @@ class SharingNgContext implements Context {
* *
* @return void * @return void
* @throws GuzzleException * @throws GuzzleException
* @codingStandardsIgnoreStart
*/ */
public function userShouldBeAbleToSendTheFollowingSpaceShareInvitationWithAllAllowedPermissionRolesUsingRootEndpointOFTheGraphApi(string $user, TableNode $table): void { public function userShouldBeAbleToSendTheFollowingSpaceShareInvitationWithAllAllowedPermissionRolesUsingRootEndpointOFTheGraphApi(
// @codingStandardsIgnoreEnd
string $user,
TableNode $table
): void {
$listPermissionResponse = $this->featureContext->getJsonDecodedResponseBodyContent(); $listPermissionResponse = $this->featureContext->getJsonDecodedResponseBodyContent();
if (!isset($listPermissionResponse->{'@libre.graph.permissions.roles.allowedValues'})) { if (!isset($listPermissionResponse->{'@libre.graph.permissions.roles.allowedValues'})) {
Assert::fail( 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( Assert::assertNotEmpty(
@@ -1682,8 +1840,13 @@ class SharingNgContext implements Context {
foreach ($allowedPermissionRoles as $role) { foreach ($allowedPermissionRoles as $role) {
// we should be able to send share invitation for each of the roles allowed which are listed in permissions (allowed) // 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); $roleAllowed = GraphHelper::getPermissionNameByPermissionRoleId($role->id);
$responseSendInvitation = $this->sendDriveShareInvitation($user, new TableNode(array_merge($table->getTable(), [['permissionsRole', $roleAllowed]]))); $responseSendInvitation = $this->sendDriveShareInvitation(
$jsonResponseSendInvitation = $this->featureContext->getJsonDecodedResponseBodyContent($responseSendInvitation); $user,
new TableNode(array_merge($table->getTable(), [['permissionsRole', $roleAllowed]]))
);
$jsonResponseSendInvitation = $this->featureContext->getJsonDecodedResponseBodyContent(
$responseSendInvitation
);
$httpsStatusCode = $responseSendInvitation->getStatusCode(); $httpsStatusCode = $responseSendInvitation->getStatusCode();
if ($httpsStatusCode === 200 && !empty($jsonResponseSendInvitation->value)) { if ($httpsStatusCode === 200 && !empty($jsonResponseSendInvitation->value)) {
// remove the share so that the same user can be share for the next allowed roles // 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()); Assert::assertEquals(204, $removePermissionsResponse->getStatusCode());
} else { } else {
$areAllSendInvitationSuccessFullForAllowedRoles = false; $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); Assert::assertTrue($areAllSendInvitationSuccessFullForAllowedRoles, $shareInvitationRequestResult);
@@ -1707,7 +1871,11 @@ class SharingNgContext implements Context {
* @return void * @return void
* @throws GuzzleException * @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"]; $spaceId = ($this->spacesContext->getSpaceByName($spaceOwner, $space))["id"];
$response = GraphHelper::getDrivePermissionsList( $response = GraphHelper::getDrivePermissionsList(
@@ -1728,8 +1896,13 @@ class SharingNgContext implements Context {
* *
* @return void * @return void
*/ */
public function userRemovesTheLastLinkShareOfSpaceUsingPermissionsEndpointOfGraphApi(string $user, string $space):void { public function userRemovesTheLastLinkShareOfSpaceUsingPermissionsEndpointOfGraphApi(
$this->featureContext->setResponse($this->removeAccessToSpaceItem($user, 'link', $space, '')); string $user,
string $space
): void {
$this->featureContext->setResponse(
$this->removeAccessToSpaceItem($user, 'link', $space, '')
);
} }
/** /**
@@ -1745,7 +1918,14 @@ class SharingNgContext implements Context {
* @throws JsonException * @throws JsonException
* @throws Exception * @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, "/"); $share = \ltrim($share, "/");
if (\strtolower($space) === "personal") { if (\strtolower($space) === "personal") {
$remoteDriveAlias = "personal/" . \strtolower($sharer); $remoteDriveAlias = "personal/" . \strtolower($sharer);
@@ -1765,11 +1945,18 @@ class SharingNgContext implements Context {
$driveList = HttpRequestHelper::getJsonDecodedResponseBodyContent($response)->value; $driveList = HttpRequestHelper::getJsonDecodedResponseBodyContent($response)->value;
$foundShareMountpoint = false; $foundShareMountpoint = false;
foreach ($driveList as $drive) { 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; $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 // check share in shared-with-me list
@@ -1793,7 +1980,11 @@ class SharingNgContext implements Context {
break; 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 * @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"); $this->checkIfShareExists($share, $sharee, $sharer, $space, $shouldOrNot === "should");
} }
@@ -1822,7 +2019,13 @@ class SharingNgContext implements Context {
* *
* @return void * @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); $this->checkIfShareExists($share, $sharee, $sharer, $space, $shouldOrNot === "should", true);
} }
@@ -1837,7 +2040,13 @@ class SharingNgContext implements Context {
* *
* @return void * @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(); $rows = $table->getRows();
foreach ($rows as $row) { foreach ($rows as $row) {
if (isset($row[0])) { if (isset($row[0])) {
+432 -91
View File
@@ -203,7 +203,8 @@ class SpacesContext implements Context {
$this->$listSpacesFn($user); $this->$listSpacesFn($user);
$spaces = $this->getAvailableSpaces(); $spaces = $this->getAvailableSpaces();
$tryAgain = !\array_key_exists($spaceName, $spaces) && $retried < HttpRequestHelper::numRetriesOnHttpTooEarly(); $tryAgain = !\array_key_exists($spaceName, $spaces)
&& $retried < HttpRequestHelper::numRetriesOnHttpTooEarly();
if ($tryAgain) { if ($tryAgain) {
$retried += 1; $retried += 1;
echo "Space '$spaceName' not found for user '$user', retrying ($retried)...\n"; echo "Space '$spaceName' not found for user '$user', retrying ($retried)...\n";
@@ -213,7 +214,10 @@ class SpacesContext implements Context {
} while ($tryAgain); } while ($tryAgain);
Assert::assertArrayHasKey($spaceName, $spaces, "Space with name '$spaceName' for user '$user' not found"); 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]; return $spaces[$spaceName];
} }
@@ -275,7 +279,12 @@ class SpacesContext implements Context {
* @return ResponseInterface * @return ResponseInterface
* @throws GuzzleException * @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(); $baseUrl = $this->featureContext->getBaseUrl();
if ($federatedShare) { if ($federatedShare) {
@@ -373,7 +382,15 @@ class SpacesContext implements Context {
"files", "files",
WebDavHelper::DAV_VERSION_SPACES 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"); Assert::assertNotEmpty($responseArray, "the PROPFIND response for $spaceName is empty");
return $responseArray[0][0]; return $responseArray[0][0];
} }
@@ -539,7 +556,11 @@ class SpacesContext implements Context {
* @throws GuzzleException * @throws GuzzleException
* @throws Exception * @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( $response = GraphHelper::getMySpaces(
$this->featureContext->getBaseUrl(), $this->featureContext->getBaseUrl(),
$user, $user,
@@ -580,7 +601,10 @@ class SpacesContext implements Context {
* @throws GuzzleException * @throws GuzzleException
* @throws Exception * @throws Exception
*/ */
public function theUserListsAllHisAvailableSpacesWithHeadersUsingTheGraphApi(string $user, TableNode $headersTable): void { public function theUserListsAllHisAvailableSpacesWithHeadersUsingTheGraphApi(
string $user,
TableNode $headersTable
): void {
$this->featureContext->verifyTableNodeColumns( $this->featureContext->verifyTableNodeColumns(
$headersTable, $headersTable,
['header', 'value'] ['header', 'value']
@@ -645,7 +669,11 @@ class SpacesContext implements Context {
* @return void * @return void
* @throws GuzzleException * @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); $space = $this->getSpaceByName(($ownerUser !== "") ? $ownerUser : $user, $spaceName);
Assert::assertIsArray($space); Assert::assertIsArray($space);
Assert::assertNotEmpty($space["id"]); Assert::assertNotEmpty($space["id"]);
@@ -777,7 +805,12 @@ class SpacesContext implements Context {
* @return void * @return void
* @throws GuzzleException * @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); $space = $this->getSpaceByName($owner, $spaceName);
Assert::assertIsArray($space); Assert::assertIsArray($space);
Assert::assertNotEmpty($spaceId = $space["id"]); Assert::assertNotEmpty($spaceId = $space["id"]);
@@ -835,7 +868,14 @@ class SpacesContext implements Context {
): void { ): void {
$space = $this->getSpaceByName($user, $spaceName); $space = $this->getSpaceByName($user, $spaceName);
$this->featureContext->setResponse($this->propfindSpace($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 $share,
string $fileContent string $fileContent
): void { ): 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"); Assert::assertEquals($fileContent, $actualFileContent, "File content did not match");
} }
@@ -1010,7 +1055,10 @@ class SpacesContext implements Context {
"Expected response status code should be 200", "Expected response status code should be 200",
$response $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"]; $permissions = $spaceAsArray["root"]["permissions"];
$userId = $this->featureContext->getUserIdByUserName($grantedUser); $userId = $this->featureContext->getUserIdByUserName($grantedUser);
@@ -1036,7 +1084,10 @@ class SpacesContext implements Context {
public function jsonRespondedShouldNotContain( public function jsonRespondedShouldNotContain(
string $spaceName string $spaceName
): void { ): 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 $response
); );
if (\trim($shouldOrNot) === "not") { 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 { } 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 GuzzleException
* @throws Exception * @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); $spaceId = $this->getSpaceIdByName($user, $spaceName);
$response = $this->featureContext->uploadFile($user, $source, $destination, $spaceId); $response = $this->featureContext->uploadFile($user, $source, $destination, $spaceId);
$this->featureContext->theHTTPStatusCodeShouldBe( $this->featureContext->theHTTPStatusCodeShouldBe(
@@ -1415,7 +1477,12 @@ class SpacesContext implements Context {
string $destination string $destination
): void { ): void {
$spaceId = $this->getSpaceIdByName($ownerUser, $spaceName); $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); $this->featureContext->setResponse($response);
} }
@@ -1475,7 +1542,9 @@ class SpacesContext implements Context {
string $owner = '' string $owner = ''
): void { ): void {
$bodyData = ["Name" => $newName]; $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 = '' string $owner = ''
): void { ): void {
$bodyData = ["description" => $newDescription]; $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 = '' string $owner = ''
): void { ): void {
$bodyData = ["quota" => ["total" => $newQuota]]; $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 $fileDestination,
string $spaceName string $spaceName
): void { ): void {
$this->featureContext->setResponse($this->moveFileWithinSpace($user, $fileSource, $fileDestination, $spaceName)); $this->featureContext->setResponse(
$this->moveFileWithinSpace(
$user,
$fileSource,
$fileDestination,
$spaceName
)
);
$this->featureContext->pushToLastHttpStatusCodesArray(); $this->featureContext->pushToLastHttpStatusCodesArray();
} }
@@ -1901,7 +1981,11 @@ class SpacesContext implements Context {
TableNode $table = null TableNode $table = null
): void { ): void {
$space = $this->getSpaceByName($user, $fromSpaceName); $space = $this->getSpaceByName($user, $fromSpaceName);
$headers['Destination'] = $this->destinationHeaderValueWithSpaceName($user, $fileDestination, $toSpaceName); $headers['Destination'] = $this->destinationHeaderValueWithSpaceName(
$user,
$fileDestination,
$toSpaceName
);
if ($table !== null) { if ($table !== null) {
$this->featureContext->verifyTableNodeColumns( $this->featureContext->verifyTableNodeColumns(
@@ -1943,7 +2027,11 @@ class SpacesContext implements Context {
string $action string $action
): void { ): void {
$space = $this->getSpaceByName($user, $fromSpaceName); $space = $this->getSpaceByName($user, $fromSpaceName);
$headers['Destination'] = $this->destinationHeaderValueWithSpaceName($user, $fileDestination, $toSpaceName); $headers['Destination'] = $this->destinationHeaderValueWithSpaceName(
$user,
$fileDestination,
$toSpaceName
);
$headers['Overwrite'] = 'T'; $headers['Overwrite'] = 'T';
$encodedName = \rawurlencode(ltrim($fileSource, "/")); $encodedName = \rawurlencode(ltrim($fileSource, "/"));
@@ -1975,7 +2063,11 @@ class SpacesContext implements Context {
string $fileName, string $fileName,
string $spaceName string $spaceName
): void { ): void {
$response = $this->featureContext->downloadFileAsUserUsingPassword($user, $fileName, $this->featureContext->getPasswordForUser($user)); $response = $this->featureContext->downloadFileAsUserUsingPassword(
$user,
$fileName,
$this->featureContext->getPasswordForUser($user)
);
Assert::assertGreaterThanOrEqual( Assert::assertGreaterThanOrEqual(
400, 400,
$response->getStatusCode(), $response->getStatusCode(),
@@ -2011,7 +2103,11 @@ class SpacesContext implements Context {
string $toSpaceName string $toSpaceName
): void { ): void {
$space = $this->getSpaceByName($user, $fromSpaceName); $space = $this->getSpaceByName($user, $fromSpaceName);
$headers['Destination'] = $this->destinationHeaderValueWithSpaceName($user, $fileDestination, $toSpaceName); $headers['Destination'] = $this->destinationHeaderValueWithSpaceName(
$user,
$fileDestination,
$toSpaceName
);
$encodedName = \rawurlencode(ltrim($fileSource, "/")); $encodedName = \rawurlencode(ltrim($fileSource, "/"));
$baseUrl = $this->featureContext->getBaseUrl(); $baseUrl = $this->featureContext->getBaseUrl();
@@ -2033,7 +2129,12 @@ class SpacesContext implements Context {
* @return string * @return string
* @throws GuzzleException * @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); $space = $this->getSpaceByName($user, $spaceName);
$fileDestination = $this->escapePath(\ltrim($fileDestination, "/")); $fileDestination = $this->escapePath(\ltrim($fileDestination, "/"));
$baseUrl = $this->featureContext->getBaseUrl(); $baseUrl = $this->featureContext->getBaseUrl();
@@ -2075,7 +2176,14 @@ class SpacesContext implements Context {
* @throws GuzzleException * @throws GuzzleException
* @return void * @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, "/"); $destinationFile = \trim($destinationFile, "/");
$destinationFolder = \trim($destinationFolder, "/"); $destinationFolder = \trim($destinationFolder, "/");
$fileDestination = $destinationFolder . '/' . $this->escapePath($destinationFile); $fileDestination = $destinationFolder . '/' . $this->escapePath($destinationFile);
@@ -2086,13 +2194,22 @@ class SpacesContext implements Context {
$davPath = WebDavHelper::getDavPath($this->featureContext->getDavPathVersion()); $davPath = WebDavHelper::getDavPath($this->featureContext->getDavPathVersion());
$headers['Destination'] = "$baseUrl/$davPath/$sharesPath"; $headers['Destination'] = "$baseUrl/$davPath/$sharesPath";
} else { } else {
$headers['Destination'] = $this->destinationHeaderValueWithSpaceName($user, $fileDestination, $toSpaceName, $fileId); $headers['Destination'] = $this->destinationHeaderValueWithSpaceName(
$user,
$fileDestination,
$toSpaceName,
$fileId
);
} }
$fullUrl = "$baseUrl/$sourceDavPath/$fileId"; $fullUrl = "$baseUrl/$sourceDavPath/$fileId";
if ($actionType === 'copies') { if ($actionType === 'copies') {
$this->featureContext->setResponse($this->copyFilesAndFoldersRequest($user, $fullUrl, $headers)); $this->featureContext->setResponse(
$this->copyFilesAndFoldersRequest($user, $fullUrl, $headers)
);
} else { } 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()); $davPath = WebDavHelper::getDavPath($this->featureContext->getDavPathVersion());
$headers['Destination'] = "$baseUrl/$davPath/$sharesPath"; $headers['Destination'] = "$baseUrl/$davPath/$sharesPath";
} else { } else {
$headers['Destination'] = $this->destinationHeaderValueWithSpaceName($user, $fileDestination, $spaceName, $fileId); $headers['Destination'] = $this->destinationHeaderValueWithSpaceName(
$user,
$fileDestination,
$spaceName,
$fileId
);
} }
$fullUrl = "$baseUrl/$sourceDavPath/$fileId"; $fullUrl = "$baseUrl/$sourceDavPath/$fileId";
$this->featureContext->setResponse($this->moveFilesAndFoldersRequest($user, $fullUrl, $headers)); $this->featureContext->setResponse($this->moveFilesAndFoldersRequest($user, $fullUrl, $headers));
@@ -2163,7 +2285,12 @@ class SpacesContext implements Context {
$davPath = WebDavHelper::getDavPath($this->featureContext->getDavPathVersion()); $davPath = WebDavHelper::getDavPath($this->featureContext->getDavPathVersion());
$headers['Destination'] = "$baseUrl/$davPath/$sharesPath"; $headers['Destination'] = "$baseUrl/$davPath/$sharesPath";
} else { } else {
$headers['Destination'] = $this->destinationHeaderValueWithSpaceName($user, $fileDestination, $spaceName, $fileId); $headers['Destination'] = $this->destinationHeaderValueWithSpaceName(
$user,
$fileDestination,
$spaceName,
$fileId
);
} }
$fullUrl = "$baseUrl/$sourceDavPath/$fileId"; $fullUrl = "$baseUrl/$sourceDavPath/$fileId";
if ($actionType === 'copied') { if ($actionType === 'copied') {
@@ -2206,7 +2333,12 @@ class SpacesContext implements Context {
$davPath = WebDavHelper::getDavPath($this->featureContext->getDavPathVersion()); $davPath = WebDavHelper::getDavPath($this->featureContext->getDavPathVersion());
$headers['Destination'] = "$baseUrl/$davPath/$sharesPath"; $headers['Destination'] = "$baseUrl/$davPath/$sharesPath";
} else { } else {
$headers['Destination'] = $this->destinationHeaderValueWithSpaceName($user, $fileDestination, $spaceName, $fileId); $headers['Destination'] = $this->destinationHeaderValueWithSpaceName(
$user,
$fileDestination,
$spaceName,
$fileId
);
} }
$fullUrl = "$baseUrl/$sourceDavPath/$fileId"; $fullUrl = "$baseUrl/$sourceDavPath/$fileId";
$response = $this->moveFilesAndFoldersRequest($user, $fullUrl, $headers); $response = $this->moveFilesAndFoldersRequest($user, $fullUrl, $headers);
@@ -2279,7 +2411,13 @@ class SpacesContext implements Context {
$response = $this->listAllAvailableSpacesOfUser($user); $response = $this->listAllAvailableSpacesOfUser($user);
$this->featureContext->theHTTPStatusCodeShouldBe(200, "", $response); $this->featureContext->theHTTPStatusCodeShouldBe(200, "", $response);
$spaceId = $this->getSpaceIdByName($user, $spaceName); $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); $this->featureContext->theHTTPStatusCodeShouldBe(['201', '204'], "", $response);
return $response->getHeader('oc-fileid'); return $response->getHeader('oc-fileid');
} }
@@ -2353,7 +2491,12 @@ class SpacesContext implements Context {
* @return void * @return void
* @throws GuzzleException * @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'); $dateTime = new DateTime('yesterday');
$rows['expireDate'] = $dateTime->format('Y-m-d\\TH:i:sP'); $rows['expireDate'] = $dateTime->format('Y-m-d\\TH:i:sP');
$rows['shareWith'] = $memberUser; $rows['shareWith'] = $memberUser;
@@ -2473,7 +2616,9 @@ class SpacesContext implements Context {
* @throws JsonException * @throws JsonException
*/ */
public function updateSharedResource(string $user, array $rows): ResponseInterface { 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; $fullUrl = $this->featureContext->getBaseUrl() . $this->ocsApiUrl . '/' . $shareId;
return HttpRequestHelper::sendRequest( return HttpRequestHelper::sendRequest(
$fullUrl, $fullUrl,
@@ -2496,7 +2641,11 @@ class SpacesContext implements Context {
* @return void * @return void
* @throws GuzzleException|JsonException * @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'); $dateTime = new DateTime('yesterday');
$rows['expireDate'] = $dateTime->format('Y-m-d\\TH:i:sP'); $rows['expireDate'] = $dateTime->format('Y-m-d\\TH:i:sP');
if ($this->featureContext->isUsingSharingNG()) { if ($this->featureContext->isUsingSharingNG()) {
@@ -2541,7 +2690,8 @@ class SpacesContext implements Context {
$rows["path"] = \array_key_exists("path", $rows) ? $rows["path"] : null; $rows["path"] = \array_key_exists("path", $rows) ? $rows["path"] : null;
$rows["shareType"] = \array_key_exists("shareType", $rows) ? $rows["shareType"] : 3; $rows["shareType"] = \array_key_exists("shareType", $rows) ? $rows["shareType"] : 3;
$rows["permissions"] = \array_key_exists("permissions", $rows) ? $rows["permissions"] : null; $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["name"] = \array_key_exists("name", $rows) ? $rows["name"] : null;
$rows["expireDate"] = \array_key_exists("expireDate", $rows) ? $rows["expireDate"] : null; $rows["expireDate"] = \array_key_exists("expireDate", $rows) ? $rows["expireDate"] : null;
@@ -2683,7 +2833,8 @@ class SpacesContext implements Context {
string $recipient string $recipient
): ResponseInterface { ): ResponseInterface {
$space = $this->getSpaceByName($user, $spaceName); $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( return HttpRequestHelper::delete(
$fullUrl, $fullUrl,
@@ -2996,7 +3147,11 @@ class SpacesContext implements Context {
): ResponseInterface { ): ResponseInterface {
$space = $this->getSpaceByName($user, $spaceName); $space = $this->getSpaceByName($user, $spaceName);
$baseUrl = $this->featureContext->getBaseUrl(); $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"; $fullUrl = "$baseUrl/$davPath";
return HttpRequestHelper::sendRequest( return HttpRequestHelper::sendRequest(
$fullUrl, $fullUrl,
@@ -3041,10 +3196,20 @@ class SpacesContext implements Context {
// get space by admin user // get space by admin user
$space = $this->getSpaceByName($this->featureContext->getAdminUserName(), $spaceName); $space = $this->getSpaceByName($this->featureContext->getAdminUserName(), $spaceName);
$baseUrl = $this->featureContext->getBaseUrl(); $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"; $fullUrl = "$baseUrl/$davPath";
$this->featureContext->setResponse( $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 === "") { 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(); $baseUrl = $this->featureContext->getBaseUrl();
@@ -3193,7 +3360,9 @@ class SpacesContext implements Context {
} }
if ($pathToDeletedObject === "") { 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; $fullUrl = $this->featureContext->getBaseUrl() . $pathToDeletedObject;
@@ -3272,7 +3441,13 @@ class SpacesContext implements Context {
string $spaceName string $spaceName
): void { ): void {
$spaceId = $this->getSpaceIdByName($user, $spaceName); $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); $this->featureContext->setResponse($response);
} }
@@ -3292,7 +3467,9 @@ class SpacesContext implements Context {
string $spaceName string $spaceName
): void { ): void {
$spaceId = $this->getSpaceIdByName($user, $spaceName); $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 { ): void {
$spaceId = $this->getSpaceIdByName($user, $spaceName); $spaceId = $this->getSpaceIdByName($user, $spaceName);
$this->featureContext->setResponse( $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 string $spaceName
): void { ): void {
$spaceId = $this->getSpaceIdByName($user, $spaceName); $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 * @return void
* @throws GuzzleException * @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 === "") { if ($storePath === "") {
$storePath = $path; $storePath = $path;
} }
@@ -3451,11 +3642,13 @@ class SpacesContext implements Context {
$storedEtag = $this->getStoredEtagForPathInSpaceOfAUser($user, $space, $path); $storedEtag = $this->getStoredEtagForPathInSpaceOfAUser($user, $space, $path);
if ($action === 'should' && $etag === $storedEtag) { if ($action === 'should' && $etag === $storedEtag) {
$changedEtagCount++; $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) { if ($action === 'should not' && $etag !== $storedEtag) {
$changedEtagCount++; $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 * @return void
* @throws Exception | GuzzleException * @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); $user = $this->featureContext->getActualUsername($user);
$this->storeEtagOfElementInSpaceForUser( $this->storeEtagOfElementInSpaceForUser(
$user, $user,
@@ -3503,7 +3701,9 @@ class SpacesContext implements Context {
$path, $path,
$storePath $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!"); 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["shareType"] = \array_key_exists("shareType", $rows) ? $rows["shareType"] : 3;
$rows["permissions"] = \array_key_exists("permissions", $rows) ? $rows["permissions"] : null; $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["name"] = \array_key_exists("name", $rows) ? $rows["name"] : null;
$rows["expireDate"] = \array_key_exists("expireDate", $rows) ? $rows["expireDate"] : null; $rows["expireDate"] = \array_key_exists("expireDate", $rows) ? $rows["expireDate"] : null;
@@ -3549,7 +3750,9 @@ class SpacesContext implements Context {
$this->featureContext->getStepLineRef() $this->featureContext->getStepLineRef()
); );
$this->featureContext->addToCreatedPublicShares(HttpRequestHelper::getResponseXml($response, __METHOD__)->data); $this->featureContext->addToCreatedPublicShares(
HttpRequestHelper::getResponseXml($response, __METHOD__)->data
);
return $response; return $response;
} }
@@ -3639,16 +3842,25 @@ class SpacesContext implements Context {
); );
$should = ($shouldOrNot !== "not"); $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) { if ($should) {
Assert::assertNotEmpty($responseArray, __METHOD__ . ' Response should contain a link, but it is empty'); Assert::assertNotEmpty($responseArray, __METHOD__ . ' Response should contain a link, but it is empty');
foreach ($responseArray as $element) { foreach ($responseArray as $element) {
if ($shareType === 'public link') { 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"); Assert::assertEquals($element["id"], $expectedLinkId, "link IDs are different");
} else { } 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"); Assert::assertEquals($element["id"], $expectedShareId, "share IDs are different");
} }
} }
@@ -3676,7 +3888,12 @@ class SpacesContext implements Context {
TableNode $propertiesTable TableNode $propertiesTable
): void { ): void {
$spaceId = $this->getSpaceIdByName($user, $spaceName); $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); $this->featureContext->setResponse($response);
} }
@@ -3702,7 +3919,12 @@ class SpacesContext implements Context {
// short wait is necessary before getting those properties // short wait is necessary before getting those properties
sleep(2); sleep(2);
$spaceId = $this->getSpaceIdByName($user, $spaceName); $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); $this->featureContext->setResponse($response);
} }
@@ -3727,7 +3949,14 @@ class SpacesContext implements Context {
string $value string $value
): void { ): void {
$spaceId = $this->getSpaceIdByName($user, $spaceName); $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 * @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); $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 GuzzleException
* @throws JsonException * @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); $this->getSpaceIdByName($user, $spaceName);
$user = $this->featureContext->getActualUsername($user); $user = $this->featureContext->getActualUsername($user);
$currentFileID = $this->featureContext->getFileIdForPath($user, $path); $currentFileID = $this->featureContext->getFileIdForPath($user, $path);
@@ -3798,7 +4042,8 @@ class SpacesContext implements Context {
$currentFileID, $currentFileID,
$storedFileID, $storedFileID,
__METHOD__ __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 { public function searchResultShouldContainSpace(string $user, string $spaceName): void {
// get a response after a Report request (called in the core) // 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"); Assert::assertNotEmpty($responseArray, "search result is empty");
// for mountpoint, id looks a little different than for project space // for mountpoint, id looks a little different than for project space
@@ -3857,7 +4109,11 @@ class SpacesContext implements Context {
* *
* @throws GuzzleException * @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->featureContext->setResponse(
$this->sendPropfindRequestToSpace($user, $spaceName, "", null, $folderDepth) $this->sendPropfindRequestToSpace($user, $spaceName, "", null, $folderDepth)
); );
@@ -3878,7 +4134,12 @@ class SpacesContext implements Context {
* *
* @throws GuzzleException * @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); $response = $this->sendPropfindRequestToSpace($user, $spaceName, $resource, null, $folderDepth);
$this->featureContext->setResponse($response); $this->featureContext->setResponse($response);
} }
@@ -3896,7 +4157,11 @@ class SpacesContext implements Context {
* *
* @throws GuzzleException * @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( $this->featureContext->verifyTableNodeColumns(
$headersTable, $headersTable,
['header', 'value'] ['header', 'value']
@@ -3922,7 +4187,13 @@ class SpacesContext implements Context {
* *
* @throws JsonException * @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); $spaceId = $this->getSpaceIdByName($user, $spaceName);
$properties = [ $properties = [
'oc:id', 'oc:id',
@@ -3984,7 +4255,12 @@ class SpacesContext implements Context {
* @throws GuzzleException * @throws GuzzleException
* @throws JsonException * @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']); $this->featureContext->verifyTableNodeColumns($table, ['key', 'value']);
if ($this->featureContext->getDavPathVersion() === WebDavHelper::DAV_VERSION_SPACES && $type === 'space') { if ($this->featureContext->getDavPathVersion() === WebDavHelper::DAV_VERSION_SPACES && $type === 'space') {
$space = $this->getSpaceByName($user, $resource); $space = $this->getSpaceByName($user, $resource);
@@ -4006,7 +4282,11 @@ class SpacesContext implements Context {
* *
* @return string * @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) return "Using xpaths:\n\t- " . \join("\n\t- ", $xpaths)
. "\n" . "\n"
. $message . $message
@@ -4022,7 +4302,11 @@ class SpacesContext implements Context {
* @return string * @return string
* @throws Exception * @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 . "/preceding-sibling::$siblingToFind";
$xpaths[] = $siblingXpath . "/following-sibling::$siblingToFind"; $xpaths[] = $siblingXpath . "/following-sibling::$siblingToFind";
@@ -4032,7 +4316,11 @@ class SpacesContext implements Context {
break; 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); Assert::assertNotEmpty($foundSibling, $errorMessage);
return \preg_quote($foundSibling[0]->__toString(), "/"); return \preg_quote($foundSibling[0]->__toString(), "/");
} }
@@ -4067,10 +4355,15 @@ class SpacesContext implements Context {
if ($property['key'] === 'oc:name') { if ($property['key'] === 'oc:name') {
$xpath = "//oc:name[text()='$decodedResource']"; $xpath = "//oc:name[text()='$decodedResource']";
} elseif (\array_key_exists('oc:shareroot', $properties)) { } 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()='"
$xpaths[] = "//oc:name[text()='$resource']/preceding-sibling::oc:shareroot[text()='" . $properties['oc:shareroot'] . "'/following-sibling::/"; . $properties['oc:shareroot'] . "'/preceding-sibling::/";
$xpaths[] = "//oc:name[text()='$resource']/following-sibling::oc:shareroot[text()='" . $properties['oc:shareroot'] . "'/preceding-sibling::/"; $xpaths[] = "//oc:name[text()='$resource']/preceding-sibling::oc:shareroot[text()='"
$xpaths[] = "//oc:name[text()='$resource']/following-sibling::oc:shareroot[text()='" . $properties['oc:shareroot'] . "'/following-sibling::/"; . $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 { } else {
$xpaths[] = "//oc:name[text()='$decodedResource']/preceding-sibling::"; $xpaths[] = "//oc:name[text()='$decodedResource']/preceding-sibling::";
$xpaths[] = "//oc:name[text()='$decodedResource']/following-sibling::"; $xpaths[] = "//oc:name[text()='$decodedResource']/following-sibling::";
@@ -4097,11 +4390,19 @@ class SpacesContext implements Context {
Assert::assertCount( Assert::assertCount(
1, 1,
$foundXmlItem, $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( Assert::assertNotEmpty(
$foundXmlItem, $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(); $actualValue = $foundXmlItem[0]->__toString();
@@ -4131,15 +4432,27 @@ class SpacesContext implements Context {
switch ($itemToFind) { switch ($itemToFind) {
case "oc:fileid": case "oc:fileid":
$expectedValue = GraphHelper::jsonSchemaRegexToPureRegex($expectedValue); $expectedValue = GraphHelper::jsonSchemaRegexToPureRegex($expectedValue);
Assert::assertMatchesRegularExpression($expectedValue, $actualValue, 'wrong "fileid" in the response'); Assert::assertMatchesRegularExpression(
$expectedValue,
$actualValue,
'wrong "fileid" in the response'
);
break; break;
case "oc:file-parent": case "oc:file-parent":
$expectedValue = GraphHelper::jsonSchemaRegexToPureRegex($expectedValue); $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; break;
case "oc:privatelink": case "oc:privatelink":
$expectedValue = GraphHelper::jsonSchemaRegexToPureRegex($expectedValue); $expectedValue = GraphHelper::jsonSchemaRegexToPureRegex($expectedValue);
Assert::assertMatchesRegularExpression($expectedValue, $actualValue, 'wrong "privatelink" in the response'); Assert::assertMatchesRegularExpression(
$expectedValue,
$actualValue,
'wrong "privatelink" in the response'
);
break; break;
case "oc:tags": case "oc:tags":
// The value should be a comma-separated string of tag names. // The value should be a comma-separated string of tag names.
@@ -4167,7 +4480,11 @@ class SpacesContext implements Context {
break; break;
case "oc:remote-item-id": case "oc:remote-item-id":
$expectedValue = GraphHelper::jsonSchemaRegexToPureRegex($expectedValue); $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; break;
default: default:
Assert::assertEquals($expectedValue, $actualValue, "wrong '$itemToFind' in the response"); Assert::assertEquals($expectedValue, $actualValue, "wrong '$itemToFind' in the response");
@@ -4186,7 +4503,11 @@ class SpacesContext implements Context {
* @return void * @return void
* @throws GuzzleException * @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__); $responseXmlObject = HttpRequestHelper::getResponseXml($this->featureContext->getResponse(), __METHOD__);
$fileId = $responseXmlObject->xpath("//oc:name[text()='$resource']/preceding-sibling::$key")[0]->__toString(); $fileId = $responseXmlObject->xpath("//oc:name[text()='$resource']/preceding-sibling::$key")[0]->__toString();
@@ -4219,7 +4540,9 @@ class SpacesContext implements Context {
* @throws Exception * @throws Exception
*/ */
public function publicDownloadsTheFolderFromTheLastCreatedPublicLink(string $resource) { 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( $responseXmlObject = HttpRequestHelper::getResponseXml(
$this->featureContext->listFolder( $this->featureContext->listFolder(
@@ -4293,14 +4616,26 @@ class SpacesContext implements Context {
"Expected response status code should be 200", "Expected response status code should be 200",
$response $response
); );
Assert::assertIsArray($spaceAsArray = $this->getSpaceByNameFromResponse($spaceName, $response), "No space with name $spaceName found"); Assert::assertIsArray(
$recipientType === 'user' ? $recipientId = $this->featureContext->getUserIdByUserName($recipient) : $recipientId = $this->featureContext->getGroupIdByGroupName($recipient); $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; $foundRoleInResponse = false;
foreach ($spaceAsArray['root']['permissions'] as $permission) { 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; $foundRoleInResponse = true;
if ($expirationDate !== null && isset($permission['expirationDateTime'])) { 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; break;
} }
@@ -4344,7 +4679,12 @@ class SpacesContext implements Context {
* @return void * @return void
* @throws GuzzleException * @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); $sharer = $this->featureContext->getActualUsername($sharer);
$resource_id = $this->getResourceId($sharer, $space, $path); $resource_id = $this->getResourceId($sharer, $space, $path);
$response = $this->featureContext->createShare( $response = $this->featureContext->createShare(
@@ -4367,7 +4707,8 @@ class SpacesContext implements Context {
Assert::assertContainsEquals( Assert::assertContainsEquals(
$responseStatusCode, $responseStatusCode,
$statusCodes, $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 Exception
* @throws GuzzleException * @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); $spaceId = $this->spacesContext->getSpaceIdByName($user, $spaceName);
$this->tusContext->uploadFileUsingTus($user, $source, $destination, $spaceId); $this->tusContext->uploadFileUsingTus($user, $source, $destination, $spaceId);
$this->featureContext->setLastUploadDeleteTime(\time()); $this->featureContext->setLastUploadDeleteTime(\time());
@@ -175,7 +180,12 @@ class SpacesTUSContext implements Context {
* @return void * @return void
* @throws Exception|GuzzleException * @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 = $this->spacesContext->getSharesRemoteItemId($user, $destination);
$remoteItemId = \rawurlencode($remoteItemId); $remoteItemId = \rawurlencode($remoteItemId);
$tmpFile = $this->tusContext->writeDataToTempFile($content); $tmpFile = $this->tusContext->writeDataToTempFile($content);
@@ -293,8 +303,10 @@ class SpacesTUSContext implements Context {
* *
* @return void * @return void
* @throws Exception|GuzzleException * @throws Exception|GuzzleException
* @codingStandardsIgnoreStart
*/ */
public function userHasUploadedFileWithChecksumToTheLastCreatedTusLocationWithOffsetAndContentViaTusInsideOfTheSpaceUsingTheWebdavApi( public function userHasUploadedFileWithChecksumToTheLastCreatedTusLocationWithOffsetAndContentViaTusInsideOfTheSpaceUsingTheWebdavApi(
// @codingStandardsIgnoreEnd
string $user, string $user,
string $checksum, string $checksum,
string $offset, string $offset,
@@ -317,8 +329,10 @@ class SpacesTUSContext implements Context {
* *
* @return void * @return void
* @throws Exception|GuzzleException * @throws Exception|GuzzleException
* @codingStandardsIgnoreStart
*/ */
public function userUploadsFileWithChecksumToTheLastCreatedTusLocationWithOffsetAndContentViaTusInsideOfTheSpaceUsingTheWebdavApi( public function userUploadsFileWithChecksumToTheLastCreatedTusLocationWithOffsetAndContentViaTusInsideOfTheSpaceUsingTheWebdavApi(
// @codingStandardsIgnoreEnd
string $user, string $user,
string $checksum, string $checksum,
string $offset, string $offset,
@@ -341,8 +355,10 @@ class SpacesTUSContext implements Context {
* *
* @return void * @return void
* @throws Exception|GuzzleException * @throws Exception|GuzzleException
* @codingStandardsIgnoreStart
*/ */
public function userSendsAChunkToTheLastCreatedTusLocationWithOffsetAndDataWithChecksumViaTusInsideOfTheSpaceUsingTheWebdavApi( public function userSendsAChunkToTheLastCreatedTusLocationWithOffsetAndDataWithChecksumViaTusInsideOfTheSpaceUsingTheWebdavApi(
// @codingStandardsIgnoreEnd
string $user, string $user,
string $offset, string $offset,
string $data, string $data,
@@ -371,7 +387,14 @@ class SpacesTUSContext implements Context {
): void { ): void {
$rows = $headers->getRowsHash(); $rows = $headers->getRowsHash();
$resourceLocation = $this->tusContext->getLastTusResourceLocation(); $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); $this->featureContext->setResponse($response);
} }
@@ -387,8 +410,10 @@ class SpacesTUSContext implements Context {
* *
* @return void * @return void
* @throws GuzzleException * @throws GuzzleException
* @codingStandardsIgnoreStart
*/ */
public function userOverwritesRecentlySharedFileWithOffsetAndDataWithChecksumViaTusInsideOfTheSpaceUsingTheWebdavApiWithTheseHeaders( public function userOverwritesRecentlySharedFileWithOffsetAndDataWithChecksumViaTusInsideOfTheSpaceUsingTheWebdavApiWithTheseHeaders(
// @codingStandardsIgnoreEnd
string $user, string $user,
string $offset, string $offset,
string $data, string $data,
+33 -5
View File
@@ -97,7 +97,12 @@ class TUSContext implements Context {
* @throws Exception * @throws Exception
* @throws GuzzleException * @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); $this->featureContext->verifyTableNodeColumnsCount($headersTable, 2);
$user = $this->featureContext->getActualUsername($user); $user = $this->featureContext->getActualUsername($user);
$password = $this->featureContext->getUserPassword($user); $password = $this->featureContext->getUserPassword($user);
@@ -182,7 +187,14 @@ class TUSContext implements Context {
* @throws GuzzleException * @throws GuzzleException
* @throws JsonException * @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); $user = $this->featureContext->getActualUsername($user);
$password = $this->featureContext->getUserPassword($user); $password = $this->featureContext->getUserPassword($user);
$headers = [ $headers = [
@@ -631,7 +643,12 @@ class TUSContext implements Context {
* @return void * @return void
* @throws Exception * @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(); $resourceLocation = $this->getLastTusResourceLocation();
$response = $this->uploadChunkToTUSLocation($user, $resourceLocation, $offset, $data, $checksum); $response = $this->uploadChunkToTUSLocation($user, $resourceLocation, $offset, $data, $checksum);
$this->featureContext->setResponse($response); $this->featureContext->setResponse($response);
@@ -648,7 +665,12 @@ class TUSContext implements Context {
* @return void * @return void
* @throws Exception * @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(); $resourceLocation = $this->getLastTusResourceLocation();
$response = $this->uploadChunkToTUSLocation($user, $resourceLocation, $offset, $data, $checksum); $response = $this->uploadChunkToTUSLocation($user, $resourceLocation, $offset, $data, $checksum);
$this->featureContext->theHTTPStatusCodeShouldBe(204, "", $response); $this->featureContext->theHTTPStatusCodeShouldBe(204, "", $response);
@@ -669,7 +691,13 @@ class TUSContext implements Context {
* @throws GuzzleException * @throws GuzzleException
* @throws Exception * @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); $createResponse = $this->createNewTUSResource($user, $headers);
$this->featureContext->theHTTPStatusCodeShouldBe(201, "", $createResponse); $this->featureContext->theHTTPStatusCodeShouldBe(201, "", $createResponse);
$resourceLocation = $this->getLastTusResourceLocation(); $resourceLocation = $this->getLastTusResourceLocation();
+58 -9
View File
@@ -64,7 +64,13 @@ class TagContext implements Context {
* @return ResponseInterface * @return ResponseInterface
* @throws Exception * @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 = []; $tagNameArray = [];
foreach ($table->getRows() as $value) { foreach ($table->getRows() as $value) {
$tagNameArray[] = $value[0]; $tagNameArray[] = $value[0];
@@ -97,7 +103,13 @@ class TagContext implements Context {
* @return void * @return void
* @throws Exception * @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); $response = $this->createTags($user, $fileOrFolder, $resource, $space, $table);
$this->featureContext->setResponse($response); $this->featureContext->setResponse($response);
} }
@@ -114,7 +126,13 @@ class TagContext implements Context {
* @return void * @return void
* @throws Exception * @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); $response = $this->createTags($user, $fileOrFolder, $resource, $space, $table);
$this->featureContext->theHttpStatusCodeShouldBe(200, "", $response); $this->featureContext->theHttpStatusCodeShouldBe(200, "", $response);
} }
@@ -130,7 +148,12 @@ class TagContext implements Context {
* @return void * @return void
* @throws Exception * @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"]); $this->featureContext->verifyTableNodeColumns($table, ["path", "tagName"]);
$rows = $table->getHash(); $rows = $table->getHash();
foreach ($rows as $row) { foreach ($rows as $row) {
@@ -174,7 +197,9 @@ class TagContext implements Context {
public function theFollowingTagsShouldExistForUser(string $shouldOrNot, TableNode $table): void { public function theFollowingTagsShouldExistForUser(string $shouldOrNot, TableNode $table): void {
$rows = $table->getRows(); $rows = $table->getRows();
foreach ($rows as $row) { foreach ($rows as $row) {
$responseArray = $this->featureContext->getJsonDecodedResponse($this->featureContext->getResponse())['value']; $responseArray = $this->featureContext->getJsonDecodedResponse(
$this->featureContext->getResponse()
)['value'];
if ($shouldOrNot === "not") { if ($shouldOrNot === "not") {
Assert::assertFalse( Assert::assertFalse(
\in_array($row[0], $responseArray), \in_array($row[0], $responseArray),
@@ -201,7 +226,13 @@ class TagContext implements Context {
* @return ResponseInterface * @return ResponseInterface
* @throws Exception * @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 = []; $tagNameArray = [];
foreach ($table->getRows() as $value) { foreach ($table->getRows() as $value) {
$tagNameArray[] = $value[0]; $tagNameArray[] = $value[0];
@@ -235,8 +266,20 @@ class TagContext implements Context {
* @return void * @return void
* @throws Exception * @throws Exception
*/ */
public function userRemovesTagsFromResourceOfTheSpace(string $user, string $fileOrFolder, string $resource, string $space, TableNode $table):void { public function userRemovesTagsFromResourceOfTheSpace(
$response = $this->removeTagsFromResourceOfTheSpace($user, $fileOrFolder, $resource, $space, $table); string $user,
string $fileOrFolder,
string $resource,
string $space,
TableNode $table
): void {
$response = $this->removeTagsFromResourceOfTheSpace(
$user,
$fileOrFolder,
$resource,
$space,
$table
);
$this->featureContext->setResponse($response); $this->featureContext->setResponse($response);
} }
@@ -252,7 +295,13 @@ class TagContext implements Context {
* @return void * @return void
* @throws Exception * @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); $response = $this->removeTagsFromResourceOfTheSpace($user, $fileOrFolder, $resource, $space, $table);
$this->featureContext->theHttpStatusCodeShouldBe(200, "", $response); $this->featureContext->theHttpStatusCodeShouldBe(200, "", $response);
} }
+73 -15
View File
@@ -109,7 +109,9 @@ class TrashbinContext implements Context {
$name = $successPropStat->xpath('./d:prop/oc:trashbin-original-filename'); $name = $successPropStat->xpath('./d:prop/oc:trashbin-original-filename');
$mtime = $successPropStat->xpath('./d:prop/oc:trashbin-delete-timestamp'); $mtime = $successPropStat->xpath('./d:prop/oc:trashbin-delete-timestamp');
$resourcetype = $successPropStat->xpath('./d:prop/d:resourcetype'); $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; $collection[0] = true;
} else { } else {
$collection[0] = false; $collection[0] = false;
@@ -224,7 +226,12 @@ class TrashbinContext implements Context {
* @return array response * @return array response
* @throws Exception * @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 // $collectionPath should be some list of file-ids like 2147497661/2147497662
// or the empty string, which will list the whole trashbin from the top. // or the empty string, which will list the whole trashbin from the top.
$collectionPath = \trim($collectionPath, "/"); $collectionPath = \trim($collectionPath, "/");
@@ -251,7 +258,11 @@ class TrashbinContext implements Context {
$response->getBody()->rewind(); $response->getBody()->rewind();
$statusCode = $response->getStatusCode(); $statusCode = $response->getStatusCode();
$respBody = $response->getBody()->getContents(); $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( $files = $this->getTrashbinContentFromResponseXml(
HttpRequestHelper::getResponseXml( HttpRequestHelper::getResponseXml(
@@ -345,7 +356,9 @@ class TrashbinContext implements Context {
*/ */
public function theTrashbinDavResponseShouldNotContainTheseNodes(TableNode $table): void { public function theTrashbinDavResponseShouldNotContainTheseNodes(TableNode $table): void {
$this->featureContext->verifyTableNodeColumns($table, ['name']); $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) { foreach ($table->getHash() as $row) {
$path = trim((string)$row['name'], "/"); $path = trim((string)$row['name'], "/");
@@ -368,7 +381,9 @@ class TrashbinContext implements Context {
public function theTrashbinDavResponseShouldContainTheseNodes(TableNode $table): void { public function theTrashbinDavResponseShouldContainTheseNodes(TableNode $table): void {
$this->featureContext->verifyTableNodeColumns($table, ['name']); $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) { foreach ($table->getHash() as $row) {
$path = trim($row['name'], "/"); $path = trim($row['name'], "/");
@@ -395,7 +410,11 @@ class TrashbinContext implements Context {
* @return ResponseInterface * @return ResponseInterface
* @throws Exception * @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; $asUser = $asUser ?? $user;
$password = $password ?? $this->featureContext->getPasswordForUser($asUser); $password = $password ?? $this->featureContext->getPasswordForUser($asUser);
@@ -445,7 +464,11 @@ class TrashbinContext implements Context {
* @return void * @return void
* @throws Exception * @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); $response = $this->sendTrashbinListRequest($user, $asUser, $password);
$this->featureContext->setResponse($response); $this->featureContext->setResponse($response);
} }
@@ -482,7 +505,9 @@ class TrashbinContext implements Context {
* @throws Exception * @throws Exception
*/ */
public function theLastWebdavResponseShouldNotContainFollowingElements(TableNode $elements): void { 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 // 'user' is also allowed in the table even though it is not used anywhere
// This for better readability in feature files // This for better readability in feature files
@@ -530,7 +555,12 @@ class TrashbinContext implements Context {
* @throws JsonException * @throws JsonException
* @throws Exception * @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); $response = $this->deleteItemFromTrashbin($user, $path, $ofUser, $password);
$this->featureContext->setResponse($response); $this->featureContext->setResponse($response);
} }
@@ -565,7 +595,12 @@ class TrashbinContext implements Context {
* @throws JsonException * @throws JsonException
* @throws Exception * @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); $asUser = $this->featureContext->getActualUsername($asUser);
$user = $this->featureContext->getActualUsername($user); $user = $this->featureContext->getActualUsername($user);
$response = $this->restoreElement($user, $path, null, $asUser, $password); $response = $this->restoreElement($user, $path, null, $asUser, $password);
@@ -596,7 +631,10 @@ class TrashbinContext implements Context {
* *
* @return void * @return void
*/ */
public function userTriesToDeleteFileWithOriginalPathFromTrashbinUsingTrashbinAPI(string $user, string $originalPath):void { public function userTriesToDeleteFileWithOriginalPathFromTrashbinUsingTrashbinAPI(
string $user,
string $originalPath
): void {
$response = $this->deleteItemFromTrashbin($user, $originalPath); $response = $this->deleteItemFromTrashbin($user, $originalPath);
$this->featureContext->setResponse($response); $this->featureContext->setResponse($response);
} }
@@ -609,7 +647,12 @@ class TrashbinContext implements Context {
* *
* @return ResponseInterface * @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; $ofUser = $ofUser ?? $user;
$user = $this->featureContext->getActualUsername($user); $user = $this->featureContext->getActualUsername($user);
$ofUser = $this->featureContext->getActualUsername($ofUser); $ofUser = $this->featureContext->getActualUsername($ofUser);
@@ -781,7 +824,13 @@ class TrashbinContext implements Context {
* @throws JsonException * @throws JsonException
* @throws GuzzleException * @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; $asUser = $asUser ?? $user;
$password = $password ?? $this->featureContext->getPasswordForUser($asUser); $password = $password ?? $this->featureContext->getPasswordForUser($asUser);
$destinationPath = \trim($destinationPath, '/'); $destinationPath = \trim($destinationPath, '/');
@@ -834,7 +883,13 @@ class TrashbinContext implements Context {
* @throws JsonException * @throws JsonException
* @throws GuzzleException * @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; $asUser = $asUser ?? $user;
$listing = $this->listTrashbinFolder($user); $listing = $this->listTrashbinFolder($user);
$originalPath = \trim($originalPath, '/'); $originalPath = \trim($originalPath, '/');
@@ -870,7 +925,10 @@ class TrashbinContext implements Context {
* @return void * @return void
* @throws Exception * @throws Exception
*/ */
public function userRestoresResourceWithOriginalPathWithoutSpecifyingDestinationUsingTrashbinApi(string $user, string $originalPath):void { public function userRestoresResourceWithOriginalPathWithoutSpecifyingDestinationUsingTrashbinApi(
string $user,
string $originalPath
): void {
$listing = $this->listTrashbinFolder($user); $listing = $this->listTrashbinFolder($user);
$originalPath = \trim($originalPath, '/'); $originalPath = \trim($originalPath, '/');
+161 -39
View File
@@ -198,7 +198,6 @@ trait WebDav {
break; break;
default: default:
throw new Exception("Invalid DAV path: $davChoice"); throw new Exception("Invalid DAV path: $davChoice");
break;
} }
} }
@@ -349,7 +348,13 @@ trait WebDav {
* @throws JsonException | GuzzleException * @throws JsonException | GuzzleException
* @throws GuzzleException | JsonException * @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( return $this->makeDavRequest(
$user, $user,
"MKCOL", "MKCOL",
@@ -377,7 +382,13 @@ trait WebDav {
* @return ResponseInterface * @return ResponseInterface
* @throws GuzzleException * @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); $user = $this->getActualUsername($user);
$doDavRequestAsUser = $this->getActualUsername($doDavRequestAsUser); $doDavRequestAsUser = $this->getActualUsername($doDavRequestAsUser);
$doDavRequestAsUser = $doDavRequestAsUser ?? $user; $doDavRequestAsUser = $doDavRequestAsUser ?? $user;
@@ -595,7 +606,12 @@ trait WebDav {
* @return void * @return void
* @throws Exception * @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); $user = $this->getActualUsername($user);
$this->checkFileOrFolderExistsForUser($user, $entry, $source); $this->checkFileOrFolderExistsForUser($user, $entry, $source);
$response = $this->moveResource($user, $source, $destination); $response = $this->moveResource($user, $source, $destination);
@@ -615,7 +631,12 @@ trait WebDav {
* @return void * @return void
* @throws Exception * @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); $this->checkFileOrFolderExistsForUser($user, $entry, $source);
$response = $this->moveResource($user, $source, $destination); $response = $this->moveResource($user, $source, $destination);
$this->theHTTPStatusCodeShouldBeBetween(400, 499, $response); $this->theHTTPStatusCodeShouldBeBetween(400, 499, $response);
@@ -684,7 +705,8 @@ trait WebDav {
$response = $this->copyFile($user, $fileSource, $fileDestination); $response = $this->copyFile($user, $fileSource, $fileDestination);
$this->theHTTPStatusCodeShouldBe( $this->theHTTPStatusCodeShouldBe(
["201", "204"], ["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 $response
); );
} }
@@ -851,7 +873,8 @@ trait WebDav {
Assert::assertEquals( Assert::assertEquals(
$expectedContent, $expectedContent,
$actualContent, $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( Assert::assertEquals(
$content, $content,
$actualContent, $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 * @throws Exception
*/ */
public function publicGetsSizeOfLastSharedPublicLinkUsingTheWebdavApi(): void { 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"); $davPath = WebDavHelper::getDavPath($this->getDavPathVersion(), $token, "public-files");
$url = "{$this->getBaseUrl()}/$davPath"; $url = "{$this->getBaseUrl()}/$davPath";
$this->response = HttpRequestHelper::sendRequest( $this->response = HttpRequestHelper::sendRequest(
@@ -1609,7 +1634,8 @@ trait WebDav {
$response = $this->uploadFile($user, $source, $destination, null, true); $response = $this->uploadFile($user, $source, $destination, null, true);
$this->theHTTPStatusCodeShouldBe( $this->theHTTPStatusCodeShouldBe(
["201", "204"], ["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 $response
); );
return $response->getHeader('oc-fileid'); return $response->getHeader('oc-fileid');
@@ -1791,7 +1817,10 @@ trait WebDav {
* @return void * @return void
* @throws Exception * @throws Exception
*/ */
public function theHTTPStatusCodeOfResponsesOnEachEndpointShouldBeOcisReva(string $ocisStatusCodes, string $revaStatusCodes):void { public function theHTTPStatusCodeOfResponsesOnEachEndpointShouldBeOcisReva(
string $ocisStatusCodes,
string $revaStatusCodes
): void {
if (OcisHelper::isTestingOnReva()) { if (OcisHelper::isTestingOnReva()) {
$expectedStatusCodes = $revaStatusCodes; $expectedStatusCodes = $revaStatusCodes;
} else { } else {
@@ -1897,7 +1926,8 @@ trait WebDav {
Assert::assertSame( Assert::assertSame(
$initialContent, $initialContent,
$currentContent, $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 { } else {
$this->checkFileOrFolderDoesNotExistsForUser($user, "file", $destination); $this->checkFileOrFolderDoesNotExistsForUser($user, "file", $destination);
@@ -1989,7 +2019,12 @@ trait WebDav {
* @return void * @return void
* @throws Exception * @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"; $filename = "filespecificSize.txt";
$this->createLocalFileOfSpecificSize($filename, $bytes, $text); $this->createLocalFileOfSpecificSize($filename, $bytes, $text);
Assert::assertFileExists($this->workStorageDirLocation() . $filename); Assert::assertFileExists($this->workStorageDirLocation() . $filename);
@@ -2021,7 +2056,9 @@ trait WebDav {
$user = $this->getActualUsername($user); $user = $this->getActualUsername($user);
$this->pauseUploadDelete(); $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"); $spaceId = $this->spacesContext->getSpaceIdByName($user, "Shares");
$destination = \str_replace("Shares/", "", $destination); $destination = \str_replace("Shares/", "", $destination);
} }
@@ -2392,7 +2429,8 @@ trait WebDav {
); );
$this->theHTTPStatusCodeShouldBe( $this->theHTTPStatusCodeShouldBe(
["201", "204"], ["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 $response
); );
} }
@@ -2468,7 +2506,12 @@ trait WebDav {
* *
* @return void * @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(); $baseUrl = $this->getBaseUrl();
$davPath = WebDavHelper::getDavPath($this->getDavPathVersion()); $davPath = WebDavHelper::getDavPath($this->getDavPathVersion());
$user = $this->getActualUsername($user); $user = $this->getActualUsername($user);
@@ -2722,7 +2765,11 @@ trait WebDav {
* @return void * @return void
* @throws Exception * @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); $user = $this->getActualUsername($user);
$response = $this->createFolder($user, $destination, true, $password); $response = $this->createFolder($user, $destination, true, $password);
$this->theHTTPStatusCodeShouldBe( $this->theHTTPStatusCodeShouldBe(
@@ -2767,7 +2814,11 @@ trait WebDav {
* @return void * @return void
* @throws Exception * @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); $user = $this->getActualUsername($user);
$response = $this->createFolder($user, $destination, false, $password); $response = $this->createFolder($user, $destination, false, $password);
$this->theHTTPStatusCodeShouldBeBetween(400, 499, $response); $this->theHTTPStatusCodeShouldBeBetween(400, 499, $response);
@@ -2958,7 +3009,13 @@ trait WebDav {
$chunkNumber = (int)$chunkDetail['number']; $chunkNumber = (int)$chunkDetail['number'];
$chunkContent = $chunkDetail['content']; $chunkContent = $chunkDetail['content'];
if ($isGivenStep) { if ($isGivenStep) {
$response = $this->userUploadNewChunkFileOfWithToId($user, $chunkNumber, $chunkContent, $chunkingId, true); $response = $this->userUploadNewChunkFileOfWithToId(
$user,
$chunkNumber,
$chunkContent,
$chunkingId,
true
);
$this->theHTTPStatusCodeShouldBeBetween(200, 299, $response); $this->theHTTPStatusCodeShouldBeBetween(200, 299, $response);
} else { } else {
$response = $this->userUploadNewChunkFileOfWithToId($user, $chunkNumber, $chunkContent, $chunkingId); $response = $this->userUploadNewChunkFileOfWithToId($user, $chunkNumber, $chunkContent, $chunkingId);
@@ -3488,7 +3545,12 @@ trait WebDav {
* *
* @return void * @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); $user = $this->getActualUsername($user);
$urlParameter = [ $urlParameter = [
'x' => $width, 'x' => $width,
@@ -3521,7 +3583,12 @@ trait WebDav {
* *
* @return void * @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) { if ($this->getDavPathVersion() === WebDavHelper::DAV_VERSION_SPACES) {
$this->setResponse($this->downloadSharedFilePreview($user, $path, $width, $height)); $this->setResponse($this->downloadSharedFilePreview($user, $path, $width, $height));
} else { } else {
@@ -3540,7 +3607,13 @@ trait WebDav {
* *
* @return void * @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); $user = $this->getActualUsername($user);
$urlParameter = [ $urlParameter = [
'x' => $width, 'x' => $width,
@@ -3574,7 +3647,12 @@ trait WebDav {
* *
* @return void * @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); $user = $this->getActualUsername($user);
$urlParameter = [ $urlParameter = [
'x' => $width, 'x' => $width,
@@ -3609,7 +3687,12 @@ trait WebDav {
* *
* @return void * @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) { if ($this->getDavPathVersion() === WebDavHelper::DAV_VERSION_SPACES) {
$response = $this->downloadSharedFilePreview($user, $path, $width, $height); $response = $this->downloadSharedFilePreview($user, $path, $width, $height);
} else { } else {
@@ -3633,7 +3716,12 @@ trait WebDav {
* *
* @return void * @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) { if ($this->getDavPathVersion() === WebDavHelper::DAV_VERSION_SPACES) {
$response = $this->downloadSharedFilePreview($user, $path, $width, $height); $response = $this->downloadSharedFilePreview($user, $path, $width, $height);
} else { } else {
@@ -3662,7 +3750,11 @@ trait WebDav {
* *
* @return void * @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)); $this->setResponse($this->uploadFileWithContent($user, $content, $destination));
} }
@@ -3754,7 +3846,13 @@ trait WebDav {
* *
* @return void * @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( $response = $this->downloadPreviews(
$ofUser, $ofUser,
$path, $path,
@@ -3819,7 +3917,12 @@ trait WebDav {
* *
* @return void * @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( $response = $this->downloadPreviews(
$user, $user,
$path, $path,
@@ -3844,7 +3947,12 @@ trait WebDav {
* *
* @return void * @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( $response = $this->downloadPreviews(
$user, $user,
$path, $path,
@@ -3917,7 +4025,8 @@ trait WebDav {
$currentFileID, $currentFileID,
$this->storedFileID, $this->storedFileID,
__METHOD__ __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 * @return void
* @throws Exception * @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( $response = $this->listFolder(
$user, $user,
$path, $path,
@@ -4234,7 +4347,8 @@ trait WebDav {
* @throws Exception * @throws Exception
*/ */
public function theLastPublicDavResponseShouldContainTheseNodes(TableNode $table): void { public function theLastPublicDavResponseShouldContainTheseNodes(TableNode $table): void {
$token = ($this->isUsingSharingNG()) ? $this->shareNgGetLastCreatedLinkShareToken() : $this->getLastCreatedPublicShareToken(); $token = ($this->isUsingSharingNG())
? $this->shareNgGetLastCreatedLinkShareToken() : $this->getLastCreatedPublicShareToken();
$this->verifyTableNodeColumns($table, ["name"]); $this->verifyTableNodeColumns($table, ["name"]);
foreach ($table->getHash() as $row) { foreach ($table->getHash() as $row) {
@@ -4253,7 +4367,8 @@ trait WebDav {
* @throws Exception * @throws Exception
*/ */
public function theLastPublicDavResponseShouldNotContainTheseNodes(TableNode $table): void { public function theLastPublicDavResponseShouldNotContainTheseNodes(TableNode $table): void {
$token = ($this->isUsingSharingNG()) ? $this->shareNgGetLastCreatedLinkShareToken() : $this->getLastCreatedPublicShareToken(); $token = ($this->isUsingSharingNG())
? $this->shareNgGetLastCreatedLinkShareToken() : $this->getLastCreatedPublicShareToken();
$this->verifyTableNodeColumns($table, ["name"]); $this->verifyTableNodeColumns($table, ["name"]);
foreach ($table->getHash() as $row) { foreach ($table->getHash() as $row) {
@@ -4271,8 +4386,11 @@ trait WebDav {
* @return void * @return void
* @throws Exception * @throws Exception
*/ */
public function thePublicListsTheResourcesInTheLastCreatedPublicLinkWithDepthUsingTheWebdavApi(string $depth):void { public function thePublicListsTheResourcesInTheLastCreatedPublicLinkWithDepthUsingTheWebdavApi(
$token = ($this->isUsingSharingNG()) ? $this->shareNgGetLastCreatedLinkShareToken() : $this->getLastCreatedPublicShareToken(); string $depth
): void {
$token = ($this->isUsingSharingNG())
? $this->shareNgGetLastCreatedLinkShareToken() : $this->getLastCreatedPublicShareToken();
$this->setResponse( $this->setResponse(
$this->listFolder( $this->listFolder(
$token, $token,
@@ -4565,14 +4683,16 @@ trait WebDav {
} }
if (!isset($authors[$index - 1])) { if (!isset($authors[$index - 1])) {
Assert::fail( 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]; $actualUser = $authors[$index - 1];
Assert::assertEquals( Assert::assertEquals(
$expectedUsername, $expectedUsername,
$actualUser, $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 // 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])) { if (!isset($displaynames[$index - 1])) {
Assert::fail( 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]; $actualUserDisplayName = $displaynames[$index - 1];
Assert::assertEquals( Assert::assertEquals(
$expectedUserDisplayName, $expectedUserDisplayName,
$actualUserDisplayName, $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) { public function userLocksFileSettingPropertiesUsingWebDavAPI(string $user, string $file, TableNode $properties) {
$spaceId = null; $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"); $spaceId = $this->spacesContext->getSpaceIdByName($user, "Shares");
$file = \str_replace("Shares/", "", $file); $file = \str_replace("Shares/", "", $file);
} }
@@ -163,7 +165,11 @@ class WebDavLockingContext implements Context {
* *
* @return void * @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); $response = $this->lockFile($user, $file, $properties, null, false, false);
$this->featureContext->setResponse($response); $this->featureContext->setResponse($response);
} }
@@ -179,7 +185,12 @@ class WebDavLockingContext implements Context {
* @return void * @return void
* @throws GuzzleException * @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)); $this->featureContext->setResponse($this->userLocksFileInProjectSpace($user, $file, $space, $properties));
} }
@@ -193,7 +204,12 @@ class WebDavLockingContext implements Context {
* *
* @throws GuzzleException * @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); $spaceId = $this->spacesContext->getSpaceIdByName($user, $space);
$baseUrl = $this->featureContext->getBaseUrl(); $baseUrl = $this->featureContext->getBaseUrl();
$davPathVersion = $this->featureContext->getDavPathVersion(); $davPathVersion = $this->featureContext->getDavPathVersion();
@@ -218,7 +234,12 @@ class WebDavLockingContext implements Context {
* @return void * @return void
* @throws GuzzleException * @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); $response = $this->userLocksFileInProjectSpace($user, $file, $space, $properties);
$this->featureContext->theHTTPStatusCodeShouldBe(200, '', $response); $this->featureContext->theHTTPStatusCodeShouldBe(200, '', $response);
} }
@@ -233,7 +254,12 @@ class WebDavLockingContext implements Context {
* *
* @return void * @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); $spaceId = $this->spacesContext->getSpaceIdByName($user, $space);
$davPathVersion = $this->featureContext->getDavPathVersion(); $davPathVersion = $this->featureContext->getDavPathVersion();
$suffixPath = $user; $suffixPath = $user;
@@ -257,7 +283,12 @@ class WebDavLockingContext implements Context {
* *
* @return void * @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 = WebdavHelper::getDavPath($this->featureContext->getDavPathVersion());
$davPath = \rtrim($davPath, '/'); $davPath = \rtrim($davPath, '/');
$fullUrl = $this->featureContext->getBaseUrl() . "/$davPath/$fileId"; $fullUrl = $this->featureContext->getBaseUrl() . "/$davPath/$fileId";
@@ -275,7 +306,12 @@ class WebDavLockingContext implements Context {
* *
* @return void * @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 = WebdavHelper::getDavPath($this->featureContext->getDavPathVersion());
$davPath = \rtrim($davPath, '/'); $davPath = \rtrim($davPath, '/');
$fullUrl = $this->featureContext->getBaseUrl() . "/$davPath/$fileId"; $fullUrl = $this->featureContext->getBaseUrl() . "/$davPath/$fileId";
@@ -307,7 +343,12 @@ class WebDavLockingContext implements Context {
* *
* @return void * @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); $spaceId = $this->spacesContext->getSpaceIdByName($this->featureContext->getActualUsername($user), $spaceName);
$response = $this->lockFile($user, $file, $properties, null, false, true, $spaceId); $response = $this->lockFile($user, $file, $properties, null, false, true, $spaceId);
$this->featureContext->theHTTPStatusCodeShouldBe(200, '', $response); $this->featureContext->theHTTPStatusCodeShouldBe(200, '', $response);
@@ -358,7 +399,9 @@ class WebDavLockingContext implements Context {
* @return void * @return void
*/ */
public function publicLocksLastSharedFile(TableNode $properties) { 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( $response = $this->lockFile(
$token, $token,
"/", "/",
@@ -382,7 +425,9 @@ class WebDavLockingContext implements Context {
string $file, string $file,
TableNode $properties 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( $response = $this->lockFile(
$token, $token,
$file, $file,
@@ -406,7 +451,9 @@ class WebDavLockingContext implements Context {
string $file, string $file,
TableNode $properties 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( $response = $this->lockFile(
$token, $token,
$file, $file,
@@ -445,7 +492,11 @@ class WebDavLockingContext implements Context {
* *
* @return void * @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); $spaceId = $this->spacesContext->getSpaceIdByName($this->featureContext->getActualUsername($user), $spaceName);
$response = $this->unlockItemWithLastLockOfUserAndItemUsingWebDavAPI( $response = $this->unlockItemWithLastLockOfUserAndItemUsingWebDavAPI(
$user, $user,
@@ -468,11 +519,22 @@ class WebDavLockingContext implements Context {
* *
* @return void * @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 = WebdavHelper::getDavPath($this->featureContext->getDavPathVersion());
$davPath = \rtrim($davPath, '/'); $davPath = \rtrim($davPath, '/');
$fullUrl = $this->featureContext->getBaseUrl() . "/$davPath/$fileId"; $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); $this->featureContext->setResponse($response);
} }
@@ -711,7 +773,9 @@ class WebDavLockingContext implements Context {
string $lockOwner, string $lockOwner,
string $itemToUseLockOf 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( $response = $this->unlockItemWithLastLockOfUserAndItemUsingWebDavAPI(
$token, $token,
$itemToUnlock, $itemToUnlock,
@@ -730,7 +794,9 @@ class WebDavLockingContext implements Context {
* @return void * @return void
*/ */
public function unlockItemAsPublicUsingWebDavAPI(string $itemToUnlock) { 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( $response = $this->unlockItemWithLastLockOfUserAndItemUsingWebDavAPI(
$token, $token,
$itemToUnlock, $itemToUnlock,
@@ -901,7 +967,12 @@ class WebDavLockingContext implements Context {
* @return void * @return void
* @throws GuzzleException * @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'); $response = $this->spacesContext->sendPropfindRequestToSpace($user, $spaceName, $file, null, '0');
$this->featureContext->theHTTPStatusCodeShouldBe(207, "", $response); $this->featureContext->theHTTPStatusCodeShouldBe(207, "", $response);
$responseXmlObject = HttpRequestHelper::getResponseXml($response, __METHOD__); $responseXmlObject = HttpRequestHelper::getResponseXml($response, __METHOD__);
@@ -170,7 +170,11 @@ class WebDavPropertiesContext implements Context {
* @return void * @return void
* @throws Exception * @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); $username = $this->featureContext->getActualUsername($username);
$this->featureContext->verifyTableNodeColumns($propertiesTable, ['propertyName', 'propertyValue']); $this->featureContext->verifyTableNodeColumns($propertiesTable, ['propertyName', 'propertyValue']);
$properties = $propertiesTable->getColumnsHash(); $properties = $propertiesTable->getColumnsHash();
@@ -262,7 +266,9 @@ class WebDavPropertiesContext implements Context {
* @throws Exception * @throws Exception
*/ */
public function getPropertiesOfEntryFromLastLinkShare(string $path, TableNode $propertiesTable): ResponseInterface { 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; $properties = null;
foreach ($propertiesTable->getRows() as $row) { foreach ($propertiesTable->getRows() as $row) {
$properties[] = $row[0]; $properties[] = $row[0];
@@ -286,7 +292,10 @@ class WebDavPropertiesContext implements Context {
* @return void * @return void
* @throws Exception * @throws Exception
*/ */
public function thePublicGetsFollowingPropertiesOfEntryFromLastLinkShare(string $path, TableNode $propertiesTable):void { public function thePublicGetsFollowingPropertiesOfEntryFromLastLinkShare(
string $path,
TableNode $propertiesTable
): void {
$response = $this->getPropertiesOfEntryFromLastLinkShare($path, $propertiesTable); $response = $this->getPropertiesOfEntryFromLastLinkShare($path, $propertiesTable);
$this->featureContext->setResponse($response); $this->featureContext->setResponse($response);
} }
@@ -636,7 +645,11 @@ class WebDavPropertiesContext implements Context {
* @return SimpleXMLElement * @return SimpleXMLElement
* @throws Exception * @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__); $xmlPart = HttpRequestHelper::getResponseXml($response, __METHOD__);
; ;
@@ -749,7 +762,11 @@ class WebDavPropertiesContext implements Context {
* @return void * @return void
* @throws Exception * @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); $this->assertValueOfItemInResponseAboutUserIs($xpath, $user, $expectedValue);
} }
@@ -794,7 +811,12 @@ class WebDavPropertiesContext implements Context {
* @return void * @return void
* @throws Exception * @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) { if (!$expectedValue2) {
$expectedValue2 = $expectedValue1; $expectedValue2 = $expectedValue1;
} }
@@ -820,7 +842,10 @@ class WebDavPropertiesContext implements Context {
$expectedValue2 = preg_replace("/^\/\//i", "/", $expectedValue2); $expectedValue2 = preg_replace("/^\/\//i", "/", $expectedValue2);
$expectedValues = [$expectedValue1, $expectedValue2]; $expectedValues = [$expectedValue1, $expectedValue2];
$isExpectedValueInMessage = \in_array($value, $expectedValues); $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 * @return void
* @throws Exception * @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']]); $propertiesTable = new TableNode([['propertyName'],['d:lockdiscovery']]);
$response = $this->getPropertiesOfEntryFromLastLinkShare($path, $propertiesTable); $response = $this->getPropertiesOfEntryFromLastLinkShare($path, $propertiesTable);
$this->featureContext->theHTTPStatusCodeShouldBe('207', "", $response); $this->featureContext->theHTTPStatusCodeShouldBe('207', "", $response);
@@ -947,7 +976,12 @@ class WebDavPropertiesContext implements Context {
* @return void * @return void
* @throws JsonException * @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); $xmlPart = $responseXmlObject->xpath($xpath);
Assert::assertTrue( Assert::assertTrue(
isset($xmlPart[0]), isset($xmlPart[0]),
@@ -955,7 +989,8 @@ class WebDavPropertiesContext implements Context {
); );
$user = $this->featureContext->getActualUsername($user); $user = $this->featureContext->getActualUsername($user);
$value = $xmlPart[0]->__toString(); $value = $xmlPart[0]->__toString();
$callback = ($this->featureContext->isUsingSharingNG()) ? "shareNgGetLastCreatedLinkShareToken" : "getLastCreatedPublicShareToken"; $callback = ($this->featureContext->isUsingSharingNG())
? "shareNgGetLastCreatedLinkShareToken" : "getLastCreatedPublicShareToken";
if (\str_ends_with($xpath, "d:href")) { if (\str_ends_with($xpath, "d:href")) {
$pattern = \preg_replace("/^\//", "", $pattern); $pattern = \preg_replace("/^\//", "", $pattern);
@@ -996,7 +1031,12 @@ class WebDavPropertiesContext implements Context {
* @return void * @return void
* @throws Exception * @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']]); $propertiesTable = new TableNode([['propertyName'],['d:lockdiscovery']]);
$response = $this->getPropertiesOfFolder( $response = $this->getPropertiesOfFolder(
$user, $user,
@@ -1163,7 +1203,12 @@ class WebDavPropertiesContext implements Context {
* @return SimpleXMLElement * @return SimpleXMLElement
* @throws Exception * @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 === "") { if ($storePath === "") {
$storePath = $path; $storePath = $path;
} }
@@ -1288,7 +1333,10 @@ class WebDavPropertiesContext implements Context {
* @throws Exception * @throws Exception
*/ */
public function theResponseShouldHavePropertyWithValue(string $username, TableNode $expectedPropTable): void { 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()); $responseXmlObject = HttpRequestHelper::getResponseXml($this->featureContext->getResponse());
$href = (string)$responseXmlObject->xpath("//d:href")[0]; $href = (string)$responseXmlObject->xpath("//d:href")[0];
@@ -1324,7 +1372,9 @@ class WebDavPropertiesContext implements Context {
null, null,
$propertiesTable $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, $path,
$this->storedETAG[$user], $this->storedETAG[$user],
$messageStart $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]; return $this->storedETAG[$user][$path];
} }
@@ -1419,7 +1470,11 @@ class WebDavPropertiesContext implements Context {
* @return void * @return void
* @throws Exception * @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); $user = $this->featureContext->getActualUsername($user);
$actualEtag = $this->getCurrentEtagOfElement($path, $user); $actualEtag = $this->getCurrentEtagOfElement($path, $user);
$storedEtag = $this->getStoredEtagOfElement($path, $user, __METHOD__); $storedEtag = $this->getStoredEtagOfElement($path, $user, __METHOD__);