mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-12-03 16:33:38 -05:00
Merge branch 'origin/main' into 'next-release/main'
This commit is contained in:
commit
fe7a662483
8 files changed
+55
-104
No files matched your search
@@ -342,9 +342,9 @@ class CliContext implements Context {
|
||||
* @param string $scope the flags that select the files, e.g. "--all"
|
||||
* @param string $flags e.g. "--strategy 1 --dry-run"
|
||||
*
|
||||
* @return void
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
private function cleanUpFileVersions(string $scope, string $flags): void {
|
||||
private function cleanUpFileVersions(string $scope, string $flags): ResponseInterface {
|
||||
// The test server keeps its file metadata cache in memory, the default, which the command
|
||||
// refuses unless it is allowed: the scenarios check the versions through the API, which
|
||||
// lists them from disk, so the cache of the server going stale doesn't matter here.
|
||||
@@ -352,7 +352,7 @@ class CliContext implements Context {
|
||||
$body = [
|
||||
"command" => $command
|
||||
];
|
||||
$this->featureContext->setResponse(CliHelper::runCommand($body));
|
||||
return CliHelper::runCommand($body);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -363,7 +363,7 @@ class CliContext implements Context {
|
||||
*/
|
||||
#[When('the administrator cleans up the file versions using the CLI with flags :flags')]
|
||||
public function theAdministratorCleansUpTheFileVersionsUsingTheCliWithFlags(string $flags): void {
|
||||
$this->cleanUpFileVersions("", $flags);
|
||||
$this->featureContext->setResponse($this->cleanUpFileVersions("", $flags));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -374,7 +374,7 @@ class CliContext implements Context {
|
||||
*/
|
||||
#[When('the administrator cleans up the file versions of all spaces using the CLI with flags :flags')]
|
||||
public function theAdministratorCleansUpTheFileVersionsOfAllSpacesUsingTheCliWithFlags(string $flags): void {
|
||||
$this->cleanUpFileVersions("--all", $flags);
|
||||
$this->featureContext->setResponse($this->cleanUpFileVersions("--all", $flags));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -392,7 +392,7 @@ class CliContext implements Context {
|
||||
string $flags
|
||||
): void {
|
||||
$spaceId = $this->spacesContext->getSpaceIdByName($user, $space);
|
||||
$this->cleanUpFileVersions("--space $spaceId", $flags);
|
||||
$this->featureContext->setResponse($this->cleanUpFileVersions("--space $spaceId", $flags));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -412,7 +412,7 @@ class CliContext implements Context {
|
||||
string $flags
|
||||
): void {
|
||||
$spaceId = $this->spacesContext->getSpaceIdByName($user, $space);
|
||||
$this->cleanUpFileVersions("--space $spaceId --path $path", $flags);
|
||||
$this->featureContext->setResponse($this->cleanUpFileVersions("--space $spaceId --path $path", $flags));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -431,7 +431,7 @@ class CliContext implements Context {
|
||||
): void {
|
||||
$userUuid = $this->featureContext->getAttributeOfCreatedUser($user, 'id');
|
||||
$fsPath = $this->getUsersStoragePath() . "/$userUuid/" . \ltrim($path, '/');
|
||||
$this->cleanUpFileVersions("--fs-path $fsPath", $flags);
|
||||
$this->featureContext->setResponse($this->cleanUpFileVersions("--fs-path $fsPath", $flags));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -23,6 +23,7 @@ use Behat\Behat\Hook\Scope\BeforeScenarioScope;
|
||||
use Behat\Gherkin\Node\TableNode;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use PHPUnit\Framework\Assert;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use TestHelpers\HttpRequestHelper;
|
||||
use TestHelpers\WebDavHelper;
|
||||
use TestHelpers\CollaborationHelper;
|
||||
@@ -158,11 +159,11 @@ class CollaborationContext implements Context {
|
||||
* @param string $password
|
||||
* @param string $folder
|
||||
*
|
||||
* @return void
|
||||
* @return ResponseInterface
|
||||
* @throws GuzzleException
|
||||
* @throws Exception
|
||||
*/
|
||||
public function createFile(string $file, string $password, string $folder = ""): void {
|
||||
public function createFile(string $file, string $password, string $folder = ""): ResponseInterface {
|
||||
$token = $this->featureContext->shareNgGetLastCreatedLinkShareToken();
|
||||
$baseUrl = $this->featureContext->getBaseUrl();
|
||||
$davPath = WebDavHelper::getDavPath(WebDavHelper::DAV_VERSION_NEW, $token, "public-files");
|
||||
@@ -182,16 +183,14 @@ class CollaborationContext implements Context {
|
||||
$headers = [
|
||||
"Public-Token" => $token
|
||||
];
|
||||
$this->featureContext->setResponse(
|
||||
CollaborationHelper::createFile(
|
||||
$this->featureContext->getBaseUrl(),
|
||||
$this->featureContext->getStepLineRef(),
|
||||
"public",
|
||||
$this->featureContext->getActualPassword($password),
|
||||
$parentContainerId,
|
||||
$file,
|
||||
$headers
|
||||
)
|
||||
return CollaborationHelper::createFile(
|
||||
$this->featureContext->getBaseUrl(),
|
||||
$this->featureContext->getStepLineRef(),
|
||||
"public",
|
||||
$this->featureContext->getActualPassword($password),
|
||||
$parentContainerId,
|
||||
$file,
|
||||
$headers
|
||||
);
|
||||
}
|
||||
|
||||
@@ -209,7 +208,7 @@ class CollaborationContext implements Context {
|
||||
string $file,
|
||||
string $password
|
||||
): void {
|
||||
$this->createFile($file, $password);
|
||||
$this->featureContext->setResponse($this->createFile($file, $password));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -228,7 +227,7 @@ class CollaborationContext implements Context {
|
||||
string $folder,
|
||||
string $password
|
||||
): void {
|
||||
$this->createFile($file, $password, $folder);
|
||||
$this->featureContext->setResponse($this->createFile($file, $password, $folder));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -3203,16 +3203,13 @@ class GraphContext implements Context {
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
public function markFavorite(string $user, string $itemId): ResponseInterface {
|
||||
$response = GraphHelper::markFavorite(
|
||||
return GraphHelper::markFavorite(
|
||||
$this->featureContext->getBaseUrl(),
|
||||
$this->featureContext->getStepLineRef(),
|
||||
$user,
|
||||
$this->featureContext->getPasswordForUser($user),
|
||||
$itemId
|
||||
);
|
||||
|
||||
$this->featureContext->setResponse($response);
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3222,15 +3219,13 @@ class GraphContext implements Context {
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
public function unmarkFavorite(string $user, string $itemId): ResponseInterface {
|
||||
$response = GraphHelper::unmarkFavorite(
|
||||
return GraphHelper::unmarkFavorite(
|
||||
$this->featureContext->getBaseUrl(),
|
||||
$this->featureContext->getStepLineRef(),
|
||||
$user,
|
||||
$this->featureContext->getPasswordForUser($user),
|
||||
$itemId
|
||||
);
|
||||
$this->featureContext->setResponse($response);
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3252,7 +3247,7 @@ class GraphContext implements Context {
|
||||
$itemId = ($item === 'file')
|
||||
? $this->spacesContext->getFileId($user, $spaceName, $itemName)
|
||||
: $this->spacesContext->getResourceId($user, $spaceName, $itemName);
|
||||
$this->markFavorite($user, $itemId);
|
||||
$this->featureContext->setResponse($this->markFavorite($user, $itemId));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3274,7 +3269,7 @@ class GraphContext implements Context {
|
||||
$itemId = ($item === 'file')
|
||||
? $this->spacesContext->getFileId($user, $spaceName, $itemName)
|
||||
: $this->spacesContext->getResourceId($user, $spaceName, $itemName);
|
||||
$this->unmarkFavorite($user, $itemId);
|
||||
$this->featureContext->setResponse($this->unmarkFavorite($user, $itemId));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3340,24 +3335,6 @@ class GraphContext implements Context {
|
||||
return \implode('/', $encoded);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a Graph API request and capture the response on FeatureContext.
|
||||
*
|
||||
* @param string $user
|
||||
* @param string $method
|
||||
* @param string $relativeUrl
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function sendGraphRequestAndCaptureResponse(
|
||||
string $user,
|
||||
string $method,
|
||||
string $relativeUrl
|
||||
): void {
|
||||
$response = $this->featureContext->sendingToWithDirectUrl($user, $method, $relativeUrl);
|
||||
$this->featureContext->setResponse($response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hits /graph/{version}/drives/{driveID}/root:/{path}, exercising the
|
||||
* colon-syntax path lookup middleware (root-anchored, no suffix).
|
||||
@@ -3379,7 +3356,7 @@ class GraphContext implements Context {
|
||||
$driveId = $this->spacesContext->getSpaceIdByName($user, $spaceName);
|
||||
$encoded = $this->encodeColonPathSegment($path);
|
||||
$url = "/graph/$apiVersion/drives/$driveId/root:/$encoded";
|
||||
$this->sendGraphRequestAndCaptureResponse($user, "GET", $url);
|
||||
$this->featureContext->setResponse($this->featureContext->sendingToWithDirectUrl($user, "GET", $url));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3403,7 +3380,7 @@ class GraphContext implements Context {
|
||||
$driveId = $this->spacesContext->getSpaceIdByName($user, $spaceName);
|
||||
$encoded = $this->encodeColonPathSegment($path);
|
||||
$url = "/graph/$apiVersion/drives/$driveId/root:/$encoded:";
|
||||
$this->sendGraphRequestAndCaptureResponse($user, "GET", $url);
|
||||
$this->featureContext->setResponse($this->featureContext->sendingToWithDirectUrl($user, "GET", $url));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3430,7 +3407,7 @@ class GraphContext implements Context {
|
||||
$folderId = $this->spacesContext->getResourceId($user, $spaceName, $folderName);
|
||||
$encoded = $this->encodeColonPathSegment($relPath);
|
||||
$url = "/graph/$apiVersion/drives/$driveId/items/$folderId:/$encoded";
|
||||
$this->sendGraphRequestAndCaptureResponse($user, "GET", $url);
|
||||
$this->featureContext->setResponse($this->featureContext->sendingToWithDirectUrl($user, "GET", $url));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3455,7 +3432,7 @@ class GraphContext implements Context {
|
||||
$driveId = $this->spacesContext->getSpaceIdByName($user, $spaceName);
|
||||
$encoded = $this->encodeColonPathSegment($path);
|
||||
$url = "/graph/$apiVersion/drives/$driveId/root:/$encoded:/permissions";
|
||||
$this->sendGraphRequestAndCaptureResponse($user, "GET", $url);
|
||||
$this->featureContext->setResponse($this->featureContext->sendingToWithDirectUrl($user, "GET", $url));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3482,7 +3459,7 @@ class GraphContext implements Context {
|
||||
$driveId = $this->spacesContext->getSpaceIdByName($owner, "Personal");
|
||||
$encoded = $this->encodeColonPathSegment($path);
|
||||
$url = "/graph/$apiVersion/drives/$driveId/root:/$encoded";
|
||||
$this->sendGraphRequestAndCaptureResponse($user, "GET", $url);
|
||||
$this->featureContext->setResponse($this->featureContext->sendingToWithDirectUrl($user, "GET", $url));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -13,7 +13,6 @@ use GuzzleHttp\Exception\GuzzleException;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use TestHelpers\EmailHelper;
|
||||
use TestHelpers\OcsApiHelper;
|
||||
use TestHelpers\GraphHelper;
|
||||
use TestHelpers\SettingsHelper;
|
||||
use TestHelpers\BehatHelper;
|
||||
use Behat\Step\Given;
|
||||
@@ -397,7 +396,6 @@ class NotificationContext implements Context {
|
||||
if ($count > 0) {
|
||||
\sleep(1);
|
||||
}
|
||||
$this->featureContext->setResponse(null);
|
||||
$response = $this->listAllNotifications($user);
|
||||
$this->featureContext->theHTTPStatusCodeShouldBe(200, "", $response);
|
||||
++$count;
|
||||
@@ -571,15 +569,6 @@ class NotificationContext implements Context {
|
||||
PyStringNode $content
|
||||
): void {
|
||||
$rawExpectedEmailBodyContent = \str_replace("\r\n", "\n", $content->getRaw());
|
||||
$this->featureContext->setResponse(
|
||||
GraphHelper::getMySpaces(
|
||||
$this->featureContext->getBaseUrl(),
|
||||
$user,
|
||||
$this->featureContext->getPasswordForUser($user),
|
||||
'',
|
||||
$this->featureContext->getStepLineRef()
|
||||
)
|
||||
);
|
||||
$expectedEmailBodyContent = $this->featureContext->substituteInLineCodes(
|
||||
$rawExpectedEmailBodyContent,
|
||||
$sender,
|
||||
|
||||
@@ -1073,14 +1073,14 @@ class SpacesContext implements Context {
|
||||
TableNode $expectedFiles
|
||||
): void {
|
||||
$space = $this->getSpaceByName($user, $spaceName);
|
||||
$this->featureContext->setResponse($this->propfindSpace($user, $spaceName));
|
||||
$this->featureContext->propfindResultShouldContainEntries(
|
||||
$shouldOrNot,
|
||||
$expectedFiles,
|
||||
$user,
|
||||
'PROPFIND',
|
||||
'',
|
||||
$space['id']
|
||||
$space['id'],
|
||||
$this->propfindSpace($user, $spaceName)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1105,14 +1105,14 @@ class SpacesContext implements Context {
|
||||
TableNode $expectedFiles
|
||||
): void {
|
||||
$space = $this->getSpaceByName($user, $spaceName);
|
||||
$this->featureContext->setResponse($this->propfindSpace($user, $spaceName, $folderPath));
|
||||
$this->featureContext->propfindResultShouldContainEntries(
|
||||
$shouldOrNot,
|
||||
$expectedFiles,
|
||||
$this->featureContext->getActualUsername($user),
|
||||
'PROPFIND',
|
||||
$folderPath,
|
||||
$space['id']
|
||||
$space['id'],
|
||||
$this->propfindSpace($user, $spaceName, $folderPath)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2525,7 +2525,7 @@ class SpacesContext implements Context {
|
||||
* @throws GuzzleException
|
||||
* @return void
|
||||
*/
|
||||
#[Given('user :user renames file with id :fileId to :destinationFile inside space :spaceName')]
|
||||
#[When('user :user renames file with id :fileId to :destinationFile inside space :spaceName')]
|
||||
public function userRenamesFileWithIdToInsideSpace(
|
||||
string $user,
|
||||
string $fileId,
|
||||
|
||||
@@ -136,14 +136,13 @@ class TrashbinContext implements Context {
|
||||
* @param string|null $user user
|
||||
* @param string $depth
|
||||
*
|
||||
* @return array response
|
||||
* @return ResponseInterface
|
||||
* @throws Exception
|
||||
*/
|
||||
public function listTopOfTrashbinFolder(?string $user, string $depth = "1"): array {
|
||||
public function listTopOfTrashbinFolder(?string $user, string $depth = "1"): ResponseInterface {
|
||||
$password = $this->featureContext->getPasswordForUser($user);
|
||||
$davPathVersion = $this->featureContext->getDavPathVersion();
|
||||
|
||||
$suffixPath = $user;
|
||||
$spaceId = null;
|
||||
if ($davPathVersion === WebDavHelper::DAV_VERSION_SPACES) {
|
||||
$spaceId = WebDavHelper::getPersonalSpaceIdForUser(
|
||||
@@ -152,9 +151,8 @@ class TrashbinContext implements Context {
|
||||
$password,
|
||||
$this->featureContext->getStepLineRef()
|
||||
);
|
||||
$suffixPath = $spaceId;
|
||||
}
|
||||
$response = WebDavHelper::listFolder(
|
||||
return WebDavHelper::listFolder(
|
||||
$this->featureContext->getBaseUrl(),
|
||||
$user,
|
||||
$password,
|
||||
@@ -171,23 +169,6 @@ class TrashbinContext implements Context {
|
||||
'trash-bin',
|
||||
$davPathVersion
|
||||
);
|
||||
$this->featureContext->setResponse($response);
|
||||
|
||||
$files = $this->getTrashbinContentFromResponseXml(
|
||||
HttpRequestHelper::getResponseXml(
|
||||
$response,
|
||||
__METHOD__
|
||||
)
|
||||
);
|
||||
// filter root element
|
||||
$files = \array_filter(
|
||||
$files,
|
||||
static function ($element) use ($davPathVersion, $suffixPath) {
|
||||
$davPath = WebDavHelper::getDavPath($davPathVersion, $suffixPath, "trash-bin");
|
||||
return ($element['href'] !== "/" . $davPath . "/");
|
||||
}
|
||||
);
|
||||
return $files;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -335,7 +316,7 @@ class TrashbinContext implements Context {
|
||||
*/
|
||||
#[When('user :user lists the resources in the trashbin with depth :depth using the WebDAV API')]
|
||||
public function userGetsFilesInTheTrashbinWithDepthUsingTheWebdavApi(string $user, string $depth): void {
|
||||
$this->listTopOfTrashbinFolder($user, $depth);
|
||||
$this->featureContext->setResponse($this->listTopOfTrashbinFolder($user, $depth));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -3625,9 +3625,8 @@ trait WebDav {
|
||||
} else {
|
||||
$response = $this->downloadPreviews($user, $path, null, $width, $height);
|
||||
}
|
||||
$this->setResponse($response);
|
||||
$this->theHTTPStatusCodeShouldBe(200, '', $response);
|
||||
$this->checkImageDimensions($width, $height);
|
||||
$this->checkImageDimensions($width, $height, $response);
|
||||
$response->getBody()->rewind();
|
||||
// save response to user response dictionary for further comparisons
|
||||
$this->setFilePreviewContent($user, $response->getBody()->getContents());
|
||||
@@ -3654,9 +3653,8 @@ trait WebDav {
|
||||
} else {
|
||||
$response = $this->downloadPreviews($user, $path, null, $width, $height);
|
||||
}
|
||||
$this->setResponse($response);
|
||||
$this->theHTTPStatusCodeShouldBe(200, '', $response);
|
||||
$newResponseBodyContents = $this->response->getBody()->getContents();
|
||||
$newResponseBodyContents = $response->getBody()->getContents();
|
||||
Assert::assertNotEquals(
|
||||
$newResponseBodyContents,
|
||||
// different users can download files before and after an update is made to a file
|
||||
@@ -3984,6 +3982,7 @@ trait WebDav {
|
||||
* @param string|null $method
|
||||
* @param string|null $folderpath
|
||||
* @param string|null $spaceId
|
||||
* @param ResponseInterface|null $response PROPFIND response to check, defaults to the last response
|
||||
*
|
||||
* @return void
|
||||
* @throws GuzzleException
|
||||
@@ -3994,7 +3993,8 @@ trait WebDav {
|
||||
?string $user = null,
|
||||
?string $method = 'REPORT',
|
||||
?string $folderpath = '',
|
||||
?string $spaceId = null
|
||||
?string $spaceId = null,
|
||||
?ResponseInterface $response = null
|
||||
): void {
|
||||
$folderpath = \trim($folderpath, "/");
|
||||
$this->verifyTableNodeColumnsCount($expectedFiles, 1);
|
||||
@@ -4021,7 +4021,8 @@ trait WebDav {
|
||||
$user,
|
||||
"files",
|
||||
$folderpath,
|
||||
$spaceId
|
||||
$spaceId,
|
||||
$response
|
||||
);
|
||||
}
|
||||
if ($should) {
|
||||
@@ -4352,13 +4353,15 @@ trait WebDav {
|
||||
* and returns multistatus data from the response
|
||||
*
|
||||
* @param string|null $user
|
||||
* @param ResponseInterface|null $response defaults to the last response
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getMultiStatusResultFromPropfindResult(
|
||||
?string $user = null
|
||||
?string $user = null,
|
||||
?ResponseInterface $response = null
|
||||
): array {
|
||||
$responseXmlArray = HttpRequestHelper::parseResponseAsXml($this->response);
|
||||
$responseXmlArray = HttpRequestHelper::parseResponseAsXml($response ?? $this->response);
|
||||
|
||||
Assert::assertNotEmpty($responseXmlArray, __METHOD__ . ' Response is empty');
|
||||
if ($user === null) {
|
||||
@@ -4403,6 +4406,7 @@ trait WebDav {
|
||||
* @param string $type
|
||||
* @param string $folderPath
|
||||
* @param string|null $spaceId
|
||||
* @param ResponseInterface|null $response defaults to the last response
|
||||
*
|
||||
* @return string|array|boolean
|
||||
*
|
||||
@@ -4417,7 +4421,8 @@ trait WebDav {
|
||||
?string $user = null,
|
||||
string $type = "files",
|
||||
string $folderPath = '',
|
||||
?string $spaceId = null
|
||||
?string $spaceId = null,
|
||||
?ResponseInterface $response = null
|
||||
) {
|
||||
$trimmedEntryNameToSearch = '';
|
||||
// trim any leading "/" passed by the caller, we can just match the "raw" name
|
||||
@@ -4438,7 +4443,7 @@ trait WebDav {
|
||||
throw new Exception("error");
|
||||
}
|
||||
|
||||
$multistatusResults = $this->getMultiStatusResultFromPropfindResult($user);
|
||||
$multistatusResults = $this->getMultiStatusResultFromPropfindResult($user, $response);
|
||||
|
||||
$results = [];
|
||||
foreach ($multistatusResults as $multistatusResult) {
|
||||
|
||||
@@ -344,7 +344,7 @@ class WebDavPropertiesContext implements Context {
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
#[Given('/^user "([^"]*)" sets property "([^"]*)" of (?:file|folder|entry) "([^"]*)" to "([^"]*)"$/')]
|
||||
#[When('/^user "([^"]*)" sets property "([^"]*)" of (?:file|folder|entry) "([^"]*)" to "([^"]*)"$/')]
|
||||
public function userSetsPropertyOfEntryTo(
|
||||
string $user,
|
||||
string $propertyName,
|
||||
|
||||
Reference in new issue
Block a user