1
0
mirror of https://github.com/owncloud/ocis.git synced 2025-04-18 23:44:07 +03:00

updating lint rules for test code

This commit is contained in:
Niraj Acharya 2024-12-24 09:30:42 +05:45
parent 24798a80d1
commit 089ccc1ca3
45 changed files with 2914 additions and 1151 deletions

View File

@ -12,6 +12,20 @@ $finder = PhpCsFixer\Finder::create()
->exclude($excludeDirs)
->in(__DIR__);
$config = new OC\CodingStandard\Config();
$ocRule = (new OC\CodingStandard\Config())->getRules();
$config = new PhpCsFixer\Config();
$config->setFinder($finder)
->setIndent("\t")
->setRules(
array_merge(
$ocRule,
[
"return_type_declaration" => [
"space_before" => "none",
],
'single_space_around_construct' => true
]
)
);
$config->setFinder($finder);
return $config;

View File

@ -19,10 +19,6 @@
<exclude name="Generic.WhiteSpace.DisallowTabIndent.NonIndentTabsUsed" />
</rule>
<rule ref="Generic.Files.LineLength">
<exclude name="Generic.Files.LineLength.TooLong" />
</rule>
<rule ref="PEAR">
<exclude name="Generic.Commenting.DocComment.ShortNotCapital" />
<exclude name="Generic.Commenting.DocComment.SpacingAfter" />
@ -77,4 +73,18 @@
<exclude-pattern>*/lib/storagewrapper.php</exclude-pattern>
</rule>
<rule ref="Generic.Commenting.Todo">
<message>Please review this TODO comment: %s</message>
<type>error</type>
</rule>
<rule ref="Squiz.PHP.NonExecutableCode" />
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace" />
<rule ref="Generic.Files.LineLength">
<properties>
<property name="ignoreComments" value="true" />
<type>error</type>
<property name="lineLimit" value="120" />
<property name="absoluteLineLimit" value="120" />
</properties>
</rule>
</ruleset>

View File

@ -42,7 +42,7 @@ class WebDav extends Assert {
?string $expectedValue,
?array $responseXmlArray,
?string $extraErrorText = ''
):void {
): void {
if ($extraErrorText !== '') {
$extraErrorText = $extraErrorText . " ";
}
@ -58,7 +58,9 @@ class WebDav extends Assert {
} elseif ($element === "reason") {
$result = $responseXmlArray['value'][3]['value'];
} else {
self::fail(__METHOD__ . " element must be one of exception, response or reason. But '$element' was passed in.");
self::fail(
__METHOD__ . " element must be one of exception, response or reason. But '$element' was passed in."
);
}
self::assertEquals(
@ -78,7 +80,7 @@ class WebDav extends Assert {
public static function assertResponseContainsShareTypes(
SimpleXMLElement $responseXmlObject,
?array $expectedShareTypes
):void {
): void {
foreach ($expectedShareTypes as $row) {
$xmlPart = $responseXmlObject->xpath(
"//d:prop/oc:share-types/oc:share-type[.=" . $row[0] . "]"

View File

@ -42,7 +42,11 @@ class AuthAppHelper {
*
* @return ResponseInterface
*/
public static function listAllAppAuthTokensForUser(string $baseUrl, string $user, string $password): ResponseInterface {
public static function listAllAppAuthTokensForUser(
string $baseUrl,
string $user,
string $password
): ResponseInterface {
$url = $baseUrl . self::getAuthAppEndpoint();
return HttpRequestHelper::sendRequest(
$url,
@ -61,7 +65,12 @@ class AuthAppHelper {
*
* @return ResponseInterface
*/
public static function createAppAuthToken(string $baseUrl, string $user, string $password, string $expiration): ResponseInterface {
public static function createAppAuthToken(
string $baseUrl,
string $user,
string $password,
string $expiration
): ResponseInterface {
$url = $baseUrl . self::getAuthAppEndpoint() . "?expiry=$expiration";
return HttpRequestHelper::sendRequest(
$url,
@ -80,7 +89,12 @@ class AuthAppHelper {
*
* @return ResponseInterface
*/
public static function deleteAppAuthToken(string $baseUrl, string $user, string $password, string $token): ResponseInterface {
public static function deleteAppAuthToken(
string $baseUrl,
string $user,
string $password,
string $token
): ResponseInterface {
$url = $baseUrl . self::getAuthAppEndpoint() . "?token=$token";
return HttpRequestHelper::sendRequest(
$url,

View File

@ -38,7 +38,11 @@ class BehatHelper {
*
* @return Context
*/
public static function getContext(ScenarioScope $scope, InitializedContextEnvironment $environment, string $class): Context {
public static function getContext(
ScenarioScope $scope,
InitializedContextEnvironment $environment,
string $class
): Context {
try {
return $environment->getContext($class);
} catch (ContextNotFoundException $e) {

View File

@ -35,7 +35,7 @@ class EmailHelper {
*
* @return string
*/
public static function getMailBoxFromEmail(string $emailAddress):string {
public static function getMailBoxFromEmail(string $emailAddress): string {
return explode("@", $emailAddress)[0];
}
@ -45,7 +45,7 @@ class EmailHelper {
*
* @return string
*/
public static function getLocalEmailUrl():string {
public static function getLocalEmailUrl(): string {
$localEmailHost = self::getLocalEmailHost();
$emailPort = \getenv('EMAIL_PORT');
if ($emailPort === false) {
@ -60,7 +60,7 @@ class EmailHelper {
*
* @return string
*/
public static function getEmailHost():string {
public static function getEmailHost(): string {
$emailHost = \getenv('EMAIL_HOST');
if ($emailHost === false) {
$emailHost = "127.0.0.1";
@ -74,7 +74,7 @@ class EmailHelper {
*
* @return string
*/
public static function getLocalEmailHost():string {
public static function getLocalEmailHost(): string {
$localEmailHost = \getenv('LOCAL_EMAIL_HOST');
if ($localEmailHost === false) {
$localEmailHost = self::getEmailHost();
@ -92,7 +92,7 @@ class EmailHelper {
* @return array
* @throws GuzzleException
*/
public static function getMailBoxInformation(string $mailBox, ?string $xRequestId = null):array {
public static function getMailBoxInformation(string $mailBox, ?string $xRequestId = null): array {
$response = HttpRequestHelper::get(
self::getLocalEmailUrl() . "/api/v1/mailbox/" . $mailBox,
$xRequestId,
@ -113,7 +113,11 @@ class EmailHelper {
* @return object
* @throws GuzzleException
*/
public static function getBodyOfAnEmailById(string $mailBox, string $mailboxId, ?string $xRequestId = null):object {
public static function getBodyOfAnEmailById(
string $mailBox,
string $mailboxId,
?string $xRequestId = null
): object {
$response = HttpRequestHelper::get(
self::getLocalEmailUrl() . "/api/v1/mailbox/" . $mailBox . "/" . $mailboxId,
$xRequestId,
@ -142,7 +146,7 @@ class EmailHelper {
string $xRequestId,
?int $emailNumber = 1,
?int $waitTimeSec = EMAIL_WAIT_TIMEOUT_SEC
):string {
): string {
$currentTime = \time();
$endTime = $currentTime + $waitTimeSec;
$mailBox = self::getMailBoxFromEmail($emailAddress);
@ -178,7 +182,7 @@ class EmailHelper {
string $localInbucketUrl,
?string $xRequestId,
string $mailBox
):ResponseInterface {
): ResponseInterface {
return HttpRequestHelper::delete(
$localInbucketUrl . "/api/v1/mailbox/" . $mailBox,
$xRequestId

View File

@ -110,7 +110,8 @@ class GraphHelper {
* @return string
*/
public static function getShareIdRegex(): string {
return self::getUUIDv4Regex() . '\\\$' . self::getUUIDv4Regex() . '!' . self::getUUIDv4Regex() . ':' . self::getUUIDv4Regex() . ':' . self::getUUIDv4Regex();
return self::getUUIDv4Regex() . '\\\$' . self::getUUIDv4Regex() . '!'
. self::getUUIDv4Regex() . ':' . self::getUUIDv4Regex() . ':' . self::getUUIDv4Regex();
}
/**
@ -1387,7 +1388,11 @@ class GraphHelper {
string $password,
array $groupIdArray
): ResponseInterface {
$url = self::getFullUrl($baseUrl, 'users' . '?$filter=memberOf/any(m:m/id ' . "eq '$groupIdArray[0]') " . "and memberOf/any(m:m/id eq '$groupIdArray[1]')");
$url = self::getFullUrl(
$baseUrl,
'users' . '?$filter=memberOf/any(m:m/id ' . "eq '$groupIdArray[0]') "
. "and memberOf/any(m:m/id eq '$groupIdArray[1]')"
);
return HttpRequestHelper::get(
$url,
$xRequestId,
@ -1416,7 +1421,11 @@ class GraphHelper {
string $firstGroup,
string $secondGroup
): ResponseInterface {
$url = self::getFullUrl($baseUrl, 'users' . '?$filter=memberOf/any(m:m/id ' . "eq '$firstGroup') " . "or memberOf/any(m:m/id eq '$secondGroup')");
$url = self::getFullUrl(
$baseUrl,
'users' . '?$filter=memberOf/any(m:m/id '
. "eq '$firstGroup') " . "or memberOf/any(m:m/id eq '$secondGroup')"
);
return HttpRequestHelper::get(
$url,
$xRequestId,
@ -1472,7 +1481,11 @@ class GraphHelper {
string $roleId,
string $groupId
): ResponseInterface {
$url = self::getFullUrl($baseUrl, 'users' . '?$filter=appRoleAssignments/any(m:m/appRoleId ' . "eq '$roleId') " . "and memberOf/any(m:m/id eq '$groupId')");
$url = self::getFullUrl(
$baseUrl,
'users' . '?$filter=appRoleAssignments/any(m:m/appRoleId '
. "eq '$roleId') " . "and memberOf/any(m:m/id eq '$groupId')"
);
return HttpRequestHelper::get(
$url,
$xRequestId,
@ -1669,7 +1682,15 @@ class GraphHelper {
): ResponseInterface {
$fullUrl = self::getFullUrl($baseUrl, 'me');
$payload['preferredLanguage'] = $language;
return HttpRequestHelper::sendRequest($fullUrl, $xRequestId, 'PATCH', $user, $password, null, \json_encode($payload));
return HttpRequestHelper::sendRequest(
$fullUrl,
$xRequestId,
'PATCH',
$user,
$password,
null,
\json_encode($payload)
);
}
/**
@ -1810,7 +1831,13 @@ class GraphHelper {
?string $expirationDateTime
): ResponseInterface {
$url = self::getBetaFullUrl($baseUrl, "drives/$spaceId/items/$itemId/invite");
$body = self::createShareInviteBody($shareeIds, $shareTypes, $permissionsRole, $permissionsAction, $expirationDateTime);
$body = self::createShareInviteBody(
$shareeIds,
$shareTypes,
$permissionsRole,
$permissionsAction,
$expirationDateTime
);
return HttpRequestHelper::post(
$url,
$xRequestId,
@ -2052,7 +2079,7 @@ class GraphHelper {
string $password,
string $itemId,
string $shareSpaceId
):ResponseInterface {
): ResponseInterface {
$url = self::getBetaFullUrl($baseUrl, "drives/$shareSpaceId/items/$itemId");
return HttpRequestHelper::delete(
$url,
@ -2083,7 +2110,7 @@ class GraphHelper {
string $itemId,
string $shareSpaceId,
array $body
):ResponseInterface {
): ResponseInterface {
$url = self::getBetaFullUrl($baseUrl, "drives/$shareSpaceId/items/$itemId");
return HttpRequestHelper::sendRequest(
$url,
@ -2186,7 +2213,13 @@ class GraphHelper {
?string $expirationDateTime
): ResponseInterface {
$url = self::getBetaFullUrl($baseUrl, "drives/$spaceId/root/invite");
$body = self::createShareInviteBody($shareeIds, $shareTypes, $permissionsRole, $permissionsAction, $expirationDateTime);
$body = self::createShareInviteBody(
$shareeIds,
$shareTypes,
$permissionsRole,
$permissionsAction,
$expirationDateTime
);
return HttpRequestHelper::post(
$url,

View File

@ -55,7 +55,7 @@ class HttpRequestHelper {
*
* @return int
*/
public static function numRetriesOnHttpTooEarly():int {
public static function numRetriesOnHttpTooEarly(): int {
// Currently reva and oCIS may return HTTP_TOO_EARLY
// So try up to 10 times before giving up.
return 10;
@ -93,7 +93,7 @@ class HttpRequestHelper {
bool $stream = false,
?int $timeout = 0,
?Client $client = null
):ResponseInterface {
): ResponseInterface {
if ($client === null) {
$client = self::createClient(
$user,
@ -196,7 +196,7 @@ class HttpRequestHelper {
?int $timeout = 0,
?Client $client = null,
?bool $isGivenStep = false
):ResponseInterface {
): ResponseInterface {
if ((\getenv('DEBUG_ACCEPTANCE_RESPONSES') !== false) || (\getenv('DEBUG_ACCEPTANCE_API_CALLS') !== false)) {
$debugResponses = true;
} else {
@ -222,7 +222,10 @@ class HttpRequestHelper {
$client
);
if ($response->getStatusCode() >= 400 && $response->getStatusCode() !== self::HTTP_TOO_EARLY && $response->getStatusCode() !== self::HTTP_CONFLICT) {
if ($response->getStatusCode() >= 400
&& $response->getStatusCode() !== self::HTTP_TOO_EARLY
&& $response->getStatusCode() !== self::HTTP_CONFLICT
) {
$sendExceptionHappened = true;
}
@ -261,7 +264,7 @@ class HttpRequestHelper {
*
* @return void
*/
private static function debugRequest(?RequestInterface $request, ?string $user, ?string $password):void {
private static function debugRequest(?RequestInterface $request, ?string $user, ?string $password): void {
print("### AUTH: $user:$password\n");
print("### REQUEST: " . $request->getMethod() . " " . $request->getUri() . "\n");
self::printHeaders($request->getHeaders());
@ -276,7 +279,7 @@ class HttpRequestHelper {
*
* @return void
*/
private static function debugResponse(?ResponseInterface $response):void {
private static function debugResponse(?ResponseInterface $response): void {
print("### RESPONSE\n");
print("Status: " . $response->getStatusCode() . "\n");
self::printHeaders($response->getHeaders());
@ -291,7 +294,7 @@ class HttpRequestHelper {
*
* @return void
*/
private static function printHeaders(?array $headers):void {
private static function printHeaders(?array $headers): void {
if ($headers) {
print("Headers:\n");
foreach ($headers as $header => $value) {
@ -313,7 +316,7 @@ class HttpRequestHelper {
*
* @return void
*/
private static function printBody(?StreamInterface $body):void {
private static function printBody(?StreamInterface $body): void {
print("Body:\n");
\var_dump($body->getContents());
// Rewind the stream so that later code can read from the start.
@ -333,7 +336,7 @@ class HttpRequestHelper {
public static function sendBatchRequest(
?array $requests,
?Client $client
):array {
): array {
return Pool::batch($client, $requests);
}
@ -358,7 +361,7 @@ class HttpRequestHelper {
?CookieJar $cookies = null,
?bool $stream = false,
?int $timeout = 0
):Client {
): Client {
$options = [];
if ($user !== null) {
$options['auth'] = [$user, $password];
@ -396,7 +399,7 @@ class HttpRequestHelper {
?string $method = 'GET',
?array $headers = null,
$body = null
):RequestInterface {
): RequestInterface {
if ($headers === null) {
$headers = [];
}
@ -449,7 +452,7 @@ class HttpRequestHelper {
?array $config = null,
?CookieJar $cookies = null,
?bool $stream = false
):ResponseInterface {
): ResponseInterface {
return self::sendRequest(
$url,
$xRequestId,
@ -491,7 +494,7 @@ class HttpRequestHelper {
?array $config = null,
?CookieJar $cookies = null,
?bool $stream = false
):ResponseInterface {
): ResponseInterface {
return self::sendRequest(
$url,
$xRequestId,
@ -533,7 +536,7 @@ class HttpRequestHelper {
?array $config = null,
?CookieJar $cookies = null,
?bool $stream = false
):ResponseInterface {
): ResponseInterface {
return self::sendRequest(
$url,
$xRequestId,
@ -576,7 +579,7 @@ class HttpRequestHelper {
?array $config = null,
?CookieJar $cookies = null,
?bool $stream = false
):ResponseInterface {
): ResponseInterface {
return self::sendRequest(
$url,
$xRequestId,
@ -605,7 +608,7 @@ class HttpRequestHelper {
* @return SimpleXMLElement
* @throws Exception
*/
public static function getResponseXml(ResponseInterface $response, ?string $exceptionText = ''):SimpleXMLElement {
public static function getResponseXml(ResponseInterface $response, ?string $exceptionText = ''): SimpleXMLElement {
// rewind just to make sure we can reparse it in case it was parsed already...
$response->getBody()->rewind();
$contents = $response->getBody()->getContents();
@ -647,7 +650,7 @@ class HttpRequestHelper {
*
* @return array
*/
public static function parseResponseAsXml(ResponseInterface $response):array {
public static function parseResponseAsXml(ResponseInterface $response): array {
// rewind so that we can reparse it if it was parsed already
$response->getBody()->rewind();
$body = $response->getBody()->getContents();

View File

@ -56,7 +56,11 @@ class OcisConfigHelper {
try {
$response = $client->send($request);
} catch (ConnectException $e) {
throw new \Error("Cannot connect to the ociswrapper at the moment, make sure that ociswrapper is running before proceeding with the test run.\n" . $e->getMessage());
throw new \Error(
"Cannot connect to the ociswrapper at the moment,"
. "make sure that ociswrapper is running before proceeding with the test run.\n"
. $e->getMessage()
);
} catch (GuzzleException $ex) {
$response = $ex->getResponse();

View File

@ -87,7 +87,7 @@ class OcisHelper {
/**
* @return bool
*/
public static function isTestingOnReva():bool {
public static function isTestingOnReva(): bool {
return (\getenv("TEST_REVA") === "true");
}
@ -106,7 +106,7 @@ class OcisHelper {
* @return string
* @throws Exception
*/
public static function getStorageDriver():string {
public static function getStorageDriver(): string {
$storageDriver = (\getenv("STORAGE_DRIVER"));
if ($storageDriver === false) {
return StorageDriver::OWNCLOUD;
@ -166,7 +166,7 @@ class OcisHelper {
*
* @return void
*/
public static function recurseCopy(?string $source, ?string $destination):void {
public static function recurseCopy(?string $source, ?string $destination): void {
$dir = \opendir($source);
@\mkdir($destination);
while (($file = \readdir($dir)) !== false) {
@ -184,7 +184,7 @@ class OcisHelper {
/**
* @return int
*/
public static function getLdapPort():int {
public static function getLdapPort(): int {
$port = \getenv("REVA_LDAP_PORT");
return $port ? (int)$port : 636;
}
@ -192,7 +192,7 @@ class OcisHelper {
/**
* @return bool
*/
public static function useSsl():bool {
public static function useSsl(): bool {
$useSsl = \getenv("REVA_LDAP_USESSL");
if ($useSsl === false) {
return (self::getLdapPort() === 636);
@ -204,7 +204,7 @@ class OcisHelper {
/**
* @return string
*/
public static function getBaseDN():string {
public static function getBaseDN(): string {
$dn = \getenv("REVA_LDAP_BASE_DN");
return $dn ?: "dc=owncloud,dc=com";
}
@ -212,7 +212,7 @@ class OcisHelper {
/**
* @return string
*/
public static function getGroupsOU():string {
public static function getGroupsOU(): string {
$ou = \getenv("REVA_LDAP_GROUPS_OU");
return $ou ?: "TestGroups";
}
@ -220,7 +220,7 @@ class OcisHelper {
/**
* @return string
*/
public static function getUsersOU():string {
public static function getUsersOU(): string {
$ou = \getenv("REVA_LDAP_USERS_OU");
return $ou ?: "TestUsers";
}
@ -228,14 +228,14 @@ class OcisHelper {
/**
* @return string
*/
public static function getGroupSchema():string {
public static function getGroupSchema(): string {
$schema = \getenv("REVA_LDAP_GROUP_SCHEMA");
return $schema ?: "rfc2307";
}
/**
* @return string
*/
public static function getHostname():string {
public static function getHostname(): string {
$hostname = \getenv("REVA_LDAP_HOSTNAME");
return $hostname ?: "localhost";
}
@ -243,7 +243,7 @@ class OcisHelper {
/**
* @return string
*/
public static function getBindDN():string {
public static function getBindDN(): string {
$dn = \getenv("REVA_LDAP_BIND_DN");
return $dn ?: "cn=admin,dc=owncloud,dc=com";
}
@ -251,7 +251,7 @@ class OcisHelper {
/**
* @return string
*/
public static function getBindPassword():string {
public static function getBindPassword(): string {
$pw = \getenv("REVA_LDAP_BIND_PASSWORD");
return $pw ?: "";
}
@ -259,7 +259,7 @@ class OcisHelper {
/**
* @return string
*/
private static function getOcisRevaDataRoot():string {
private static function getOcisRevaDataRoot(): string {
$root = \getenv("OCIS_REVA_DATA_ROOT");
if ($root === false || $root === "") {
$root = "/var/tmp/ocis/owncloud/";
@ -275,7 +275,7 @@ class OcisHelper {
*
* @return bool
*/
private static function recurseRmdir(?string $dir):bool {
private static function recurseRmdir(?string $dir): bool {
if (\file_exists($dir) === true) {
$files = \array_diff(\scandir($dir), ['.', '..']);
foreach ($files as $file) {
@ -307,7 +307,7 @@ class OcisHelper {
?string $user,
?string $password,
?string $xRequestId = ''
):void {
): void {
HttpRequestHelper::get(
$baseUrl . "/ocs/v2.php/apps/notifications/api/v1/notifications",
$xRequestId,

View File

@ -56,7 +56,7 @@ class OcsApiHelper {
$body = [],
?int $ocsApiVersion = 2,
?array $headers = []
):ResponseInterface {
): ResponseInterface {
$fullUrl = $baseUrl;
if (\substr($fullUrl, -1) !== '/') {
$fullUrl .= '/';
@ -86,7 +86,7 @@ class OcsApiHelper {
$body = [],
?int $ocsApiVersion = 2,
?array $headers = []
):RequestInterface {
): RequestInterface {
$fullUrl = $baseUrl;
if (\substr($fullUrl, -1) !== '/') {
$fullUrl .= '/';

View File

@ -55,7 +55,13 @@ class SettingsHelper {
* @throws GuzzleException
* @throws Exception
*/
public static function getBundlesList(string $baseUrl, string $user, string $password, string $xRequestId, array $headers = []): ResponseInterface {
public static function getBundlesList(
string $baseUrl,
string $user,
string $password,
string $xRequestId,
array $headers = []
): ResponseInterface {
$fullUrl = self::buildFullUrl($baseUrl, "bundles-list");
return HttpRequestHelper::post(
$fullUrl,
@ -79,7 +85,13 @@ class SettingsHelper {
* @throws GuzzleException
* @throws Exception
*/
public static function getBundleByName(string $baseUrl, string $user, string $password, string $bundleName, string $xRequestId): array {
public static function getBundleByName(
string $baseUrl,
string $user,
string $password,
string $bundleName,
string $xRequestId
): array {
$response = self::getBundlesList($baseUrl, $user, $password, $xRequestId);
Assert::assertEquals(201, $response->getStatusCode(), "Failed to get bundles list");
@ -104,7 +116,13 @@ class SettingsHelper {
* @throws GuzzleException
* @throws Exception
*/
public static function getRolesList(string $baseUrl, string $user, string $password, string $xRequestId, array $headers = []): ResponseInterface {
public static function getRolesList(
string $baseUrl,
string $user,
string $password,
string $xRequestId,
array $headers = []
): ResponseInterface {
$fullUrl = self::buildFullUrl($baseUrl, "roles-list");
return HttpRequestHelper::post(
$fullUrl,
@ -130,7 +148,15 @@ class SettingsHelper {
* @throws GuzzleException
* @throws Exception
*/
public static function assignRoleToUser(string $baseUrl, string $user, string $password, string $assigneeId, string $roleId, string $xRequestId, array $headers = []): ResponseInterface {
public static function assignRoleToUser(
string $baseUrl,
string $user,
string $password,
string $assigneeId,
string $roleId,
string $xRequestId,
array $headers = []
): ResponseInterface {
$fullUrl = self::buildFullUrl($baseUrl, "assignments-add");
$body = json_encode(["account_uuid" => $assigneeId, "role_id" => $roleId], JSON_THROW_ON_ERROR);
return HttpRequestHelper::post(
@ -156,7 +182,14 @@ class SettingsHelper {
* @throws GuzzleException
* @throws Exception
*/
public static function getAssignmentsList(string $baseUrl, string $user, string $password, string $userId, string $xRequestId, array $headers = []): ResponseInterface {
public static function getAssignmentsList(
string $baseUrl,
string $user,
string $password,
string $userId,
string $xRequestId,
array $headers = []
): ResponseInterface {
$fullUrl = self::buildFullUrl($baseUrl, "assignments-list");
$body = json_encode(["account_uuid" => $userId], JSON_THROW_ON_ERROR);
return HttpRequestHelper::post(
@ -181,7 +214,13 @@ class SettingsHelper {
* @throws GuzzleException
* @throws Exception
*/
public static function getValuesList(string $baseUrl, string $user, string $password, string $xRequestId, array $headers = []): ResponseInterface {
public static function getValuesList(
string $baseUrl,
string $user,
string $password,
string $xRequestId,
array $headers = []
): ResponseInterface {
$fullUrl = self::buildFullUrl($baseUrl, "values-list");
$body = json_encode(["account_uuid" => "me"], JSON_THROW_ON_ERROR);
return HttpRequestHelper::post(
@ -205,7 +244,12 @@ class SettingsHelper {
* @throws GuzzleException
* @throws Exception
*/
public static function getAutoAcceptSharesSettingValue(string $baseUrl, string $user, string $password, string $xRequestId): bool {
public static function getAutoAcceptSharesSettingValue(
string $baseUrl,
string $user,
string $password,
string $xRequestId
): bool {
$response = self::getValuesList($baseUrl, $user, $password, $xRequestId);
Assert::assertEquals(201, $response->getStatusCode(), "Failed to get values list");
@ -235,7 +279,12 @@ class SettingsHelper {
* @throws GuzzleException
* @throws Exception
*/
public static function getLanguageSettingValue(string $baseUrl, string $user, string $password, string $xRequestId): string {
public static function getLanguageSettingValue(
string $baseUrl,
string $user,
string $password,
string $xRequestId
): string {
$response = self::getValuesList($baseUrl, $user, $password, $xRequestId);
Assert::assertEquals(201, $response->getStatusCode(), "Failed to get values list");
@ -267,7 +316,14 @@ class SettingsHelper {
* @throws GuzzleException
* @throws Exception
*/
public static function updateSettings(string $baseUrl, string $user, string $password, string $body, string $xRequestId, array $headers = []): ResponseInterface {
public static function updateSettings(
string $baseUrl,
string $user,
string $password,
string $body,
string $xRequestId,
array $headers = []
): ResponseInterface {
$fullUrl = self::buildFullUrl($baseUrl, "values-save");
return HttpRequestHelper::post(
$fullUrl,

View File

@ -43,7 +43,7 @@ class SetupHelper extends \PHPUnit\Framework\Assert {
*
* @return array of suite context parameters
*/
public static function getSuiteParameters(HookScope $scope):array {
public static function getSuiteParameters(HookScope $scope): array {
return $scope->getEnvironment()->getSuite()
->getSettings() ['context'] ['parameters'];
}
@ -90,7 +90,7 @@ class SetupHelper extends \PHPUnit\Framework\Assert {
?string $adminUsername,
?string $adminPassword,
?string $xRequestId = ''
):SimpleXMLElement {
): SimpleXMLElement {
$result = OcsApiHelper::sendRequest(
$baseUrl,
$adminUsername,
@ -122,7 +122,7 @@ class SetupHelper extends \PHPUnit\Framework\Assert {
?string $adminUsername,
?string $adminPassword,
?string $xRequestId = ''
):string {
): string {
$sysInfo = self::getSysInfo(
$baseUrl,
$adminUsername,
@ -141,7 +141,7 @@ class SetupHelper extends \PHPUnit\Framework\Assert {
* @return string
* @throws Exception
*/
private static function checkAdminUsername(?string $adminUsername, ?string $callerName):?string {
private static function checkAdminUsername(?string $adminUsername, ?string $callerName): ?string {
if (self::$adminUsername === null
&& $adminUsername === null
) {
@ -162,7 +162,7 @@ class SetupHelper extends \PHPUnit\Framework\Assert {
* @return string
* @throws Exception
*/
private static function checkAdminPassword(?string $adminPassword, ?string $callerName):string {
private static function checkAdminPassword(?string $adminPassword, ?string $callerName): string {
if (self::$adminPassword === null
&& $adminPassword === null
) {
@ -183,7 +183,7 @@ class SetupHelper extends \PHPUnit\Framework\Assert {
* @return string
* @throws Exception
*/
private static function checkBaseUrl(?string $baseUrl, ?string $callerName):?string {
private static function checkBaseUrl(?string $baseUrl, ?string $callerName): ?string {
if (self::$baseUrl === null
&& $baseUrl === null
) {
@ -215,7 +215,7 @@ class SetupHelper extends \PHPUnit\Framework\Assert {
?string $baseUrl = null,
?string $adminUsername = null,
?string $adminPassword = null
):void {
): void {
$baseUrl = self::checkBaseUrl($baseUrl, "mkDirOnServer");
$adminUsername = self::checkAdminUsername($adminUsername, "mkDirOnServer");
$adminPassword = self::checkAdminPassword($adminPassword, "mkDirOnServer");
@ -254,7 +254,7 @@ class SetupHelper extends \PHPUnit\Framework\Assert {
?string $baseUrl = null,
?string $adminUsername = null,
?string $adminPassword = null
):void {
): void {
$baseUrl = self::checkBaseUrl($baseUrl, "rmDirOnServer");
$adminUsername = self::checkAdminUsername($adminUsername, "rmDirOnServer");
$adminPassword = self::checkAdminPassword($adminPassword, "rmDirOnServer");
@ -295,7 +295,7 @@ class SetupHelper extends \PHPUnit\Framework\Assert {
?string $baseUrl = null,
?string $adminUsername = null,
?string $adminPassword = null
):void {
): void {
$baseUrl = self::checkBaseUrl($baseUrl, "createFileOnServer");
$adminUsername = self::checkAdminUsername($adminUsername, "createFileOnServer");
$adminPassword = self::checkAdminPassword($adminPassword, "createFileOnServer");
@ -337,7 +337,7 @@ class SetupHelper extends \PHPUnit\Framework\Assert {
?string $baseUrl = null,
?string $adminUsername = null,
?string $adminPassword = null
):void {
): void {
$baseUrl = self::checkBaseUrl($baseUrl, "deleteFileOnServer");
$adminUsername = self::checkAdminUsername($adminUsername, "deleteFileOnServer");
$adminPassword = self::checkAdminPassword($adminPassword, "deleteFileOnServer");
@ -377,7 +377,7 @@ class SetupHelper extends \PHPUnit\Framework\Assert {
?string $baseUrl = null,
?string $adminUsername = null,
?string $adminPassword = null
):string {
): string {
$baseUrl = self::checkBaseUrl($baseUrl, "readFile");
$adminUsername = self::checkAdminUsername(
$adminUsername,

View File

@ -192,7 +192,7 @@ class SharingHelper {
* @throws InvalidArgumentException
*
*/
public static function getPermissionSum($permissions):int {
public static function getPermissionSum($permissions): int {
if (\is_numeric($permissions)) {
// Allow any permission number so that test scenarios can
// specifically test invalid permission values
@ -230,7 +230,7 @@ class SharingHelper {
* @throws InvalidArgumentException
*
*/
public static function getShareType($shareType):int {
public static function getShareType($shareType): int {
if (\array_key_exists($shareType, self::SHARE_TYPES)) {
return self::SHARE_TYPES[$shareType];
} else {
@ -259,7 +259,7 @@ class SharingHelper {
public static function getLastShareIdFromResponse(
SimpleXMLElement $responseXmlObject,
string $errorMessage = "cannot find share id in response"
):string {
): string {
$xmlPart = $responseXmlObject->xpath("//data/element[last()]/id");
if (!\is_array($xmlPart) || (\count($xmlPart) === 0)) {

View File

@ -138,7 +138,7 @@ class UploadHelper extends Assert {
*
* @return array $string
*/
public static function chunkFile(?string $file, ?int $noOfChunks = 1):array {
public static function chunkFile(?string $file, ?int $noOfChunks = 1): array {
$size = \filesize($file);
$chunkSize = \ceil($size / $noOfChunks);
$chunks = [];
@ -162,7 +162,7 @@ class UploadHelper extends Assert {
*
* @return void
*/
public static function createFileSpecificSize(?string $name, ?int $size):void {
public static function createFileSpecificSize(?string $name, ?int $size): void {
if (\file_exists($name)) {
\unlink($name);
}
@ -190,7 +190,7 @@ class UploadHelper extends Assert {
*
* @return void
*/
public static function createFileWithText(?string $name, ?string $text):void {
public static function createFileWithText(?string $name, ?string $text): void {
$file = \fopen($name, 'w');
\fwrite($file, $text);
\fclose($file);
@ -207,7 +207,7 @@ class UploadHelper extends Assert {
*
* @return string
*/
public static function getUploadFilesDir(?string $name):string {
public static function getUploadFilesDir(?string $name): string {
return \getenv("FILES_FOR_UPLOAD") . $name;
}
}

View File

@ -56,7 +56,7 @@ class UserHelper {
string $adminPassword,
string $xRequestId = '',
?int $ocsApiVersion = 2
):ResponseInterface {
): ResponseInterface {
return OcsApiHelper::sendRequest(
$baseUrl,
$adminUser,
@ -90,7 +90,7 @@ class UserHelper {
?string $adminPassword,
?string $xRequestId = '',
?int $ocsApiVersion = 2
):array {
): array {
$requests = [];
$client = HttpRequestHelper::createClient(
$adminUser,
@ -143,7 +143,7 @@ class UserHelper {
?string $adminPassword,
?string $xRequestId = '',
?int $ocsApiVersion = 2
):ResponseInterface {
): ResponseInterface {
return OcsApiHelper::sendRequest(
$baseUrl,
$adminUser,
@ -175,7 +175,7 @@ class UserHelper {
?string $adminPassword,
?string $xRequestId = '',
?int $ocsApiVersion = 2
):ResponseInterface {
): ResponseInterface {
return OcsApiHelper::sendRequest(
$baseUrl,
$adminUser,
@ -209,7 +209,7 @@ class UserHelper {
?string $adminPassword,
?string $xRequestId = '',
?int $ocsApiVersion = 2
):ResponseInterface {
): ResponseInterface {
return OcsApiHelper::sendRequest(
$baseUrl,
$adminUser,
@ -243,7 +243,7 @@ class UserHelper {
?string $adminPassword,
?string $xRequestId,
?int $ocsApiVersion = 2
):ResponseInterface {
): ResponseInterface {
return OcsApiHelper::sendRequest(
$baseUrl,
$adminUser,
@ -273,7 +273,7 @@ class UserHelper {
?string $adminPassword,
?string $xRequestId = '',
?string $search =""
):ResponseInterface {
): ResponseInterface {
return OcsApiHelper::sendRequest(
$baseUrl,
$adminUser,
@ -301,7 +301,7 @@ class UserHelper {
?string $adminPassword,
?string $xRequestId = '',
?string $search = ""
):array {
): array {
$result = self::getGroups(
$baseUrl,
$adminUser,

View File

@ -86,7 +86,7 @@ class WebDavHelper {
*/
public static function removeSpaceIdReferenceForUser(
?string $user
):void {
): void {
if (\array_key_exists($user, self::$spacesIdRef)) {
unset(self::$spacesIdRef[$user]);
}
@ -245,7 +245,7 @@ class WebDavHelper {
?int $davPathVersionToUse = self::DAV_VERSION_NEW,
?string $doDavRequestAsUser = null,
?array $headers = []
):ResponseInterface {
): ResponseInterface {
$body = self::getBodyForPropfind($properties);
$folderDepth = (string) $folderDepth;
if ($folderDepth !== '0' && $folderDepth !== '1' && $folderDepth !== 'infinity') {
@ -307,7 +307,7 @@ class WebDavHelper {
?int $davPathVersionToUse = self::DAV_VERSION_NEW,
?string $type="files",
?string $spaceId = null,
):ResponseInterface {
): ResponseInterface {
if ($namespaceString !== null) {
$ns = self::parseNamespace($namespaceString);
$propertyBody = "<$ns->prefix:$propertyName" .
@ -348,7 +348,7 @@ class WebDavHelper {
*
* @return array
*/
public static function getPropertyWithNamespaceInfo(string $namespaceString = "", string $property = ""):array {
public static function getPropertyWithNamespaceInfo(string $namespaceString = "", string $property = ""): array {
$namespace = "";
$namespacePrefix = "";
if (\is_int($namespaceString)) {
@ -396,7 +396,7 @@ class WebDavHelper {
?int $davPathVersion = null,
?string $namespaceString = null,
?string $type="files"
):ResponseInterface {
): ResponseInterface {
$propertyBody = "";
foreach ($propertiesArray as $propertyArray) {
$property = $propertyArray["propertyName"];
@ -466,7 +466,7 @@ class WebDavHelper {
?array $properties = null,
?string $type = "files",
?int $davPathVersionToUse = self::DAV_VERSION_NEW
):ResponseInterface {
): ResponseInterface {
if (!$properties) {
$properties = [
'd:getetag', 'd:resourcetype'
@ -493,7 +493,7 @@ class WebDavHelper {
* @return string
* @throws Exception
*/
public static function generateUUIDv4():string {
public static function generateUUIDv4(): string {
// generate 16 bytes (128 bits) of random data or use the data passed into the function.
$data = random_bytes(16);
\assert(\strlen($data) == 16);
@ -516,7 +516,12 @@ class WebDavHelper {
* @throws GuzzleException
* @throws Exception
*/
public static function getPersonalSpaceIdForUser(string $baseUrl, string $user, string $password, string $xRequestId):string {
public static function getPersonalSpaceIdForUser(
string $baseUrl,
string $user,
string $password,
string $xRequestId
): string {
if (\array_key_exists($user, self::$spacesIdRef) && \array_key_exists("personal", self::$spacesIdRef[$user])) {
return self::$spacesIdRef[$user]["personal"];
}
@ -546,14 +551,21 @@ class WebDavHelper {
$user,
$password
);
Assert::assertEquals(207, $response->getStatusCode(), "PROPFIND for user '$user' failed so the personal space id cannot be discovered");
Assert::assertEquals(
207,
$response->getStatusCode(),
"PROPFIND for user '$user' failed so the personal space id cannot be discovered"
);
$responseXmlObject = HttpRequestHelper::getResponseXml(
$response,
__METHOD__
);
$xmlPart = $responseXmlObject->xpath("/d:multistatus/d:response[1]/d:propstat/d:prop/oc:spaceid");
Assert::assertNotEmpty($xmlPart, "The 'oc:spaceid' for user '$user' was not found in the PROPFIND response");
Assert::assertNotEmpty(
$xmlPart,
"The 'oc:spaceid' for user '$user' was not found in the PROPFIND response"
);
$personalSpaceId = $xmlPart[0]->__toString();
}
@ -577,7 +589,12 @@ class WebDavHelper {
* @return string
* @throws Exception|GuzzleException
*/
public static function getPersonalSpaceIdForUserOrFakeIfNotFound(string $baseUrl, string $user, string $password, string $xRequestId):string {
public static function getPersonalSpaceIdForUserOrFakeIfNotFound(
string $baseUrl,
string $user,
string $password,
string $xRequestId
): string {
if (\str_starts_with($user, "non-exist") || \str_starts_with($user, "nonexist")) {
return self::generateUUIDv4();
}
@ -641,7 +658,7 @@ class WebDavHelper {
?array $urlParameter = [],
?string $doDavRequestAsUser = null,
?bool $isGivenStep = false,
):ResponseInterface {
): ResponseInterface {
$baseUrl = self::sanitizeUrl($baseUrl, true);
// We need to manipulate and use path as a string.
@ -651,7 +668,9 @@ class WebDavHelper {
}
// get space id if testing with spaces dav
if ($spaceId === null && $davPathVersionToUse === self::DAV_VERSION_SPACES && !\in_array($type, ["public-files", "versions"])) {
if ($spaceId === null && $davPathVersionToUse === self::DAV_VERSION_SPACES
&& !\in_array($type, ["public-files", "versions"])
) {
$path = \ltrim($path, "/");
if (\str_starts_with($path, "Shares/")) {
$spaceId = GraphHelper::SHARES_SPACE_ID;
@ -667,7 +686,9 @@ class WebDavHelper {
}
$suffixPath = $user;
if ($davPathVersionToUse === self::DAV_VERSION_SPACES && !\in_array($type, ["archive", "versions", "public-files"])) {
if ($davPathVersionToUse === self::DAV_VERSION_SPACES
&& !\in_array($type, ["archive", "versions", "public-files"])
) {
$suffixPath = $spaceId;
} elseif ($type === "versions") {
// $path is file-id in case of versions
@ -751,7 +772,7 @@ class WebDavHelper {
int $davPathVersion,
?string $userOrItemIdOrSpaceIdOrToken = null,
?string $type = "files"
):string {
): string {
switch ($type) {
case 'archive':
return self::prefixRemotePhp("dav/archive/$userOrItemIdOrSpaceIdOrToken/files");
@ -807,7 +828,7 @@ class WebDavHelper {
*
* @return string
*/
public static function sanitizeUrl(?string $url, ?bool $trailingSlash = false):string {
public static function sanitizeUrl(?string $url, ?bool $trailingSlash = false): string {
if ($trailingSlash === true) {
$url = $url . "/";
} else {
@ -834,7 +855,7 @@ class WebDavHelper {
?string $token,
?string $xRequestId = '',
?int $davVersionToUse = self::DAV_VERSION_NEW
):string {
): string {
$response = self::propfind(
$baseUrl,
null,
@ -879,7 +900,7 @@ class WebDavHelper {
?string $xRequestId = '',
?int $davPathVersionToUse = self::DAV_VERSION_NEW,
?string $spaceId = null,
):string {
): string {
$response = self::propfind(
$baseUrl,
$user,
@ -900,7 +921,9 @@ class WebDavHelper {
Assert::assertArrayHasKey(
0,
$xmlPart,
__METHOD__ . " XML part does not have key 0. Expected a value at index 0 of 'xmlPart' but, found: " . json_encode($xmlPart)
__METHOD__
. " XML part does not have key 0. Expected a value at index 0 of 'xmlPart' but, found: "
. json_encode($xmlPart)
);
$mtime = new DateTime($xmlPart[0]->__toString());
return $mtime->format('U');

View File

@ -164,7 +164,9 @@ class ArchiverContext implements Context {
foreach ($headersTable as $row) {
$headers[$row['header']] = $row ['value'];
}
$this->featureContext->setResponse($this->downloadArchive($user, $resource, $addressType, $archiveType, null, $headers));
$this->featureContext->setResponse(
$this->downloadArchive($user, $resource, $addressType, $archiveType, null, $headers)
);
}
/**
@ -267,7 +269,7 @@ class ArchiverContext implements Context {
*
* @throws Exception
*/
public function theDownloadedArchiveShouldContainTheseFiles(string $type, TableNode $expectedFiles):void {
public function theDownloadedArchiveShouldContainTheseFiles(string $type, TableNode $expectedFiles): void {
$this->featureContext->verifyTableNodeColumns($expectedFiles, ['name', 'content']);
$contents = $this->featureContext->getResponse()->getBody()->getContents();
$tempFile = \tempnam(\sys_get_temp_dir(), 'OcAcceptanceTests_');

View File

@ -40,7 +40,7 @@ class AuthContext implements Context {
*
* @return void
*/
public function before(BeforeScenarioScope $scope):void {
public function before(BeforeScenarioScope $scope): void {
// Get the environment
$environment = $scope->getEnvironment();
// Get all the contexts you need in this context
@ -141,7 +141,7 @@ class AuthContext implements Context {
*
* @return void
*/
public function userRequestsURLWithNoAuth(string $url, string $method):void {
public function userRequestsURLWithNoAuth(string $url, string $method): void {
$this->featureContext->setResponse($this->sendRequest($url, $method));
}
@ -156,7 +156,12 @@ class AuthContext implements Context {
* @return void
* @throws JsonException
*/
public function userRequestsEndpointsWithBodyAndNoAuthThenStatusCodeAboutUser(string $method, string $body, string $ofUser, TableNode $table): void {
public function userRequestsEndpointsWithBodyAndNoAuthThenStatusCodeAboutUser(
string $method,
string $body,
string $ofUser,
TableNode $table
): void {
$ofUser = \strtolower($this->featureContext->getActualUsername($ofUser));
$this->featureContext->verifyTableNodeColumns($table, ['endpoint']);
foreach ($table->getHash() as $row) {
@ -180,7 +185,11 @@ class AuthContext implements Context {
* @return void
* @throws Exception
*/
public function userRequestsEndpointsWithoutBodyAndNoAuthAboutUser(string $method, string $ofUser, TableNode $table): void {
public function userRequestsEndpointsWithoutBodyAndNoAuthAboutUser(
string $method,
string $ofUser,
TableNode $table
): void {
$ofUser = \strtolower($this->featureContext->getActualUsername($ofUser));
$this->featureContext->verifyTableNodeColumns($table, ['endpoint']);
foreach ($table->getHash() as $row) {
@ -203,7 +212,7 @@ class AuthContext implements Context {
* @return void
* @throws Exception
*/
public function userRequestsEndpointsWithNoAuthentication(string $method, TableNode $table):void {
public function userRequestsEndpointsWithNoAuthentication(string $method, TableNode $table): void {
$this->featureContext->verifyTableNodeColumns($table, ['endpoint'], ['service']);
foreach ($table->getHash() as $row) {
$this->featureContext->setResponse(
@ -226,7 +235,7 @@ class AuthContext implements Context {
* @return void
* @throws Exception
*/
public function userRequestsEndpointsWithBasicAuth(string $user, string $method, TableNode $table):void {
public function userRequestsEndpointsWithBasicAuth(string $user, string $method, TableNode $table): void {
$this->featureContext->verifyTableNodeColumns($table, ['endpoint']);
foreach ($table->getHash() as $row) {
$response = $this->requestUrlWithBasicAuth($user, $row['endpoint'], $method);
@ -253,7 +262,7 @@ class AuthContext implements Context {
string $property,
string $ofUser,
TableNode $table
):void {
): void {
$this->featureContext->verifyTableNodeColumns($table, ['endpoint']);
foreach ($table->getHash() as $row) {
@ -276,7 +285,7 @@ class AuthContext implements Context {
* @return void
* @throws Exception
*/
public function theAdminRequestsTheseEndpointsWithMethod(string $method, TableNode $table):void {
public function theAdminRequestsTheseEndpointsWithMethod(string $method, TableNode $table): void {
$this->featureContext->verifyTableNodeColumns($table, ['endpoint']);
foreach ($table->getHash() as $row) {
$response = $this->requestUrlWithBasicAuth(
@ -302,7 +311,7 @@ class AuthContext implements Context {
string $user,
string $url,
string $method
):void {
): void {
$response = $this->requestUrlWithBasicAuth($user, $url, $method);
$this->featureContext->setResponse($response);
}
@ -318,7 +327,12 @@ class AuthContext implements Context {
* @return void
* @throws Exception
*/
public function userRequestsURLWithUsingBasicAuthAndDepthHeader(string $user, string $url, string $method, TableNode $headersTable):void {
public function userRequestsURLWithUsingBasicAuthAndDepthHeader(
string $user,
string $url,
string $method,
TableNode $headersTable
): void {
$user = $this->featureContext->getActualUsername($user);
$url = $this->featureContext->substituteInLineCodes(
$url,
@ -390,7 +404,7 @@ class AuthContext implements Context {
string $password,
string $ofUser,
TableNode $table
):void {
): void {
$user = $this->featureContext->getActualUsername($user);
$ofUser = $this->featureContext->getActualUsername($ofUser);
$this->featureContext->verifyTableNodeColumns($table, ['endpoint'], ['destination']);
@ -407,7 +421,8 @@ class AuthContext implements Context {
$row['destination'],
$ofUser
);
$headers['Destination'] = $this->featureContext->getBaseUrl() . "/" . WebdavHelper::prefixRemotePhp(\ltrim($destination, "/"));
$headers['Destination'] = $this->featureContext->getBaseUrl()
. "/" . WebdavHelper::prefixRemotePhp(\ltrim($destination, "/"));
}
$response = $this->sendRequest(
$row['endpoint'],
@ -440,7 +455,7 @@ class AuthContext implements Context {
string $password,
string $ofUser,
TableNode $table
):void {
): void {
$user = $this->featureContext->getActualUsername($user);
$ofUser = $this->featureContext->getActualUsername($ofUser);
$this->featureContext->verifyTableNodeColumns($table, ['endpoint'], ['destination']);
@ -457,7 +472,8 @@ class AuthContext implements Context {
$row['destination'],
$ofUser
);
$headers['Destination'] = $this->featureContext->getBaseUrl() . "/" . WebdavHelper::prefixRemotePhp(\ltrim($destination, "/"));
$headers['Destination'] = $this->featureContext->getBaseUrl()
. "/" . WebdavHelper::prefixRemotePhp(\ltrim($destination, "/"));
}
$response = $this->sendRequest(
$row['endpoint'],
@ -482,7 +498,13 @@ class AuthContext implements Context {
* @return void
* @throws Exception
*/
public function userRequestsTheseEndpointsIncludingBodyAboutUser(string $user, string $method, string $body, string $ofUser, TableNode $table):void {
public function userRequestsTheseEndpointsIncludingBodyAboutUser(
string $user,
string $method,
string $body,
string $ofUser,
TableNode $table
): void {
$user = $this->featureContext->getActualUsername($user);
$ofUser = $this->featureContext->getActualUsername($ofUser);
$this->featureContext->verifyTableNodeColumns($table, ['endpoint']);
@ -520,7 +542,12 @@ class AuthContext implements Context {
* @return void
* @throws Exception
*/
public function userRequestsTheseEndpointsWithoutBodyUsingThePasswordOfUser(string $asUser, string $method, string $ofUser, TableNode $table):void {
public function userRequestsTheseEndpointsWithoutBodyUsingThePasswordOfUser(
string $asUser,
string $method,
string $ofUser,
TableNode $table
): void {
$asUser = $this->featureContext->getActualUsername($asUser);
$ofUser = $this->featureContext->getActualUsername($ofUser);
$this->featureContext->verifyTableNodeColumns($table, ['endpoint']);
@ -556,7 +583,13 @@ class AuthContext implements Context {
* @return void
* @throws JsonException
*/
public function userRequestsTheseEndpointsIncludingBodyUsingPasswordOfUser(string $asUser, string $method, ?string $body, string $ofUser, TableNode $table):void {
public function userRequestsTheseEndpointsIncludingBodyUsingPasswordOfUser(
string $asUser,
string $method,
?string $body,
string $ofUser,
TableNode $table
): void {
$asUser = $this->featureContext->getActualUsername($asUser);
$ofUser = $this->featureContext->getActualUsername($ofUser);
$this->featureContext->verifyTableNodeColumns($table, ['endpoint']);
@ -591,7 +624,12 @@ class AuthContext implements Context {
* @return void
* @throws Exception
*/
public function userRequestsTheseEndpointsAboutUser(string $user, string $method, string $ofUser, TableNode $table):void {
public function userRequestsTheseEndpointsAboutUser(
string $user,
string $method,
string $ofUser,
TableNode $table
): void {
$headers = [];
if ($method === 'MOVE' || $method === 'COPY') {
$baseUrl = $this->featureContext->getBaseUrl();
@ -633,7 +671,7 @@ class AuthContext implements Context {
string $user,
string $endpoint,
string $method
):void {
): void {
$username = $this->featureContext->getActualUsername($user);
$endpoint = $this->featureContext->substituteInLineCodes(
$endpoint,

View File

@ -49,7 +49,7 @@ class CapabilitiesContext implements Context {
*
* @return void
*/
public function before(BeforeScenarioScope $scope):void {
public function before(BeforeScenarioScope $scope): void {
// Get the environment
$environment = $scope->getEnvironment();
// Get all the contexts you need in this context
@ -164,7 +164,7 @@ class CapabilitiesContext implements Context {
* @return void
* @throws Exception
*/
public function checkVersionMajorMinorMicroResponse():void {
public function checkVersionMajorMinorMicroResponse(): void {
$jsonResponse = $this->featureContext->getJsonDecodedResponseBodyContent();
$versionData = $jsonResponse->ocs->data->version;
$versionString = (string) $versionData->string;

View File

@ -47,7 +47,7 @@ class ChecksumContext implements Context {
string $source,
string $destination,
string $checksum
):ResponseInterface {
): ResponseInterface {
$file = \file_get_contents(
$this->featureContext->acceptanceTestsDirLocation() . $source
);
@ -75,8 +75,10 @@ class ChecksumContext implements Context {
string $source,
string $destination,
string $checksum
):void {
$this->featureContext->setResponse($this->uploadFileToWithChecksumUsingTheAPI($user, $source, $destination, $checksum));
): void {
$this->featureContext->setResponse(
$this->uploadFileToWithChecksumUsingTheAPI($user, $source, $destination, $checksum)
);
}
/**
@ -94,7 +96,7 @@ class ChecksumContext implements Context {
string $source,
string $destination,
string $checksum
):void {
): void {
$user = $this->featureContext->getActualUsername($user);
$response = $this->uploadFileToWithChecksumUsingTheAPI(
$user,
@ -118,7 +120,7 @@ class ChecksumContext implements Context {
string $content,
string $checksum,
string $destination
):ResponseInterface {
): ResponseInterface {
return $this->featureContext->makeDavRequest(
$user,
'PUT',
@ -143,7 +145,7 @@ class ChecksumContext implements Context {
string $content,
string $checksum,
string $destination
):void {
): void {
$user = $this->featureContext->getActualUsername($user);
$response = $this->uploadFileWithContentAndChecksumToUsingTheAPI($user, $content, $checksum, $destination);
$this->featureContext->theHTTPStatusCodeShouldBe(201, '', $response);
@ -157,7 +159,7 @@ class ChecksumContext implements Context {
*
* @return void
*/
public function userRequestsTheChecksumOfViaPropfind(string $user, string $path):void {
public function userRequestsTheChecksumOfViaPropfind(string $user, string $path): void {
$this->featureContext->setResponse($this->propfindResourceChecksum($user, $path));
}
@ -168,7 +170,7 @@ class ChecksumContext implements Context {
*
* @return ResponseInterface
*/
public function propfindResourceChecksum(string $user, string $path, ?string $spaceId = null) : ResponseInterface {
public function propfindResourceChecksum(string $user, string $path, ?string $spaceId = null): ResponseInterface {
$user = $this->featureContext->getActualUsername($user);
$body = '<?xml version="1.0"?>
<d:propfind xmlns:d="DAV:" xmlns:oc="http://owncloud.org/ns">
@ -199,7 +201,7 @@ class ChecksumContext implements Context {
* @return void
* @throws Exception
*/
public function theWebdavChecksumShouldMatch(string $expectedChecksum):void {
public function theWebdavChecksumShouldMatch(string $expectedChecksum): void {
$bodyContents = $this->featureContext->getResponse()->getBody()->getContents();
$this->validateChecksum($bodyContents, $expectedChecksum);
}
@ -214,7 +216,11 @@ class ChecksumContext implements Context {
* @return void
* @throws Exception
*/
public function asUserTheWebdavChecksumOfPathViaPropfindShouldMatch(string $user, string $path, string $expectedChecksum):void {
public function asUserTheWebdavChecksumOfPathViaPropfindShouldMatch(
string $user,
string $path,
string $expectedChecksum
): void {
$user = $this->featureContext->getActualUsername($user);
$resource = $this->propfindResourceChecksum($user, $path);
$bodyContents = $resource->getBody()->getContents();
@ -226,7 +232,7 @@ class ChecksumContext implements Context {
*
* @return void
*/
public function validateChecksum(string $bodyContents, string $expectedChecksum):void {
public function validateChecksum(string $bodyContents, string $expectedChecksum): void {
$service = new Sabre\Xml\Service();
$parsed = $service->parse($bodyContents);
@ -243,7 +249,8 @@ class ChecksumContext implements Context {
Assert::assertIsArray(
$parsed,
__METHOD__ . " could not parse response as XML. Expected parsed XML to be an array but found " . $bodyContents
__METHOD__
. " could not parse response as XML. Expected parsed XML to be an array but found " . $bodyContents
);
Assert::assertArrayHasKey(
0,
@ -320,7 +327,7 @@ class ChecksumContext implements Context {
* @return void
* @throws Exception
*/
public function theHeaderChecksumShouldMatch(string $expectedChecksum):void {
public function theHeaderChecksumShouldMatch(string $expectedChecksum): void {
$headerChecksums
= $this->featureContext->getResponse()->getHeader('OC-Checksum');
@ -360,7 +367,11 @@ class ChecksumContext implements Context {
* @return void
* @throws Exception
*/
public function theHeaderChecksumWhenUserDownloadsFileUsingTheWebdavApiShouldMatch(string $user, string $fileName, string $expectedChecksum):void {
public function theHeaderChecksumWhenUserDownloadsFileUsingTheWebdavApiShouldMatch(
string $user,
string $fileName,
string $expectedChecksum
): void {
$response = $this->featureContext->downloadFileAsUserUsingPassword($user, $fileName);
$headerChecksums = $response->getHeader('OC-Checksum');
@ -407,7 +418,7 @@ class ChecksumContext implements Context {
string $data,
string $destination,
string $expectedChecksum
):ResponseInterface {
): ResponseInterface {
$user = $this->featureContext->getActualUsername($user);
$num -= 1;
$file = "$destination-chunking-42-$total-$num";
@ -439,8 +450,15 @@ class ChecksumContext implements Context {
string $data,
string $destination,
string $expectedChecksum
):void {
$response = $this->uploadChunkFileOfWithToWithChecksum($user, $num, $total, $data, $destination, $expectedChecksum);
): void {
$response = $this->uploadChunkFileOfWithToWithChecksum(
$user,
$num,
$total,
$data,
$destination,
$expectedChecksum
);
$this->featureContext->setResponse($response);
}
@ -463,8 +481,15 @@ class ChecksumContext implements Context {
string $data,
string $destination,
string $expectedChecksum
):void {
$response = $this->uploadChunkFileOfWithToWithChecksum($user, $num, $total, $data, $destination, $expectedChecksum);
): void {
$response = $this->uploadChunkFileOfWithToWithChecksum(
$user,
$num,
$total,
$data,
$destination,
$expectedChecksum
);
$this->featureContext->theHTTPStatusCodeShouldBe(
[201, 206],
'',
@ -482,7 +507,7 @@ class ChecksumContext implements Context {
*
* @return void
*/
public function before(BeforeScenarioScope $scope):void {
public function before(BeforeScenarioScope $scope): void {
// Get the environment
$environment = $scope->getEnvironment();
// Get all the contexts you need in this context

View File

@ -80,7 +80,11 @@ class CliContext implements Context {
*
* @return void
*/
public function theAdministratorResetsThePasswordOfUserUsingTheCLI(string $status, string $user, string $password): void {
public function theAdministratorResetsThePasswordOfUserUsingTheCLI(
string $status,
string $user,
string $password
): void {
$command = "idm resetpassword -u $user";
$body = [
"command" => $command,
@ -99,7 +103,7 @@ class CliContext implements Context {
*
* @return void
*/
public function theAdministratorDeletesEmptyTrashbinFoldersUsingTheCli():void {
public function theAdministratorDeletesEmptyTrashbinFoldersUsingTheCli(): void {
$path = $this->featureContext->getStorageUsersRoot();
$command = "trash purge-empty-dirs -p $path --dry-run=false";
$body = [
@ -113,7 +117,7 @@ class CliContext implements Context {
*
* @return void
*/
public function theAdministratorChecksTheBackupConsistencyUsingTheCli():void {
public function theAdministratorChecksTheBackupConsistencyUsingTheCli(): void {
$path = $this->featureContext->getStorageUsersRoot();
$command = "backup consistency -p $path";
$body = [
@ -121,7 +125,7 @@ class CliContext implements Context {
];
$this->featureContext->setResponse(CliHelper::runCommand($body));
}
/**
* @When the administrator creates app token for user :user with expiration time :expirationTime using the auth-app CLI
*
@ -130,7 +134,10 @@ class CliContext implements Context {
*
* @return void
*/
public function theAdministratorCreatesAppTokenForUserWithExpirationTimeUsingTheAuthAppCLI(string $user, string $expirationTime): void {
public function theAdministratorCreatesAppTokenForUserWithExpirationTimeUsingTheAuthAppCLI(
string $user,
string $expirationTime
): void {
$user = $this->featureContext->getActualUserName($user);
$command = "auth-app create --user-name=$user --expiration=$expirationTime";
$body = [
@ -147,7 +154,10 @@ class CliContext implements Context {
*
* @return void
*/
public function userHasCreatedAppTokenWithExpirationTimeUsingTheAuthAppCLI(string $user, string $expirationTime): void {
public function userHasCreatedAppTokenWithExpirationTimeUsingTheAuthAppCLI(
string $user,
string $expirationTime
): void {
$user = $this->featureContext->getActualUserName($user);
$command = "auth-app create --user-name=$user --expiration=$expirationTime";
$body = [
@ -158,7 +168,11 @@ class CliContext implements Context {
$this->featureContext->theHTTPStatusCodeShouldBe(200, '', $response);
$jsonResponse = $this->featureContext->getJsonDecodedResponse($response);
Assert::assertSame("OK", $jsonResponse["status"]);
Assert::assertSame(0, $jsonResponse["exitCode"], "Expected exit code to be 0, but got " . $jsonResponse["exitCode"]);
Assert::assertSame(
0,
$jsonResponse["exitCode"],
"Expected exit code to be 0, but got " . $jsonResponse["exitCode"]
);
}
/**
@ -230,7 +244,7 @@ class CliContext implements Context {
*
* @return void
*/
public function theAdministratorRemovesTheVersionsOfFilesInSpaceUsingSpaceId(string $space):void {
public function theAdministratorRemovesTheVersionsOfFilesInSpaceUsingSpaceId(string $space): void {
$path = $this->featureContext->getStorageUsersRoot();
$adminUsername = $this->featureContext->getAdminUsername();
$spaceId = $this->spacesContext->getSpaceIdByName($adminUsername, $space);
@ -253,7 +267,11 @@ class CliContext implements Context {
$jsonResponse = $this->featureContext->getJsonDecodedResponse($response);
Assert::assertSame("OK", $jsonResponse["status"]);
Assert::assertSame(0, $jsonResponse["exitCode"], "Expected exit code to be 0, but got " . $jsonResponse["exitCode"]);
Assert::assertSame(
0,
$jsonResponse["exitCode"],
"Expected exit code to be 0, but got " . $jsonResponse["exitCode"]
);
}
/**

View File

@ -86,7 +86,13 @@ class CollaborationContext implements Context {
*
* @throws GuzzleException
*/
public function userChecksTheInformationOfFileOfSpaceUsingOffice(string $user, string $file, string $space, string $app, string $viewMode = null): void {
public function userChecksTheInformationOfFileOfSpaceUsingOffice(
string $user,
string $file,
string $space,
string $app,
string $viewMode = null
): void {
$fileId = $this->spacesContext->getFileId($user, $space, $file);
$response = \json_decode(
CollaborationHelper::sendPOSTRequestToAppOpen(
@ -127,7 +133,12 @@ class CollaborationContext implements Context {
* @return void
* @throws GuzzleException
*/
public function userCreatesFileInsideFolderInSpaceUsingWopiEndpoint(string $user, string $file, string $folder, string $space): void {
public function userCreatesFileInsideFolderInSpaceUsingWopiEndpoint(
string $user,
string $file,
string $folder,
string $space
): void {
$parentContainerId = $this->spacesContext->getResourceId($user, $space, $folder);
$this->featureContext->setResponse(
CollaborationHelper::createFile(
@ -193,7 +204,10 @@ class CollaborationContext implements Context {
* @return void
* @throws GuzzleException
*/
public function thePublicCreatesAFileInsideTheLastSharedPublicLinkFolderWithPasswordUsingWopiEndpoint(string $file, string $password): void {
public function thePublicCreatesAFileInsideTheLastSharedPublicLinkFolderWithPasswordUsingWopiEndpoint(
string $file,
string $password
): void {
$this->createFile($file, $password);
}
@ -208,7 +222,11 @@ class CollaborationContext implements Context {
* @return void
* @throws GuzzleException
*/
public function thePublicCreatesAFileInsideFolderInTheLastSharedPublicLinkSpaceWithPasswordUsingWopiEndpoint(string $file, string $folder, string $password): void {
public function thePublicCreatesAFileInsideFolderInTheLastSharedPublicLinkSpaceWithPasswordUsingWopiEndpoint(
string $file,
string $folder,
string $password
): void {
$this->createFile($file, $password, $folder);
}
@ -225,7 +243,12 @@ class CollaborationContext implements Context {
* @throws GuzzleException
* @throws JsonException
*/
public function userTriesToCheckTheInformationOfFileOfSpaceUsingOfficeWithInvalidFileId(string $user, string $file, string $space, string $app): void {
public function userTriesToCheckTheInformationOfFileOfSpaceUsingOfficeWithInvalidFileId(
string $user,
string $file,
string $space,
string $app
): void {
$response = \json_decode(
CollaborationHelper::sendPOSTRequestToAppOpen(
$this->spacesContext->getFileId($user, $space, $file),
@ -335,9 +358,11 @@ class CollaborationContext implements Context {
* @return void
* @throws Exception
*/
public function theFollowingMimeTypesShouldExistForUser(string $shouldOrNot, TableNode $table):void {
public function theFollowingMimeTypesShouldExistForUser(string $shouldOrNot, TableNode $table): void {
$rows = $table->getRows();
$responseArray = $this->featureContext->getJsonDecodedResponse($this->featureContext->getResponse())['mime-types'];
$responseArray = $this->featureContext->getJsonDecodedResponse(
$this->featureContext->getResponse()
)['mime-types'];
$mimeTypes = \array_column($responseArray, 'mime_type');
foreach ($rows as $row) {
if ($shouldOrNot === "should not") {
@ -364,10 +389,17 @@ class CollaborationContext implements Context {
*
* @return void
*/
public function theAppListResponseShouldContainTheFollowingTemplateInformationForOffice(string $app, TableNode $table): void {
public function theAppListResponseShouldContainTheFollowingTemplateInformationForOffice(
string $app,
TableNode $table
): void {
$responseArray = $this->featureContext->getJsonDecodedResponse($this->featureContext->getResponse());
Assert::assertArrayHasKey("mime-types", $responseArray, "Expected 'mime-types' in the response but not found.\n" . print_r($responseArray, true));
Assert::assertArrayHasKey(
"mime-types",
$responseArray,
"Expected 'mime-types' in the response but not found.\n" . print_r($responseArray, true)
);
$mimeTypes = $responseArray['mime-types'];
@ -377,7 +409,12 @@ class CollaborationContext implements Context {
}
foreach ($table->getColumnsHash() as $row) {
Assert::assertArrayHasKey($row['mime-type'], $mimeTypeMap, "Expected mime-type '{$row['mime-type']}' to exist in the response but it doesn't.\n" . print_r($mimeTypeMap, true));
Assert::assertArrayHasKey(
$row['mime-type'],
$mimeTypeMap,
"Expected mime-type '{$row['mime-type']}' to exist in the response but it doesn't.\n"
. print_r($mimeTypeMap, true)
);
$mimeType = $mimeTypeMap[$row['mime-type']];
$found = false;
@ -387,7 +424,8 @@ class CollaborationContext implements Context {
Assert::assertSame(
$row['target-extension'],
$provider['target_ext'],
"Expected 'target_ext' for $app to be '{$row['target-extension']}' but found '{$provider['target_ext']}'"
"Expected 'target_ext' for $app to be '{$row['target-extension']}'"
. " but found '{$provider['target_ext']}'"
);
$found = true;
break;
@ -396,8 +434,10 @@ class CollaborationContext implements Context {
if (!$found) {
Assert::fail(
"Expected response to contain app-provider '$app' with target-extension '{$row['target-extension']}' for mime-type '{$row['mime-type']}', but no matching provider was found.\n" .
"App Providers Found: " . print_r($mimeType['app_providers'], true)
"Expected response to contain app-provider '$app' with target-extension "
. "'{$row['target-extension']}' for mime-type '{$row['mime-type']}',"
. " but no matching provider was found.\n App Providers Found: "
. print_r($mimeType['app_providers'], true)
);
}
}
@ -412,7 +452,7 @@ class CollaborationContext implements Context {
* @return string
* @throws GuzzleException
*/
public function userHasCreatedAFileInSpaceUsingWopiEndpoint(string $user, string $file):string {
public function userHasCreatedAFileInSpaceUsingWopiEndpoint(string $user, string $file): string {
$parentContainerId = $this->featureContext->getFileIdForPath($user, "/");
$response = CollaborationHelper::createFile(
$this->featureContext->getBaseUrl(),

View File

@ -43,7 +43,7 @@ class FavoritesContext implements Context {
*
* @return ResponseInterface
*/
public function userFavoritesElement(string $user, string $path, string $spaceId = null):ResponseInterface {
public function userFavoritesElement(string $user, string $path, string $spaceId = null): ResponseInterface {
return $this->changeFavStateOfAnElement(
$user,
$path,
@ -60,7 +60,7 @@ class FavoritesContext implements Context {
*
* @return void
*/
public function userFavoritesElementUsingWebDavApi(string $user, string $path):void {
public function userFavoritesElementUsingWebDavApi(string $user, string $path): void {
$this->featureContext->setResponse($this->userFavoritesElement($user, $path));
}
@ -72,7 +72,7 @@ class FavoritesContext implements Context {
*
* @return void
*/
public function userHasFavoritedElementUsingWebDavApi(string $user, string $path):void {
public function userHasFavoritedElementUsingWebDavApi(string $user, string $path): void {
$this->featureContext->theHTTPStatusCodeShouldBe(207, '', $this->userFavoritesElement($user, $path));
}
@ -82,7 +82,7 @@ class FavoritesContext implements Context {
*
* @return ResponseInterface
*/
public function userUnfavoritesElement(string $user, string $path):ResponseInterface {
public function userUnfavoritesElement(string $user, string $path): ResponseInterface {
return $this->changeFavStateOfAnElement(
$user,
$path,
@ -99,7 +99,7 @@ class FavoritesContext implements Context {
*
* @return void
*/
public function userUnfavoritesElementUsingWebDavApi(string $user, string $path):void {
public function userUnfavoritesElementUsingWebDavApi(string $user, string $path): void {
$this->featureContext->setResponse($this->userUnfavoritesElement($user, $path));
}
@ -116,7 +116,7 @@ class FavoritesContext implements Context {
string $user,
string $shouldOrNot,
TableNode $expectedElements
):void {
): void {
$user = $this->featureContext->getActualUsername($user);
$this->userListsFavorites($user);
$this->featureContext->propfindResultShouldContainEntries(
@ -134,7 +134,7 @@ class FavoritesContext implements Context {
*
* @return void
*/
public function userListsFavorites(string $user, ?int $limit = null):void {
public function userListsFavorites(string $user, ?int $limit = null): void {
$renamedUser = $this->featureContext->getActualUsername($user);
$baseUrl = $this->featureContext->getBaseUrl();
$password = $this->featureContext->getPasswordForUser($user);
@ -176,7 +176,12 @@ class FavoritesContext implements Context {
*
* @return void
*/
public function asUserFileOrFolderShouldBeFavorited(string $user, string $path, int $expectedValue = 1, string $spaceId = null):void {
public function asUserFileOrFolderShouldBeFavorited(
string $user,
string $path,
int $expectedValue = 1,
string $spaceId = null
): void {
$property = "oc:favorite";
$this->webDavPropertiesContext->checkPropertyOfAFolder(
$user,
@ -196,7 +201,7 @@ class FavoritesContext implements Context {
*
* @return void
*/
public function asUserFileShouldNotBeFavorited(string $user, string $path):void {
public function asUserFileShouldNotBeFavorited(string $user, string $path): void {
$this->asUserFileOrFolderShouldBeFavorited($user, $path, 0);
}
@ -215,7 +220,7 @@ class FavoritesContext implements Context {
string $path,
?int $favOrUnfav,
?string $spaceId,
):ResponseInterface {
): ResponseInterface {
$renamedUser = $this->featureContext->getActualUsername($user);
return WebDavHelper::proppatch(
$this->featureContext->getBaseUrl(),
@ -242,7 +247,7 @@ class FavoritesContext implements Context {
*
* @return void
*/
public function before(BeforeScenarioScope $scope):void {
public function before(BeforeScenarioScope $scope): void {
// Get the environment
$environment = $scope->getEnvironment();
// Get all the contexts you need in this context

View File

@ -1034,7 +1034,11 @@ class FeatureContext extends BehatVariablesContext {
private function checkInvalidValidator(JsonSchema $schemaObj): void {
$validators = \array_keys((array)$schemaObj->jsonSerialize());
foreach ($validators as $validator) {
Assert::assertContains(\ltrim($validator, "$"), $this->jsonSchemaValidators, "Invalid schema validator: '$validator'");
Assert::assertContains(
\ltrim($validator, "$"),
$this->jsonSchemaValidators,
"Invalid schema validator: '$validator'"
);
}
}
@ -1091,7 +1095,9 @@ class FeatureContext extends BehatVariablesContext {
return;
}
$hasTwoElementValidator = ($schemaObj->enum && $schemaObj->const) || ($schemaObj->enum && $schemaObj->items) || ($schemaObj->const && $schemaObj->items);
$hasTwoElementValidator = ($schemaObj->enum && $schemaObj->const)
|| ($schemaObj->enum && $schemaObj->items)
|| ($schemaObj->const && $schemaObj->items);
Assert::assertFalse($hasTwoElementValidator, "'items', 'enum' and 'const' should not be used together");
if ($schemaObj->enum || $schemaObj->const) {
// do not try to validate of enum or const is present
@ -1113,7 +1119,11 @@ class FeatureContext extends BehatVariablesContext {
Assert::assertNotNull($schemaObj->$validator, \sprintf($errMsg, $validator));
}
Assert::assertEquals($schemaObj->minItems, $schemaObj->maxItems, "'minItems' and 'maxItems' should be equal for strict assertion");
Assert::assertEquals(
$schemaObj->minItems,
$schemaObj->maxItems,
"'minItems' and 'maxItems' should be equal for strict assertion"
);
// check optional validators
foreach ($optionalValidators as $validator) {
@ -1127,18 +1137,34 @@ class FeatureContext extends BehatVariablesContext {
if ($schemaObj->maxItems > 1) {
if (\is_array($value)) {
foreach ($value as $element) {
Assert::assertNotNull($element->oneOf, "'oneOf' is required to assert more than one elements");
Assert::assertNotNull(
$element->oneOf,
"'oneOf' is required to assert more than one elements"
);
}
Assert::fail("'$validator' should be an object not an array");
}
Assert::assertFalse($value->allOf || $value->anyOf, "'allOf' and 'anyOf' are not allowed in array");
Assert::assertFalse(
$value->allOf || $value->anyOf,
"'allOf' and 'anyOf' are not allowed in array"
);
if ($value->oneOf) {
Assert::assertNotNull($value->oneOf, "'oneOf' is required to assert more than one elements");
Assert::assertNotNull(
$value->oneOf,
"'oneOf' is required to assert more than one elements"
);
Assert::assertTrue(\is_array($value->oneOf), "'oneOf' should be an array");
Assert::assertEquals($schemaObj->maxItems, \count($value->oneOf), "Expected " . $schemaObj->maxItems . " 'oneOf' items but got " . \count($value->oneOf));
Assert::assertEquals(
$schemaObj->maxItems,
\count($value->oneOf),
"Expected " . $schemaObj->maxItems . " 'oneOf' items but got " . \count($value->oneOf)
);
}
}
Assert::assertTrue(\is_object($value), "'$validator' should be an object when expecting 1 element");
Assert::assertTrue(
\is_object($value),
"'$validator' should be an object when expecting 1 element"
);
break;
case "uniqueItems":
if ($schemaObj->minItems > 1) {
@ -1340,7 +1366,12 @@ class FeatureContext extends BehatVariablesContext {
* @throws GuzzleException
* @throws JsonException
*/
public function userSendsHTTPMethodToUrlWithHeaders(string $user, string $verb, string $url, TableNode $headersTable): void {
public function userSendsHTTPMethodToUrlWithHeaders(
string $user,
string $verb,
string $url,
TableNode $headersTable
): void {
$this->verifyTableNodeColumns(
$headersTable,
['header', 'value']
@ -1385,7 +1416,12 @@ class FeatureContext extends BehatVariablesContext {
*
* @return void
*/
public function userSendsHttpMethodToUrlWithContent(string $user, string $method, string $davPath, string $content): void {
public function userSendsHttpMethodToUrlWithContent(
string $user,
string $method,
string $davPath,
string $content
): void {
$this->setResponse($this->sendingToWithDirectUrl($user, $method, $davPath, $content));
}
@ -1399,7 +1435,12 @@ class FeatureContext extends BehatVariablesContext {
*
* @return void
*/
public function userSendsHTTPMethodToUrlWithPassword(string $user, string $verb, string $url, string $password): void {
public function userSendsHTTPMethodToUrlWithPassword(
string $user,
string $verb,
string $url,
string $password
): void {
$this->setResponse($this->sendingToWithDirectUrl($user, $verb, $url, null, $password));
}
@ -1414,7 +1455,14 @@ class FeatureContext extends BehatVariablesContext {
* @return ResponseInterface
* @throws GuzzleException
*/
public function sendingToWithDirectUrl(string $user, string $verb, string $url, ?string $body = null, ?string $password = null, ?array $headers = null): ResponseInterface {
public function sendingToWithDirectUrl(
string $user,
string $verb,
string $url,
?string $body = null,
?string $password = null,
?array $headers = null
): ResponseInterface {
$url = \ltrim($url, '/');
if (WebdavHelper::isDAVRequest($url)) {
$url = WebdavHelper::prefixRemotePhp($url);
@ -1498,12 +1546,17 @@ class FeatureContext extends BehatVariablesContext {
*
* @return void
*/
public function theHTTPStatusCodeShouldBe($expectedStatusCode, ?string $message = "", ?ResponseInterface $response = null): void {
public function theHTTPStatusCodeShouldBe(
$expectedStatusCode,
?string $message = "",
?ResponseInterface $response = null
): void {
$response = $response ?? $this->response;
$actualStatusCode = $response->getStatusCode();
if (\is_array($expectedStatusCode)) {
if ($message === "") {
$message = "HTTP status code $actualStatusCode is not one of the expected values " . \implode(" or ", $expectedStatusCode);
$message = "HTTP status code $actualStatusCode is not one of the expected values "
. \implode(" or ", $expectedStatusCode);
}
Assert::assertContainsEquals(
@ -2745,7 +2798,11 @@ class FeatureContext extends BehatVariablesContext {
* @return void
* @throws Exception
*/
public function verifyTableNodeColumns(?TableNode $table, ?array $requiredHeader = [], ?array $allowedHeader = []): void {
public function verifyTableNodeColumns(
?TableNode $table,
?array $requiredHeader = [],
?array $allowedHeader = []
): void {
if ($table === null || \count($table->getHash()) < 1) {
throw new Exception("Table should have at least one row.");
}
@ -2830,14 +2887,17 @@ class FeatureContext extends BehatVariablesContext {
public function getBodyForOCSRequest(string $method, string $property): ?string {
$body = null;
if ($method === 'PROPFIND') {
$body = '<?xml version="1.0"?><d:propfind xmlns:d="DAV:" xmlns:oc="http://owncloud.org/ns"><d:prop><' . $property . '/></d:prop></d:propfind>';
$body = '<?xml version="1.0"?><d:propfind xmlns:d="DAV:" xmlns:oc="http://owncloud.org/ns"><d:prop><'
. $property . '/></d:prop></d:propfind>';
} elseif ($method === 'LOCK') {
$body = "<?xml version='1.0' encoding='UTF-8'?><d:lockinfo xmlns:d='DAV:'> <d:lockscope><" . $property . " /></d:lockscope></d:lockinfo>";
$body = "<?xml version='1.0' encoding='UTF-8'?><d:lockinfo xmlns:d='DAV:'> <d:lockscope><"
. $property . " /></d:lockscope></d:lockinfo>";
} elseif ($method === 'PROPPATCH') {
if ($property === 'favorite') {
$property = '<oc:favorite xmlns:oc="http://owncloud.org/ns">1</oc:favorite>';
}
$body = '<?xml version="1.0"?><d:propertyupdate xmlns:d="DAV:" xmlns:oc="http://owncloud.org/ns"><d:set><d:prop>' . $property . '</d:prop></d:set></d:propertyupdate>';
$body = '<?xml version="1.0"?><d:propertyupdate xmlns:d="DAV:" xmlns:oc="http://owncloud.org/ns"><d:set>'
. "<d:prop>" . $property . '</d:prop></d:set></d:propertyupdate>';
}
if ($property === '') {
$body = '';
@ -2877,7 +2937,7 @@ class FeatureContext extends BehatVariablesContext {
* @return string
* @throws Exception|GuzzleException
*/
public function getGroupIdByGroupName(string $groupName):string {
public function getGroupIdByGroupName(string $groupName): string {
$response = GraphHelper::getGroup(
$this->getBaseUrl(),
$this->getStepLineRef(),

View File

@ -48,7 +48,7 @@ class FilesVersionsContext implements Context {
*
* @return void
*/
public function before(BeforeScenarioScope $scope):void {
public function before(BeforeScenarioScope $scope): void {
// Get the environment
$environment = $scope->getEnvironment();
// Get all the contexts you need in this context
@ -66,7 +66,7 @@ class FilesVersionsContext implements Context {
* @return void
* @throws Exception
*/
public function userTriesToGetFileVersions(string $user, string $file, string $fileOwner):void {
public function userTriesToGetFileVersions(string $user, string $file, string $fileOwner): void {
$this->featureContext->setResponse($this->getFileVersions($user, $file, $fileOwner));
}
@ -79,7 +79,7 @@ class FilesVersionsContext implements Context {
* @return void
* @throws Exception
*/
public function userGetsFileVersions(string $user, string $file):void {
public function userGetsFileVersions(string $user, string $file): void {
$this->featureContext->setResponse($this->getFileVersions($user, $file));
}
@ -92,7 +92,11 @@ class FilesVersionsContext implements Context {
*
* @return void
*/
public function thePublicTriesToGetTheNumberOfVersionsOfFileWithPasswordUsingFileId(string $file, string $password, string $fileId): void {
public function thePublicTriesToGetTheNumberOfVersionsOfFileWithPasswordUsingFileId(
string $file,
string $password,
string $fileId
): void {
$password = $this->featureContext->getActualPassword($password);
$this->featureContext->setResponse(
$this->featureContext->makeDavRequest(
@ -129,7 +133,11 @@ class FilesVersionsContext implements Context {
$user = $this->featureContext->getActualUsername($user);
$fileOwner = $fileOwner ? $this->featureContext->getActualUsername($fileOwner) : $user;
$fileId = $this->featureContext->getFileIdForPath($fileOwner, $file, $spaceId);
Assert::assertNotNull($fileId, __METHOD__ . " fileid of file $file user $fileOwner not found (the file may not exist)");
Assert::assertNotNull(
$fileId,
__METHOD__
. " fileid of file $file user $fileOwner not found (the file may not exist)"
);
return $this->featureContext->makeDavRequest(
$user,
"PROPFIND",
@ -150,7 +158,7 @@ class FilesVersionsContext implements Context {
*
* @return void
*/
public function userGetsTheNumberOfVersionsOfFileOfTheSpace(string $user, string $fileId):void {
public function userGetsTheNumberOfVersionsOfFileOfTheSpace(string $user, string $fileId): void {
$this->featureContext->setResponse(
$this->featureContext->makeDavRequest(
$user,
@ -173,7 +181,7 @@ class FilesVersionsContext implements Context {
* @return void
* @throws Exception
*/
public function userGetsVersionMetadataOfFile(string $user, string $file):void {
public function userGetsVersionMetadataOfFile(string $user, string $file): void {
$response = $this->getFileVersionMetadata($user, $file);
$this->featureContext->setResponse($response, $user);
}
@ -184,10 +192,14 @@ class FilesVersionsContext implements Context {
*
* @return ResponseInterface
*/
public function getFileVersionMetadata(string $user, string $file) : ResponseInterface {
public function getFileVersionMetadata(string $user, string $file): ResponseInterface {
$user = $this->featureContext->getActualUsername($user);
$fileId = $this->featureContext->getFileIdForPath($user, $file);
Assert::assertNotNull($fileId, __METHOD__ . " fileid of file $file user $user not found (the file may not exist)");
Assert::assertNotNull(
$fileId,
__METHOD__
. " fileid of file $file user $user not found (the file may not exist)"
);
$body = '<?xml version="1.0"?>
<d:propfind xmlns:d="DAV:" xmlns:oc="http://owncloud.org/ns">
<d:prop>
@ -214,10 +226,14 @@ class FilesVersionsContext implements Context {
* @return ResponseInterface
* @throws Exception
*/
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);
$fileId = $this->featureContext->getFileIdForPath($user, $path);
Assert::assertNotNull($fileId, __METHOD__ . " fileid of file $path user $user not found (the file may not exist)");
Assert::assertNotNull(
$fileId,
__METHOD__
. " fileid of file $path user $user not found (the file may not exist)"
);
$response = $this->listVersionFolder($user, $fileId, 1);
$responseXmlObject = HttpRequestHelper::getResponseXml(
$response,
@ -249,7 +265,7 @@ class FilesVersionsContext implements Context {
* @return void
* @throws Exception
*/
public function userHasRestoredVersionIndexOfFile(string $user, int $versionIndex, string $path):void {
public function userHasRestoredVersionIndexOfFile(string $user, int $versionIndex, string $path): void {
$response = $this->restoreVersionIndexOfFile($user, $versionIndex, $path);
$this->featureContext->theHTTPStatusCodeShouldBe(204, "", $response);
}
@ -264,7 +280,7 @@ class FilesVersionsContext implements Context {
* @return void
* @throws Exception
*/
public function userRestoresVersionIndexOfFile(string $user, int $versionIndex, string $path):void {
public function userRestoresVersionIndexOfFile(string $user, int $versionIndex, string $path): void {
$response = $this->restoreVersionIndexOfFile($user, $versionIndex, $path);
$this->featureContext->setResponse($response, $user);
}
@ -279,7 +295,7 @@ class FilesVersionsContext implements Context {
* @return void
* @throws Exception
*/
public function assertFileVersionsCount(string $user, string $fileId, int $expectedCount):void {
public function assertFileVersionsCount(string $user, string $fileId, int $expectedCount): void {
$response = $this->listVersionFolder($user, $fileId, 1);
$responseXmlObject = HttpRequestHelper::getResponseXml(
$response,
@ -310,10 +326,14 @@ class FilesVersionsContext implements Context {
string $path,
string $user,
int $count
):void {
): void {
$user = $this->featureContext->getActualUsername($user);
$fileId = $this->featureContext->getFileIdForPath($user, $path);
Assert::assertNotNull($fileId, __METHOD__ . ". file '$path' for user '$user' not found (the file may not exist)");
Assert::assertNotNull(
$fileId,
__METHOD__
. ". file '$path' for user '$user' not found (the file may not exist)"
);
$this->assertFileVersionsCount($user, $fileId, $count);
}
@ -331,7 +351,7 @@ class FilesVersionsContext implements Context {
string $fileId,
string $user,
int $count
):void {
): void {
$this->assertFileVersionsCount($user, $fileId, $count);
}
@ -351,10 +371,14 @@ class FilesVersionsContext implements Context {
int $index,
string $user,
int $length
):void {
): void {
$user = $this->featureContext->getActualUsername($user);
$fileId = $this->featureContext->getFileIdForPath($user, $path);
Assert::assertNotNull($fileId, __METHOD__ . " fileid of file $path user $user not found (the file may not exist)");
Assert::assertNotNull(
$fileId,
__METHOD__
. " fileid of file $path user $user not found (the file may not exist)"
);
$response = $this->listVersionFolder($user, $fileId, 1, ['d:getcontentlength']);
$responseXmlObject = HttpRequestHelper::getResponseXml(
$response,
@ -413,10 +437,19 @@ class FilesVersionsContext implements Context {
* @return ResponseInterface
* @throws Exception
*/
public function downloadVersion(string $user, string $path, string $index, ?string $spaceId = null):ResponseInterface {
public function downloadVersion(
string $user,
string $path,
string $index,
?string $spaceId = null
): ResponseInterface {
$user = $this->featureContext->getActualUsername($user);
$fileId = $this->featureContext->getFileIdForPath($user, $path, $spaceId);
Assert::assertNotNull($fileId, __METHOD__ . " fileid of file $path user $user not found (the file may not exist)");
Assert::assertNotNull(
$fileId,
__METHOD__
. " fileid of file $path user $user not found (the file may not exist)"
);
$index = (int)$index;
$response = $this->listVersionFolder($user, $fileId, 1);
if ($response->getStatusCode() === 403) {
@ -451,7 +484,7 @@ class FilesVersionsContext implements Context {
* @return void
* @throws Exception
*/
public function userDownloadsVersion(string $user, string $path, string $index):void {
public function userDownloadsVersion(string $user, string $path, string $index): void {
$this->featureContext->setResponse($this->downloadVersion($user, $path, $index), $user);
}
@ -486,7 +519,7 @@ class FilesVersionsContext implements Context {
*
* @return void
*/
public function userGetMetaInfo(string $user, string $fileOrFileId, string $path):void {
public function userGetMetaInfo(string $user, string $fileOrFileId, string $path): void {
$user = $this->featureContext->getActualUsername($user);
$baseUrl = $this->featureContext->getBaseUrl();
$password = $this->featureContext->getPasswordForUser($user);
@ -538,7 +571,7 @@ class FilesVersionsContext implements Context {
string $fileId,
int $folderDepth,
?array $properties = null
):ResponseInterface {
): ResponseInterface {
if (!$properties) {
$properties = [
'd:getetag'

View File

@ -81,7 +81,11 @@ class GraphContext implements Context {
* @throws GuzzleException
* @throws Exception
*/
public function theUserChangesTheDisplayNameOfUserToUsingTheGraphApi(string $byUser, string $user, string $displayName): void {
public function theUserChangesTheDisplayNameOfUserToUsingTheGraphApi(
string $byUser,
string $user,
string $displayName
): void {
$response = $this->editUserUsingTheGraphApi($byUser, $user, null, null, null, $displayName);
$this->featureContext->setResponse($response);
}
@ -98,7 +102,11 @@ class GraphContext implements Context {
* @throws GuzzleException
* @throws Exception
*/
public function theUserChangesTheUserNameOfUserToUsingTheGraphApi(string $byUser, string $user, string $userName): void {
public function theUserChangesTheUserNameOfUserToUsingTheGraphApi(
string $byUser,
string $user,
string $userName
): void {
$response = $this->editUserUsingTheGraphApi($byUser, $user, $userName);
$this->featureContext->setResponse($response);
// need to add user to list to delete him after test
@ -189,7 +197,16 @@ class GraphContext implements Context {
* @return void
* @throws GuzzleException
*/
public function editUserUsingTheGraphApi(string $byUser, string $user, string $userName = null, string $password = null, string $email = null, string $displayName = null, bool $accountEnabled = true, string $method="PATCH"): ResponseInterface {
public function editUserUsingTheGraphApi(
string $byUser,
string $user,
string $userName = null,
string $password = null,
string $email = null,
string $displayName = null,
bool $accountEnabled = true,
string $method="PATCH"
): ResponseInterface {
$user = $this->featureContext->getActualUsername($user);
$userId = $this->featureContext->getAttributeOfCreatedUser($user, 'id') ?: $user;
return GraphHelper::editUser(
@ -528,8 +545,10 @@ class GraphContext implements Context {
* @return array
*/
public function getAdminOrUserCredentials(?string $user): array {
$credentials["username"] = $user ? $this->featureContext->getActualUsername($user) : $this->featureContext->getAdminUsername();
$credentials["password"] = $user ? $this->featureContext->getPasswordForUser($user) : $this->featureContext->getAdminPassword();
$credentials["username"] = $user ? $this->featureContext->getActualUsername($user)
: $this->featureContext->getAdminUsername();
$credentials["password"] = $user ? $this->featureContext->getPasswordForUser($user)
: $this->featureContext->getAdminPassword();
return $credentials;
}
/**
@ -574,7 +593,7 @@ class GraphContext implements Context {
* @throws GuzzleException
*/
public function adminHasRetrievedGroupListUsingTheGraphApi(): array {
return $this->getArrayOfGroupsResponded($this->listGroups());
return $this->getArrayOfGroupsResponded($this->listGroups());
}
/**
@ -605,7 +624,10 @@ class GraphContext implements Context {
* @return ResponseInterface
* @throws GuzzleException
*/
public function listSingleOrAllGroupsAlongWithAllMemberInformation(string $user, ?string $group = null): ResponseInterface {
public function listSingleOrAllGroupsAlongWithAllMemberInformation(
string $user,
?string $group = null
): ResponseInterface {
$credentials = $this->getAdminOrUserCredentials($user);
return GraphHelper::getSingleOrAllGroupsAlongWithMembers(
@ -759,7 +781,10 @@ class GraphContext implements Context {
*
* @return void
*/
public function theAdministratorTriesToAddNonExistentUserToGroupUsingTheGraphAPI(string $group, ?string $byUser = null): void {
public function theAdministratorTriesToAddNonExistentUserToGroupUsingTheGraphAPI(
string $group,
?string $byUser = null
): void {
$this->featureContext->setResponse($this->addUserToGroup($group, "nonexistent", $byUser));
}
@ -774,7 +799,10 @@ class GraphContext implements Context {
*
* @throws GuzzleException | Exception
*/
public function theAdministratorTriesToAddUserToNonExistentGroupUsingTheGraphAPI(string $user, ?string $byUser = null): void {
public function theAdministratorTriesToAddUserToNonExistentGroupUsingTheGraphAPI(
string $user,
?string $byUser = null
): void {
$this->featureContext->setResponse($this->addUserToGroup("nonexistent", $user, $byUser));
}
@ -799,7 +827,11 @@ class GraphContext implements Context {
*
* @return void
*/
public function theUserTriesToAddAnotherUserToGroupUsingTheGraphAPI(string $byUser, string $user, string $group): void {
public function theUserTriesToAddAnotherUserToGroupUsingTheGraphAPI(
string $byUser,
string $user,
string $group
): void {
$this->featureContext->setResponse($this->addUserToGroup($group, $user, $byUser));
}
@ -1032,7 +1064,8 @@ class GraphContext implements Context {
Assert::assertTrue(
$exists,
__METHOD__
. "\nExpected user '" . $userGroup['username'] . "' to be in group '" . $userGroup['groupname'] . "'. But not found."
. "\nExpected user '" . $userGroup['username'] . "' to be in group '"
. $userGroup['groupname'] . "'. But not found."
);
}
}
@ -1098,12 +1131,16 @@ class GraphContext implements Context {
*
* @return void
*/
public function theAdministratorRemovesTheFollowingUsersFromTheFollowingGroupsUsingTheGraphApi(TableNode $table): void {
public function theAdministratorRemovesTheFollowingUsersFromTheFollowingGroupsUsingTheGraphApi(
TableNode $table
): void {
$this->featureContext->verifyTableNodeColumns($table, ['username', 'groupname']);
$usersGroups = $table->getColumnsHash();
foreach ($usersGroups as $userGroup) {
$this->featureContext->setResponse($this->removeUserFromGroup($userGroup['groupname'], $userGroup['username']));
$this->featureContext->setResponse(
$this->removeUserFromGroup($userGroup['groupname'], $userGroup['username'])
);
$this->featureContext->pushToLastHttpStatusCodesArray();
}
}
@ -1118,7 +1155,11 @@ class GraphContext implements Context {
* @return void
* @throws Exception | GuzzleException
*/
public function theUserTriesToRemoveAnotherUserFromGroupUsingTheGraphAPI(string $user, string $group, ?string $byUser = null): void {
public function theUserTriesToRemoveAnotherUserFromGroupUsingTheGraphAPI(
string $user,
string $group,
?string $byUser = null
): void {
$this->featureContext->setResponse($this->removeUserFromGroup($group, $user, $byUser));
}
@ -1132,7 +1173,10 @@ class GraphContext implements Context {
* @return void
* @throws GuzzleException
*/
public function theUserTriesToRemoveAnotherUserFromNonExistentGroupUsingTheGraphAPI(string $user, ?string $byUser = null): void {
public function theUserTriesToRemoveAnotherUserFromNonExistentGroupUsingTheGraphAPI(
string $user,
?string $byUser = null
): void {
$this->featureContext->setResponse($this->removeUserFromGroup('', $user, $byUser));
}
@ -1145,7 +1189,7 @@ class GraphContext implements Context {
*/
public function retrieveUserInformationUsingGraphApi(
string $user
):ResponseInterface {
): ResponseInterface {
$credentials = $this->getAdminOrUserCredentials($user);
return GraphHelper::getOwnInformationAndGroupMemberships(
$this->featureContext->getBaseUrl(),
@ -1165,7 +1209,7 @@ class GraphContext implements Context {
*/
public function userRetrievesHisOrHerInformationOfUserUsingGraphApi(
string $user
):void {
): void {
$response = $this->retrieveUserInformationUsingGraphApi($user);
$this->featureContext->setResponse($response);
}
@ -1266,7 +1310,7 @@ class GraphContext implements Context {
public function retrieveUserInformationAlongWithDriveUsingGraphApi(
string $byUser,
?string $user = null
):ResponseInterface {
): ResponseInterface {
$user = $user ?? $byUser;
$credentials = $this->getAdminOrUserCredentials($user);
return GraphHelper::getUserWithDriveInformation(
@ -1289,7 +1333,7 @@ class GraphContext implements Context {
public function retrieveUserInformationAlongWithGroupUsingGraphApi(
string $byUser,
?string $user = null
):ResponseInterface {
): ResponseInterface {
$user = $user ?? $byUser;
$credentials = $this->getAdminOrUserCredentials($user);
return GraphHelper::getUserWithGroupInformation(
@ -1351,7 +1395,11 @@ class GraphContext implements Context {
* @throws GuzzleException
* @throws Exception
*/
public function addMultipleUsersToGroup(string $user, array $userIds, string $groupId): ResponseInterface {
public function addMultipleUsersToGroup(
string $user,
array $userIds,
string $groupId
): ResponseInterface {
$credentials = $this->getAdminOrUserCredentials($user);
return GraphHelper::addUsersToGroup(
@ -1375,7 +1423,11 @@ class GraphContext implements Context {
* @throws Exception
* @throws GuzzleException
*/
public function theAdministratorAddsTheFollowingUsersToAGroupInASingleRequestUsingTheGraphApi(string $user, string $group, TableNode $table): void {
public function theAdministratorAddsTheFollowingUsersToAGroupInASingleRequestUsingTheGraphApi(
string $user,
string $group,
TableNode $table
): void {
$userIds = [];
$groupId = $this->featureContext->getAttributeOfCreatedGroup($group, "id");
foreach ($table->getHash() as $row) {
@ -1397,7 +1449,11 @@ class GraphContext implements Context {
* @throws Exception
* @throws GuzzleException
*/
public function userTriesToAddTheFollowingUsersToAGroupAtOnceWithInvalidHostUsingTheGraphApi(string $user, string $group, TableNode $table): void {
public function userTriesToAddTheFollowingUsersToAGroupAtOnceWithInvalidHostUsingTheGraphApi(
string $user,
string $group,
TableNode $table
): void {
$userIds = [];
$groupId = $this->featureContext->getAttributeOfCreatedGroup($group, "id");
$credentials = $this->getAdminOrUserCredentials($user);
@ -1436,7 +1492,11 @@ class GraphContext implements Context {
* @throws Exception
* @throws GuzzleException
*/
public function userTriesToAddUserToGroupWithInvalidHostUsingTheGraphApi(string $adminUser, string $user, string $group): void {
public function userTriesToAddUserToGroupWithInvalidHostUsingTheGraphApi(
string $adminUser,
string $user,
string $group
): void {
$groupId = $this->featureContext->getAttributeOfCreatedGroup($group, "id");
$userId = $this->featureContext->getAttributeOfCreatedUser($user, "id");
$credentials = $this->getAdminOrUserCredentials($adminUser);
@ -1467,7 +1527,10 @@ class GraphContext implements Context {
* @throws GuzzleException
* @throws Exception
*/
public function theAdministratorTriesToAddsTheFollowingUsersToANonExistingGroupAtOnceUsingTheGraphApi(string $user, TableNode $table): void {
public function theAdministratorTriesToAddsTheFollowingUsersToANonExistingGroupAtOnceUsingTheGraphApi(
string $user,
TableNode $table
): void {
$userIds = [];
$groupId = WebDavHelper::generateUUIDv4();
foreach ($table->getHash() as $row) {
@ -1489,7 +1552,11 @@ class GraphContext implements Context {
* @throws GuzzleException
* @throws Exception
*/
public function theAdministratorTriesToAddTheFollowingNonExistingUsersToAGroupAtOnceUsingTheGraphApi(string $user, string $group, TableNode $table): void {
public function theAdministratorTriesToAddTheFollowingNonExistingUsersToAGroupAtOnceUsingTheGraphApi(
string $user,
string $group,
TableNode $table
): void {
$userIds = [];
$groupId = $this->featureContext->getAttributeOfCreatedGroup($group, "id");
foreach ($table->getHash() as $row) {
@ -1512,7 +1579,11 @@ class GraphContext implements Context {
* @throws GuzzleException
* @throws Exception
*/
public function theAdministratorTriesToAddTheFollowingUsersToAGroupAtOnceUsingTheGraphApi(string $user, string $group, TableNode $table): void {
public function theAdministratorTriesToAddTheFollowingUsersToAGroupAtOnceUsingTheGraphApi(
string $user,
string $group,
TableNode $table
): void {
$userIds = [];
$groupId = $this->featureContext->getAttributeOfCreatedGroup($group, "id");
foreach ($table->getHash() as $row) {
@ -1550,7 +1621,11 @@ class GraphContext implements Context {
* @return void
*/
public function theResponseShouldContainTheFollowingApplicationInformation(TableNode $table): void {
Assert::assertIsArray($responseArray = ($this->featureContext->getJsonDecodedResponse($this->featureContext->getResponse()))['value'][0]);
Assert::assertIsArray(
$responseArray = (
$this->featureContext->getJsonDecodedResponse($this->featureContext->getResponse())
)['value'][0]
);
foreach ($table->getHash() as $row) {
$key = $row["key"];
if ($key === 'id') {
@ -1572,7 +1647,11 @@ class GraphContext implements Context {
* @return void
*/
public function theResponseShouldContainTheFollowingAppRolesInformation(TableNode $table): void {
Assert::assertIsArray($responseArray = ($this->featureContext->getJsonDecodedResponse($this->featureContext->getResponse()))['value'][0]);
Assert::assertIsArray(
$responseArray = (
$this->featureContext->getJsonDecodedResponse($this->featureContext->getResponse())
)['value'][0]
);
foreach ($table->getRows() as $row) {
$foundRoleInResponse = false;
foreach ($responseArray['appRoles'] as $role) {
@ -1640,7 +1719,11 @@ class GraphContext implements Context {
* @return void
* @throws GuzzleException
*/
public function userGetsAllUsersOfFirstGroupOderSecondGroupUsingTheGraphApi(string $user, string $firstGroup, string $secondGroup) {
public function userGetsAllUsersOfFirstGroupOderSecondGroupUsingTheGraphApi(
string $user,
string $firstGroup,
string $secondGroup
) {
$response = GraphHelper::getUsersFromOneOrOtherGroup(
$this->featureContext->getBaseUrl(),
$this->featureContext->getStepLineRef(),
@ -1708,7 +1791,11 @@ class GraphContext implements Context {
* @return void
* @throws GuzzleException
*/
public function userGetsAllUsersWithRoleAndMemberOfGroupUsingTheGraphApi(string $user, string $role, string $group) {
public function userGetsAllUsersWithRoleAndMemberOfGroupUsingTheGraphApi(
string $user,
string $role,
string $group
) {
$response = GraphHelper::getUsersWithFilterRolesAssignmentAndMemberOf(
$this->featureContext->getBaseUrl(),
$this->featureContext->getStepLineRef(),
@ -1841,7 +1928,8 @@ class GraphContext implements Context {
$this->appEntity["appRoles"][$role],
$response['appRoleId'],
__METHOD__
. "\nExpected rolId for role '$role'' to be '" . $this->appEntity["appRoles"][$role] . "' but got '" . $response['appRoleId'] . "'"
. "\nExpected rolId for role '$role'' to be '" . $this->appEntity["appRoles"][$role]
. "' but got '" . $response['appRoleId'] . "'"
);
}
@ -1890,7 +1978,7 @@ class GraphContext implements Context {
*
* @return void
*/
public function userSearchesForGroupUsingGraphApi(string $user, string $searchTerm):void {
public function userSearchesForGroupUsingGraphApi(string $user, string $searchTerm): void {
$credentials = $this->getAdminOrUserCredentials($user);
$this->featureContext->setResponse(
GraphHelper::searchGroup(
@ -1953,7 +2041,11 @@ class GraphContext implements Context {
* @throws GuzzleException
* @throws Exception
*/
public function theAdministratorHasAddedTheFollowingUsersToAGroupAtOnceUsingTheGraphApi(string $user, string $group, TableNode $table) {
public function theAdministratorHasAddedTheFollowingUsersToAGroupAtOnceUsingTheGraphApi(
string $user,
string $group,
TableNode $table
) {
$userIds = [];
$groupId = $this->featureContext->getAttributeOfCreatedGroup($group, "id");
foreach ($table->getHash() as $row) {
@ -1975,13 +2067,18 @@ class GraphContext implements Context {
* @throws GuzzleException
* @throws Exception
*/
public function theAdministratorTriesToAddGroupToAGroupAtOnceUsingTheGraphApi(string $user, string $groupToAdd, string $group) {
public function theAdministratorTriesToAddGroupToAGroupAtOnceUsingTheGraphApi(
string $user,
string $groupToAdd,
string $group
) {
$groupId = $this->featureContext->getAttributeOfCreatedGroup($group, "id");
$groupIdToAdd = $this->featureContext->getAttributeOfCreatedGroup($groupToAdd, "id");
$credentials = $this->getAdminOrUserCredentials($user);
$payload = [
"members@odata.bind" => [GraphHelper::getFullUrl($this->featureContext->getBaseUrl(), 'groups/' . $groupIdToAdd)]
"members@odata.bind" => [
GraphHelper::getFullUrl($this->featureContext->getBaseUrl(), 'groups/' . $groupIdToAdd)]
];
$this->featureContext->setResponse(
@ -2008,7 +2105,11 @@ class GraphContext implements Context {
* @throws GuzzleException
* @throws Exception
*/
public function theAdministratorTriesToAddAGroupToAGroupThroughPostRequestUsingTheGraphApi(string $user, string $groupToAdd, string $group) {
public function theAdministratorTriesToAddAGroupToAGroupThroughPostRequestUsingTheGraphApi(
string $user,
string $groupToAdd,
string $group
) {
$groupId = $this->featureContext->getAttributeOfCreatedGroup($group, "id");
$groupIdToAdd = $this->featureContext->getAttributeOfCreatedGroup($groupToAdd, "id");
$credentials = $this->getAdminOrUserCredentials($user);
@ -2041,7 +2142,12 @@ class GraphContext implements Context {
* @throws Exception
* @throws GuzzleException
*/
public function userTriesToAddUserToGroupWithInvalidJsonUsingTheGraphApi(string $adminUser, string $user, string $group, string $invalidJSON): void {
public function userTriesToAddUserToGroupWithInvalidJsonUsingTheGraphApi(
string $adminUser,
string $user,
string $group,
string $invalidJSON
): void {
$groupId = $this->featureContext->getAttributeOfCreatedGroup($group, "id");
$credentials = $this->getAdminOrUserCredentials($adminUser);
@ -2078,7 +2184,12 @@ class GraphContext implements Context {
* @throws Exception
* @throws GuzzleException
*/
public function userTriesToAddTheFollowingUsersToAGroupAtOnceWithInvalidJsonUsingTheGraphApi(string $user, string $group, string $invalidJSON, TableNode $table): void {
public function userTriesToAddTheFollowingUsersToAGroupAtOnceWithInvalidJsonUsingTheGraphApi(
string $user,
string $group,
string $invalidJSON,
TableNode $table
): void {
$groupId = $this->featureContext->getAttributeOfCreatedGroup($group, "id");
$credentials = $this->getAdminOrUserCredentials($user);
foreach ($table->getHash() as $row) {
@ -2116,7 +2227,11 @@ class GraphContext implements Context {
* @throws GuzzleException
* @throws Exception
*/
public function theAdministratorTriesToAddTheFollowingUserIdWithInvalidCharacterToAGroup(string $user, string $group, TableNode $table) {
public function theAdministratorTriesToAddTheFollowingUserIdWithInvalidCharacterToAGroup(
string $user,
string $group,
TableNode $table
) {
$userIds = [];
$credentials = $this->getAdminOrUserCredentials($user);
$groupId = $this->featureContext->getAttributeOfCreatedGroup($group, "id");
@ -2146,7 +2261,11 @@ class GraphContext implements Context {
* @throws GuzzleException
* @throws Exception
*/
public function theAdministratorTriesToAddUserIdWithInvalidCharactersToAGroup(string $user, string $userId, string $group): void {
public function theAdministratorTriesToAddUserIdWithInvalidCharactersToAGroup(
string $user,
string $userId,
string $group
): void {
$credentials = $this->getAdminOrUserCredentials($user);
$groupId = $this->featureContext->getAttributeOfCreatedGroup($group, "id");
$this->featureContext->setResponse(
@ -2183,7 +2302,8 @@ class GraphContext implements Context {
Assert::assertEquals(
1,
$count,
"Expected user '" . $user . "' to be added once to group '" . $group . "' but the user is listed '" . $count . "' times"
"Expected user '" . $user . "' to be added once to group '"
. $group . "' but the user is listed '" . $count . "' times"
);
}
@ -2248,7 +2368,11 @@ class GraphContext implements Context {
* @throws Exception
*
*/
public function downloadedJsonContentShouldContainEventTypeInItemAndShouldMatch(string $eventType, ?string $spaceType=null, PyStringNode $schemaString=null): void {
public function downloadedJsonContentShouldContainEventTypeInItemAndShouldMatch(
string $eventType,
?string $spaceType=null,
PyStringNode $schemaString=null
): void {
$actualResponseToAssert = null;
$events = $this->featureContext->getJsonDecodedResponseBodyContent()->events;
foreach ($events as $event) {
@ -2307,7 +2431,11 @@ class GraphContext implements Context {
* @return void
*
*/
public function userTriesToExportGdprReportOfAnotherUserUsingGraphApi(string $user, string $ofUser, string $path): void {
public function userTriesToExportGdprReportOfAnotherUserUsingGraphApi(
string $user,
string $ofUser,
string $path
): void {
$credentials = $this->getAdminOrUserCredentials($user);
$this->featureContext->setResponse(
GraphHelper::generateGDPRReport(
@ -2328,7 +2456,8 @@ class GraphContext implements Context {
* @throws GuzzleException
*/
public function getAssignedRole(string $user): ResponseInterface {
$userId = $this->featureContext->getAttributeOfCreatedUser($user, 'id') ?: $this->featureContext->getUserIdByUserName($user);
$userId = $this->featureContext->getAttributeOfCreatedUser($user, 'id')
?: $this->featureContext->getUserIdByUserName($user);
return (
GraphHelper::getAssignedRole(
$this->featureContext->getBAseUrl(),
@ -2359,7 +2488,9 @@ class GraphContext implements Context {
if (!$userId && $ofUser !== $this->featureContext->getAdminUsername()) {
$appRoleAssignmentId = $this->getRoleIdByRoleName("User");
} else {
$appRoleAssignmentId = $this->featureContext->getJsonDecodedResponse($this->getAssignedRole($ofUser))["value"][0]["id"];
$appRoleAssignmentId = $this->featureContext->getJsonDecodedResponse(
$this->getAssignedRole($ofUser)
)["value"][0]["id"];
}
$userId = $userId ?: $ofUser;
@ -2508,7 +2639,11 @@ class GraphContext implements Context {
* @return void
* @throws GuzzleException
*/
public function userListsTheResourcesSharedWithThemUsingGraphApi(string $user, string $cacheStepString, string $retryOption): void {
public function userListsTheResourcesSharedWithThemUsingGraphApi(
string $user,
string $cacheStepString,
string $retryOption
): void {
if ($cacheStepString !== '') {
// ENV (GRAPH_SPACES_GROUPS_CACHE_TTL | GRAPH_SPACES_USERS_CACHE_TTL) is set default to 60 sec
// which means 60 sec is required to clean up all the user|group cache once they are deleted
@ -2537,7 +2672,9 @@ class GraphContext implements Context {
if ($retryEnabled) {
foreach ($jsonBody->value as $share) {
$autoSync = $this->featureContext->getUserAutoSyncSetting($credentials['username']);
$tryAgain = !$share->{'@client.synchronize'} && $autoSync && $retried < HttpRequestHelper::numRetriesOnHttpTooEarly();
$tryAgain = !$share->{'@client.synchronize'}
&& $autoSync
&& $retried < HttpRequestHelper::numRetriesOnHttpTooEarly();
if ($tryAgain) {
$retried += 1;
@ -2676,7 +2813,11 @@ class GraphContext implements Context {
* @throws GuzzleException
* @throws JsonException
*/
public function userUsingPasswordShouldBeAbleToCreateANewUserWithDefaultAttributes(string $byUser, string $password, string $user): void {
public function userUsingPasswordShouldBeAbleToCreateANewUserWithDefaultAttributes(
string $byUser,
string $password,
string $user
): void {
$response = GraphHelper::createUser(
$this->featureContext->getBaseUrl(),
$this->featureContext->getStepLineRef(),
@ -2749,7 +2890,7 @@ class GraphContext implements Context {
* @throws GuzzleException
* @throws Exception
*/
public function getPermissionRoleDefinitionUsingGraphAPI(string $user, string $permissionRole):void {
public function getPermissionRoleDefinitionUsingGraphAPI(string $user, string $permissionRole): void {
$credentials = $this->getAdminOrUserCredentials($user);
$this->featureContext->setResponse(
GraphHelper::getPermissionRoleDefinition(
@ -2772,7 +2913,11 @@ class GraphContext implements Context {
* @return void
* @throws Exception
*/
public function userListsTheActivitiesForResourceOfSpaceUsingTheGraphAPI(string $user, string $resource, string $spaceName): void {
public function userListsTheActivitiesForResourceOfSpaceUsingTheGraphAPI(
string $user,
string $resource,
string $spaceName
): void {
$resourceId = $this->featureContext->spacesContext->getResourceId($user, $spaceName, $resource);
$response = GraphHelper::getActivities(
$this->featureContext->getBaseUrl(),
@ -2792,7 +2937,10 @@ class GraphContext implements Context {
*
* @return void
*/
public function userTriesToListTheActivitiesOfFolderWithShareMountIdPointIdUsingTheGraphApi(string $user, string $folder): void {
public function userTriesToListTheActivitiesOfFolderWithShareMountIdPointIdUsingTheGraphApi(
string $user,
string $folder
): void {
$resourceId = GraphHelper::getShareMountId(
$this->featureContext->getBaseUrl(),
$this->featureContext->getStepLineRef(),
@ -2820,7 +2968,12 @@ class GraphContext implements Context {
*
* @return void
*/
public function userTriesToListActivitiesOfFileFromSpaceOwnedByUserUsingTheGraphApi(string $user, string $file, string $owner, string $spaceName): void {
public function userTriesToListActivitiesOfFileFromSpaceOwnedByUserUsingTheGraphApi(
string $user,
string $file,
string $owner,
string $spaceName
): void {
$resourceId = $this->featureContext->spacesContext->getResourceId($owner, $spaceName, $file);
$response = GraphHelper::getActivities(
$this->featureContext->getBaseUrl(),
@ -2861,7 +3014,11 @@ class GraphContext implements Context {
*
* @return void
*/
public function thePublicTriesToCheckTheActivitiesOfSpaceOwnedByUserWithPasswordUsingGraphApi(string $spaceName, string $user, string $password): void {
public function thePublicTriesToCheckTheActivitiesOfSpaceOwnedByUserWithPasswordUsingGraphApi(
string $spaceName,
string $user,
string $password
): void {
$response = GraphHelper::getActivities(
$this->featureContext->getBaseUrl(),
$this->featureContext->getStepLineRef(),
@ -2882,7 +3039,12 @@ class GraphContext implements Context {
*
* @return void
*/
public function thePublicTriesToCheckTheActivitiesOfResourceFromSpaceOwnedByUserWithPasswordUsingGraphApi(string $resource, string $space, string $owner, string $password): void {
public function thePublicTriesToCheckTheActivitiesOfResourceFromSpaceOwnedByUserWithPasswordUsingGraphApi(
string $resource,
string $space,
string $owner,
string $password
): void {
$response = GraphHelper::getActivities(
$this->featureContext->getBaseUrl(),
$this->featureContext->getStepLineRef(),
@ -2904,7 +3066,13 @@ class GraphContext implements Context {
*
* @return void
*/
public function userListsTheActivitiesForFolderOfSpaceWithDepthOrLimitUsingTheGraphApi(string $user, string $resource, string $spaceName, string $filterType, string $filterValue): void {
public function userListsTheActivitiesForFolderOfSpaceWithDepthOrLimitUsingTheGraphApi(
string $user,
string $resource,
string $spaceName,
string $filterType,
string $filterValue
): void {
$resourceId = $this->featureContext->spacesContext->getResourceId($user, $spaceName, $resource);
$response = GraphHelper::getActivities(
$this->featureContext->getBaseUrl(),
@ -2932,7 +3100,8 @@ class GraphContext implements Context {
foreach ($table->getHash() as $index => $expectedValue) {
$actualActivity = $activities[$index];
$expectedActivity = $expectedValue['resource'] . ":" . $expectedValue['message'];
$actualActivity = $actualActivity->template->variables->resource->name . ":" . $actualActivity->template->message;
$actualActivity = $actualActivity->template->variables->resource->name
. ":" . $actualActivity->template->message;
Assert::assertEquals($expectedActivity, $actualActivity, "Activity didn't match");
}
}

View File

@ -36,14 +36,14 @@ class NotificationContext implements Context {
/**
* @return array[]
*/
public function getNotificationIds():array {
public function getNotificationIds(): array {
return $this->notificationIds;
}
/**
* @return array[]
*/
public function getLastNotificationId():array {
public function getLastNotificationId(): array {
return \end($this->notificationIds);
}
@ -95,7 +95,7 @@ class NotificationContext implements Context {
* @return void
* @throws Exception
*/
public function before(BeforeScenarioScope $scope):void {
public function before(BeforeScenarioScope $scope): void {
// Get the environment
$environment = $scope->getEnvironment();
// Get all the contexts you need in this context
@ -109,7 +109,7 @@ class NotificationContext implements Context {
*
* @return ResponseInterface
*/
public function listAllNotifications(string $user):ResponseInterface {
public function listAllNotifications(string $user): ResponseInterface {
$this->setUserRecipient($user);
$language = SettingsHelper::getLanguageSettingValue(
$this->featureContext->getBaseUrl(),
@ -138,7 +138,7 @@ class NotificationContext implements Context {
*
* @return void
*/
public function userListAllNotifications(string $user):void {
public function userListAllNotifications(string $user): void {
$response = $this->listAllNotifications($user);
$this->featureContext->setResponse($response);
$this->featureContext->pushToLastHttpStatusCodesArray();
@ -151,7 +151,7 @@ class NotificationContext implements Context {
* @throws GuzzleException
* @throws JsonException
*/
public function deleteAllNotifications(string $user):ResponseInterface {
public function deleteAllNotifications(string $user): ResponseInterface {
$response = $this->listAllNotifications($user);
if (isset($this->featureContext->getJsonDecodedResponseBodyContent($response)->ocs->data)) {
$responseBody = $this->featureContext->getJsonDecodedResponseBodyContent($response)->ocs->data;
@ -172,7 +172,7 @@ class NotificationContext implements Context {
* @throws GuzzleException
* @throws JsonException
*/
public function userDeletesAllNotifications(string $user):void {
public function userDeletesAllNotifications(string $user): void {
$response = $this->deleteAllNotifications($user);
$this->featureContext->setResponse($response);
}
@ -186,7 +186,7 @@ class NotificationContext implements Context {
* @throws GuzzleException
* @throws JsonException
*/
public function userHasDeletedAllNotifications(string $user):void {
public function userHasDeletedAllNotifications(string $user): void {
$response = $this->deleteAllNotifications($user);
$this->featureContext->theHTTPStatusCodeShouldBe(200, "", $response);
}
@ -202,7 +202,7 @@ class NotificationContext implements Context {
* @throws GuzzleException
* @throws JsonException
*/
public function userDeletesNotificationOfResourceAndSubject(string $user, string $resource, string $subject):void {
public function userDeletesNotificationOfResourceAndSubject(string $user, string $resource, string $subject): void {
$response = $this->listAllNotifications($user);
$this->filterNotificationsBySubjectAndResource($subject, $resource, $response);
$this->featureContext->setResponse($this->userDeletesNotification($user));
@ -217,7 +217,7 @@ class NotificationContext implements Context {
* @throws GuzzleException
* @throws JsonException
*/
public function userDeletesNotification(string $user):ResponseInterface {
public function userDeletesNotification(string $user): ResponseInterface {
$this->setUserRecipient($user);
$payload["ids"] = $this->getNotificationIds();
return OcsApiHelper::sendRequest(
@ -324,7 +324,10 @@ class NotificationContext implements Context {
*
* @return object
*/
public function filterResponseAccordingToNotificationSubject(string $subject, ?ResponseInterface $response = null): object {
public function filterResponseAccordingToNotificationSubject(
string $subject,
?ResponseInterface $response = null
): object {
$response = $response ?? $this->featureContext->getResponse();
if (isset($this->featureContext->getJsonDecodedResponseBodyContent($response)->ocs->data)) {
$responseBody = $this->featureContext->getJsonDecodedResponseBodyContent($response)->ocs->data;
@ -351,7 +354,11 @@ class NotificationContext implements Context {
*
* @return array
*/
public function filterNotificationsBySubjectAndResource(string $subject, string $resource, ?ResponseInterface $response = null): array {
public function filterNotificationsBySubjectAndResource(
string $subject,
string $resource,
?ResponseInterface $response = null
): array {
$filteredNotifications = [];
$response = $response ?? $this->featureContext->getResponse();
$responseObject = $this->featureContext->getJsonDecodedResponseBodyContent($response);
@ -362,7 +369,10 @@ class NotificationContext implements Context {
$notifications = $responseObject->ocs->data;
foreach ($notifications as $notification) {
if (isset($notification->subject) && $notification->subject === $subject && isset($notification->messageRichParameters->resource->name) && $notification->messageRichParameters->resource->name === $resource) {
if (isset($notification->subject) && $notification->subject === $subject
&& isset($notification->messageRichParameters->resource->name)
&& $notification->messageRichParameters->resource->name === $resource
) {
$this->notificationIds[] = $notification->notification_id;
$filteredNotifications[] = $notification;
}
@ -380,7 +390,7 @@ class NotificationContext implements Context {
* @return void
* @throws Exception
*/
public function userShouldGetANotificationWithMessage(string $user, string $subject, TableNode $table):void {
public function userShouldGetANotificationWithMessage(string $user, string $subject, TableNode $table): void {
$count = 0;
// Sometimes the test might try to get the notifications before the server has created the notification.
// To prevent the test from failing because of that, try to list the notifications again
@ -392,9 +402,15 @@ class NotificationContext implements Context {
$response = $this->listAllNotifications($user);
$this->featureContext->theHTTPStatusCodeShouldBe(200, "", $response);
++$count;
} while (!isset($this->filterResponseAccordingToNotificationSubject($subject, $response)->message) && $count <= 5);
} while (!isset($this->filterResponseAccordingToNotificationSubject($subject, $response)->message)
&& $count <= 5
);
if (isset($this->filterResponseAccordingToNotificationSubject($subject, $response)->message)) {
$actualMessage = str_replace(["\r", "\n"], " ", $this->filterResponseAccordingToNotificationSubject($subject, $response)->message);
$actualMessage = str_replace(
["\r", "\n"],
" ",
$this->filterResponseAccordingToNotificationSubject($subject, $response)->message
);
} else {
throw new \Exception("Notification was not found even after retrying for 5 seconds.");
}
@ -417,7 +433,12 @@ class NotificationContext implements Context {
* @return void
* @throws Exception
*/
public function userShouldGetNotificationForResourceWithMessage(string $user, string $resource, string $subject, TableNode $table):void {
public function userShouldGetNotificationForResourceWithMessage(
string $user,
string $resource,
string $subject,
TableNode $table
): void {
$response = $this->listAllNotifications($user);
$notification = $this->filterNotificationsBySubjectAndResource($subject, $resource, $response);
@ -432,9 +453,15 @@ class NotificationContext implements Context {
$response = $this->userDeletesNotification($user);
$this->featureContext->theHTTPStatusCodeShouldBe(200, '', $response);
} elseif (\count($notification) === 0) {
throw new \Exception("Response doesn't contain any notification with resource '$resource' and subject '$subject'.\n" . print_r($notification, true));
throw new \Exception(
"Response doesn't contain any notification with resource '$resource' and subject '$subject'.\n"
. print_r($notification, true)
);
} else {
throw new \Exception("Response contains more than one notification with resource '$resource' and subject '$subject'.\n" . print_r($notification, true));
throw new \Exception(
"Response contains more than one notification with resource '$resource' and subject '$subject'.\n"
. print_r($notification, true)
);
}
}
@ -447,10 +474,19 @@ class NotificationContext implements Context {
*
* @return void
*/
public function userShouldNotHaveANotificationRelatedToResourceWithSubject(string $user, string $resource, string $subject):void {
public function userShouldNotHaveANotificationRelatedToResourceWithSubject(
string $user,
string $resource,
string $subject
): void {
$response = $this->listAllNotifications($user);
$filteredResponse = $this->filterNotificationsBySubjectAndResource($subject, $resource, $response);
Assert::assertCount(0, $filteredResponse, "Response should not contain notification related to resource '$resource' with subject '$subject' but found" . print_r($filteredResponse, true));
Assert::assertCount(
0,
$filteredResponse,
"Response should not contain notification related to resource '$resource' with subject '$subject' but found"
. print_r($filteredResponse, true)
);
}
/**
@ -464,7 +500,12 @@ class NotificationContext implements Context {
* @return void
* @throws Exception
*/
public function userShouldHaveReceivedTheFollowingEmailFromUserAboutTheShareOfProjectSpace(string $user, string $sender, string $spaceName, PyStringNode $content):void {
public function userShouldHaveReceivedTheFollowingEmailFromUserAboutTheShareOfProjectSpace(
string $user,
string $sender,
string $spaceName,
PyStringNode $content
): void {
$rawExpectedEmailBodyContent = \str_replace("\r\n", "\n", $content->getRaw());
$this->featureContext->setResponse(
GraphHelper::getMySpaces(
@ -501,7 +542,11 @@ class NotificationContext implements Context {
* @return void
* @throws Exception
*/
public function userShouldHaveReceivedTheFollowingEmailFromUser(string $user, string $sender, PyStringNode $content):void {
public function userShouldHaveReceivedTheFollowingEmailFromUser(
string $user,
string $sender,
PyStringNode $content
): void {
$rawExpectedEmailBodyContent = \str_replace("\r\n", "\n", $content->getRaw());
$expectedEmailBodyContent = $this->featureContext->substituteInLineCodes(
$rawExpectedEmailBodyContent,
@ -520,7 +565,11 @@ class NotificationContext implements Context {
* @return void
* @throws Exception
*/
public function userShouldHaveReceivedTheFollowingEmailFromUserIgnoringWhitespaces(string $user, string $sender, PyStringNode $content):void {
public function userShouldHaveReceivedTheFollowingEmailFromUserIgnoringWhitespaces(
string $user,
string $sender,
PyStringNode $content
): void {
$rawExpectedEmailBodyContent = \str_replace("\r\n", "\n", $content->getRaw());
$expectedEmailBodyContent = $this->featureContext->substituteInLineCodes(
$rawExpectedEmailBodyContent,
@ -537,7 +586,11 @@ class NotificationContext implements Context {
* @return void
* @throws GuzzleException
*/
public function assertEmailContains(string $user, string $expectedEmailBodyContent, $ignoreWhiteSpace = false):void {
public function assertEmailContains(
string $user,
string $expectedEmailBodyContent,
$ignoreWhiteSpace = false
): void {
$address = $this->featureContext->getEmailAddressForUser($user);
$this->featureContext->pushEmailRecipientAsMailBox($address);
$actualEmailBodyContent = EmailHelper::getBodyOfLastEmail($address, $this->featureContext->getStepLineRef());
@ -548,7 +601,8 @@ class NotificationContext implements Context {
Assert::assertStringContainsString(
$expectedEmailBodyContent,
$actualEmailBodyContent,
"The email address '$address' should have received an email with the body containing $expectedEmailBodyContent
"The email address '$address' should have received an"
. "email with the body containing $expectedEmailBodyContent
but the received email is $actualEmailBodyContent"
);
}
@ -560,7 +614,7 @@ class NotificationContext implements Context {
*
* @return void
*/
public function clearInbucketMessages():void {
public function clearInbucketMessages(): void {
try {
if (!empty($this->featureContext->emailRecipients)) {
foreach ($this->featureContext->emailRecipients as $emailRecipient) {
@ -594,9 +648,10 @@ class NotificationContext implements Context {
?string $user = null,
?string $deprovision_date = "2043-07-04T11:23:12Z",
?string $deprovision_date_format= "2006-01-02T15:04:05Z07:00"
):ResponseInterface {
): ResponseInterface {
$payload["type"] = "deprovision";
$payload["data"] = ["deprovision_date" => $deprovision_date, "deprovision_date_format" => $deprovision_date_format];
$payload["data"] = [
"deprovision_date" => $deprovision_date, "deprovision_date_format" => $deprovision_date_format];
return OcsApiHelper::sendRequest(
$this->featureContext->getBaseUrl(),
$user ? $this->featureContext->getActualUsername($user) : $this->featureContext->getAdminUsername(),
@ -636,7 +691,10 @@ class NotificationContext implements Context {
* @throws GuzzleException
* @throws JsonException
*/
public function theAdministratorCreatesADeprovisioningNotificationUsingDateFormat($deprovision_date, $deprovision_date_format) {
public function theAdministratorCreatesADeprovisioningNotificationUsingDateFormat(
$deprovision_date,
$deprovision_date_format
) {
$response = $this->userCreatesDeprovisioningNotification(null, $deprovision_date, $deprovision_date_format);
$this->featureContext->setResponse($response);
$this->featureContext->pushToLastHttpStatusCodesArray();
@ -647,7 +705,7 @@ class NotificationContext implements Context {
*
* @return void
*/
public function userHasCreatedDeprovisioningNotification():void {
public function userHasCreatedDeprovisioningNotification(): void {
$response = $this->userCreatesDeprovisioningNotification();
$this->featureContext->theHTTPStatusCodeShouldBe(200, "", $response);
}
@ -660,7 +718,7 @@ class NotificationContext implements Context {
*
* @return void
*/
public function userDeletesDeprovisioningNotification(?string $user = null):void {
public function userDeletesDeprovisioningNotification(?string $user = null): void {
$payload["ids"] = ["deprovision"];
$response = OcsApiHelper::sendRequest(

View File

@ -47,7 +47,7 @@ class OCSContext implements Context {
*
* @return void
*/
public function theUserSendsToOcsApiEndpoint(string $verb, string $url):void {
public function theUserSendsToOcsApiEndpoint(string $verb, string $url): void {
$response = $this->theUserSendsToOcsApiEndpointWithBody($verb, $url);
$this->featureContext->setResponse($response);
}
@ -63,7 +63,7 @@ class OCSContext implements Context {
*
* @return void
*/
public function userSendsToOcsApiEndpoint(string $user, string $verb, string $url, ?string $password = null):void {
public function userSendsToOcsApiEndpoint(string $user, string $verb, string $url, ?string $password = null): void {
$response = $this->sendRequestToOcsEndpoint(
$user,
$verb,
@ -91,7 +91,7 @@ class OCSContext implements Context {
?TableNode $body = null,
?string $password = null,
?array $headers = null
):ResponseInterface {
): ResponseInterface {
/**
* array of the data to be sent in the body.
* contains $body data converted to an array
@ -134,7 +134,7 @@ class OCSContext implements Context {
string $verb,
string $url,
?TableNode $body
):ResponseInterface {
): ResponseInterface {
$admin = $this->featureContext->getAdminUsername();
return $this->sendRequestToOcsEndpoint(
$admin,
@ -151,7 +151,11 @@ class OCSContext implements Context {
*
* @return ResponseInterface
*/
public function theUserSendsToOcsApiEndpointWithBody(string $verb, string $url, ?TableNode $body = null):ResponseInterface {
public function theUserSendsToOcsApiEndpointWithBody(
string $verb,
string $url,
?TableNode $body = null
): ResponseInterface {
return $this->sendRequestToOcsEndpoint(
$this->featureContext->getCurrentUser(),
$verb,
@ -177,7 +181,7 @@ class OCSContext implements Context {
string $url,
?TableNode $body = null,
?string $password = null
):void {
): void {
$response = $this->sendRequestToOcsEndpoint(
$user,
$verb,
@ -202,7 +206,7 @@ class OCSContext implements Context {
string $verb,
string $url,
?string $password = null
):void {
): void {
$this->featureContext->setResponse(
$this->sendRequestToOcsEndpoint(
$this->featureContext->getAdminUsername(),
@ -230,7 +234,7 @@ class OCSContext implements Context {
string $verb,
string $url,
TableNode $headersTable
):void {
): void {
$user = $this->featureContext->getActualUsername($user);
$password = $this->featureContext->getPasswordForUser($user);
$this->featureContext->setResponse(
@ -259,7 +263,7 @@ class OCSContext implements Context {
string $verb,
string $url,
TableNode $headersTable
):void {
): void {
$user = $this->featureContext->getAdminUsername();
$password = $this->featureContext->getPasswordForUser($user);
$this->featureContext->setResponse(
@ -290,7 +294,7 @@ class OCSContext implements Context {
string $url,
string $password,
TableNode $headersTable
):void {
): void {
$this->featureContext->setResponse(
$this->sendRequestToOcsEndpoint(
$this->featureContext->getAdminUsername(),
@ -316,7 +320,7 @@ class OCSContext implements Context {
string $verb,
string $url,
?TableNode $body
):void {
): void {
$response = $this->adminSendsHttpMethodToOcsApiEndpointWithBody(
$verb,
$url,
@ -334,7 +338,7 @@ class OCSContext implements Context {
*
* @return void
*/
public function theUserSendsHTTPMethodToOcsApiEndpointWithBody(string $verb, string $url, TableNode $body):void {
public function theUserSendsHTTPMethodToOcsApiEndpointWithBody(string $verb, string $url, TableNode $body): void {
$response = $this->theUserSendsToOcsApiEndpointWithBody(
$verb,
$url,
@ -358,7 +362,7 @@ class OCSContext implements Context {
string $url,
string $password,
TableNode $body
):void {
): void {
$admin = $this->featureContext->getAdminUsername();
$response = $this->sendRequestToOcsEndpoint(
$admin,
@ -387,7 +391,7 @@ class OCSContext implements Context {
string $url,
string $password,
TableNode $body
):void {
): void {
$response = $this->sendRequestToOcsEndpoint(
$user,
$verb,
@ -408,7 +412,11 @@ class OCSContext implements Context {
* @return void
* @throws Exception
*/
public function theOCSStatusCodeShouldBe(string $statusCode, string $message = "", ?ResponseInterface $response = null):void {
public function theOCSStatusCodeShouldBe(
string $statusCode,
string $message = "",
?ResponseInterface $response = null
): void {
$statusCodes = explode(",", $statusCode);
$response = $response ?? $this->featureContext->getResponse();
$responseStatusCode = $this->getOCSResponseStatusCode(
@ -416,7 +424,8 @@ class OCSContext implements Context {
);
if (\is_array($statusCodes)) {
if ($message === "") {
$message = "OCS status code is not any of the expected values " . \implode(",", $statusCodes) . " got " . $responseStatusCode;
$message = "OCS status code is not any of the expected values "
. \implode(",", $statusCodes) . " got " . $responseStatusCode;
}
Assert::assertContainsEquals(
$responseStatusCode,
@ -446,7 +455,7 @@ class OCSContext implements Context {
* @return void
* @throws Exception
*/
public function theOcsStatusCodeShouldBeOr(string $statusCode1, string $statusCode2):void {
public function theOcsStatusCodeShouldBeOr(string $statusCode1, string $statusCode2): void {
$statusCodes = [$statusCode1,$statusCode1];
$response = $this->featureContext->getResponse();
$responseStatusCode = $this->getOCSResponseStatusCode(
@ -455,7 +464,8 @@ class OCSContext implements Context {
Assert::assertContainsEquals(
$responseStatusCode,
$statusCodes,
"OCS status code is not any of the expected values " . \implode(",", $statusCodes) . " got " . $responseStatusCode
"OCS status code is not any of the expected values "
. \implode(",", $statusCodes) . " got " . $responseStatusCode
);
$this->featureContext->emptyLastOCSStatusCodesArray();
}
@ -471,7 +481,7 @@ class OCSContext implements Context {
*
* @return void
*/
public function theOCSStatusMessageShouldBe(string $statusMessage, ?string $language = null):void {
public function theOCSStatusMessageShouldBe(string $statusMessage, ?string $language = null): void {
$language = TranslationHelper::getLanguage($language);
$statusMessage = $this->getActualStatusMessage($statusMessage, $language);
@ -496,7 +506,7 @@ class OCSContext implements Context {
*
* @return void
*/
public function theOCSStatusMessageAboutUserShouldBe(string $user, string $statusMessage):void {
public function theOCSStatusMessageAboutUserShouldBe(string $user, string $statusMessage): void {
$user = \strtolower($this->featureContext->getActualUsername($user));
$statusMessage = $this->featureContext->substituteInLineCodes(
$statusMessage,
@ -533,7 +543,7 @@ class OCSContext implements Context {
*/
public function theOCSStatusMessageShouldBePyString(
PyStringNode $statusMessage
):void {
): void {
Assert::assertEquals(
$statusMessage->getRaw(),
$this->getOCSResponseStatusMessage(
@ -554,7 +564,7 @@ class OCSContext implements Context {
* @return string
* @throws Exception
*/
public function getOCSResponseStatusCode(ResponseInterface $response):string {
public function getOCSResponseStatusCode(ResponseInterface $response): string {
try {
$jsonResponse = $this->featureContext->getJsonDecodedResponseBodyContent($response);
} catch (JsonException $e) {
@ -596,7 +606,7 @@ class OCSContext implements Context {
*
* @return string
*/
public function getOCSResponseStatusMessage(ResponseInterface $response):string {
public function getOCSResponseStatusMessage(ResponseInterface $response): string {
return (string) HttpRequestHelper::getResponseXml($response, __METHOD__)->meta[0]->message;
}
@ -608,7 +618,7 @@ class OCSContext implements Context {
*
* @return string
*/
public function getActualStatusMessage(string $statusMessage, ?string $language = null):string {
public function getActualStatusMessage(string $statusMessage, ?string $language = null): string {
if ($language !== null) {
$multiLingualMessage = \json_decode(
\file_get_contents(__DIR__ . "/../fixtures/multiLanguageErrors.json"),
@ -632,7 +642,10 @@ class OCSContext implements Context {
* @return void
* @throws Exception
*/
public function assertOCSResponseIndicatesSuccess(?string $message = "", ?ResponseInterface $response = null):void {
public function assertOCSResponseIndicatesSuccess(
?string $message = "",
?ResponseInterface $response = null
): void {
$response = $response ?? $this->featureContext->getResponse();
$this->featureContext->theHTTPStatusCodeShouldBe('200', $message, $response);
if ($this->featureContext->getOcsApiVersion() === 1) {
@ -652,7 +665,7 @@ class OCSContext implements Context {
*
* @return void
*/
public function before(BeforeScenarioScope $scope):void {
public function before(BeforeScenarioScope $scope): void {
// Get the environment
$environment = $scope->getEnvironment();
// Get all the contexts you need in this context

View File

@ -56,7 +56,7 @@ class OcmContext implements Context {
* @return string
* @throws Exception
*/
public function getLastFederatedInvitationToken():string {
public function getLastFederatedInvitationToken(): string {
if (empty($this->invitationToken)) {
throw new Exception(__METHOD__ . " token not found");
}
@ -286,7 +286,11 @@ class OcmContext implements Context {
*/
public function userHasDeletedFederatedConnectionWithUser(string $user, string $ocmUser): void {
$response = $this->deleteConnection($user, $ocmUser);
$this->featureContext->theHTTPStatusCodeShouldBe(200, "failed while deleting connection with user $ocmUser", $response);
$this->featureContext->theHTTPStatusCodeShouldBe(
200,
"failed while deleting connection with user $ocmUser",
$response
);
}
/**

View File

@ -59,7 +59,7 @@ trait Provisioning {
*
* @return boolean
*/
public function isLocalAdminGroup(string $groupname):bool {
public function isLocalAdminGroup(string $groupname): bool {
return ($groupname === "admin");
}
@ -72,28 +72,28 @@ trait Provisioning {
*
* @return string
*/
public function normalizeUsername(?string $username):string {
public function normalizeUsername(?string $username): string {
return \strtolower((string)$username);
}
/**
* @return array
*/
public function getCreatedUsers():array {
public function getCreatedUsers(): array {
return $this->createdUsers;
}
/**
* @return array
*/
public function getAllCreatedUsers():array {
public function getAllCreatedUsers(): array {
return array_merge($this->createdUsers, $this->createdRemoteUsers);
}
/**
* @return array
*/
public function getCreatedGroups():array {
public function getCreatedGroups(): array {
return $this->createdGroups;
}
@ -105,7 +105,7 @@ trait Provisioning {
*
* @return string
*/
public function getUserDisplayName(string $username):string {
public function getUserDisplayName(string $username): string {
$normalizedUsername = $this->normalizeUsername($username);
$users = $this->getAllCreatedUsers();
if (isset($users[$normalizedUsername]['displayname'])) {
@ -169,7 +169,7 @@ trait Provisioning {
* @return string password
* @throws Exception
*/
public function getUserPassword(string $username):string {
public function getUserPassword(string $username): string {
$normalizedUsername = $this->normalizeUsername($username);
if ($normalizedUsername === $this->getAdminUsername()) {
$password = $this->getAdminPassword();
@ -197,7 +197,7 @@ trait Provisioning {
*/
public function userHasBeenCreatedWithDefaultAttributes(
string $user
):void {
): void {
$this->userHasBeenCreated(["userName" => $user]);
}
@ -211,7 +211,7 @@ trait Provisioning {
*/
public function userHasBeenCreatedWithDefaultAttributesAndNotInitialized(
TableNode $table
):void {
): void {
$this->usersHaveBeenCreated($table, true, false);
}
@ -225,7 +225,7 @@ trait Provisioning {
* @return void
* @throws Exception|GuzzleException
*/
public function theseUsersHaveBeenCreatedWithDefaultAttributesAndWithoutSkeletonFiles(TableNode $table):void {
public function theseUsersHaveBeenCreatedWithDefaultAttributesAndWithoutSkeletonFiles(TableNode $table): void {
$this->usersHaveBeenCreated($table);
}
@ -253,7 +253,7 @@ trait Provisioning {
* @return boolean
* @throws Exception
*/
public function theGroupShouldBeAbleToBeDeleted(string $groupname):bool {
public function theGroupShouldBeAbleToBeDeleted(string $groupname): bool {
if (\array_key_exists($groupname, $this->createdGroups)) {
return $this->createdGroups[$groupname]['possibleToDelete'] ?? true;
}
@ -274,7 +274,7 @@ trait Provisioning {
*
* @return void
*/
public function importLdifFile(string $path):void {
public function importLdifFile(string $path): void {
$ldifData = \file_get_contents($path);
$this->importLdifData($ldifData);
}
@ -286,7 +286,7 @@ trait Provisioning {
*
* @return void
*/
public function importLdifData(string $ldifData):void {
public function importLdifData(string $ldifData): void {
$items = Laminas\Ldap\Ldif\Encoder::decode($ldifData);
if (isset($items['dn'])) {
//only one item in the ldif data
@ -314,7 +314,7 @@ trait Provisioning {
* @throws Exception
* @throws \LdapException
*/
public function connectToLdap(array $suiteParameters):void {
public function connectToLdap(array $suiteParameters): void {
$this->ldapBaseDN = OcisHelper::getBaseDN();
$this->ldapUsersOU = OcisHelper::getUsersOU();
$this->ldapGroupsOU = OcisHelper::getGroupsOU();
@ -365,7 +365,7 @@ trait Provisioning {
* @return array
* @throws JsonException
*/
public function buildUsersAttributesArray(bool $setDefaultAttributes, array $table):array {
public function buildUsersAttributesArray(bool $setDefaultAttributes, array $table): array {
$usersAttributes = [];
foreach ($table as $row) {
$userAttribute['userid'] = $this->getActualUsername($row['username']);
@ -412,7 +412,7 @@ trait Provisioning {
* @return void
* @throws Exception
*/
public function createLdapUser(array $setting):void {
public function createLdapUser(array $setting): void {
$ou = $this->ldapUsersOU ;
// Some special characters need to be escaped in LDAP DN and attributes
// The special characters allowed in a username (UID) are +_.@-
@ -455,7 +455,11 @@ trait Provisioning {
} catch (LdapException $e) {
if (\str_contains($e->getMessage(), "Already exists")) {
$this->ldap->delete(
"uid=" . ldap_escape($entry['uid'], "", LDAP_ESCAPE_DN) . ",ou=" . $this->ldapUsersOU . "," . $this->ldapBaseDN,
"uid=" . ldap_escape(
$entry['uid'],
"",
LDAP_ESCAPE_DN
) . ",ou=" . $this->ldapUsersOU . "," . $this->ldapBaseDN,
);
OcisHelper::deleteRevaUserData([$entry['uid']]);
$this->ldap->add($newDN, $entry);
@ -472,7 +476,7 @@ trait Provisioning {
* @throws Exception
* @throws LdapException
*/
public function createLdapGroup(string $group):void {
public function createLdapGroup(string $group): void {
$baseDN = $this->getLdapBaseDN();
$newDN = 'cn=' . $group . ',ou=' . $this->ldapGroupsOU . ',' . $baseDN;
$entry = [];
@ -496,7 +500,8 @@ trait Provisioning {
} catch (LdapException $e) {
if (\str_contains($e->getMessage(), "Already exists")) {
$this->ldap->delete(
"cn=" . ldap_escape($group, "", LDAP_ESCAPE_DN) . ",ou=" . $this->ldapGroupsOU . "," . $this->ldapBaseDN,
"cn=" . ldap_escape($group, "", LDAP_ESCAPE_DN)
. ",ou=" . $this->ldapGroupsOU . "," . $this->ldapBaseDN,
);
$this->ldap->add($newDN, $entry);
}
@ -510,7 +515,7 @@ trait Provisioning {
* @return void
* @throws Exception
*/
public function deleteLdapUsersAndGroups():void {
public function deleteLdapUsersAndGroups(): void {
foreach ($this->ldapCreatedUsers as $user) {
$this->ldap->delete(
"uid=" . ldap_escape($user, "", LDAP_ESCAPE_DN) . ",ou=" . $this->ldapUsersOU . "," . $this->ldapBaseDN,
@ -519,7 +524,8 @@ trait Provisioning {
}
foreach ($this->ldapCreatedGroups as $group) {
$this->ldap->delete(
"cn=" . ldap_escape($group, "", LDAP_ESCAPE_DN) . ",ou=" . $this->ldapGroupsOU . "," . $this->ldapBaseDN,
"cn=" . ldap_escape($group, "", LDAP_ESCAPE_DN)
. ",ou=" . $this->ldapGroupsOU . "," . $this->ldapBaseDN,
);
$this->rememberThatGroupIsNotExpectedToExist($group);
}
@ -667,7 +673,7 @@ trait Provisioning {
*
* @return void
*/
public function resetUserPasswordAsAdminUsingTheProvisioningApi(string $username, ?string $password):void {
public function resetUserPasswordAsAdminUsingTheProvisioningApi(string $username, ?string $password): void {
$this->userResetUserPasswordUsingProvisioningApi(
$this->getAdminUsername(),
$username,
@ -682,7 +688,11 @@ trait Provisioning {
*
* @return void
*/
public function userResetUserPasswordUsingProvisioningApi(?string $user, ?string $username, ?string $password):void {
public function userResetUserPasswordUsingProvisioningApi(
?string $user,
?string $username,
?string $password
): void {
$targetUsername = $this->getActualUsername($username);
$password = $this->getActualPassword($password);
$this->userTriesToResetUserPasswordUsingTheProvisioningApi(
@ -700,7 +710,11 @@ trait Provisioning {
*
* @return void
*/
public function userTriesToResetUserPasswordUsingTheProvisioningApi(?string $user, ?string $username, ?string $password):void {
public function userTriesToResetUserPasswordUsingTheProvisioningApi(
?string $user,
?string $username,
?string $password
): void {
$password = $this->getActualPassword($password);
$bodyTable = new TableNode([['key', 'password'], ['value', $password]]);
$this->ocsContext->sendRequestToOcsEndpoint(
@ -719,7 +733,7 @@ trait Provisioning {
* @return void
* @throws Exception
*/
public function theAdminDeletesUserUsingTheProvisioningApi(string $user):void {
public function theAdminDeletesUserUsingTheProvisioningApi(string $user): void {
$user = $this->getActualUsername($user);
$this->setResponse($this->deleteUser($user));
$this->pushToLastHttpStatusCodesArray();
@ -733,7 +747,7 @@ trait Provisioning {
* @return void
* @throws JsonException
*/
public function userShouldExist(string $user):void {
public function userShouldExist(string $user): void {
Assert::assertTrue(
$this->userExists($user),
"User '$user' should exist but does not exist"
@ -748,7 +762,7 @@ trait Provisioning {
* @return void
* @throws JsonException
*/
public function userShouldNotExist(string $user):void {
public function userShouldNotExist(string $user): void {
$user = $this->getActualUsername($user);
Assert::assertFalse(
$this->userExists($user),
@ -766,7 +780,7 @@ trait Provisioning {
* @throws Exception
* @throws GuzzleException
*/
public function groupShouldExist(string $group):void {
public function groupShouldExist(string $group): void {
Assert::assertTrue(
$this->groupExists($group),
"Group '$group' should exist but does not exist"
@ -782,7 +796,7 @@ trait Provisioning {
* @throws Exception
* @throws GuzzleException
*/
public function groupShouldNotExist(string $group):void {
public function groupShouldNotExist(string $group): void {
Assert::assertFalse(
$this->groupExists($group),
"Group '$group' should not exist but does exist"
@ -799,7 +813,7 @@ trait Provisioning {
* @return void
* @throws Exception
*/
public function theseGroupsShouldNotExist(string $shouldOrNot, TableNode $table):void {
public function theseGroupsShouldNotExist(string $shouldOrNot, TableNode $table): void {
$should = ($shouldOrNot !== "not");
$this->verifyTableNodeColumns($table, ['groupname']);
if ($this->isTestingWithLdap()) {
@ -826,7 +840,7 @@ trait Provisioning {
* @return void
* @throws Exception
*/
public function userHasBeenDeleted(string $user):void {
public function userHasBeenDeleted(string $user): void {
$user = $this->getActualUsername($user);
if ($this->userExists($user)) {
if ($this->isTestingWithLdap() && \in_array($user, $this->ldapCreatedUsers)) {
@ -853,7 +867,7 @@ trait Provisioning {
*
* @return void
*/
public function theseUsersHaveBeenInitialized(TableNode $table):void {
public function theseUsersHaveBeenInitialized(TableNode $table): void {
foreach ($table as $row) {
if (!isset($row ['password'])) {
$password = $this->getPasswordForUser($row ['username']);
@ -872,7 +886,7 @@ trait Provisioning {
*
* @return ResponseInterface
*/
public function getAllGroups():ResponseInterface {
public function getAllGroups(): ResponseInterface {
$fullUrl = $this->getBaseUrl() . "/ocs/v$this->ocsApiVersion.php/cloud/groups";
return HttpRequestHelper::get(
$fullUrl,
@ -888,7 +902,7 @@ trait Provisioning {
*
* @return void
*/
public function userGetsAllTheGroupsOfUser(string $user, string $otherUser):void {
public function userGetsAllTheGroupsOfUser(string $user, string $otherUser): void {
$actualOtherUser = $this->getActualUsername($otherUser);
$fullUrl = $this->getBaseUrl() . "/ocs/v$this->ocsApiVersion.php/cloud/users/$actualOtherUser/groups";
$actualUser = $this->getActualUsername($user);
@ -909,7 +923,7 @@ trait Provisioning {
* @return void
* @throws Exception
*/
public function userGetsTheListOfAllUsersUsingTheProvisioningApi(string $user):void {
public function userGetsTheListOfAllUsersUsingTheProvisioningApi(string $user): void {
$this->featureContext->setResponse(
$this->userGetsTheListOfAllUsers($user)
);
@ -920,7 +934,7 @@ trait Provisioning {
*
* @return ResponseInterface
*/
public function userGetsTheListOfAllUsers(string $user):ResponseInterface {
public function userGetsTheListOfAllUsers(string $user): ResponseInterface {
$fullUrl = $this->getBaseUrl() . "/ocs/v$this->ocsApiVersion.php/cloud/users";
$actualUser = $this->getActualUsername($user);
$actualPassword = $this->getUserPassword($actualUser);
@ -941,7 +955,7 @@ trait Provisioning {
*
* @return void
*/
public function initializeUser(string $user, string $password):void {
public function initializeUser(string $user, string $password): void {
$url = $this->getBaseUrl() . "/graph/v1.0/users/$user";
if (OcisHelper::isTestingOnReva()) {
@ -979,7 +993,7 @@ trait Provisioning {
?string $email = null,
?string $userId = null,
bool $shouldExist = true
):void {
): void {
$user = $this->getActualUsername($user);
$normalizedUsername = $this->normalizeUsername($user);
$userData = [
@ -1021,7 +1035,7 @@ trait Provisioning {
public function rememberUserPassword(
string $user,
string $password
):void {
): void {
$normalizedUsername = $this->normalizeUsername($user);
if ($this->currentServer === 'LOCAL') {
if (\array_key_exists($normalizedUsername, $this->createdUsers)) {
@ -1040,7 +1054,7 @@ trait Provisioning {
*
* @return void
*/
public function updateUsernameInCreatedUserList(string $oldUserName, string $newUserName) :void {
public function updateUsernameInCreatedUserList(string $oldUserName, string $newUserName): void {
$normalizedUsername = $this->normalizeUsername($oldUserName);
$normalizeNewUserName = $this->normalizeUsername($newUserName);
if (\array_key_exists($normalizedUsername, $this->createdUsers)) {
@ -1064,7 +1078,7 @@ trait Provisioning {
*
* @return void
*/
public function rememberThatUserIsNotExpectedToExist(string $user):void {
public function rememberThatUserIsNotExpectedToExist(string $user): void {
$user = $this->getActualUsername($user);
$normalizedUsername = $this->normalizeUsername($user);
if (\array_key_exists($normalizedUsername, $this->createdUsers)) {
@ -1085,7 +1099,7 @@ trait Provisioning {
public function userHasBeenCreated(
array $userData,
string $byUser = null
):void {
): void {
$userId = null;
$user = $userData["userName"];
@ -1167,7 +1181,7 @@ trait Provisioning {
* @return void
* @throws Exception
*/
public function adminRemovesUserFromGroupUsingTheProvisioningApi(string $user, string $group):void {
public function adminRemovesUserFromGroupUsingTheProvisioningApi(string $user, string $group): void {
$user = $this->getActualUsername($user);
if (OcisHelper::isTestingOnReva()) {
$this->response = UserHelper::removeUserFromGroup(
@ -1199,7 +1213,7 @@ trait Provisioning {
* @return void
* @throws Exception
*/
public function theExtraGroupsShouldBe(TableNode $groupsList):void {
public function theExtraGroupsShouldBe(TableNode $groupsList): void {
$this->verifyTableNodeColumnsCount($groupsList, 1);
$groups = $groupsList->getRows();
$groupsSimplified = $this->simplifyArray($groups);
@ -1227,7 +1241,7 @@ trait Provisioning {
* @return void
* @throws Exception
*/
public function cleanupGroup(string $group):void {
public function cleanupGroup(string $group): void {
try {
if ($this->isTestingWithLdap()) {
$this->deleteLdapGroup($group);
@ -1259,7 +1273,7 @@ trait Provisioning {
* @return bool
* @throws JsonException
*/
public function userExists(string $user):bool {
public function userExists(string $user): bool {
$path = (!OcisHelper::isTestingOnReva())
? "/graph/v1.0"
: "/ocs/v2.php/cloud";
@ -1294,7 +1308,7 @@ trait Provisioning {
* @return void
* @throws Exception
*/
public function userShouldBelongToGroup(string $user, string $group):void {
public function userShouldBelongToGroup(string $user, string $group): void {
$user = $this->getActualUsername($user);
if (OcisHelper::isTestingOnReva()) {
$this->userGetsAllTheGroupsOfUser($this->getAdminUsername(), $user);
@ -1331,7 +1345,7 @@ trait Provisioning {
* @return void
* @throws Exception
*/
public function theTheFollowingUserShouldNotBelongToTheFollowingGroup(TableNode $table):void {
public function theTheFollowingUserShouldNotBelongToTheFollowingGroup(TableNode $table): void {
$this->verifyTableNodeColumns($table, ["username", "groupname"]);
$rows = $table->getHash();
foreach ($rows as $row) {
@ -1366,7 +1380,7 @@ trait Provisioning {
*
* @return void
*/
public function groupShouldNotContainUser(string $group, string $username):void {
public function groupShouldNotContainUser(string $group, string $username): void {
$username = $this->getActualUsername($username);
$fullUrl = $this->getBaseUrl() . "/ocs/v2.php/cloud/groups/$group";
$response = HttpRequestHelper::get(
@ -1387,7 +1401,7 @@ trait Provisioning {
* @return void
* @throws Exception
*/
public function adminAddsUserToGroupUsingTheProvisioningApi(string $user, string $group):void {
public function adminAddsUserToGroupUsingTheProvisioningApi(string $user, string $group): void {
$response = $this->graphContext->addUserToGroup($group, $user);
$this->setResponse($response);
}
@ -1401,7 +1415,7 @@ trait Provisioning {
* @return void
* @throws Exception
*/
public function userHasBeenAddedToGroup(string $user, string $group):void {
public function userHasBeenAddedToGroup(string $user, string $group): void {
$user = $this->getActualUsername($user);
if ($this->isTestingWithLdap()) {
try {
@ -1428,7 +1442,7 @@ trait Provisioning {
* @return void
* @throws Exception
*/
public function theFollowingUserHaveBeenAddedToTheFollowingGroup(TableNode $table):void {
public function theFollowingUserHaveBeenAddedToTheFollowingGroup(TableNode $table): void {
$this->verifyTableNodeColumns($table, ['username', 'groupname']);
foreach ($table as $row) {
$user = $row['username'];
@ -1465,7 +1479,7 @@ trait Provisioning {
bool $shouldExist = true,
bool $possibleToDelete = true,
?string $id = null
):void {
): void {
$groupData = [
"shouldExist" => $shouldExist,
"possibleToDelete" => $possibleToDelete
@ -1491,7 +1505,7 @@ trait Provisioning {
*
* @return void
*/
public function rememberThatGroupIsNotExpectedToExist(string $group):void {
public function rememberThatGroupIsNotExpectedToExist(string $group): void {
if (\array_key_exists($group, $this->createdGroups)) {
$this->createdGroups[$group]['shouldExist'] = false;
$this->createdGroups[$group]['possibleToDelete'] = false;
@ -1507,7 +1521,7 @@ trait Provisioning {
* @throws Exception
* @throws GuzzleException
*/
public function groupHasBeenCreated(string $group):void {
public function groupHasBeenCreated(string $group): void {
$this->createTheGroup($group);
Assert::assertTrue(
$this->groupExists($group),
@ -1524,7 +1538,7 @@ trait Provisioning {
* @return void
* @throws Exception
*/
public function theseGroupsHaveBeenCreated(TableNode $table):void {
public function theseGroupsHaveBeenCreated(TableNode $table): void {
$this->verifyTableNodeColumns($table, ['groupname'], ['comment']);
foreach ($table as $row) {
$this->createTheGroup($row['groupname']);
@ -1540,7 +1554,7 @@ trait Provisioning {
* @return void
* @throws Exception
*/
public function createTheGroup(string $group, ?string $method = null):void {
public function createTheGroup(string $group, ?string $method = null): void {
//guess yourself
if ($method === null) {
if ($this->isTestingWithLdap()) {
@ -1594,7 +1608,7 @@ trait Provisioning {
string $entry,
string $value,
bool $append = false
):void {
): void {
$ldapEntry = $this->ldap->getEntry($entry . "," . $this->ldapBaseDN);
Laminas\Ldap\Attribute::setAttribute($ldapEntry, $attribute, $value, $append);
$this->ldap->update($entry . "," . $this->ldapBaseDN, $ldapEntry);
@ -1608,7 +1622,7 @@ trait Provisioning {
* @return void
* @throws Exception
*/
public function addUserToLdapGroup(string $user, string $group, ?string $ou = null):void {
public function addUserToLdapGroup(string $user, string $group, ?string $ou = null): void {
if ($ou === null) {
$ou = $this->getLdapGroupsOU();
}
@ -1635,7 +1649,7 @@ trait Provisioning {
*
* @return void
*/
public function deleteValueFromLdapAttribute(string $value, string $attribute, string $entry):void {
public function deleteValueFromLdapAttribute(string $value, string $attribute, string $entry): void {
$this->ldap->deleteAttributes(
$entry . "," . $this->ldapBaseDN,
[$attribute => [$value]]
@ -1650,7 +1664,7 @@ trait Provisioning {
* @return void
* @throws Exception
*/
public function removeUserFromLdapGroup(string $user, string $group, ?string $ou = null):void {
public function removeUserFromLdapGroup(string $user, string $group, ?string $ou = null): void {
if ($ou === null) {
$ou = $this->getLdapGroupsOU();
}
@ -1675,7 +1689,7 @@ trait Provisioning {
* @return void
* @throws Exception
*/
public function deleteTheLdapEntry(string $entry):void {
public function deleteTheLdapEntry(string $entry): void {
$this->ldap->delete($entry . "," . $this->ldapBaseDN);
}
@ -1687,7 +1701,7 @@ trait Provisioning {
* @throws LdapException
* @throws Exception
*/
public function deleteLdapGroup(string $group, ?string $ou = null):void {
public function deleteLdapGroup(string $group, ?string $ou = null): void {
if ($ou === null) {
$ou = $this->getLdapGroupsOU();
}
@ -1706,7 +1720,7 @@ trait Provisioning {
* @return void
* @throws Exception
*/
public function deleteLdapUser(?string $username, ?string $ou = null):void {
public function deleteLdapUser(?string $username, ?string $ou = null): void {
if (!\in_array($username, $this->ldapCreatedUsers)) {
throw new Error(
"User " . $username . " was not created using Ldap and does not exist as an Ldap User"
@ -1732,12 +1746,20 @@ trait Provisioning {
* @return void
* @throws Exception
*/
public function adminHasDisabledUserUsingTheProvisioningApi(?string $user):void {
public function adminHasDisabledUserUsingTheProvisioningApi(?string $user): void {
$user = $this->getActualUsername($user);
if (OcisHelper::isTestingOnReva()) {
$response = $this->disableOrEnableUser($this->getAdminUsername(), $user, 'disable');
} else {
$response = $this->graphContext->editUserUsingTheGraphApi($this->getAdminUsername(), $user, null, null, null, null, false);
$response = $this->graphContext->editUserUsingTheGraphApi(
$this->getAdminUsername(),
$user,
null,
null,
null,
null,
false
);
}
Assert::assertEquals(
200,
@ -1754,7 +1776,7 @@ trait Provisioning {
* @return void
* @throws Exception
*/
public function deleteUser(string $user):ResponseInterface {
public function deleteUser(string $user): ResponseInterface {
// Always try to delete the user
if (OcisHelper::isTestingOnReva()) {
$response = UserHelper::deleteUser(
@ -1781,7 +1803,7 @@ trait Provisioning {
* @throws Exception
* @throws GuzzleException
*/
public function groupHasBeenDeleted(string $group):void {
public function groupHasBeenDeleted(string $group): void {
if ($this->isTestingWithLdap()) {
$this->deleteLdapGroup($group);
} else {
@ -1802,7 +1824,7 @@ trait Provisioning {
* @throws Exception
* @throws GuzzleException
*/
public function groupExists(string $group):bool {
public function groupExists(string $group): bool {
if ($this->isTestingWithLdap()) {
$baseDN = $this->getLdapBaseDN();
$newDN = 'cn=' . $group . ',ou=' . $this->ldapGroupsOU . ',' . $baseDN;
@ -1834,7 +1856,7 @@ trait Provisioning {
* @return void
* @throws Exception
*/
public function adminHasRemovedUserFromGroup(string $user, string $group):void {
public function adminHasRemovedUserFromGroup(string $user, string $group): void {
$user = $this->getActualUsername($user);
if ($this->isTestingWithLdap()
&& !$this->isLocalAdminGroup($group)
@ -1874,7 +1896,7 @@ trait Provisioning {
* @return void
* @throws Exception
*/
public function theUsersShouldBe(TableNode $usersList):void {
public function theUsersShouldBe(TableNode $usersList): void {
$this->verifyTableNodeColumnsCount($usersList, 1);
$users = $usersList->getRows();
$usersSimplified = \array_map(
@ -1904,7 +1926,7 @@ trait Provisioning {
* @return array
* @throws Exception
*/
public function getArrayOfUsersResponded(ResponseInterface $resp):array {
public function getArrayOfUsersResponded(ResponseInterface $resp): array {
$listCheckedElements = HttpRequestHelper::getResponseXml($resp, __METHOD__)->data[0]->users[0]->element;
return \json_decode(\json_encode($listCheckedElements), true);
}
@ -1917,7 +1939,7 @@ trait Provisioning {
* @return array
* @throws Exception
*/
public function getArrayOfGroupsResponded(ResponseInterface $resp):array {
public function getArrayOfGroupsResponded(ResponseInterface $resp): array {
$listCheckedElements
= HttpRequestHelper::getResponseXml($resp, __METHOD__)->data[0]->groups[0]->element;
return \json_decode(\json_encode($listCheckedElements), true);
@ -1931,7 +1953,7 @@ trait Provisioning {
* @return array
* @throws Exception
*/
public function getArrayOfAppsResponded(ResponseInterface $resp):array {
public function getArrayOfAppsResponded(ResponseInterface $resp): array {
$listCheckedElements = HttpRequestHelper::getResponseXml($resp, __METHOD__)->data[0]->apps[0]->element;
return \json_decode(\json_encode($listCheckedElements), true);
}
@ -1942,7 +1964,7 @@ trait Provisioning {
* @return void
* @throws Exception
*/
public function theApiShouldNotReturnAnyData():void {
public function theApiShouldNotReturnAnyData(): void {
$responseData = HttpRequestHelper::getResponseXml($this->response, __METHOD__)->data[0];
Assert::assertEmpty(
$responseData,
@ -1956,7 +1978,7 @@ trait Provisioning {
* @return void
* @throws Exception
*/
public function afterScenario():void {
public function afterScenario(): void {
if (OcisHelper::isTestingOnReva()) {
OcisHelper::deleteRevaUserData($this->getCreatedUsers());
}
@ -1973,7 +1995,7 @@ trait Provisioning {
* @return void
* @throws Exception
*/
public function cleanupDatabaseUsers():void {
public function cleanupDatabaseUsers(): void {
$previousServer = $this->currentServer;
$this->usingServer('LOCAL');
foreach ($this->createdUsers as $userData) {
@ -2003,7 +2025,7 @@ trait Provisioning {
* @return void
* @throws Exception
*/
public function cleanupDatabaseGroups():void {
public function cleanupDatabaseGroups(): void {
$previousServer = $this->currentServer;
$this->usingServer('LOCAL');
foreach ($this->createdGroups as $group => $groupData) {
@ -2036,7 +2058,7 @@ trait Provisioning {
* @return void
* @throws Exception
*/
public function rememberGroupsThatExistAtTheStartOfTheScenario():void {
public function rememberGroupsThatExistAtTheStartOfTheScenario(): void {
$this->startingGroups = $this->getArrayOfGroupsResponded($this->getAllGroups());
}

View File

@ -43,7 +43,7 @@ class PublicWebDavContext implements Context {
*
* @return ResponseInterface
*/
public function downloadPublicFileWithRange(string $range, ?string $password = ""):ResponseInterface {
public function downloadPublicFileWithRange(string $range, ?string $password = ""): ResponseInterface {
// In this case a single file has been shared as a public link.
// Even if that file is somewhere down inside a folder(s), when
// accessing it as a public link using the public webDAV API
@ -66,7 +66,7 @@ class PublicWebDavContext implements Context {
*
* @return void
*/
public function downloadPublicFile():void {
public function downloadPublicFile(): void {
$response = $this->downloadPublicFileWithRange("");
$this->featureContext->setResponse($response);
}
@ -79,7 +79,7 @@ class PublicWebDavContext implements Context {
*
* @return void
*/
public function downloadPublicFileWithPassword(string $password):void {
public function downloadPublicFileWithPassword(string $password): void {
$response = $this->downloadPublicFileWithRange("", $password);
$this->featureContext->setResponse($response);
}
@ -92,7 +92,10 @@ class PublicWebDavContext implements Context {
*
* @return void
*/
public function userTriesToDownloadFileFromPublicLinkUsingBasicAuthAndPublicWebdav(string $user, string $path): void {
public function userTriesToDownloadFileFromPublicLinkUsingBasicAuthAndPublicWebdav(
string $user,
string $path
): void {
$response = $this->downloadFromPublicLinkAsUser($path, $user);
$this->featureContext->setResponse($response);
}
@ -104,7 +107,9 @@ class PublicWebDavContext implements Context {
*
* @return void
*/
public function thePublicDeletesFileFolderFromTheLastPublicLinkShareUsingThePublicWebdavApi(string $fileName):void {
public function thePublicDeletesFileFolderFromTheLastPublicLinkShareUsingThePublicWebdavApi(
string $fileName
): void {
$response = $this->deleteFileFromPublicShare(
$fileName
);
@ -119,7 +124,9 @@ class PublicWebDavContext implements Context {
* @return ResponseInterface
*/
public function deleteFileFromPublicShare(string $fileName, string $password = ""): ResponseInterface {
$token = ($this->featureContext->isUsingSharingNG()) ? $this->featureContext->shareNgGetLastCreatedLinkShareToken() : $this->featureContext->getLastCreatedPublicShareToken();
$token = ($this->featureContext->isUsingSharingNG())
? $this->featureContext->shareNgGetLastCreatedLinkShareToken()
: $this->featureContext->getLastCreatedPublicShareToken();
$davPath = WebDavHelper::getDavPath(
WebDavHelper::DAV_VERSION_NEW,
$token,
@ -151,7 +158,10 @@ class PublicWebDavContext implements Context {
*
* @return void
*/
public function thePublicHasDeletedFileFromTheLastLinkShareWithPasswordUsingPublicWebdavApi(string $file, string $password): void {
public function thePublicHasDeletedFileFromTheLastLinkShareWithPasswordUsingPublicWebdavApi(
string $file,
string $password
): void {
$response = $this->deleteFileFromPublicShare($file, $password);
$this->featureContext->theHTTPStatusCodeShouldBe([201, 204], "", $response);
}
@ -164,7 +174,10 @@ class PublicWebDavContext implements Context {
*
* @return void
*/
public function thePublicDeletesFileFromTheLastLinkShareWithPasswordUsingPublicWebdavApi(string $file, string $password): void {
public function thePublicDeletesFileFromTheLastLinkShareWithPasswordUsingPublicWebdavApi(
string $file,
string $password
): void {
$this->featureContext->setResponse(
$this->deleteFileFromPublicShare($file, $password)
);
@ -178,8 +191,14 @@ class PublicWebDavContext implements Context {
*
* @return ResponseInterface
*/
public function renameFileFromPublicShare(string $fileName, string $toFileName, ?string $password = ""):ResponseInterface {
$token = ($this->featureContext->isUsingSharingNG()) ? $this->featureContext->shareNgGetLastCreatedLinkShareToken() : $this->featureContext->getLastCreatedPublicShareToken();
public function renameFileFromPublicShare(
string $fileName,
string $toFileName,
?string $password = ""
): ResponseInterface {
$token = ($this->featureContext->isUsingSharingNG())
? $this->featureContext->shareNgGetLastCreatedLinkShareToken()
: $this->featureContext->getLastCreatedPublicShareToken();
$davPath = WebDavHelper::getDavPath(
WebDavHelper::DAV_VERSION_NEW,
$token,
@ -215,7 +234,11 @@ class PublicWebDavContext implements Context {
*
* @return void
*/
public function thePublicRenamesFileFromTheLastPublicShareUsingThePasswordPasswordAndOldPublicWebdavApi(string $fileName, string $toName, string $password):void {
public function thePublicRenamesFileFromTheLastPublicShareUsingThePasswordPasswordAndOldPublicWebdavApi(
string $fileName,
string $toName,
string $password
): void {
$this->featureContext->setResponse(
$this->renameFileFromPublicShare($fileName, $toName, $password)
);
@ -231,7 +254,10 @@ class PublicWebDavContext implements Context {
*
* @return void
*/
public function publicDownloadsFileFromInsideLastPublicSharedFolderWithPassword(string $path, string $password = ""):void {
public function publicDownloadsFileFromInsideLastPublicSharedFolderWithPassword(
string $path,
string $password = ""
): void {
$response = $this->downloadFileFromPublicFolder(
$path,
$password,
@ -249,7 +275,9 @@ class PublicWebDavContext implements Context {
*/
public function downloadFromPublicLinkAsUser(string $path, string $user): ResponseInterface {
$path = \ltrim($path, "/");
$token = ($this->featureContext->isUsingSharingNG()) ? $this->featureContext->shareNgGetLastCreatedLinkShareToken() : $this->featureContext->getLastCreatedPublicShareToken();
$token = ($this->featureContext->isUsingSharingNG())
? $this->featureContext->shareNgGetLastCreatedLinkShareToken()
: $this->featureContext->getLastCreatedPublicShareToken();
$davPath = WebDavHelper::getDavPath(
$this->featureContext->getDavPathVersion(),
@ -281,7 +309,7 @@ class PublicWebDavContext implements Context {
string $password,
string $range,
bool $shareNg = false
):ResponseInterface {
): ResponseInterface {
$path = \ltrim($path, "/");
$password = $this->featureContext->getActualPassword($password);
if ($shareNg) {
@ -320,7 +348,7 @@ class PublicWebDavContext implements Context {
*
* @return ResponseInterface
*/
public function publicUploadFile(string $source):ResponseInterface {
public function publicUploadFile(string $source): ResponseInterface {
return $this->publicUploadContent(
\basename($source),
'',
@ -344,7 +372,7 @@ class PublicWebDavContext implements Context {
string $baseUrl,
string $source,
string $destination
):ResponseInterface {
): ResponseInterface {
$fullSourceUrl = "$baseUrl/$source";
$fullDestUrl = WebDavHelper::sanitizeUrl(
"$baseUrl/$destination"
@ -369,8 +397,10 @@ class PublicWebDavContext implements Context {
*
* @return void
*/
public function thePublicCopiesFileUsingTheWebDAVApi(string $source, string $destination):void {
$token = ($this->featureContext->isUsingSharingNG()) ? $this->featureContext->shareNgGetLastCreatedLinkShareToken() : $this->featureContext->getLastCreatedPublicShareToken();
public function thePublicCopiesFileUsingTheWebDAVApi(string $source, string $destination): void {
$token = ($this->featureContext->isUsingSharingNG())
? $this->featureContext->shareNgGetLastCreatedLinkShareToken()
: $this->featureContext->getLastCreatedPublicShareToken();
$davPath = WebDavHelper::getDavPath(
WebDavHelper::DAV_VERSION_NEW,
$token,
@ -395,7 +425,7 @@ class PublicWebDavContext implements Context {
*
* @return ResponseInterface
*/
public function publiclyUploadingContentAutoRename(string $filename, string $body = 'test'):ResponseInterface {
public function publiclyUploadingContentAutoRename(string $filename, string $body = 'test'): ResponseInterface {
return $this->publicUploadContent($filename, '', $body, true);
}
@ -407,7 +437,7 @@ class PublicWebDavContext implements Context {
*
* @return void
*/
public function thePublicUploadsFileWithContentWithAutoRenameMode(string $filename, string $body = 'test'):void {
public function thePublicUploadsFileWithContentWithAutoRenameMode(string $filename, string $body = 'test'): void {
$response = $this->publiclyUploadingContentAutoRename($filename, $body);
$this->featureContext->setResponse($response);
}
@ -420,7 +450,10 @@ class PublicWebDavContext implements Context {
*
* @return void
*/
public function thePublicHasUploadedFileWithContentWithAutoRenameMode(string $filename, string $body = 'test'):void {
public function thePublicHasUploadedFileWithContentWithAutoRenameMode(
string $filename,
string $body = 'test'
): void {
$response = $this->publiclyUploadingContentAutoRename($filename, $body);
$this->featureContext->theHTTPStatusCodeShouldBe([201, 204], "", $response);
}
@ -436,7 +469,7 @@ class PublicWebDavContext implements Context {
string $filename,
string $password = '',
string $body = 'test',
):ResponseInterface {
): ResponseInterface {
return $this->publicUploadContent(
$filename,
$password,
@ -455,7 +488,11 @@ class PublicWebDavContext implements Context {
*
* @return void
*/
public function thePublicHasUploadedFileWithContentAndPasswordToLastLinkShareUsingPublicWebdavApi(string $filename, string $content = 'test', string $password = ''): void {
public function thePublicHasUploadedFileWithContentAndPasswordToLastLinkShareUsingPublicWebdavApi(
string $filename,
string $content = 'test',
string $password = ''
): void {
$response = $this->publiclyUploadingContentWithPassword(
$filename,
$password,
@ -477,7 +514,7 @@ class PublicWebDavContext implements Context {
string $filename,
string $password,
string $body,
):void {
): void {
$response = $this->publiclyUploadingContentWithPassword(
$filename,
$password,
@ -494,7 +531,7 @@ class PublicWebDavContext implements Context {
*
* @return void
*/
public function thePublicOverwritesFileWithContentUsingWebDavApi(string $filename, string $body):void {
public function thePublicOverwritesFileWithContentUsingWebDavApi(string $filename, string $body): void {
$response = $this->publicUploadContent($filename, '', $body);
$this->featureContext->setResponse($response);
}
@ -510,7 +547,7 @@ class PublicWebDavContext implements Context {
public function thePublicUploadsFileWithContentUsingThePublicWebDavApi(
string $filename,
string $body = 'test'
):void {
): void {
$response = $this->publicUploadContent($filename, '', $body);
$this->featureContext->setResponse($response);
$this->featureContext->pushToLastStatusCodesArrays();
@ -541,7 +578,7 @@ class PublicWebDavContext implements Context {
public function checkLastPublicSharedFileWithPasswordDownload(
string $password,
string $expectedContent
):void {
): void {
$response = $this->downloadPublicFileWithRange(
"",
$password
@ -568,7 +605,7 @@ class PublicWebDavContext implements Context {
public function shouldNotBeAbleToDownloadFileInsidePublicSharedFolder(
string $path,
string $expectedHttpCode = "401"
):void {
): void {
$response = $this->downloadFileFromPublicFolder(
$path,
"",
@ -589,7 +626,7 @@ class PublicWebDavContext implements Context {
public function shouldBeAbleToDownloadFileInsidePublicSharedFolderWithPassword(
string $path,
string $password
):void {
): void {
$response = $this->downloadFileFromPublicFolder(
$path,
$password,
@ -613,7 +650,7 @@ class PublicWebDavContext implements Context {
string $path,
string $password,
string $content
):void {
): void {
$response = $this->downloadFileFromPublicFolder(
$path,
$password,
@ -638,7 +675,7 @@ class PublicWebDavContext implements Context {
string $path,
string $password,
string $content
):void {
): void {
$response = $this->downloadFileFromPublicFolder(
$path,
$password,
@ -664,7 +701,7 @@ class PublicWebDavContext implements Context {
string $path,
string $password,
string $expectedHttpCode = "401"
):void {
): void {
$response = $this->downloadFileFromPublicFolder(
$path,
$password,
@ -687,7 +724,7 @@ class PublicWebDavContext implements Context {
string $path,
string $password,
string $expectedHttpCode = "401"
):void {
): void {
$this->tryingToDownloadUsingWebDAVAPI(
$path,
"new",
@ -712,7 +749,7 @@ class PublicWebDavContext implements Context {
string $range = "",
string $expectedHttpCode = "401",
bool $shareNg = false
):void {
): void {
$response = $this->downloadFileFromPublicFolder(
$path,
$password,
@ -734,7 +771,7 @@ class PublicWebDavContext implements Context {
public function publiclyUploadingShouldToSharedFileShouldFail(
string $password,
string $expectedHttpCode
):void {
): void {
$filename = (string)$this->featureContext->getLastCreatedPublicShare()->file_target;
$response = $this->publicUploadContent(
@ -756,7 +793,7 @@ class PublicWebDavContext implements Context {
public function publiclyUploadingWithPasswordShouldNotWork(
string $password,
string $expectedHttpCode = null
):void {
): void {
$response = $this->publicUploadContent(
'whateverfilefortesting.txt',
$password
@ -779,7 +816,7 @@ class PublicWebDavContext implements Context {
public function publiclyUploadingIntoFolderWithPasswordShouldWork(
string $filename,
string $password
):void {
): void {
$response = $this->publicUploadContent(
$filename,
$password
@ -796,7 +833,7 @@ class PublicWebDavContext implements Context {
* @return void
* @throws Exception
*/
public function publiclyUploadingShouldWork(string $password):void {
public function publiclyUploadingShouldWork(string $password): void {
$path = "whateverfilefortesting-publicWebDAVAPI.txt";
$content = "test";
@ -832,7 +869,7 @@ class PublicWebDavContext implements Context {
public function publiclyUploadingToPublicLinkSharedFileShouldWork(
string $password,
string $shouldOrNot,
):void {
): void {
$content = "test";
$should = ($shouldOrNot !== "not");
$path = (string) $this->featureContext->getLastCreatedPublicShare()->path;
@ -880,7 +917,7 @@ class PublicWebDavContext implements Context {
public function thePublicUploadsFileToInsideLastLinkSharedFolderUsingThePublicWebdavApi(
string $source,
string $destination,
):void {
): void {
$content = \file_get_contents(
$this->featureContext->acceptanceTestsDirLocation() . $source
);
@ -906,7 +943,7 @@ class PublicWebDavContext implements Context {
string $source,
string $destination,
string $password
):void {
): void {
$content = \file_get_contents(
$this->featureContext->acceptanceTestsDirLocation() . $source
);
@ -932,7 +969,7 @@ class PublicWebDavContext implements Context {
string $fileName,
string $password,
string $mtime
):void {
): void {
$mtime = new DateTime($mtime);
$mtime = $mtime->format('U');
@ -955,8 +992,10 @@ class PublicWebDavContext implements Context {
public function publicCreatesFolderUsingPassword(
string $destination,
string $password
):ResponseInterface {
$token = ($this->featureContext->isUsingSharingNG()) ? $this->featureContext->shareNgGetLastCreatedLinkShareToken() : $this->featureContext->getLastCreatedPublicShareToken();
): ResponseInterface {
$token = ($this->featureContext->isUsingSharingNG())
? $this->featureContext->shareNgGetLastCreatedLinkShareToken()
: $this->featureContext->getLastCreatedPublicShareToken();
$davPath = WebDavHelper::getDavPath(
$this->featureContext->getDavPathVersion(),
$token,
@ -990,7 +1029,7 @@ class PublicWebDavContext implements Context {
*
* @return void
*/
public function publicCreatesFolder(string $destination):void {
public function publicCreatesFolder(string $destination): void {
$this->featureContext->setResponse($this->publicCreatesFolderUsingPassword($destination, ''));
}
@ -1005,7 +1044,7 @@ class PublicWebDavContext implements Context {
public function publicShouldBeAbleToCreateFolderWithPassword(
string $foldername,
string $password
):void {
): void {
$response = $this->publicCreatesFolderUsingPassword($foldername, $password);
$this->featureContext->theHTTPStatusCodeShouldBe(201, "", $response);
}
@ -1023,7 +1062,7 @@ class PublicWebDavContext implements Context {
string $foldername,
string $password,
string $expectedHttpCode
):void {
): void {
$response = $this->publicCreatesFolderUsingPassword($foldername, $password);
$this->featureContext->theHTTPStatusCodeShouldBe(
$expectedHttpCode,
@ -1045,8 +1084,10 @@ class PublicWebDavContext implements Context {
public function theMtimeOfFileInTheLastSharedPublicLinkUsingTheWebdavApiShouldBe(
string $fileName,
string $mtime
):void {
$token = ($this->featureContext->isUsingSharingNG()) ? $this->featureContext->shareNgGetLastCreatedLinkShareToken() : $this->featureContext->getLastCreatedPublicShareToken();
): void {
$token = ($this->featureContext->isUsingSharingNG())
? $this->featureContext->shareNgGetLastCreatedLinkShareToken()
: $this->featureContext->getLastCreatedPublicShareToken();
$baseUrl = $this->featureContext->getBaseUrl();
$mtime = \explode(" ", $mtime);
\array_pop($mtime);
@ -1074,7 +1115,7 @@ class PublicWebDavContext implements Context {
public function theMtimeOfFileInTheLastSharedPublicLinkUsingTheWebdavApiShouldNotBe(
string $fileName,
string $mtime
):void {
): void {
$token = $this->featureContext->getLastCreatedPublicShareToken();
$baseUrl = $this->featureContext->getBaseUrl();
Assert::assertNotEquals(
@ -1105,7 +1146,7 @@ class PublicWebDavContext implements Context {
string $body = 'test',
bool $autoRename = false,
array $additionalHeaders = [],
):?ResponseInterface {
): ?ResponseInterface {
$password = $this->featureContext->getActualPassword($password);
if ($this->featureContext->isUsingSharingNG()) {
$token = $this->featureContext->shareNgGetLastCreatedLinkShareToken();
@ -1157,7 +1198,7 @@ class PublicWebDavContext implements Context {
private function getUsernameForPublicWebdavApi(
string $token,
string $password
):?string {
): ?string {
if ($password !== '') {
$userName = 'public';
} else {
@ -1173,7 +1214,7 @@ class PublicWebDavContext implements Context {
*
* @return void
*/
public function before(BeforeScenarioScope $scope):void {
public function before(BeforeScenarioScope $scope): void {
// Get the environment
$environment = $scope->getEnvironment();
// Get all the contexts you need in this context
@ -1189,7 +1230,7 @@ class PublicWebDavContext implements Context {
* @return void
* @throws GuzzleException
*/
public function publicSendsRequestToLastPublicShare(string $method, ?string $password = ''):void {
public function publicSendsRequestToLastPublicShare(string $method, ?string $password = ''): void {
if ($method === "PROPFIND") {
$body = '<?xml version="1.0"?>
<d:propfind xmlns:d="DAV:" xmlns:oc="http://owncloud.org/ns">
@ -1205,7 +1246,9 @@ class PublicWebDavContext implements Context {
} else {
$body = null;
}
$token = ($this->featureContext->isUsingSharingNG()) ? $this->featureContext->shareNgGetLastCreatedLinkShareToken() : $this->featureContext->getLastCreatedPublicShareToken();
$token = ($this->featureContext->isUsingSharingNG())
? $this->featureContext->shareNgGetLastCreatedLinkShareToken()
: $this->featureContext->getLastCreatedPublicShareToken();
$davPath = WebDavHelper::getDavPath(
WebDavHelper::DAV_VERSION_NEW,
$token,

View File

@ -84,7 +84,11 @@ class SearchContext implements Context {
$spaceId = $this->featureContext->spacesContext->getSpaceIdByName($user, $scope);
$pattern .= " scope:$spaceId";
} else {
$resourceID = $this->featureContext->spacesContext->getResourceId($user, $spaceName ?? "Personal", $scope);
$resourceID = $this->featureContext->spacesContext->getResourceId(
$user,
$spaceName ?? "Personal",
$scope
);
$pattern .= " scope:$resourceID";
}
}

View File

@ -263,7 +263,11 @@ class SettingsContext implements Context {
$assignmentResponse = $this->featureContext->getJsonDecodedResponseBodyContent($response);
if (isset($assignmentResponse->assignments[0]->roleId)) {
$actualRoleId = $assignmentResponse->assignments[0]->roleId;
Assert::assertEquals($this->getRoleIdByRoleName($this->featureContext->getAdminUserName(), $role), $actualRoleId, "user $user has no role $role");
Assert::assertEquals(
$this->getRoleIdByRoleName($this->featureContext->getAdminUserName(), $role),
$actualRoleId,
"user $user has no role $role"
);
} else {
Assert::fail("Response should contain user role but not found.\n" . json_encode($assignmentResponse));
}
@ -279,8 +283,14 @@ class SettingsContext implements Context {
* @throws Exception
*/
public function theSettingApiResponseShouldHaveTheRole(string $role): void {
$assignmentRoleId = $this->featureContext->getJsonDecodedResponse($this->featureContext->getResponse())["assignments"][0]["roleId"];
Assert::assertEquals($this->getRoleIdByRoleName($this->featureContext->getAdminUserName(), $role), $assignmentRoleId, "user has no role $role");
$assignmentRoleId = $this->featureContext->getJsonDecodedResponse(
$this->featureContext->getResponse()
)["assignments"][0]["roleId"];
Assert::assertEquals(
$this->getRoleIdByRoleName($this->featureContext->getAdminUserName(), $role),
$assignmentRoleId,
"user has no role $role"
);
}
/**

View File

@ -46,7 +46,7 @@ class ShareesContext implements Context {
*
* @return void
*/
public function theUserGetsTheShareesWithParameters(TableNode $body):void {
public function theUserGetsTheShareesWithParameters(TableNode $body): void {
$this->featureContext->setResponse(
$this->getShareesWithParameters(
$this->featureContext->getCurrentUser(),
@ -63,7 +63,7 @@ class ShareesContext implements Context {
*
* @return void
*/
public function userGetsTheShareesWithParameters(string $user, TableNode $body):void {
public function userGetsTheShareesWithParameters(string $user, TableNode $body): void {
$this->featureContext->setResponse(
$this->getShareesWithParameters(
$user,
@ -81,7 +81,7 @@ class ShareesContext implements Context {
* @return void
* @throws Exception
*/
public function theShareesReturnedShouldBe(string $shareeType, TableNode $shareesList):void {
public function theShareesReturnedShouldBe(string $shareeType, TableNode $shareesList): void {
$this->featureContext->verifyTableNodeColumnsCount($shareesList, 4);
$sharees = $shareesList->getRows();
$respondedArray = $this->getArrayOfShareesResponded(
@ -104,7 +104,7 @@ class ShareesContext implements Context {
* @return void
* @throws Exception
*/
public function theShareesReturnedShouldInclude(string $shareeType, TableNode $shareesList):void {
public function theShareesReturnedShouldInclude(string $shareeType, TableNode $shareesList): void {
$this->featureContext->verifyTableNodeColumnsCount($shareesList, 3);
$sharees = $shareesList->getRows();
$respondedArray = $this->getArrayOfShareesResponded(
@ -127,7 +127,7 @@ class ShareesContext implements Context {
*
* @return void
*/
public function theShareesReturnedShouldBeEmpty(string $shareeType):void {
public function theShareesReturnedShouldBeEmpty(string $shareeType): void {
$respondedArray = $this->getArrayOfShareesResponded(
$this->featureContext->getResponse(),
$shareeType
@ -155,7 +155,7 @@ class ShareesContext implements Context {
public function getArrayOfShareesResponded(
ResponseInterface $response,
string $shareeType
):array {
): array {
$elements = HttpRequestHelper::getResponseXml($response, __METHOD__)->data;
$elements = \json_decode(\json_encode($elements), true);
if (\strpos($shareeType, 'exact ') === 0) {
@ -229,7 +229,7 @@ class ShareesContext implements Context {
*
* @return void
*/
public function before(BeforeScenarioScope $scope):void {
public function before(BeforeScenarioScope $scope): void {
// Get the environment
$environment = $scope->getEnvironment();
// Get all the contexts you need in this context

File diff suppressed because it is too large Load Diff

View File

@ -87,7 +87,8 @@ class SharingNgContext implements Context {
$bodyRows['quickLink'] = $bodyRows['quickLink'] ?? false;
$bodyRows['displayName'] = $bodyRows['displayName'] ?? null;
$bodyRows['expirationDateTime'] = \array_key_exists('expirationDateTime', $bodyRows) ? \date('Y-m-d', \strtotime($bodyRows['expirationDateTime'])) . 'T14:00:00.000Z' : null;
$bodyRows['expirationDateTime'] = \array_key_exists('expirationDateTime', $bodyRows)
? \date('Y-m-d', \strtotime($bodyRows['expirationDateTime'])) . 'T14:00:00.000Z' : null;
$bodyRows['password'] = $bodyRows['password'] ?? null;
$body = [
'type' => $bodyRows['permissionsRole'],
@ -154,7 +155,12 @@ class SharingNgContext implements Context {
* @return ResponseInterface
* @throws GuzzleException
*/
public function getPermissionsList(string $user, string $fileOrFolder, string $space, ?string $resource = ''):ResponseInterface {
public function getPermissionsList(
string $user,
string $fileOrFolder,
string $space,
?string $resource = ''
): ResponseInterface {
$spaceId = ($this->spacesContext->getSpaceByName($user, $space))["id"];
if ($fileOrFolder === 'folder') {
@ -184,7 +190,12 @@ class SharingNgContext implements Context {
* @return void
* @throws Exception
*/
public function userGetsPermissionsListForResourceOfTheSpaceUsingTheGraphAPI(string $user, string $fileOrFolder, string $resource, string $space):void {
public function userGetsPermissionsListForResourceOfTheSpaceUsingTheGraphAPI(
string $user,
string $fileOrFolder,
string $resource,
string $space
): void {
$this->featureContext->setResponse(
$this->getPermissionsList($user, $fileOrFolder, $space, $resource)
);
@ -199,7 +210,7 @@ class SharingNgContext implements Context {
* @return void
* @throws Exception
*/
public function userListsThePermissionsOfSpaceUsingTheGraphApi(string $user, string $space):void {
public function userListsThePermissionsOfSpaceUsingTheGraphApi(string $user, string $space): void {
$this->featureContext->setResponse(
$this->getPermissionsList($user, 'folder', $space)
);
@ -215,7 +226,11 @@ class SharingNgContext implements Context {
* @return void
* @throws Exception
*/
public function userTriesToListThePermissionsOfSpaceUsingPermissionsEndpointOfTheGraphApi(string $user, string $space, string $spaceOwner):void {
public function userTriesToListThePermissionsOfSpaceUsingPermissionsEndpointOfTheGraphApi(
string $user,
string $space,
string $spaceOwner
): void {
$spaceId = ($this->spacesContext->getSpaceByName($spaceOwner, $space))["id"];
$itemId = $this->spacesContext->getResourceId($spaceOwner, $space, '');
@ -287,7 +302,12 @@ class SharingNgContext implements Context {
if ($shareType === "user") {
$shareeId = $this->featureContext->getAttributeOfCreatedUser($sharee, 'id');
if ($federatedShare) {
$shareeId = ($this->featureContext->ocmContext->getAcceptedUserByName($user, $sharee))['user_id'];
$shareeId = (
$this->featureContext->ocmContext->getAcceptedUserByName(
$user,
$sharee
)
)['user_id'];
}
} elseif ($shareType === "group") {
$shareeId = $this->featureContext->getAttributeOfCreatedGroup($sharee, 'id');
@ -333,7 +353,11 @@ class SharingNgContext implements Context {
* @throws GuzzleException
* @throws Exception
*/
public function sendDriveShareInvitation(string $user, TableNode $table, bool $federatedShare = false): ResponseInterface {
public function sendDriveShareInvitation(
string $user,
TableNode $table,
bool $federatedShare = false
): ResponseInterface {
$shareeIds = [];
$rows = $table->getRowsHash();
if ($rows['space'] === 'Personal' || $rows['space'] === 'Shares') {
@ -396,7 +420,11 @@ class SharingNgContext implements Context {
*/
public function userHasSentTheFollowingResourceShareInvitation(string $user, TableNode $table): void {
$rows = $table->getRowsHash();
Assert::assertArrayHasKey("resource", $rows, "'resource' should be provided in the data-table while sharing a resource");
Assert::assertArrayHasKey(
"resource",
$rows,
"'resource' should be provided in the data-table while sharing a resource"
);
$response = $this->sendShareInvitation($user, $rows);
$this->featureContext->theHTTPStatusCodeShouldBe(200, "", $response);
}
@ -411,9 +439,16 @@ class SharingNgContext implements Context {
* @throws Exception
* @throws GuzzleException
*/
public function userHasSentTheFollowingResourceShareInvitationToFederatedUser(string $user, TableNode $table): void {
public function userHasSentTheFollowingResourceShareInvitationToFederatedUser(
string $user,
TableNode $table
): void {
$rows = $table->getRowsHash();
Assert::assertArrayHasKey("resource", $rows, "'resource' should be provided in the data-table while sharing a resource");
Assert::assertArrayHasKey(
"resource",
$rows,
"'resource' should be provided in the data-table while sharing a resource"
);
$response = $this->sendShareInvitation($user, $rows, null, true);
$this->featureContext->theHTTPStatusCodeShouldBe(200, "", $response);
}
@ -430,7 +465,11 @@ class SharingNgContext implements Context {
*/
public function userHasSentTheFollowingShareShareInvitation(string $user, TableNode $table): void {
$rows = $table->getRowsHash();
Assert::assertArrayNotHasKey("resource", $rows, "'resource' should not be provided in the data-table while sharing a space");
Assert::assertArrayNotHasKey(
"resource",
$rows,
"'resource' should not be provided in the data-table while sharing a space"
);
$response = $this->sendDriveShareInvitation($user, $table);
$this->featureContext->theHTTPStatusCodeShouldBe(200, "", $response);
}
@ -448,7 +487,11 @@ class SharingNgContext implements Context {
*/
public function userSendsTheFollowingResourceShareInvitationUsingTheGraphApi(string $user, TableNode $table): void {
$rows = $table->getRowsHash();
Assert::assertArrayHasKey("resource", $rows, "'resource' should be provided in the data-table while sharing a resource");
Assert::assertArrayHasKey(
"resource",
$rows,
"'resource' should be provided in the data-table while sharing a resource"
);
$this->featureContext->setResponse(
$this->sendShareInvitation($user, $rows)
);
@ -464,9 +507,16 @@ class SharingNgContext implements Context {
* @throws Exception
* @throws GuzzleException
*/
public function userSendsTheFollowingResourceShareInvitationToFederatedUserUsingTheGraphApi(string $user, TableNode $table): void {
public function userSendsTheFollowingResourceShareInvitationToFederatedUserUsingTheGraphApi(
string $user,
TableNode $table
): void {
$rows = $table->getRowsHash();
Assert::assertArrayHasKey("resource", $rows, "'resource' should be provided in the data-table while sharing a resource");
Assert::assertArrayHasKey(
"resource",
$rows,
"'resource' should be provided in the data-table while sharing a resource"
);
$this->featureContext->setResponse(
$this->sendShareInvitation($user, $rows, null, true)
);
@ -482,9 +532,16 @@ class SharingNgContext implements Context {
* @throws Exception
* @throws GuzzleException
*/
public function userSendsTheFollowingSpaceShareInvitationUsingPermissionsEndpointOfTheGraphApi(string $user, TableNode $table): void {
public function userSendsTheFollowingSpaceShareInvitationUsingPermissionsEndpointOfTheGraphApi(
string $user,
TableNode $table
): void {
$rows = $table->getRowsHash();
Assert::assertArrayNotHasKey("resource", $rows, "'resource' should not be provided in the data-table while sharing a space");
Assert::assertArrayNotHasKey(
"resource",
$rows,
"'resource' should not be provided in the data-table while sharing a space"
);
$this->featureContext->setResponse(
$this->sendShareInvitation($user, $rows)
);
@ -500,9 +557,16 @@ class SharingNgContext implements Context {
* @throws Exception
* @throws GuzzleException
*/
public function userSendsTheFollowingSpaceShareInvitationToFederatedUserUsingPermissionsEndpointOfTheGraphApi(string $user, TableNode $table): void {
public function userSendsTheFollowingSpaceShareInvitationToFederatedUserUsingPermissionsEndpointOfTheGraphApi(
string $user,
TableNode $table
): void {
$rows = $table->getRowsHash();
Assert::assertArrayNotHasKey("resource", $rows, "'resource' should not be provided in the data-table while sharing a space");
Assert::assertArrayNotHasKey(
"resource",
$rows,
"'resource' should not be provided in the data-table while sharing a space"
);
$this->featureContext->setResponse(
$this->sendShareInvitation($user, $rows, null, true)
);
@ -555,7 +619,12 @@ class SharingNgContext implements Context {
*
* @return void
*/
public function userUpdatesTheSpaceShareForUserOrGroupWithFollowingUsingGraphApi(string $user, string $shareType, string $sharee, TableNode $table) {
public function userUpdatesTheSpaceShareForUserOrGroupWithFollowingUsingGraphApi(
string $user,
string $shareType,
string $sharee,
TableNode $table
) {
$permissionID = "";
if ($shareType === "user") {
$permissionID = "u:" . $this->featureContext->getAttributeOfCreatedUser($sharee, 'id');
@ -600,7 +669,8 @@ class SharingNgContext implements Context {
}
if (\array_key_exists('expirationDateTime', $bodyRows)) {
$body['expirationDateTime'] = empty($bodyRows['expirationDateTime']) ? null : $bodyRows['expirationDateTime'];
$body['expirationDateTime'] = empty($bodyRows['expirationDateTime'])
? null : $bodyRows['expirationDateTime'];
}
return GraphHelper::updateShare(
@ -626,7 +696,11 @@ class SharingNgContext implements Context {
* @throws JsonException
* @throws GuzzleException
*/
public function userSendsTheFollowingShareInvitationWithFileIdUsingTheGraphApi(string $user, string $fileId, TableNode $table): void {
public function userSendsTheFollowingShareInvitationWithFileIdUsingTheGraphApi(
string $user,
string $fileId,
TableNode $table
): void {
$rows = $table->getRowsHash();
$this->featureContext->setResponse(
$this->sendShareInvitation($user, $rows, $fileId)
@ -642,7 +716,7 @@ class SharingNgContext implements Context {
* @return void
* @throws GuzzleException
*/
public function userCreatesAPublicLinkShareWithSettings(string $user, TableNode $body):void {
public function userCreatesAPublicLinkShareWithSettings(string $user, TableNode $body): void {
$response = $this->createLinkShare($user, $body);
$this->featureContext->setResponse($response);
}
@ -656,7 +730,10 @@ class SharingNgContext implements Context {
* @return void
* @throws GuzzleException
*/
public function userCreatesTheFollowingSpaceLinkShareUsingPermissionsEndpointOfTheGraphApi(string $user, TableNode $body):void {
public function userCreatesTheFollowingSpaceLinkShareUsingPermissionsEndpointOfTheGraphApi(
string $user,
TableNode $body
): void {
$this->featureContext->setResponse($this->createLinkShare($user, $body));
}
@ -671,7 +748,11 @@ class SharingNgContext implements Context {
*/
public function userHasCreatedTheFollowingResourceLinkShare(string $user, TableNode $body): void {
$rows = $body->getRowsHash();
Assert::assertArrayHasKey("resource", $rows, "'resource' should be provided in the data-table while sharing a resource");
Assert::assertArrayHasKey(
"resource",
$rows,
"'resource' should be provided in the data-table while sharing a resource"
);
$response = $this->createLinkShare($user, $body);
$this->featureContext->theHTTPStatusCodeShouldBe(200, "Failed while creating public share link!", $response);
$this->featureContext->shareNgAddToCreatedLinkShares($response);
@ -688,7 +769,11 @@ class SharingNgContext implements Context {
*/
public function userHasCreatedTheFollowingLinkShare(string $user, TableNode $body): void {
$rows = $body->getRowsHash();
Assert::assertArrayNotHasKey("resource", $rows, "'resource' should not be provided in the data-table while sharing a space");
Assert::assertArrayNotHasKey(
"resource",
$rows,
"'resource' should not be provided in the data-table while sharing a space"
);
$response = $this->createDriveLinkShare($user, $body);
$this->featureContext->theHTTPStatusCodeShouldBe(200, "Failed while creating public share link!", $response);
$this->featureContext->shareNgAddToCreatedLinkShares($response);
@ -703,7 +788,7 @@ class SharingNgContext implements Context {
* @return void
* @throws Exception|GuzzleException
*/
public function userHasUpdatedLastPublicLinkShare(string $user, TableNode $body):void {
public function userHasUpdatedLastPublicLinkShare(string $user, TableNode $body): void {
$response = $this->updateLinkShare(
$user,
$body,
@ -721,7 +806,10 @@ class SharingNgContext implements Context {
* @return void
* @throws Exception
*/
public function userUpdatesTheLastPublicLinkShareUsingThePermissionsEndpointOfTheGraphApi(string $user, TableNode $body):void {
public function userUpdatesTheLastPublicLinkShareUsingThePermissionsEndpointOfTheGraphApi(
string $user,
TableNode $body
): void {
$this->featureContext->setResponse(
$this->updateLinkShare(
$user,
@ -755,7 +843,8 @@ class SharingNgContext implements Context {
}
if (\array_key_exists('expirationDateTime', $bodyRows)) {
$body['expirationDateTime'] = empty($bodyRows['expirationDateTime']) ? null : $bodyRows['expirationDateTime'];
$body['expirationDateTime'] = empty($bodyRows['expirationDateTime'])
? null : $bodyRows['expirationDateTime'];
}
if (\array_key_exists('displayName', $bodyRows)) {
@ -818,13 +907,17 @@ class SharingNgContext implements Context {
* @return void
* @throws Exception
*/
public function userHasSetTheFollowingPasswordForTheLastLinkShare(string $user, TableNode $body):void {
public function userHasSetTheFollowingPasswordForTheLastLinkShare(string $user, TableNode $body): void {
$response = $this->setLinkSharePassword(
$user,
$body,
$this->featureContext->shareNgGetLastCreatedLinkShareID()
);
$this->featureContext->theHTTPStatusCodeShouldBe(200, "Failed while setting public share link password!", $response);
$this->featureContext->theHTTPStatusCodeShouldBe(
200,
"Failed while setting public share link password!",
$response
);
}
/**
@ -836,7 +929,10 @@ class SharingNgContext implements Context {
* @return void
* @throws Exception
*/
public function userSetsOrUpdatesFollowingPasswordForLastLinkShareUsingTheGraphApi(string $user, TableNode $body):void {
public function userSetsOrUpdatesFollowingPasswordForLastLinkShareUsingTheGraphApi(
string $user,
TableNode $body
): void {
$this->featureContext->setResponse(
$this->setLinkSharePassword(
$user,
@ -867,7 +963,8 @@ class SharingNgContext implements Context {
?string $recipient = null
): ResponseInterface {
$spaceId = ($this->spacesContext->getSpaceByName($sharer, $space))["id"];
$itemId = (isset($resource)) ? $this->spacesContext->getResourceId($sharer, $space, $resource) : $this->spacesContext->getResourceId($sharer, $space, $space);
$itemId = (isset($resource)) ? $this->spacesContext->getResourceId($sharer, $space, $resource)
: $this->spacesContext->getResourceId($sharer, $space, $space);
$permissionID = "";
@ -1043,7 +1140,7 @@ class SharingNgContext implements Context {
string $sharer,
string $resource,
string $space
):void {
): void {
$this->featureContext->setResponse(
$this->removeAccessToSpaceItem($sharer, 'link', $space, $resource)
);
@ -1086,7 +1183,7 @@ class SharingNgContext implements Context {
public function userRemovesLinkFromSpaceUsingRootEndpointOfGraphAPI(
string $sharer,
string $space
):void {
): void {
$this->featureContext->setResponse(
$this->removeAccessToSpace($sharer, 'link', $space)
);
@ -1146,7 +1243,7 @@ class SharingNgContext implements Context {
* @return void
* @throws Exception|GuzzleException
*/
public function userHasDisabledSyncOfLastSharedResource(string $user):void {
public function userHasDisabledSyncOfLastSharedResource(string $user): void {
$shareItemId = $this->featureContext->shareNgGetLastCreatedUserGroupShareID();
$shareSpaceId = GraphHelper::SHARES_SPACE_ID;
$itemId = $shareSpaceId . '!' . $shareItemId;
@ -1158,7 +1255,11 @@ class SharingNgContext implements Context {
$itemId,
$shareSpaceId,
);
$this->featureContext->theHTTPStatusCodeShouldBe(204, __METHOD__ . " could not disable sync of last share", $response);
$this->featureContext->theHTTPStatusCodeShouldBe(
204,
__METHOD__ . " could not disable sync of last share",
$response
);
}
/**
@ -1170,7 +1271,7 @@ class SharingNgContext implements Context {
* @return void
* @throws Exception
*/
public function userDisablesSyncOfShareUsingTheGraphApi(string $user):void {
public function userDisablesSyncOfShareUsingTheGraphApi(string $user): void {
$shareItemId = $this->featureContext->shareNgGetLastCreatedUserGroupShareID();
$shareSpaceId = GraphHelper::SHARES_SPACE_ID;
$itemId = $shareSpaceId . '!' . $shareItemId;
@ -1197,7 +1298,7 @@ class SharingNgContext implements Context {
* @throws Exception
* @throws GuzzleException
*/
public function userHidesTheSharedResourceUsingTheGraphApi(string $user):void {
public function userHidesTheSharedResourceUsingTheGraphApi(string $user): void {
$shareItemId = $this->featureContext->shareNgGetLastCreatedUserGroupShareID();
$response = $this->hideOrUnhideSharedResource($user, $shareItemId);
$this->featureContext->setResponse($response);
@ -1212,7 +1313,7 @@ class SharingNgContext implements Context {
* @throws Exception
* @throws GuzzleException
*/
public function userHasHiddenTheShare(string $user):void {
public function userHasHiddenTheShare(string $user): void {
$shareItemId = $this->featureContext->shareNgGetLastCreatedUserGroupShareID();
$response = $this->hideOrUnhideSharedResource($user, $shareItemId);
$this->featureContext->theHTTPStatusCodeShouldBe(200, '', $response);
@ -1227,7 +1328,7 @@ class SharingNgContext implements Context {
* @throws Exception
* @throws GuzzleException
*/
public function userUnhidesTheSharedResourceUsingTheGraphApi(string $user):void {
public function userUnhidesTheSharedResourceUsingTheGraphApi(string $user): void {
$shareItemId = $this->featureContext->shareNgGetLastCreatedUserGroupShareID();
$response = $this->hideOrUnhideSharedResource($user, $shareItemId, false);
$this->featureContext->setResponse($response);
@ -1244,7 +1345,12 @@ class SharingNgContext implements Context {
* @return void
* @throws Exception
*/
public function userEnablesSyncOfShareUsingTheGraphApi(string $user, string $share, string $offeredBy, string $space):void {
public function userEnablesSyncOfShareUsingTheGraphApi(
string $user,
string $share,
string $offeredBy,
string $space
): void {
$share = ltrim($share, '/');
$itemId = $this->spacesContext->getResourceId($offeredBy, $space, $share);
$shareSpaceId = GraphHelper::SHARES_SPACE_ID;
@ -1271,7 +1377,7 @@ class SharingNgContext implements Context {
* @return void
* @throws Exception|GuzzleException
*/
public function userTriesToEnableShareSyncOfResourceUsingTheGraphApi(string $user, string $resource):void {
public function userTriesToEnableShareSyncOfResourceUsingTheGraphApi(string $user, string $resource): void {
$shareSpaceId = GraphHelper::SHARES_SPACE_ID;
$itemId = ($resource === 'nonexistent') ? WebDavHelper::generateUUIDv4() : $resource;
@ -1295,7 +1401,7 @@ class SharingNgContext implements Context {
* @return void
* @throws Exception|GuzzleException
*/
public function userTriesToDisableShareSyncOfResourceUsingTheGraphApi(string $user, string $resource):void {
public function userTriesToDisableShareSyncOfResourceUsingTheGraphApi(string $user, string $resource): void {
$shareSpaceId = GraphHelper::SHARES_SPACE_ID;
$shareID = ($resource === 'nonexistent') ? WebDavHelper::generateUUIDv4() : $resource;
$itemId = $shareSpaceId . '!' . $shareID;
@ -1392,7 +1498,7 @@ class SharingNgContext implements Context {
* @return void
* @throws GuzzleException
*/
public function userShouldHaveSyncEnabledOrDisabledForShare(string $user, string $status, string $resource):void {
public function userShouldHaveSyncEnabledOrDisabledForShare(string $user, string $status, string $resource): void {
$this->waitAndCheckShareSyncStatus($user, $resource, $status);
}
@ -1406,11 +1512,15 @@ class SharingNgContext implements Context {
* @throws Exception
* @throws GuzzleException
*/
public function userShouldBeAbleToSendShareTheFollowingInvitationWithAllAllowedPermissionRoles(string $user, TableNode $table): void {
public function userShouldBeAbleToSendShareTheFollowingInvitationWithAllAllowedPermissionRoles(
string $user,
TableNode $table
): void {
$listPermissionResponse = $this->featureContext->getJsonDecodedResponseBodyContent();
if (!isset($listPermissionResponse->{'@libre.graph.permissions.roles.allowedValues'})) {
Assert::fail(
"The following response does not contain '@libre.graph.permissions.roles.allowedValues' property:\n" . $listPermissionResponse
"The following response does not contain '@libre.graph.permissions.roles.allowedValues' property:\n"
. $listPermissionResponse
);
}
Assert::assertNotEmpty(
@ -1431,8 +1541,13 @@ class SharingNgContext implements Context {
foreach ($allowedPermissionRoles as $role) {
//we should be able to send share invitation for each of the role allowed for the files/folders which are listed in permissions (allowed)
$roleAllowed = GraphHelper::getPermissionNameByPermissionRoleId($role->id);
$responseSendInvitation = $this->sendShareInvitation($user, array_merge($rows, ['permissionsRole' => $roleAllowed]));
$jsonResponseSendInvitation = $this->featureContext->getJsonDecodedResponseBodyContent($responseSendInvitation);
$responseSendInvitation = $this->sendShareInvitation(
$user,
array_merge($rows, ['permissionsRole' => $roleAllowed])
);
$jsonResponseSendInvitation = $this->featureContext->getJsonDecodedResponseBodyContent(
$responseSendInvitation
);
$httpsStatusCode = $responseSendInvitation->getStatusCode();
if ($httpsStatusCode === 200 && !empty($jsonResponseSendInvitation->value)) {
// remove the share so that the same user can be share for the next allowed roles
@ -1440,7 +1555,8 @@ class SharingNgContext implements Context {
Assert::assertEquals(204, $removePermissionsResponse->getStatusCode());
} else {
$areAllSendInvitationSuccessFullForAllowedRoles = false;
$shareInvitationRequestResult .= "\tShare invitation for " . $resourceDetail . "' with role '" . $roleAllowed . "' failed and was not allowed.\n";
$shareInvitationRequestResult .= "\tShare invitation for " . $resourceDetail
. "' with role '" . $roleAllowed . "' failed and was not allowed.\n";
}
}
Assert::assertTrue($areAllSendInvitationSuccessFullForAllowedRoles, $shareInvitationRequestResult);
@ -1457,7 +1573,7 @@ class SharingNgContext implements Context {
* @throws GuzzleException
*
*/
public function userListsThePermissionsOfDriveUsingRootEndPointOFTheGraphApi(string $user, string $space):void {
public function userListsThePermissionsOfDriveUsingRootEndPointOFTheGraphApi(string $user, string $space): void {
$spaceId = ($this->spacesContext->getSpaceByName($user, $space))["id"];
$response = GraphHelper::getDrivePermissionsList(
@ -1479,7 +1595,10 @@ class SharingNgContext implements Context {
* @return void
* @throws GuzzleException
*/
public function userSendsTheFollowingShareInvitationUsingRootEndPointTheGraphApi(string $user, TableNode $table):void {
public function userSendsTheFollowingShareInvitationUsingRootEndPointTheGraphApi(
string $user,
TableNode $table
): void {
$response = $this->sendDriveShareInvitation($user, $table);
$this->featureContext->setResponse($response);
}
@ -1493,7 +1612,10 @@ class SharingNgContext implements Context {
* @return void
* @throws GuzzleException
*/
public function userSendsTheFollowingShareInvitationToFederatedUserUsingRootEndPointTheGraphApi(string $user, TableNode $table):void {
public function userSendsTheFollowingShareInvitationToFederatedUserUsingRootEndPointTheGraphApi(
string $user,
TableNode $table
): void {
$response = $this->sendDriveShareInvitation($user, $table, true);
$this->featureContext->setResponse($response);
}
@ -1507,7 +1629,10 @@ class SharingNgContext implements Context {
* @return void
* @throws GuzzleException
*/
public function userUpdatesTheLastDriveShareWithTheFollowingUsingRootEndpointOfTheGraphApi(string $user, TableNode $table): void {
public function userUpdatesTheLastDriveShareWithTheFollowingUsingRootEndpointOfTheGraphApi(
string $user,
TableNode $table
): void {
$bodyRows = $table->getRowsHash();
$permissionID = match ($bodyRows['shareType']) {
'user' => 'u:' . $this->featureContext->getAttributeOfCreatedUser($bodyRows['sharee'], 'id'),
@ -1523,7 +1648,8 @@ class SharingNgContext implements Context {
}
if (\array_key_exists('expirationDateTime', $bodyRows)) {
$body['expirationDateTime'] = empty($bodyRows['expirationDateTime']) ? null : $bodyRows['expirationDateTime'];
$body['expirationDateTime'] = empty($bodyRows['expirationDateTime'])
? null : $bodyRows['expirationDateTime'];
}
$this->featureContext->setResponse(
@ -1548,9 +1674,16 @@ class SharingNgContext implements Context {
* @return void
* @throws GuzzleException
*/
public function userCreatesTheFollowingSpaceLinkShareUsingRootEndpointOfTheGraphApi(string $user, TableNode $body): void {
public function userCreatesTheFollowingSpaceLinkShareUsingRootEndpointOfTheGraphApi(
string $user,
TableNode $body
): void {
$rows = $body->getRowsHash();
Assert::assertArrayNotHasKey("resource", $rows, "'resource' should not be provided in the data-table while sharing a space");
Assert::assertArrayNotHasKey(
"resource",
$rows,
"'resource' should not be provided in the data-table while sharing a space"
);
$response = $this->createDriveLinkShare($user, $body);
$this->featureContext->setResponse($response);
@ -1565,9 +1698,16 @@ class SharingNgContext implements Context {
* @return void
* @throws GuzzleException
*/
public function userSetsTheFollowingPasswordForTheLastSpaceLinkShareUsingRootEndpointOfTheGraphAPI(string $user, TableNode $body): void {
public function userSetsTheFollowingPasswordForTheLastSpaceLinkShareUsingRootEndpointOfTheGraphAPI(
string $user,
TableNode $body
): void {
$rows = $body->getRowsHash();
Assert::assertArrayNotHasKey("resource", $rows, "'resource' should not be provided in the data-table while setting password in space shared link");
Assert::assertArrayNotHasKey(
"resource",
$rows,
"'resource' should not be provided in the data-table while setting password in space shared link"
);
Assert::assertArrayHasKey("password", $rows, "'password' is missing in the data-table");
$body = [
@ -1599,7 +1739,11 @@ class SharingNgContext implements Context {
* @return void
* @throws GuzzleException
*/
public function userTriesToRemoveShareLinkOfSpaceOwnedByUsingRootEndpointOfTheGraphApi(string $user, string $space, string $spaceOwner): void {
public function userTriesToRemoveShareLinkOfSpaceOwnedByUsingRootEndpointOfTheGraphApi(
string $user,
string $space,
string $spaceOwner
): void {
$permissionID = $this->featureContext->shareNgGetLastCreatedLinkShareID();
$spaceId = ($this->spacesContext->getSpaceByName($spaceOwner, $space))["id"];
@ -1638,10 +1782,18 @@ class SharingNgContext implements Context {
foreach ($responseBody['value'] as $value) {
switch ($shareType) {
case $shareType === 'link':
Assert::assertArrayNotHasKey('link', $value, $space . ' space should not have any link permissions but found ' . print_r($value, true));
Assert::assertArrayNotHasKey(
'link',
$value,
$space . ' space should not have any link permissions but found ' . print_r($value, true)
);
break;
case $shareType === "share":
Assert::assertArrayNotHasKey('grantedToV2', $value, $space . ' space should not have any share permissions but found ' . print_r($value, true));
Assert::assertArrayNotHasKey(
'grantedToV2',
$value,
$space . ' space should not have any share permissions but found ' . print_r($value, true)
);
break;
default:
Assert::fail('Invalid share type has been specified');
@ -1657,12 +1809,18 @@ class SharingNgContext implements Context {
*
* @return void
* @throws GuzzleException
* @codingStandardsIgnoreStart
*/
public function userShouldBeAbleToSendTheFollowingSpaceShareInvitationWithAllAllowedPermissionRolesUsingRootEndpointOFTheGraphApi(string $user, TableNode $table): void {
public function userShouldBeAbleToSendTheFollowingSpaceShareInvitationWithAllAllowedPermissionRolesUsingRootEndpointOFTheGraphApi(
// @codingStandardsIgnoreEnd
string $user,
TableNode $table
): void {
$listPermissionResponse = $this->featureContext->getJsonDecodedResponseBodyContent();
if (!isset($listPermissionResponse->{'@libre.graph.permissions.roles.allowedValues'})) {
Assert::fail(
"The following response does not contain '@libre.graph.permissions.roles.allowedValues' property:\n" . $listPermissionResponse
"The following response does not contain '@libre.graph.permissions.roles.allowedValues' property:\n"
. $listPermissionResponse
);
}
Assert::assertNotEmpty(
@ -1682,8 +1840,13 @@ class SharingNgContext implements Context {
foreach ($allowedPermissionRoles as $role) {
// we should be able to send share invitation for each of the roles allowed which are listed in permissions (allowed)
$roleAllowed = GraphHelper::getPermissionNameByPermissionRoleId($role->id);
$responseSendInvitation = $this->sendDriveShareInvitation($user, new TableNode(array_merge($table->getTable(), [['permissionsRole', $roleAllowed]])));
$jsonResponseSendInvitation = $this->featureContext->getJsonDecodedResponseBodyContent($responseSendInvitation);
$responseSendInvitation = $this->sendDriveShareInvitation(
$user,
new TableNode(array_merge($table->getTable(), [['permissionsRole', $roleAllowed]]))
);
$jsonResponseSendInvitation = $this->featureContext->getJsonDecodedResponseBodyContent(
$responseSendInvitation
);
$httpsStatusCode = $responseSendInvitation->getStatusCode();
if ($httpsStatusCode === 200 && !empty($jsonResponseSendInvitation->value)) {
// remove the share so that the same user can be share for the next allowed roles
@ -1691,7 +1854,8 @@ class SharingNgContext implements Context {
Assert::assertEquals(204, $removePermissionsResponse->getStatusCode());
} else {
$areAllSendInvitationSuccessFullForAllowedRoles = false;
$shareInvitationRequestResult .= "\tShare invitation for " . $space . "' with role '" . $roleAllowed . "' failed and was not allowed.\n";
$shareInvitationRequestResult .= "\tShare invitation for " . $space . "' with role '"
. $roleAllowed . "' failed and was not allowed.\n";
}
}
Assert::assertTrue($areAllSendInvitationSuccessFullForAllowedRoles, $shareInvitationRequestResult);
@ -1707,7 +1871,11 @@ class SharingNgContext implements Context {
* @return void
* @throws GuzzleException
*/
public function userTriesToListThePermissionsOfSpaceOwnedByUsingRootEndpointOfTheGraphApi(string $user, string $space, string $spaceOwner): void {
public function userTriesToListThePermissionsOfSpaceOwnedByUsingRootEndpointOfTheGraphApi(
string $user,
string $space,
string $spaceOwner
): void {
$spaceId = ($this->spacesContext->getSpaceByName($spaceOwner, $space))["id"];
$response = GraphHelper::getDrivePermissionsList(
@ -1728,8 +1896,13 @@ class SharingNgContext implements Context {
*
* @return void
*/
public function userRemovesTheLastLinkShareOfSpaceUsingPermissionsEndpointOfGraphApi(string $user, string $space):void {
$this->featureContext->setResponse($this->removeAccessToSpaceItem($user, 'link', $space, ''));
public function userRemovesTheLastLinkShareOfSpaceUsingPermissionsEndpointOfGraphApi(
string $user,
string $space
): void {
$this->featureContext->setResponse(
$this->removeAccessToSpaceItem($user, 'link', $space, '')
);
}
/**
@ -1745,7 +1918,14 @@ class SharingNgContext implements Context {
* @throws JsonException
* @throws Exception
*/
public function checkIfShareExists(string $share, string $sharee, string $sharer, string $space, bool $shouldExist = true, bool $federatedShare = false): void {
public function checkIfShareExists(
string $share,
string $sharee,
string $sharer,
string $space,
bool $shouldExist = true,
bool $federatedShare = false
): void {
$share = \ltrim($share, "/");
if (\strtolower($space) === "personal") {
$remoteDriveAlias = "personal/" . \strtolower($sharer);
@ -1765,11 +1945,18 @@ class SharingNgContext implements Context {
$driveList = HttpRequestHelper::getJsonDecodedResponseBodyContent($response)->value;
$foundShareMountpoint = false;
foreach ($driveList as $drive) {
if ($drive->driveType === "mountpoint" && $drive->name === $share && $drive->root->remoteItem->driveAlias === $remoteDriveAlias) {
if ($drive->driveType === "mountpoint"
&& $drive->name === $share
&& $drive->root->remoteItem->driveAlias === $remoteDriveAlias
) {
$foundShareMountpoint = true;
}
}
Assert::assertSame($shouldExist, $foundShareMountpoint, "Share mountpoint '$share' was not found in the drives list.");
Assert::assertSame(
$shouldExist,
$foundShareMountpoint,
"Share mountpoint '$share' was not found in the drives list."
);
}
// check share in shared-with-me list
@ -1793,7 +1980,11 @@ class SharingNgContext implements Context {
break;
}
}
Assert::assertSame($shouldExist, $foundShareInSharedWithMe, "Share '$share' was not found in the shared-with-me list");
Assert::assertSame(
$shouldExist,
$foundShareInSharedWithMe,
"Share '$share' was not found in the shared-with-me list"
);
}
/**
@ -1807,7 +1998,13 @@ class SharingNgContext implements Context {
*
* @return void
*/
public function userShouldHaveShareSharedByUserFromSpace(string $sharee, string $shouldOrNot, string $share, string $sharer, string $space): void {
public function userShouldHaveShareSharedByUserFromSpace(
string $sharee,
string $shouldOrNot,
string $share,
string $sharer,
string $space
): void {
$this->checkIfShareExists($share, $sharee, $sharer, $space, $shouldOrNot === "should");
}
@ -1822,7 +2019,13 @@ class SharingNgContext implements Context {
*
* @return void
*/
public function userShouldOrShouldNotHaveFederatedShareSharedByUserFromSpace(string $sharee, string $shouldOrNot, string $share, string $sharer, string $space): void {
public function userShouldOrShouldNotHaveFederatedShareSharedByUserFromSpace(
string $sharee,
string $shouldOrNot,
string $share,
string $sharer,
string $space
): void {
$this->checkIfShareExists($share, $sharee, $sharer, $space, $shouldOrNot === "should", true);
}
@ -1837,7 +2040,13 @@ class SharingNgContext implements Context {
*
* @return void
*/
public function userHasSharedTheFollowingFilesFromSpaceWithUserAndRole(string $sharer, string $space, string $sharee, string $role, TableNode $table):void {
public function userHasSharedTheFollowingFilesFromSpaceWithUserAndRole(
string $sharer,
string $space,
string $sharee,
string $role,
TableNode $table
): void {
$rows = $table->getRows();
foreach ($rows as $row) {
if (isset($row[0])) {
@ -1861,7 +2070,7 @@ class SharingNgContext implements Context {
*
* @return void
*/
public function theJsonResponseShouldContainTheFollowingShares(TableNode $table):void {
public function theJsonResponseShouldContainTheFollowingShares(TableNode $table): void {
$responseBody = $this->featureContext->getJsonDecodedResponseBodyContent();
$resourceNames = [];

File diff suppressed because it is too large Load Diff

View File

@ -61,7 +61,12 @@ class SpacesTUSContext implements Context {
* @throws Exception
* @throws GuzzleException
*/
public function userHasUploadedFileViaTusInSpace(string $user, string $source, string $destination, string $spaceName): void {
public function userHasUploadedFileViaTusInSpace(
string $user,
string $source,
string $destination,
string $spaceName
): void {
$spaceId = $this->spacesContext->getSpaceIdByName($user, $spaceName);
$this->tusContext->uploadFileUsingTus($user, $source, $destination, $spaceId);
$this->featureContext->setLastUploadDeleteTime(\time());
@ -175,7 +180,12 @@ class SpacesTUSContext implements Context {
* @return void
* @throws Exception|GuzzleException
*/
public function userUploadsAFileWithContentToInsideFederatedShareViaTusUsingTheWebdavApi(string $user, string $content, string $file, string $destination): void {
public function userUploadsAFileWithContentToInsideFederatedShareViaTusUsingTheWebdavApi(
string $user,
string $content,
string $file,
string $destination
): void {
$remoteItemId = $this->spacesContext->getSharesRemoteItemId($user, $destination);
$remoteItemId = \rawurlencode($remoteItemId);
$tmpFile = $this->tusContext->writeDataToTempFile($content);
@ -293,8 +303,10 @@ class SpacesTUSContext implements Context {
*
* @return void
* @throws Exception|GuzzleException
* @codingStandardsIgnoreStart
*/
public function userHasUploadedFileWithChecksumToTheLastCreatedTusLocationWithOffsetAndContentViaTusInsideOfTheSpaceUsingTheWebdavApi(
// @codingStandardsIgnoreEnd
string $user,
string $checksum,
string $offset,
@ -317,8 +329,10 @@ class SpacesTUSContext implements Context {
*
* @return void
* @throws Exception|GuzzleException
* @codingStandardsIgnoreStart
*/
public function userUploadsFileWithChecksumToTheLastCreatedTusLocationWithOffsetAndContentViaTusInsideOfTheSpaceUsingTheWebdavApi(
// @codingStandardsIgnoreEnd
string $user,
string $checksum,
string $offset,
@ -341,8 +355,10 @@ class SpacesTUSContext implements Context {
*
* @return void
* @throws Exception|GuzzleException
* @codingStandardsIgnoreStart
*/
public function userSendsAChunkToTheLastCreatedTusLocationWithOffsetAndDataWithChecksumViaTusInsideOfTheSpaceUsingTheWebdavApi(
// @codingStandardsIgnoreEnd
string $user,
string $offset,
string $data,
@ -371,7 +387,14 @@ class SpacesTUSContext implements Context {
): void {
$rows = $headers->getRowsHash();
$resourceLocation = $this->tusContext->getLastTusResourceLocation();
$response = $this->tusContext->uploadChunkToTUSLocation($user, $resourceLocation, $rows['Upload-Offset'], $data, $rows['Upload-Checksum'], ['Origin' => $rows['Origin']]);
$response = $this->tusContext->uploadChunkToTUSLocation(
$user,
$resourceLocation,
$rows['Upload-Offset'],
$data,
$rows['Upload-Checksum'],
['Origin' => $rows['Origin']]
);
$this->featureContext->setResponse($response);
}
@ -387,8 +410,10 @@ class SpacesTUSContext implements Context {
*
* @return void
* @throws GuzzleException
* @codingStandardsIgnoreStart
*/
public function userOverwritesRecentlySharedFileWithOffsetAndDataWithChecksumViaTusInsideOfTheSpaceUsingTheWebdavApiWithTheseHeaders(
// @codingStandardsIgnoreEnd
string $user,
string $offset,
string $data,

View File

@ -97,7 +97,12 @@ class TUSContext implements Context {
* @throws Exception
* @throws GuzzleException
*/
public function createNewTUSResourceWithHeaders(string $user, TableNode $headersTable, string $content = '', ?string $spaceId = null): ResponseInterface {
public function createNewTUSResourceWithHeaders(
string $user,
TableNode $headersTable,
string $content = '',
?string $spaceId = null
): ResponseInterface {
$this->featureContext->verifyTableNodeColumnsCount($headersTable, 2);
$user = $this->featureContext->getActualUsername($user);
$password = $this->featureContext->getUserPassword($user);
@ -163,7 +168,7 @@ class TUSContext implements Context {
*
* @return ResponseInterface
*/
public function createNewTUSResource(string $user, TableNode $headers, ?string $spaceId = null):ResponseInterface {
public function createNewTUSResource(string $user, TableNode $headers, ?string $spaceId = null): ResponseInterface {
$rows = $headers->getRows();
$rows[] = ['Tus-Resumable', '1.0.0'];
return $this->createNewTUSResourceWithHeaders($user, new TableNode($rows), '', $spaceId);
@ -182,7 +187,14 @@ class TUSContext implements Context {
* @throws GuzzleException
* @throws JsonException
*/
public function uploadChunkToTUSLocation(string $user, string $resourceLocation, string $offset, string $data, string $checksum = '', ?array $extraHeaders = null): ResponseInterface {
public function uploadChunkToTUSLocation(
string $user,
string $resourceLocation,
string $offset,
string $data,
string $checksum = '',
?array $extraHeaders = null
): ResponseInterface {
$user = $this->featureContext->getActualUsername($user);
$password = $this->featureContext->getUserPassword($user);
$headers = [
@ -631,7 +643,12 @@ class TUSContext implements Context {
* @return void
* @throws Exception
*/
public function userUploadsChunkFileWithChecksum(string $user, string $offset, string $data, string $checksum): void {
public function userUploadsChunkFileWithChecksum(
string $user,
string $offset,
string $data,
string $checksum
): void {
$resourceLocation = $this->getLastTusResourceLocation();
$response = $this->uploadChunkToTUSLocation($user, $resourceLocation, $offset, $data, $checksum);
$this->featureContext->setResponse($response);
@ -648,7 +665,12 @@ class TUSContext implements Context {
* @return void
* @throws Exception
*/
public function userHasUploadedChunkFileWithChecksum(string $user, string $offset, string $data, string $checksum): void {
public function userHasUploadedChunkFileWithChecksum(
string $user,
string $offset,
string $data,
string $checksum
): void {
$resourceLocation = $this->getLastTusResourceLocation();
$response = $this->uploadChunkToTUSLocation($user, $resourceLocation, $offset, $data, $checksum);
$this->featureContext->theHTTPStatusCodeShouldBe(204, "", $response);
@ -669,7 +691,13 @@ class TUSContext implements Context {
* @throws GuzzleException
* @throws Exception
*/
public function userOverwritesFileWithChecksum(string $user, string $offset, string $data, string $checksum, TableNode $headers): void {
public function userOverwritesFileWithChecksum(
string $user,
string $offset,
string $data,
string $checksum,
TableNode $headers
): void {
$createResponse = $this->createNewTUSResource($user, $headers);
$this->featureContext->theHTTPStatusCodeShouldBe(201, "", $createResponse);
$resourceLocation = $this->getLastTusResourceLocation();

View File

@ -64,7 +64,13 @@ class TagContext implements Context {
* @return ResponseInterface
* @throws Exception
*/
public function createTags(string $user, string $fileOrFolder, string $resource, string $space, TableNode $table):ResponseInterface {
public function createTags(
string $user,
string $fileOrFolder,
string $resource,
string $space,
TableNode $table
): ResponseInterface {
$tagNameArray = [];
foreach ($table->getRows() as $value) {
$tagNameArray[] = $value[0];
@ -97,7 +103,13 @@ class TagContext implements Context {
* @return void
* @throws Exception
*/
public function theUserCreatesFollowingTags(string $user, string $fileOrFolder, string $resource, string $space, TableNode $table):void {
public function theUserCreatesFollowingTags(
string $user,
string $fileOrFolder,
string $resource,
string $space,
TableNode $table
): void {
$response = $this->createTags($user, $fileOrFolder, $resource, $space, $table);
$this->featureContext->setResponse($response);
}
@ -114,7 +126,13 @@ class TagContext implements Context {
* @return void
* @throws Exception
*/
public function theUserHasCreatedFollowingTags(string $user, string $fileOrFolder, string $resource, string $space, TableNode $table):void {
public function theUserHasCreatedFollowingTags(
string $user,
string $fileOrFolder,
string $resource,
string $space,
TableNode $table
): void {
$response = $this->createTags($user, $fileOrFolder, $resource, $space, $table);
$this->featureContext->theHttpStatusCodeShouldBe(200, "", $response);
}
@ -130,7 +148,12 @@ class TagContext implements Context {
* @return void
* @throws Exception
*/
public function userHasCreatedTheFollowingTagsForFilesOfTheSpace(string $user, string $filesOrFolders, string $space, TableNode $table):void {
public function userHasCreatedTheFollowingTagsForFilesOfTheSpace(
string $user,
string $filesOrFolders,
string $space,
TableNode $table
): void {
$this->featureContext->verifyTableNodeColumns($table, ["path", "tagName"]);
$rows = $table->getHash();
foreach ($rows as $row) {
@ -148,7 +171,7 @@ class TagContext implements Context {
* @return void
* @throws Exception
*/
public function theUserGetsAllAvailableTags(string $user):void {
public function theUserGetsAllAvailableTags(string $user): void {
// Note: after creating or deleting tags, in some cases tags do not appear or disappear immediately,
// So wait is necessary before listing tags
sleep(5);
@ -171,10 +194,12 @@ class TagContext implements Context {
* @return void
* @throws Exception
*/
public function theFollowingTagsShouldExistForUser(string $shouldOrNot, TableNode $table):void {
public function theFollowingTagsShouldExistForUser(string $shouldOrNot, TableNode $table): void {
$rows = $table->getRows();
foreach ($rows as $row) {
$responseArray = $this->featureContext->getJsonDecodedResponse($this->featureContext->getResponse())['value'];
$responseArray = $this->featureContext->getJsonDecodedResponse(
$this->featureContext->getResponse()
)['value'];
if ($shouldOrNot === "not") {
Assert::assertFalse(
\in_array($row[0], $responseArray),
@ -201,7 +226,13 @@ class TagContext implements Context {
* @return ResponseInterface
* @throws Exception
*/
public function removeTagsFromResourceOfTheSpace(string $user, string $fileOrFolder, string $resource, string $space, TableNode $table):ResponseInterface {
public function removeTagsFromResourceOfTheSpace(
string $user,
string $fileOrFolder,
string $resource,
string $space,
TableNode $table
): ResponseInterface {
$tagNameArray = [];
foreach ($table->getRows() as $value) {
$tagNameArray[] = $value[0];
@ -235,8 +266,20 @@ class TagContext implements Context {
* @return void
* @throws Exception
*/
public function userRemovesTagsFromResourceOfTheSpace(string $user, string $fileOrFolder, string $resource, string $space, TableNode $table):void {
$response = $this->removeTagsFromResourceOfTheSpace($user, $fileOrFolder, $resource, $space, $table);
public function userRemovesTagsFromResourceOfTheSpace(
string $user,
string $fileOrFolder,
string $resource,
string $space,
TableNode $table
): void {
$response = $this->removeTagsFromResourceOfTheSpace(
$user,
$fileOrFolder,
$resource,
$space,
$table
);
$this->featureContext->setResponse($response);
}
@ -252,7 +295,13 @@ class TagContext implements Context {
* @return void
* @throws Exception
*/
public function userHAsRemovedTheFollowingTagsForFileOfSpace(string $user, string $fileOrFolder, string $resource, string $space, TableNode $table):void {
public function userHAsRemovedTheFollowingTagsForFileOfSpace(
string $user,
string $fileOrFolder,
string $resource,
string $space,
TableNode $table
): void {
$response = $this->removeTagsFromResourceOfTheSpace($user, $fileOrFolder, $resource, $space, $table);
$this->featureContext->theHttpStatusCodeShouldBe(200, "", $response);
}

View File

@ -42,7 +42,7 @@ class TrashbinContext implements Context {
*
* @return ResponseInterface
*/
public function emptyTrashbin(?string $user):ResponseInterface {
public function emptyTrashbin(?string $user): ResponseInterface {
$user = $this->featureContext->getActualUsername($user);
$davPathVersion = $this->featureContext->getDavPathVersion();
return WebDavHelper::makeDavRequest(
@ -77,7 +77,7 @@ class TrashbinContext implements Context {
*
* @return void
*/
public function userHasEmptiedTrashbin(string $user):void {
public function userHasEmptiedTrashbin(string $user): void {
$response = $this->emptyTrashbin($user);
$this->featureContext->theHTTPStatusCodeShouldBe(204, '', $response);
}
@ -109,7 +109,9 @@ class TrashbinContext implements Context {
$name = $successPropStat->xpath('./d:prop/oc:trashbin-original-filename');
$mtime = $successPropStat->xpath('./d:prop/oc:trashbin-delete-timestamp');
$resourcetype = $successPropStat->xpath('./d:prop/d:resourcetype');
if (\array_key_exists(0, $resourcetype) && ($resourcetype[0]->asXML() === "<d:resourcetype><d:collection/></d:resourcetype>")) {
if (\array_key_exists(0, $resourcetype)
&& ($resourcetype[0]->asXML() === "<d:resourcetype><d:collection/></d:resourcetype>")
) {
$collection[0] = true;
} else {
$collection[0] = false;
@ -145,7 +147,7 @@ class TrashbinContext implements Context {
* @return array response
* @throws Exception
*/
public function listTopOfTrashbinFolder(?string $user, string $depth = "1"):array {
public function listTopOfTrashbinFolder(?string $user, string $depth = "1"): array {
$password = $this->featureContext->getPasswordForUser($user);
$davPathVersion = $this->featureContext->getDavPathVersion();
@ -205,7 +207,7 @@ class TrashbinContext implements Context {
* @return array of all the items in the trashbin of the user
* @throws Exception
*/
public function listTrashbinFolder(?string $user, string $depth = "1"):array {
public function listTrashbinFolder(?string $user, string $depth = "1"): array {
return $this->listTrashbinFolderCollection(
$user,
"",
@ -224,7 +226,12 @@ class TrashbinContext implements Context {
* @return array response
* @throws Exception
*/
public function listTrashbinFolderCollection(?string $user, ?string $collectionPath = "", string $depth = "1", int $level = 1):array {
public function listTrashbinFolderCollection(
?string $user,
?string $collectionPath = "",
string $depth = "1",
int $level = 1
): array {
// $collectionPath should be some list of file-ids like 2147497661/2147497662
// or the empty string, which will list the whole trashbin from the top.
$collectionPath = \trim($collectionPath, "/");
@ -251,7 +258,11 @@ class TrashbinContext implements Context {
$response->getBody()->rewind();
$statusCode = $response->getStatusCode();
$respBody = $response->getBody()->getContents();
Assert::assertEquals("207", $statusCode, "Expected status code to be '207' but got $statusCode \nResponse\n$respBody");
Assert::assertEquals(
"207",
$statusCode,
"Expected status code to be '207' but got $statusCode \nResponse\n$respBody"
);
$files = $this->getTrashbinContentFromResponseXml(
HttpRequestHelper::getResponseXml(
@ -331,7 +342,7 @@ class TrashbinContext implements Context {
* @return void
* @throws Exception
*/
public function userGetsFilesInTheTrashbinWithDepthUsingTheWebdavApi(string $user, string $depth):void {
public function userGetsFilesInTheTrashbinWithDepthUsingTheWebdavApi(string $user, string $depth): void {
$this->listTopOfTrashbinFolder($user, $depth);
}
@ -343,9 +354,11 @@ class TrashbinContext implements Context {
* @return void
* @throws Exception
*/
public function theTrashbinDavResponseShouldNotContainTheseNodes(TableNode $table):void {
public function theTrashbinDavResponseShouldNotContainTheseNodes(TableNode $table): void {
$this->featureContext->verifyTableNodeColumns($table, ['name']);
$files = $this->getTrashbinContentFromResponseXml(HttpRequestHelper::getResponseXml($this->featureContext->getResponse(), __METHOD__));
$files = $this->getTrashbinContentFromResponseXml(
HttpRequestHelper::getResponseXml($this->featureContext->getResponse(), __METHOD__)
);
foreach ($table->getHash() as $row) {
$path = trim((string)$row['name'], "/");
@ -365,10 +378,12 @@ class TrashbinContext implements Context {
* @return void
* @throws Exception
*/
public function theTrashbinDavResponseShouldContainTheseNodes(TableNode $table):void {
public function theTrashbinDavResponseShouldContainTheseNodes(TableNode $table): void {
$this->featureContext->verifyTableNodeColumns($table, ['name']);
$files = $this->getTrashbinContentFromResponseXml(HttpRequestHelper::getResponseXml($this->featureContext->getResponse(), __METHOD__));
$files = $this->getTrashbinContentFromResponseXml(
HttpRequestHelper::getResponseXml($this->featureContext->getResponse(), __METHOD__)
);
foreach ($table->getHash() as $row) {
$path = trim($row['name'], "/");
@ -395,7 +410,11 @@ class TrashbinContext implements Context {
* @return ResponseInterface
* @throws Exception
*/
public function sendTrashbinListRequest(string $user, ?string $asUser = null, ?string $password = null): ResponseInterface {
public function sendTrashbinListRequest(
string $user,
?string $asUser = null,
?string $password = null
): ResponseInterface {
$asUser = $asUser ?? $user;
$password = $password ?? $this->featureContext->getPasswordForUser($asUser);
@ -445,7 +464,11 @@ class TrashbinContext implements Context {
* @return void
* @throws Exception
*/
public function userTriesToListTheTrashbinContentForUserUsingPassword(string $asUser, string $user, string $password):void {
public function userTriesToListTheTrashbinContentForUserUsingPassword(
string $asUser,
string $user,
string $password
): void {
$response = $this->sendTrashbinListRequest($user, $asUser, $password);
$this->featureContext->setResponse($response);
}
@ -457,7 +480,7 @@ class TrashbinContext implements Context {
*
* @return void
*/
public function theLastWebdavResponseShouldContainFollowingElements(TableNode $elements):void {
public function theLastWebdavResponseShouldContainFollowingElements(TableNode $elements): void {
$files = $this->getTrashbinContentFromResponseXml(HttpRequestHelper::getResponseXml($response, __METHOD__));
$elementRows = $elements->getHash();
foreach ($elementRows as $expectedElement) {
@ -481,8 +504,10 @@ class TrashbinContext implements Context {
* @return void
* @throws Exception
*/
public function theLastWebdavResponseShouldNotContainFollowingElements(TableNode $elements):void {
$files = $this->getTrashbinContentFromResponseXml(HttpRequestHelper::getResponseXml($this->featureContext->getResponse()));
public function theLastWebdavResponseShouldNotContainFollowingElements(TableNode $elements): void {
$files = $this->getTrashbinContentFromResponseXml(
HttpRequestHelper::getResponseXml($this->featureContext->getResponse())
);
// 'user' is also allowed in the table even though it is not used anywhere
// This for better readability in feature files
@ -513,7 +538,7 @@ class TrashbinContext implements Context {
* @return void
* @throws Exception
*/
public function userTriesToDeleteFromTrashbinOfUser(string $user, string $path, string $ofUser):void {
public function userTriesToDeleteFromTrashbinOfUser(string $user, string $path, string $ofUser): void {
$response = $this->deleteItemFromTrashbin($user, $path, $ofUser);
$this->featureContext->setResponse($response);
}
@ -530,7 +555,12 @@ class TrashbinContext implements Context {
* @throws JsonException
* @throws Exception
*/
public function userTriesToDeleteFromTrashbinOfUserUsingPassword(string $user, string $path, string $ofUser, string $password):void {
public function userTriesToDeleteFromTrashbinOfUserUsingPassword(
string $user,
string $path,
string $ofUser,
string $password
): void {
$response = $this->deleteItemFromTrashbin($user, $path, $ofUser, $password);
$this->featureContext->setResponse($response);
}
@ -546,7 +576,7 @@ class TrashbinContext implements Context {
* @throws JsonException
* @throws Exception
*/
public function userTriesToRestoreFromTrashbinOfUser(?string $asUser, ?string $path, ?string $user):void {
public function userTriesToRestoreFromTrashbinOfUser(?string $asUser, ?string $path, ?string $user): void {
$user = $this->featureContext->getActualUsername($user);
$asUser = $this->featureContext->getActualUsername($asUser);
$response = $this->restoreElement($user, $path, null, $asUser);
@ -565,7 +595,12 @@ class TrashbinContext implements Context {
* @throws JsonException
* @throws Exception
*/
public function userTriesToRestoreFromTrashbinOfUserUsingPassword(?string $asUser, ?string $path, ?string $user, ?string $password):void {
public function userTriesToRestoreFromTrashbinOfUserUsingPassword(
?string $asUser,
?string $path,
?string $user,
?string $password
): void {
$asUser = $this->featureContext->getActualUsername($asUser);
$user = $this->featureContext->getActualUsername($user);
$response = $this->restoreElement($user, $path, null, $asUser, $password);
@ -579,7 +614,7 @@ class TrashbinContext implements Context {
*
* @return string
*/
private function convertTrashbinHref(string $href):string {
private function convertTrashbinHref(string $href): string {
$trashItemHRef = \trim($href, '/');
$trashItemHRef = \strstr($trashItemHRef, '/trash-bin');
$trashItemHRef = \trim($trashItemHRef, '/');
@ -596,7 +631,10 @@ class TrashbinContext implements Context {
*
* @return void
*/
public function userTriesToDeleteFileWithOriginalPathFromTrashbinUsingTrashbinAPI(string $user, string $originalPath):void {
public function userTriesToDeleteFileWithOriginalPathFromTrashbinUsingTrashbinAPI(
string $user,
string $originalPath
): void {
$response = $this->deleteItemFromTrashbin($user, $originalPath);
$this->featureContext->setResponse($response);
}
@ -609,7 +647,12 @@ class TrashbinContext implements Context {
*
* @return ResponseInterface
*/
public function deleteItemFromTrashbin(string $user, string $originalPath, ?string $ofUser = null, ?string $password = null): ResponseInterface {
public function deleteItemFromTrashbin(
string $user,
string $originalPath,
?string $ofUser = null,
?string $password = null
): ResponseInterface {
$ofUser = $ofUser ?? $user;
$user = $this->featureContext->getActualUsername($user);
$ofUser = $this->featureContext->getActualUsername($ofUser);
@ -656,7 +699,7 @@ class TrashbinContext implements Context {
* @return void
* @throws Exception
*/
public function deleteFileFromTrashbin(string $user, string $originalPath):void {
public function deleteFileFromTrashbin(string $user, string $originalPath): void {
$response = $this->deleteItemFromTrashbin($user, $originalPath);
$this->featureContext->setResponse($response);
$this->featureContext->pushToLastStatusCodesArrays();
@ -671,7 +714,7 @@ class TrashbinContext implements Context {
* @return void
* @throws Exception
*/
public function userHasDeletedTheFolderWithOriginalPathFromTheTrashbin(string $user, string $originalPath):void {
public function userHasDeletedTheFolderWithOriginalPathFromTheTrashbin(string $user, string $originalPath): void {
$response = $this->deleteItemFromTrashbin($user, $originalPath);
$this->featureContext->theHTTPStatusCodeShouldBe(204, '', $response);
}
@ -685,7 +728,7 @@ class TrashbinContext implements Context {
* @return void
* @throws Exception
*/
public function deleteFollowingFilesFromTrashbin(string $user, TableNode $table):void {
public function deleteFollowingFilesFromTrashbin(string $user, TableNode $table): void {
$this->featureContext->verifyTableNodeColumns($table, ["path"]);
$paths = $table->getHash();
@ -706,7 +749,7 @@ class TrashbinContext implements Context {
* @throws JsonException
* @throws Exception
*/
public function asFileOrFolderExistsInTrash(?string $user, ?string $path):void {
public function asFileOrFolderExistsInTrash(?string $user, ?string $path): void {
$user = $this->featureContext->getActualUsername($user);
$path = \trim($path, '/');
$sections = \explode('/', $path, 2);
@ -756,7 +799,7 @@ class TrashbinContext implements Context {
* @return bool
* @throws Exception
*/
private function isInTrash(?string $user, ?string $originalPath):bool {
private function isInTrash(?string $user, ?string $originalPath): bool {
$listing = $this->listTrashbinFolder($user);
// we don't care if the test step writes a leading "/" or not
@ -781,7 +824,13 @@ class TrashbinContext implements Context {
* @throws JsonException
* @throws GuzzleException
*/
private function sendUndeleteRequest(string $user, string $trashItemHRef, string $destinationPath, ?string $asUser = null, ?string $password = null):ResponseInterface {
private function sendUndeleteRequest(
string $user,
string $trashItemHRef,
string $destinationPath,
?string $asUser = null,
?string $password = null
): ResponseInterface {
$asUser = $asUser ?? $user;
$password = $password ?? $this->featureContext->getPasswordForUser($asUser);
$destinationPath = \trim($destinationPath, '/');
@ -834,7 +883,13 @@ class TrashbinContext implements Context {
* @throws JsonException
* @throws GuzzleException
*/
private function restoreElement(string $user, string $originalPath, ?string $destinationPath = null, ?string $asUser = null, ?string $password = null):ResponseInterface {
private function restoreElement(
string $user,
string $originalPath,
?string $destinationPath = null,
?string $asUser = null,
?string $password = null
): ResponseInterface {
$asUser = $asUser ?? $user;
$listing = $this->listTrashbinFolder($user);
$originalPath = \trim($originalPath, '/');
@ -870,7 +925,10 @@ class TrashbinContext implements Context {
* @return void
* @throws Exception
*/
public function userRestoresResourceWithOriginalPathWithoutSpecifyingDestinationUsingTrashbinApi(string $user, string $originalPath):void {
public function userRestoresResourceWithOriginalPathWithoutSpecifyingDestinationUsingTrashbinApi(
string $user,
string $originalPath
): void {
$listing = $this->listTrashbinFolder($user);
$originalPath = \trim($originalPath, '/');
@ -912,7 +970,7 @@ class TrashbinContext implements Context {
?string $user,
?string $content,
?string $alternativeContent
):void {
): void {
$isInTrash = $this->isInTrash($user, $fileName);
$user = $this->featureContext->getActualUsername($user);
$response = $this->featureContext->downloadFileAsUserUsingPassword($user, $fileName);
@ -933,7 +991,7 @@ class TrashbinContext implements Context {
* @throws JsonException
* @throws Exception
*/
public function elementInTrashIsRestored(?string $user, string $originalPath):void {
public function elementInTrashIsRestored(?string $user, string $originalPath): void {
$user = $this->featureContext->getActualUsername($user);
$this->featureContext->setResponse($this->restoreElement($user, $originalPath));
}
@ -947,7 +1005,7 @@ class TrashbinContext implements Context {
* @return void
* @throws Exception
*/
public function userRestoresFollowingFiles(string $user, TableNode $table):void {
public function userRestoresFollowingFiles(string $user, TableNode $table): void {
$this->featureContext->verifyTableNodeColumns($table, ["path"]);
$paths = $table->getHash();
@ -967,7 +1025,7 @@ class TrashbinContext implements Context {
* @return void
* @throws Exception
*/
public function elementInTrashHasBeenRestored(string $user, string $originalPath):void {
public function elementInTrashHasBeenRestored(string $user, string $originalPath): void {
$response = $this->restoreElement($user, $originalPath);
$this->featureContext->theHTTPStatusCodeShouldBe(201, "", $response);
if ($this->isInTrash($user, $originalPath)) {
@ -990,7 +1048,7 @@ class TrashbinContext implements Context {
?string $user,
?string $originalPath,
?string $destinationPath
):void {
): void {
$user = $this->featureContext->getActualUsername($user);
$this->featureContext->setResponse($this->restoreElement($user, $originalPath, $destinationPath));
}
@ -1008,7 +1066,7 @@ class TrashbinContext implements Context {
public function elementIsInTrashCheckingOriginalPath(
?string $user,
?string $originalPath
):void {
): void {
$user = $this->featureContext->getActualUsername($user);
Assert::assertTrue(
$this->isInTrash($user, $originalPath),
@ -1028,7 +1086,7 @@ class TrashbinContext implements Context {
public function elementIsNotInTrashCheckingOriginalPath(
?string $user,
string $originalPath
):void {
): void {
$user = $this->featureContext->getActualUsername($user);
Assert::assertFalse(
$this->isInTrash($user, $originalPath),
@ -1048,7 +1106,7 @@ class TrashbinContext implements Context {
public function followingElementsAreNotInTrashCheckingOriginalPath(
string $user,
TableNode $table
):void {
): void {
$this->featureContext->verifyTableNodeColumns($table, ["path"]);
$paths = $table->getHash();
@ -1073,7 +1131,7 @@ class TrashbinContext implements Context {
public function followingElementsAreInTrashCheckingOriginalPath(
string $user,
TableNode $table
):void {
): void {
$this->featureContext->verifyTableNodeColumns($table, ["path"]);
$paths = $table->getHash();
@ -1095,7 +1153,7 @@ class TrashbinContext implements Context {
* @return array|null real entry name with timestamp suffix or null if not found
* @throws Exception
*/
private function findFirstTrashedEntry(string $user, string $name):?array {
private function findFirstTrashedEntry(string $user, string $name): ?array {
$listing = $this->listTrashbinFolder($user);
foreach ($listing as $entry) {
@ -1117,7 +1175,7 @@ class TrashbinContext implements Context {
*
* @return void
*/
public function before(BeforeScenarioScope $scope):void {
public function before(BeforeScenarioScope $scope): void {
// Get the environment
$environment = $scope->getEnvironment();
// Get all the contexts you need in this context
@ -1131,7 +1189,7 @@ class TrashbinContext implements Context {
*
* @return void
*/
public function theDeletedFileFolderShouldHaveCorrectDeletionMtimeInTheResponse(string $resource):void {
public function theDeletedFileFolderShouldHaveCorrectDeletionMtimeInTheResponse(string $resource): void {
$files = $this->getTrashbinContentFromResponseXml(
HttpRequestHelper::getResponseXml($this->featureContext->getResponse())
);

File diff suppressed because it is too large Load Diff

View File

@ -69,7 +69,7 @@ class WebDavLockingContext implements Context {
bool $public = false,
bool $expectToSucceed = true,
?string $spaceId = null
):ResponseInterface {
): ResponseInterface {
$user = $this->featureContext->getActualUsername($user);
if ($public === true) {
$type = "public-files";
@ -146,7 +146,9 @@ class WebDavLockingContext implements Context {
*/
public function userLocksFileSettingPropertiesUsingWebDavAPI(string $user, string $file, TableNode $properties) {
$spaceId = null;
if (\str_starts_with($file, "Shares/") && $this->featureContext->getDavPathVersion() === WebDavHelper::DAV_VERSION_SPACES) {
if (\str_starts_with($file, "Shares/")
&& $this->featureContext->getDavPathVersion() === WebDavHelper::DAV_VERSION_SPACES
) {
$spaceId = $this->spacesContext->getSpaceIdByName($user, "Shares");
$file = \str_replace("Shares/", "", $file);
}
@ -163,7 +165,11 @@ class WebDavLockingContext implements Context {
*
* @return void
*/
public function userTriesToLockFileSettingPropertiesUsingWebDavAPI(string $user, string $file, TableNode $properties) {
public function userTriesToLockFileSettingPropertiesUsingWebDavAPI(
string $user,
string $file,
TableNode $properties
) {
$response = $this->lockFile($user, $file, $properties, null, false, false);
$this->featureContext->setResponse($response);
}
@ -179,7 +185,12 @@ class WebDavLockingContext implements Context {
* @return void
* @throws GuzzleException
*/
public function userLocksFileInProjectSpaceUsingWebDavAPI(string $user, string $file, string $space, TableNode $properties) {
public function userLocksFileInProjectSpaceUsingWebDavAPI(
string $user,
string $file,
string $space,
TableNode $properties
) {
$this->featureContext->setResponse($this->userLocksFileInProjectSpace($user, $file, $space, $properties));
}
@ -193,7 +204,12 @@ class WebDavLockingContext implements Context {
*
* @throws GuzzleException
*/
public function userLocksFileInProjectSpace(string $user, string $file, string $space, TableNode $properties): ?ResponseInterface {
public function userLocksFileInProjectSpace(
string $user,
string $file,
string $space,
TableNode $properties
): ?ResponseInterface {
$spaceId = $this->spacesContext->getSpaceIdByName($user, $space);
$baseUrl = $this->featureContext->getBaseUrl();
$davPathVersion = $this->featureContext->getDavPathVersion();
@ -218,7 +234,12 @@ class WebDavLockingContext implements Context {
* @return void
* @throws GuzzleException
*/
public function userHasLockedFileInProjectSpaceUsingWebDavAPI(string $user, string $file, string $space, TableNode $properties): void {
public function userHasLockedFileInProjectSpaceUsingWebDavAPI(
string $user,
string $file,
string $space,
TableNode $properties
): void {
$response = $this->userLocksFileInProjectSpace($user, $file, $space, $properties);
$this->featureContext->theHTTPStatusCodeShouldBe(200, '', $response);
}
@ -233,7 +254,12 @@ class WebDavLockingContext implements Context {
*
* @return void
*/
public function userTriesToLockFileInProjectSpaceUsingWebDavAPI(string $user, string $file, string $space, TableNode $properties) {
public function userTriesToLockFileInProjectSpaceUsingWebDavAPI(
string $user,
string $file,
string $space,
TableNode $properties
) {
$spaceId = $this->spacesContext->getSpaceIdByName($user, $space);
$davPathVersion = $this->featureContext->getDavPathVersion();
$suffixPath = $user;
@ -257,7 +283,12 @@ class WebDavLockingContext implements Context {
*
* @return void
*/
public function userLocksFileUsingFileIdUsingWebDavAPISettingFollowingProperties(string $user, string $file, string $fileId, TableNode $properties) {
public function userLocksFileUsingFileIdUsingWebDavAPISettingFollowingProperties(
string $user,
string $file,
string $fileId,
TableNode $properties
) {
$davPath = WebdavHelper::getDavPath($this->featureContext->getDavPathVersion());
$davPath = \rtrim($davPath, '/');
$fullUrl = $this->featureContext->getBaseUrl() . "/$davPath/$fileId";
@ -275,7 +306,12 @@ class WebDavLockingContext implements Context {
*
* @return void
*/
public function userTriesToLockFileUsingFileIdUsingWebDavAPI(string $user, string $file, string $fileId, TableNode $properties) {
public function userTriesToLockFileUsingFileIdUsingWebDavAPI(
string $user,
string $file,
string $fileId,
TableNode $properties
) {
$davPath = WebdavHelper::getDavPath($this->featureContext->getDavPathVersion());
$davPath = \rtrim($davPath, '/');
$fullUrl = $this->featureContext->getBaseUrl() . "/$davPath/$fileId";
@ -307,7 +343,12 @@ class WebDavLockingContext implements Context {
*
* @return void
*/
public function userHasLockedFileInsideSpaceSettingTheFollowingProperties(string $user, string $file, string $spaceName, TableNode $properties) {
public function userHasLockedFileInsideSpaceSettingTheFollowingProperties(
string $user,
string $file,
string $spaceName,
TableNode $properties
) {
$spaceId = $this->spacesContext->getSpaceIdByName($this->featureContext->getActualUsername($user), $spaceName);
$response = $this->lockFile($user, $file, $properties, null, false, true, $spaceId);
$this->featureContext->theHTTPStatusCodeShouldBe(200, '', $response);
@ -358,7 +399,9 @@ class WebDavLockingContext implements Context {
* @return void
*/
public function publicLocksLastSharedFile(TableNode $properties) {
$token = ($this->featureContext->isUsingSharingNG()) ? $this->featureContext->shareNgGetLastCreatedLinkShareToken() : $this->featureContext->getLastCreatedPublicShareToken();
$token = ($this->featureContext->isUsingSharingNG())
? $this->featureContext->shareNgGetLastCreatedLinkShareToken()
: $this->featureContext->getLastCreatedPublicShareToken();
$response = $this->lockFile(
$token,
"/",
@ -382,7 +425,9 @@ class WebDavLockingContext implements Context {
string $file,
TableNode $properties
) {
$token = ($this->featureContext->isUsingSharingNG()) ? $this->featureContext->shareNgGetLastCreatedLinkShareToken() : $this->featureContext->getLastCreatedPublicShareToken();
$token = ($this->featureContext->isUsingSharingNG())
? $this->featureContext->shareNgGetLastCreatedLinkShareToken()
: $this->featureContext->getLastCreatedPublicShareToken();
$response = $this->lockFile(
$token,
$file,
@ -406,7 +451,9 @@ class WebDavLockingContext implements Context {
string $file,
TableNode $properties
) {
$token = ($this->featureContext->isUsingSharingNG()) ? $this->featureContext->shareNgGetLastCreatedLinkShareToken() : $this->featureContext->getLastCreatedPublicShareToken();
$token = ($this->featureContext->isUsingSharingNG())
? $this->featureContext->shareNgGetLastCreatedLinkShareToken()
: $this->featureContext->getLastCreatedPublicShareToken();
$response = $this->lockFile(
$token,
$file,
@ -445,7 +492,11 @@ class WebDavLockingContext implements Context {
*
* @return void
*/
public function userUnlocksTheLastCreatedLockOfFileInsideSpaceUsingTheWebdavApi(string $user, string $spaceName, string $file) {
public function userUnlocksTheLastCreatedLockOfFileInsideSpaceUsingTheWebdavApi(
string $user,
string $spaceName,
string $file
) {
$spaceId = $this->spacesContext->getSpaceIdByName($this->featureContext->getActualUsername($user), $spaceName);
$response = $this->unlockItemWithLastLockOfUserAndItemUsingWebDavAPI(
$user,
@ -468,11 +519,22 @@ class WebDavLockingContext implements Context {
*
* @return void
*/
public function userUnlocksTheLastCreatedLockOfFileWithFileIdPathUsingTheWebdavApi(string $user, string $itemToUnlock, string $fileId) {
public function userUnlocksTheLastCreatedLockOfFileWithFileIdPathUsingTheWebdavApi(
string $user,
string $itemToUnlock,
string $fileId
) {
$davPath = WebdavHelper::getDavPath($this->featureContext->getDavPathVersion());
$davPath = \rtrim($davPath, '/');
$fullUrl = $this->featureContext->getBaseUrl() . "/$davPath/$fileId";
$response = $this->unlockItemWithLastLockOfUserAndItemUsingWebDavAPI($user, $itemToUnlock, $user, $itemToUnlock, false, $fullUrl);
$response = $this->unlockItemWithLastLockOfUserAndItemUsingWebDavAPI(
$user,
$itemToUnlock,
$user,
$itemToUnlock,
false,
$fullUrl
);
$this->featureContext->setResponse($response);
}
@ -535,7 +597,7 @@ class WebDavLockingContext implements Context {
private function countLockOfResources(
string $user,
string $itemToUnlock
):int {
): int {
$user = $this->featureContext->getActualUsername($user);
$baseUrl = $this->featureContext->getBaseUrl();
$password = $this->featureContext->getPasswordForUser($user);
@ -625,7 +687,7 @@ class WebDavLockingContext implements Context {
bool $public = false,
string $fullUrl = null,
?string $spaceId = null,
):ResponseInterface {
): ResponseInterface {
$user = $this->featureContext->getActualUsername($user);
$lockOwner = $this->featureContext->getActualUsername($lockOwner);
if ($public === true) {
@ -711,7 +773,9 @@ class WebDavLockingContext implements Context {
string $lockOwner,
string $itemToUseLockOf
) {
$token = ($this->featureContext->isUsingSharingNG()) ? $this->featureContext->shareNgGetLastCreatedLinkShareToken() : $this->featureContext->getLastCreatedPublicShareToken();
$token = ($this->featureContext->isUsingSharingNG())
? $this->featureContext->shareNgGetLastCreatedLinkShareToken()
: $this->featureContext->getLastCreatedPublicShareToken();
$response = $this->unlockItemWithLastLockOfUserAndItemUsingWebDavAPI(
$token,
$itemToUnlock,
@ -730,7 +794,9 @@ class WebDavLockingContext implements Context {
* @return void
*/
public function unlockItemAsPublicUsingWebDavAPI(string $itemToUnlock) {
$token = ($this->featureContext->isUsingSharingNG()) ? $this->featureContext->shareNgGetLastCreatedLinkShareToken() : $this->featureContext->getLastCreatedPublicShareToken();
$token = ($this->featureContext->isUsingSharingNG())
? $this->featureContext->shareNgGetLastCreatedLinkShareToken()
: $this->featureContext->getLastCreatedPublicShareToken();
$response = $this->unlockItemWithLastLockOfUserAndItemUsingWebDavAPI(
$token,
$itemToUnlock,
@ -782,7 +848,7 @@ class WebDavLockingContext implements Context {
string $fileDestination,
string $itemToUseLockOf,
string $lockOwner
):ResponseInterface {
): ResponseInterface {
$user = $this->featureContext->getActualUsername($user);
$lockOwner = $this->featureContext->getActualUsername($lockOwner);
$destination = $this->featureContext->destinationHeaderValue(
@ -901,7 +967,12 @@ class WebDavLockingContext implements Context {
* @return void
* @throws GuzzleException
*/
public function numberOfLockShouldBeReportedInProjectSpace(int $count, string $file, string $spaceName, string $user) {
public function numberOfLockShouldBeReportedInProjectSpace(
int $count,
string $file,
string $spaceName,
string $user
) {
$response = $this->spacesContext->sendPropfindRequestToSpace($user, $spaceName, $file, null, '0');
$this->featureContext->theHTTPStatusCodeShouldBe(207, "", $response);
$responseXmlObject = HttpRequestHelper::getResponseXml($response, __METHOD__);

View File

@ -56,7 +56,7 @@ class WebDavPropertiesContext implements Context {
public function userGetsThePropertiesOfFolder(
string $user,
string $path
):void {
): void {
$response = $this->featureContext->listFolder(
$user,
$path,
@ -79,7 +79,7 @@ class WebDavPropertiesContext implements Context {
string $user,
string $path,
string $depth
):void {
): void {
$response = $this->featureContext->listFolder(
$user,
$path,
@ -133,7 +133,7 @@ class WebDavPropertiesContext implements Context {
string $user,
string $path,
TableNode $propertiesTable
):void {
): void {
$response = $this->getPropertiesOfFolder($user, $path, null, $propertiesTable);
$this->featureContext->setResponse($response);
$this->featureContext->pushToLastStatusCodesArrays();
@ -170,7 +170,11 @@ class WebDavPropertiesContext implements Context {
* @return void
* @throws Exception
*/
public function userHasSetFollowingPropertiesUsingProppatch(string $username, string $path, TableNode $propertiesTable) {
public function userHasSetFollowingPropertiesUsingProppatch(
string $username,
string $path,
TableNode $propertiesTable
) {
$username = $this->featureContext->getActualUsername($username);
$this->featureContext->verifyTableNodeColumns($propertiesTable, ['propertyName', 'propertyValue']);
$properties = $propertiesTable->getColumnsHash();
@ -200,7 +204,7 @@ class WebDavPropertiesContext implements Context {
string $user,
string $propertyName,
string $path
):void {
): void {
$user = $this->featureContext->getActualUsername($user);
$properties = [$propertyName];
$response = WebDavHelper::propfind(
@ -234,7 +238,7 @@ class WebDavPropertiesContext implements Context {
string $propertyName,
string $namespace,
string $path
):void {
): void {
$user = $this->featureContext->getActualUsername($user);
$properties = [
$namespace => $propertyName
@ -262,7 +266,9 @@ class WebDavPropertiesContext implements Context {
* @throws Exception
*/
public function getPropertiesOfEntryFromLastLinkShare(string $path, TableNode $propertiesTable): ResponseInterface {
$token = ($this->featureContext->isUsingSharingNG()) ? $this->featureContext->shareNgGetLastCreatedLinkShareToken() : $this->featureContext->getLastCreatedPublicShareToken();
$token = ($this->featureContext->isUsingSharingNG())
? $this->featureContext->shareNgGetLastCreatedLinkShareToken()
: $this->featureContext->getLastCreatedPublicShareToken();
$properties = null;
foreach ($propertiesTable->getRows() as $row) {
$properties[] = $row[0];
@ -286,7 +292,10 @@ class WebDavPropertiesContext implements Context {
* @return void
* @throws Exception
*/
public function thePublicGetsFollowingPropertiesOfEntryFromLastLinkShare(string $path, TableNode $propertiesTable):void {
public function thePublicGetsFollowingPropertiesOfEntryFromLastLinkShare(
string $path,
TableNode $propertiesTable
): void {
$response = $this->getPropertiesOfEntryFromLastLinkShare($path, $propertiesTable);
$this->featureContext->setResponse($response);
}
@ -307,7 +316,7 @@ class WebDavPropertiesContext implements Context {
string $path,
string $propertyValue,
string $namespace = null,
):ResponseInterface {
): ResponseInterface {
$user = $this->featureContext->getActualUsername($user);
return WebDavHelper::proppatch(
$this->featureContext->getBaseUrl(),
@ -338,7 +347,7 @@ class WebDavPropertiesContext implements Context {
string $propertyName,
string $path,
string $propertyValue
):void {
): void {
$response = $this->setResourceProperty(
$user,
$propertyName,
@ -366,7 +375,7 @@ class WebDavPropertiesContext implements Context {
string $namespace,
string $path,
string $propertyValue
):void {
): void {
$response = $this->setResourceProperty(
$user,
$propertyName,
@ -393,7 +402,7 @@ class WebDavPropertiesContext implements Context {
string $propertyName,
string $path,
string $propertyValue
):void {
): void {
$response = $this->setResourceProperty(
$user,
$propertyName,
@ -421,7 +430,7 @@ class WebDavPropertiesContext implements Context {
string $namespace,
string $path,
string $propertyValue
):void {
): void {
$response = $this->setResourceProperty(
$user,
$propertyName,
@ -477,7 +486,7 @@ class WebDavPropertiesContext implements Context {
string $propertyName,
string $namespaceString,
string $propertyValue
):void {
): void {
// let's unescape quotes first
$propertyValue = \str_replace('\"', '"', $propertyValue);
$responseXmlObject = HttpRequestHelper::getResponseXml(
@ -518,7 +527,7 @@ class WebDavPropertiesContext implements Context {
public function theSingleResponseShouldContainAPropertyWithChildProperty(
string $property,
string $childProperty
):void {
): void {
$xmlPart = HttpRequestHelper::getResponseXml($this->featureContext->getResponse())->xpath(
"//d:prop/$property/$childProperty"
);
@ -572,7 +581,7 @@ class WebDavPropertiesContext implements Context {
public function theSingleResponseShouldContainAPropertyWithValue(
string $key,
string $expectedValue
):void {
): void {
$this->checkResponseContainsAPropertyWithValue(
$this->featureContext->getResponse(),
$key,
@ -595,7 +604,7 @@ class WebDavPropertiesContext implements Context {
string $user,
string $key,
string $expectedValue
):void {
): void {
$this->checkResponseContainsAPropertyWithValue(
$this->featureContext->getResponse(),
$key,
@ -619,7 +628,7 @@ class WebDavPropertiesContext implements Context {
string $key,
string $expectedValue,
string $altExpectedValue
):void {
): void {
$this->checkResponseContainsAPropertyWithValue(
$this->featureContext->getResponse(),
$key,
@ -636,7 +645,11 @@ class WebDavPropertiesContext implements Context {
* @return SimpleXMLElement
* @throws Exception
*/
public function checkResponseContainsProperty(ResponseInterface $response, string $key, string $namespaceString = null): SimpleXMLElement {
public function checkResponseContainsProperty(
ResponseInterface $response,
string $key,
string $namespaceString = null
): SimpleXMLElement {
$xmlPart = HttpRequestHelper::getResponseXml($response, __METHOD__);
;
@ -680,7 +693,7 @@ class WebDavPropertiesContext implements Context {
string $expectedValue,
string $altExpectedValue,
?string $user = null
):void {
): void {
$xmlPart = $this->checkResponseContainsProperty($response, $key);
$value = $xmlPart->__toString();
$expectedValue = $this->featureContext->substituteInLineCodes(
@ -708,7 +721,7 @@ class WebDavPropertiesContext implements Context {
* @return void
* @throws Exception
*/
public function assertValueOfItemInResponseIs(string $xpath, string $expectedValue):void {
public function assertValueOfItemInResponseIs(string $xpath, string $expectedValue): void {
$this->assertValueOfItemInResponseAboutUserIs(
$xpath,
null,
@ -727,7 +740,7 @@ class WebDavPropertiesContext implements Context {
* @return void
* @throws Exception
*/
public function valueOfItemOfPathShouldBe(string $user, string $xpath, string $path, string $expectedValue):void {
public function valueOfItemOfPathShouldBe(string $user, string $xpath, string $path, string $expectedValue): void {
$path = $this->featureContext->substituteInLineCodes($path, $user);
$path = \ltrim($path, '/');
$path = "/" . WebdavHelper::prefixRemotePhp($path);
@ -749,7 +762,11 @@ class WebDavPropertiesContext implements Context {
* @return void
* @throws Exception
*/
public function theValueOfTheItemInTheResponseAboutUserShouldBe(string $xpath, string $user, string $expectedValue):void {
public function theValueOfTheItemInTheResponseAboutUserShouldBe(
string $xpath,
string $user,
string $expectedValue
): void {
$this->assertValueOfItemInResponseAboutUserIs($xpath, $user, $expectedValue);
}
@ -760,7 +777,7 @@ class WebDavPropertiesContext implements Context {
*
* @return void
*/
public function assertValueOfItemInResponseAboutUserIs(string $xpath, ?string $user, string $expectedValue):void {
public function assertValueOfItemInResponseAboutUserIs(string $xpath, ?string $user, string $expectedValue): void {
$responseXmlObject = HttpRequestHelper::getResponseXml(
$this->featureContext->getResponse(),
__METHOD__
@ -794,7 +811,12 @@ class WebDavPropertiesContext implements Context {
* @return void
* @throws Exception
*/
public function assertValueOfItemInResponseAboutUserIsEitherOr(string $xpath, ?string $user, string $expectedValue1, string $expectedValue2):void {
public function assertValueOfItemInResponseAboutUserIsEitherOr(
string $xpath,
?string $user,
string $expectedValue1,
string $expectedValue2
): void {
if (!$expectedValue2) {
$expectedValue2 = $expectedValue1;
}
@ -820,7 +842,10 @@ class WebDavPropertiesContext implements Context {
$expectedValue2 = preg_replace("/^\/\//i", "/", $expectedValue2);
$expectedValues = [$expectedValue1, $expectedValue2];
$isExpectedValueInMessage = \in_array($value, $expectedValues);
Assert::assertTrue($isExpectedValueInMessage, "The actual value \"$value\" is not one of the expected values: \"$expectedValue1\" or \"$expectedValue2\"");
Assert::assertTrue(
$isExpectedValueInMessage,
"The actual value \"$value\" is not one of the expected values: \"$expectedValue1\" or \"$expectedValue2\""
);
}
/**
@ -850,7 +875,7 @@ class WebDavPropertiesContext implements Context {
* @return void
* @throws Exception
*/
public function assertValueOfItemInResponseRegExp(string $xpath, string $pattern):void {
public function assertValueOfItemInResponseRegExp(string $xpath, string $pattern): void {
$this->assertXpathValueMatchesPattern(
HttpRequestHelper::getResponseXml($this->featureContext->getResponse()),
$xpath,
@ -868,7 +893,11 @@ class WebDavPropertiesContext implements Context {
* @return void
* @throws Exception
*/
public function publicGetsThePropertiesOfFolderAndAssertValueOfItemInResponseRegExp(string $xpath, string $path, string $pattern):void {
public function publicGetsThePropertiesOfFolderAndAssertValueOfItemInResponseRegExp(
string $xpath,
string $path,
string $pattern
): void {
$propertiesTable = new TableNode([['propertyName'],['d:lockdiscovery']]);
$response = $this->getPropertiesOfEntryFromLastLinkShare($path, $propertiesTable);
$this->featureContext->theHTTPStatusCodeShouldBe('207', "", $response);
@ -888,7 +917,7 @@ class WebDavPropertiesContext implements Context {
* @return void
* @throws Exception
*/
public function assertEntryWithHrefMatchingRegExpInResponseToUser(string $expectedHref, string $user):void {
public function assertEntryWithHrefMatchingRegExpInResponseToUser(string $expectedHref, string $user): void {
$responseXmlObject = HttpRequestHelper::getResponseXml(
$this->featureContext->getResponse(),
__METHOD__
@ -947,7 +976,12 @@ class WebDavPropertiesContext implements Context {
* @return void
* @throws JsonException
*/
public function assertXpathValueMatchesPattern(SimpleXMLElement $responseXmlObject, string $xpath, string $pattern, ?string $user = null): void {
public function assertXpathValueMatchesPattern(
SimpleXMLElement $responseXmlObject,
string $xpath,
string $pattern,
?string $user = null
): void {
$xmlPart = $responseXmlObject->xpath($xpath);
Assert::assertTrue(
isset($xmlPart[0]),
@ -955,7 +989,8 @@ class WebDavPropertiesContext implements Context {
);
$user = $this->featureContext->getActualUsername($user);
$value = $xmlPart[0]->__toString();
$callback = ($this->featureContext->isUsingSharingNG()) ? "shareNgGetLastCreatedLinkShareToken" : "getLastCreatedPublicShareToken";
$callback = ($this->featureContext->isUsingSharingNG())
? "shareNgGetLastCreatedLinkShareToken" : "getLastCreatedPublicShareToken";
if (\str_ends_with($xpath, "d:href")) {
$pattern = \preg_replace("/^\//", "", $pattern);
@ -996,7 +1031,12 @@ class WebDavPropertiesContext implements Context {
* @return void
* @throws Exception
*/
public function userGetsPropertiesOfFolderAndAssertValueOfItemInResponseToUserRegExp(string $user, string $xpath, string $path, string $pattern):void {
public function userGetsPropertiesOfFolderAndAssertValueOfItemInResponseToUserRegExp(
string $user,
string $xpath,
string $path,
string $pattern
): void {
$propertiesTable = new TableNode([['propertyName'],['d:lockdiscovery']]);
$response = $this->getPropertiesOfFolder(
$user,
@ -1021,7 +1061,7 @@ class WebDavPropertiesContext implements Context {
* @return void
* @throws Exception
*/
public function assertItemInResponseDoesNotExist(string $xpath):void {
public function assertItemInResponseDoesNotExist(string $xpath): void {
$xmlPart = HttpRequestHelper::getResponseXml($this->featureContext->getResponse())->xpath($xpath);
Assert::assertFalse(
isset($xmlPart[0]),
@ -1047,7 +1087,7 @@ class WebDavPropertiesContext implements Context {
string $property,
string $expectedValue,
?string $altExpectedValue = null
):void {
): void {
$this->checkPropertyOfAFolder($user, $path, $property, $expectedValue, $altExpectedValue);
}
@ -1068,7 +1108,7 @@ class WebDavPropertiesContext implements Context {
string $expectedValue,
?string $altExpectedValue = null,
?string $spaceId = null,
):void {
): void {
$response = $this->featureContext->listFolder(
$user,
$path,
@ -1099,7 +1139,7 @@ class WebDavPropertiesContext implements Context {
public function theSingleResponseShouldContainAPropertyWithValueLike(
string $key,
string $regex
):void {
): void {
$xmlPart = HttpRequestHelper::getResponseXml($this->featureContext->getResponse())->xpath(
"//d:prop/$key"
);
@ -1123,7 +1163,7 @@ class WebDavPropertiesContext implements Context {
* @return void
* @throws Exception
*/
public function theResponseShouldContainAShareTypesPropertyWith(TableNode $table):void {
public function theResponseShouldContainAShareTypesPropertyWith(TableNode $table): void {
$this->featureContext->verifyTableNodeColumnsCount($table, 1);
WebdavTest::assertResponseContainsShareTypes(
HttpRequestHelper::getResponseXml($this->featureContext->getResponse()),
@ -1139,7 +1179,7 @@ class WebDavPropertiesContext implements Context {
* @return void
* @throws Exception
*/
public function theResponseShouldContainAnEmptyProperty(string $property):void {
public function theResponseShouldContainAnEmptyProperty(string $property): void {
$xmlPart = HttpRequestHelper::getResponseXml($this->featureContext->getResponse())->xpath(
"//d:prop/$property"
);
@ -1163,7 +1203,12 @@ class WebDavPropertiesContext implements Context {
* @return SimpleXMLElement
* @throws Exception
*/
public function storeEtagOfElement(string $user, string $path, ?string $storePath = "", ?string $spaceId = null):SimpleXMLElement {
public function storeEtagOfElement(
string $user,
string $path,
?string $storePath = "",
?string $spaceId = null
): SimpleXMLElement {
if ($storePath === "") {
$storePath = $path;
}
@ -1190,7 +1235,7 @@ class WebDavPropertiesContext implements Context {
* @return void
* @throws Exception
*/
public function userStoresEtagOfElement(string $user, string $path):void {
public function userStoresEtagOfElement(string $user, string $path): void {
$this->storeEtagOfElement(
$user,
$path
@ -1207,7 +1252,7 @@ class WebDavPropertiesContext implements Context {
* @return void
* @throws Exception
*/
public function userStoresEtagOfElementOnPath(string $user, string $path, string $storePath):void {
public function userStoresEtagOfElementOnPath(string $user, string $path, string $storePath): void {
$user = $this->featureContext->getActualUsername($user);
$this->storeEtagOfElement(
$user,
@ -1231,7 +1276,7 @@ class WebDavPropertiesContext implements Context {
* @return void
* @throws Exception
*/
public function userHasStoredEtagOfElement(string $user, string $path):void {
public function userHasStoredEtagOfElement(string $user, string $path): void {
$user = $this->featureContext->getActualUsername($user);
$this->storeEtagOfElement(
$user,
@ -1248,7 +1293,7 @@ class WebDavPropertiesContext implements Context {
* @return void
* @throws Exception
*/
public function thePropertiesResponseShouldContainAnEtag():void {
public function thePropertiesResponseShouldContainAnEtag(): void {
Assert::assertTrue(
$this->featureContext->isEtagValid($this->featureContext->getEtagFromResponseXmlObject()),
__METHOD__
@ -1287,8 +1332,11 @@ class WebDavPropertiesContext implements Context {
* @return void
* @throws Exception
*/
public function theResponseShouldHavePropertyWithValue(string $username, TableNode $expectedPropTable):void {
$this->featureContext->verifyTableNodeColumns($expectedPropTable, ['resource', 'propertyName', 'propertyValue']);
public function theResponseShouldHavePropertyWithValue(string $username, TableNode $expectedPropTable): void {
$this->featureContext->verifyTableNodeColumns(
$expectedPropTable,
['resource', 'propertyName', 'propertyValue']
);
$responseXmlObject = HttpRequestHelper::getResponseXml($this->featureContext->getResponse());
$href = (string)$responseXmlObject->xpath("//d:href")[0];
@ -1315,7 +1363,7 @@ class WebDavPropertiesContext implements Context {
* @return string
* @throws Exception
*/
public function getCurrentEtagOfElement(string $path, string $user):string {
public function getCurrentEtagOfElement(string $path, string $user): string {
$user = $this->featureContext->getActualUsername($user);
$propertiesTable = new TableNode([['propertyName'],['d:getetag']]);
$response = $this->getPropertiesOfFolder(
@ -1324,7 +1372,9 @@ class WebDavPropertiesContext implements Context {
null,
$propertiesTable
);
return $this->featureContext->getEtagFromResponseXmlObject(HttpRequestHelper::getResponseXml($response, __METHOD__));
return $this->featureContext->getEtagFromResponseXmlObject(
HttpRequestHelper::getResponseXml($response, __METHOD__)
);
}
/**
@ -1334,7 +1384,7 @@ class WebDavPropertiesContext implements Context {
*
* @return string
*/
public function getStoredEtagOfElement(string $path, string $user, string $messageStart = ''):string {
public function getStoredEtagOfElement(string $path, string $user, string $messageStart = ''): string {
if ($messageStart === '') {
$messageStart = __METHOD__;
}
@ -1348,7 +1398,8 @@ class WebDavPropertiesContext implements Context {
$path,
$this->storedETAG[$user],
$messageStart
. " Trying to check etag of element $path of user $user but the user does not have a stored etag for the element"
. " Trying to check etag of element $path of user "
. "$user but the user does not have a stored etag for the element"
);
return $this->storedETAG[$user][$path];
}
@ -1361,7 +1412,7 @@ class WebDavPropertiesContext implements Context {
* @return void
* @throws Exception
*/
public function theseEtagsShouldNotHaveChanged(TableNode $etagTable):void {
public function theseEtagsShouldNotHaveChanged(TableNode $etagTable): void {
$this->featureContext->verifyTableNodeColumns($etagTable, ["user", "path"]);
$this->featureContext->verifyTableNodeColumnsCount($etagTable, 2);
$changedEtagCount = 0;
@ -1389,7 +1440,7 @@ class WebDavPropertiesContext implements Context {
* @return void
* @throws Exception
*/
public function theseEtagsShouldHaveChanged(TableNode $etagTable):void {
public function theseEtagsShouldHaveChanged(TableNode $etagTable): void {
$this->featureContext->verifyTableNodeColumns($etagTable, ["user", "path"]);
$this->featureContext->verifyTableNodeColumnsCount($etagTable, 2);
$unchangedEtagCount = 0;
@ -1419,7 +1470,11 @@ class WebDavPropertiesContext implements Context {
* @return void
* @throws Exception
*/
public function etagOfElementOfUserShouldOrShouldNotHaveChanged(string $path, string $user, string $shouldShouldNot):void {
public function etagOfElementOfUserShouldOrShouldNotHaveChanged(
string $path,
string $user,
string $shouldShouldNot
): void {
$user = $this->featureContext->getActualUsername($user);
$actualEtag = $this->getCurrentEtagOfElement($path, $user);
$storedEtag = $this->getStoredEtagOfElement($path, $user, __METHOD__);
@ -1452,7 +1507,7 @@ class WebDavPropertiesContext implements Context {
*
* @return void
*/
public function before(BeforeScenarioScope $scope):void {
public function before(BeforeScenarioScope $scope): void {
// Get the environment
$environment = $scope->getEnvironment();
// Get all the contexts you need in this context