ci: make remote.php default

docs: add documentation

test: rename uniquePath to suffixPath
This commit is contained in:
Saw-jan
2024-10-21 17:08:25 +05:45
parent f86d137f87
commit 766ad4b40c
15 changed files with 151 additions and 109 deletions
+5 -5
View File
@@ -81,7 +81,7 @@ class AuthContext implements Context {
$trimmedUrl = \ltrim($url, '/');
$slashCount = \strlen($url) - \strlen($trimmedUrl);
if (WebdavHelper::isDAVRequest($url)) {
$url = WebdavHelper::withRemotePhp($trimmedUrl);
$url = WebdavHelper::prefixRemotePhp($trimmedUrl);
}
$url = \str_repeat("/", $slashCount) . $url;
$fullUrl = $this->featureContext->getBaseUrl() . "/$url";
@@ -403,7 +403,7 @@ class AuthContext implements Context {
$row['destination'],
$ofUser
);
$headers['Destination'] = $this->featureContext->getBaseUrl() . "/" . WebdavHelper::withRemotePhp(\ltrim($destination, "/"));
$headers['Destination'] = $this->featureContext->getBaseUrl() . "/" . WebdavHelper::prefixRemotePhp(\ltrim($destination, "/"));
}
$response = $this->sendRequest(
$row['endpoint'],
@@ -453,7 +453,7 @@ class AuthContext implements Context {
$row['destination'],
$ofUser
);
$headers['Destination'] = $this->featureContext->getBaseUrl() . "/" . WebdavHelper::withRemotePhp(\ltrim($destination, "/"));
$headers['Destination'] = $this->featureContext->getBaseUrl() . "/" . WebdavHelper::prefixRemotePhp(\ltrim($destination, "/"));
}
$response = $this->sendRequest(
$row['endpoint'],
@@ -596,7 +596,7 @@ class AuthContext implements Context {
$suffix = $this->featureContext->spacesContext->getSpaceIdByName($user, "Personal");
}
$davPath = WebDavHelper::getDavPath($this->featureContext->getDavPathVersion(), $user);
$headers['Destination'] = "{$baseUrl}/{$davPath}/{$suffix}/moved";
$headers['Destination'] = "$baseUrl/$davPath/$suffix/moved";
}
foreach ($table->getHash() as $row) {
@@ -637,7 +637,7 @@ class AuthContext implements Context {
);
$endpoint = \ltrim($endpoint, '/');
if (WebdavHelper::isDAVRequest($endpoint)) {
$endpoint = WebdavHelper::withRemotePhp($endpoint);
$endpoint = WebdavHelper::prefixRemotePhp($endpoint);
}
$fullUrl = $this->featureContext->getBaseUrl() . "/$endpoint";
$response = HttpRequestHelper::sendRequestOnce(
@@ -1450,7 +1450,7 @@ class FeatureContext extends BehatVariablesContext {
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::withRemotePhp($url);
$url = WebdavHelper::prefixRemotePhp($url);
}
$fullUrl = $this->getBaseUrl() . "/$url";
@@ -2112,7 +2112,7 @@ class FeatureContext extends BehatVariablesContext {
public function getCommentUrlRegExp(): string {
$basePath = \ltrim($this->getBasePath() . "/", "/");
$commentsPath = WebDAVHelper::getDavPath(WebDavHelper::DAV_VERSION_NEW, null, "comments");
return "/{$basePath}/{$commentsPath}/([0-9]+)";
return "/$basePath/$commentsPath/([0-9]+)";
}
/**
+1 -1
View File
@@ -3248,7 +3248,7 @@ trait Sharing {
public function getPublicPreviewOfFile(string $fileName, string $token):ResponseInterface {
$baseUrl = $this->getBaseUrl();
$davPath = WebdavHelper::getDavPath($this->getDavPathVersion(), $token, "public-files");
$url = "{$baseUrl}/{$davPath}/$fileName?preview=1";
$url = "$baseUrl/$davPath/$fileName?preview=1";
return HttpRequestHelper::get(
$url,
$this->getStepLineRef()
+19 -19
View File
@@ -269,7 +269,7 @@ class SpacesContext implements Context {
$space = $this->getSpaceByName($user, $spaceName);
$baseUrl = $this->featureContext->getBaseUrl();
$davPath = WebdavHelper::getDavPath(WebDavHelper::DAV_VERSION_SPACES, $space["id"]);
$fullUrl = "{$baseUrl}/{$davPath}/{$fileName}";
$fullUrl = "$baseUrl/$davPath/$fileName";
return HttpRequestHelper::get(
$fullUrl,
@@ -316,7 +316,7 @@ class SpacesContext implements Context {
$encodedName = \rawurlencode($folderName);
$baseUrl = $this->featureContext->getBaseUrl();
$davPath = WebDavHelper::getDavPath(WebDavHelper::DAV_VERSION_SPACES, $space["id"]);
$fullUrl = "{$baseUrl}/{$davPath}/{$encodedName}";
$fullUrl = "$baseUrl/$davPath/$encodedName";
$response = HttpRequestHelper::sendRequest(
$fullUrl,
@@ -1701,7 +1701,7 @@ class SpacesContext implements Context {
$encodedName = \rawurlencode(ltrim($fileSource, "/"));
$baseUrl = $this->featureContext->getBaseUrl();
$davPath = WebdavHelper::getDavPath(WebDavHelper::DAV_VERSION_SPACES, $space["id"]);
$fullUrl = "{$baseUrl}/{$davPath}/{$encodedName}";
$fullUrl = "$baseUrl/$davPath/$encodedName";
$this->featureContext->setResponse($this->copyFilesAndFoldersRequest($user, $fullUrl, $headers));
}
@@ -1732,7 +1732,7 @@ class SpacesContext implements Context {
$encodedName = \rawurlencode(ltrim($fileSource, "/"));
$baseUrl = $this->featureContext->getBaseUrl();
$davPath = WebdavHelper::getDavPath(WebDavHelper::DAV_VERSION_SPACES, $space["id"]);
$fullUrl = "{$baseUrl}/{$davPath}/{$encodedName}";
$fullUrl = "$baseUrl/$davPath/$encodedName";
return $this->moveFilesAndFoldersRequest($user, $fullUrl, $headers);
}
@@ -1849,7 +1849,7 @@ class SpacesContext implements Context {
$encodedName = \rawurlencode(ltrim($fileSource, "/"));
$baseUrl = $this->featureContext->getBaseUrl();
$davPath = WebdavHelper::getDavPath(WebDavHelper::DAV_VERSION_SPACES, $space["id"]);
$fullUrl = "{$baseUrl}/{$davPath}/{$encodedName}";
$fullUrl = "$baseUrl/$davPath/$encodedName";
$this->featureContext->setResponse($this->copyFilesAndFoldersRequest($user, $fullUrl, $headers));
}
@@ -1882,7 +1882,7 @@ class SpacesContext implements Context {
$encodedName = \rawurlencode(ltrim($fileSource, "/"));
$baseUrl = $this->featureContext->getBaseUrl();
$davPath = WebdavHelper::getDavPath(WebDavHelper::DAV_VERSION_SPACES, $space["id"]);
$fullUrl = "{$baseUrl}/{$davPath}/{$encodedName}";
$fullUrl = "$baseUrl/$davPath/$encodedName";
if ($action === 'copying') {
$response = $this->copyFilesAndFoldersRequest($user, $fullUrl, $headers);
@@ -1950,7 +1950,7 @@ class SpacesContext implements Context {
$encodedName = \rawurlencode(ltrim($fileSource, "/"));
$baseUrl = $this->featureContext->getBaseUrl();
$davPath = WebdavHelper::getDavPath(WebDavHelper::DAV_VERSION_SPACES, $space["id"]);
$fullUrl = "{$baseUrl}/{$davPath}/{$encodedName}";
$fullUrl = "$baseUrl/$davPath/$encodedName";
$this->featureContext->setResponse($this->moveFilesAndFoldersRequest($user, $fullUrl, $headers));
$this->featureContext->pushToLastHttpStatusCodesArray();
@@ -1972,7 +1972,7 @@ class SpacesContext implements Context {
$fileDestination = $this->escapePath(\ltrim($fileDestination, "/"));
$baseUrl = $this->featureContext->getBaseUrl();
$davPath = WebdavHelper::getDavPath(WebDavHelper::DAV_VERSION_SPACES, $space["id"]);
return "{$baseUrl}/{$davPath}/{$fileDestination}";
return "$baseUrl/$davPath/$fileDestination";
}
/**
@@ -2062,11 +2062,11 @@ class SpacesContext implements Context {
$source = \trim($source, "/");
$baseUrl = $this->featureContext->getBaseUrl();
$davPathVersion = $this->featureContext->getDavPathVersion();
$uniquePath = $user;
$suffixPath = $user;
if ($davPathVersion === WebDavHelper::DAV_VERSION_SPACES) {
$uniquePath = $this->getSpaceIdByName($user, $sourceSpace);
$suffixPath = $this->getSpaceIdByName($user, $sourceSpace);
}
$sourceDavPath = WebDavHelper::getDavPath($davPathVersion, $uniquePath);
$sourceDavPath = WebDavHelper::getDavPath($davPathVersion, $suffixPath);
$fullUrl = "$baseUrl/$sourceDavPath/$source";
if ($destinationType === "space") {
@@ -2553,7 +2553,7 @@ class SpacesContext implements Context {
$encodedName = \rawurlencode(ltrim($object, "/"));
$baseUrl = $this->featureContext->getBaseUrl();
$davPath = WebdavHelper::getDavPath(WebDavHelper::DAV_VERSION_SPACES, $space["id"]);
$fullUrl = "{$baseUrl}/{$davPath}/{$encodedName}";
$fullUrl = "$baseUrl/$davPath/$encodedName";
return HttpRequestHelper::delete(
$fullUrl,
@@ -2819,7 +2819,7 @@ class SpacesContext implements Context {
$space = $this->getSpaceByName($user, $spaceName);
$baseUrl = $this->featureContext->getBaseUrl();
$davPath = WebDavHelper::getDavPath(WebDavHelper::DAV_VERSION_SPACES, $space["id"], "trash-bin");
$fullUrl = "{$baseUrl}/{$davPath}";
$fullUrl = "$baseUrl/$davPath";
return HttpRequestHelper::sendRequest(
$fullUrl,
$this->featureContext->getStepLineRef(),
@@ -2864,7 +2864,7 @@ class SpacesContext implements Context {
$space = $this->getSpaceByName($this->featureContext->getAdminUserName(), $spaceName);
$baseUrl = $this->featureContext->getBaseUrl();
$davPath = WebDavHelper::getDavPath(WebDavHelper::DAV_VERSION_SPACES, $space["id"], "trash-bin");
$fullUrl = "{$baseUrl}/{$davPath}";
$fullUrl = "$baseUrl/$davPath";
$this->featureContext->setResponse(
HttpRequestHelper::sendRequest($fullUrl, $this->featureContext->getStepLineRef(), 'PROPFIND', $user, $this->featureContext->getPasswordForUser($user))
);
@@ -2971,7 +2971,7 @@ class SpacesContext implements Context {
$baseUrl = $this->featureContext->getBaseUrl();
$davPath = WebDavHelper::getDavPath(WebDavHelper::DAV_VERSION_SPACES, $space["id"]);
$destination = "{$baseUrl}/{$davPath}/{$destination}";
$destination = "$baseUrl/$davPath/$destination";
$header = ["Destination" => $destination, "Overwrite" => "F"];
$fullUrl = $baseUrl . $pathToDeletedObject;
@@ -3067,7 +3067,7 @@ class SpacesContext implements Context {
$baseUrl = $this->featureContext->getBaseUrl();
$davPath = WebDavHelper::getDavPath(WebDavHelper::DAV_VERSION_SPACES, $space["id"]);
$fullUrl = "{$baseUrl}/{$davPath}/{$fileName}?{$urlParameters}";
$fullUrl = "$baseUrl/$davPath/$fileName?$urlParameters";
$this->featureContext->setResponse(
HttpRequestHelper::get(
$fullUrl,
@@ -3648,13 +3648,13 @@ class SpacesContext implements Context {
$space = $this->getSpaceByName($user, $spaceName);
$spaceId = $space['id'];
}
$uniquePath = $user;
$suffixPath = $user;
$davPathVersion = $this->featureContext->getDavPathVersion();
if ($davPathVersion === WebDavHelper::DAV_VERSION_SPACES) {
$uniquePath = $spaceId;
$suffixPath = $spaceId;
}
$topWebDavPath = "/" . WebDavHelper::getDavPath($davPathVersion, $uniquePath);
$topWebDavPath = "/" . WebDavHelper::getDavPath($davPathVersion, $suffixPath);
$spaceFound = false;
foreach ($responseArray as $value) {
+3 -3
View File
@@ -306,13 +306,13 @@ class TUSContext implements Context {
);
$davPathVersion = $this->featureContext->getDavPathVersion();
$uniquePath = $user;
$suffixPath = $user;
if ($davPathVersion === WebDavHelper::DAV_VERSION_SPACES) {
$uniquePath = $spaceId ?: $this->featureContext->getPersonalSpaceIdForUser($user);
$suffixPath = $spaceId ?: $this->featureContext->getPersonalSpaceIdForUser($user);
}
$client->setChecksumAlgorithm('sha1');
$client->setApiPath(WebDavHelper::getDavPath($davPathVersion, $uniquePath));
$client->setApiPath(WebDavHelper::getDavPath($davPathVersion, $suffixPath));
$client->setMetadata($uploadMetadata);
$sourceFile = $this->featureContext->acceptanceTestsDirLocation() . $source;
$client->setKey((string)rand())->file($sourceFile, $destination);
+12 -12
View File
@@ -149,7 +149,7 @@ class TrashbinContext implements Context {
$password = $this->featureContext->getPasswordForUser($user);
$davPathVersion = $this->featureContext->getDavPathVersion();
$uniquePath = $user;
$suffixPath = $user;
$spaceId = null;
if ($davPathVersion === WebDavHelper::DAV_VERSION_SPACES) {
$spaceId = WebDavHelper::getPersonalSpaceIdForUser(
@@ -158,7 +158,7 @@ class TrashbinContext implements Context {
$password,
$this->featureContext->getStepLineRef()
);
$uniquePath = $spaceId;
$suffixPath = $spaceId;
}
$response = WebDavHelper::listFolder(
$this->featureContext->getBaseUrl(),
@@ -188,8 +188,8 @@ class TrashbinContext implements Context {
// filter root element
$files = \array_filter(
$files,
static function ($element) use ($davPathVersion, $uniquePath) {
$davPath = WebDavHelper::getDavPath($davPathVersion, $uniquePath, "trash-bin");
static function ($element) use ($davPathVersion, $suffixPath) {
$davPath = WebDavHelper::getDavPath($davPathVersion, $suffixPath, "trash-bin");
return ($element['href'] !== "/" . $davPath . "/");
}
);
@@ -260,16 +260,16 @@ class TrashbinContext implements Context {
$files = $this->getTrashbinContentFromResponseXml($responseXml);
$uniquePath = $user;
$suffixPath = $user;
if ($davPathVersion === WebDavHelper::DAV_VERSION_SPACES) {
$uniquePath = WebDavHelper::getPersonalSpaceIdForUser(
$suffixPath = WebDavHelper::getPersonalSpaceIdForUser(
$this->featureContext->getBaseUrl(),
$user,
$this->featureContext->getPasswordForUser($user),
$this->featureContext->getStepLineRef()
);
}
$endpoint = WebDavHelper::getDavPath($davPathVersion, $uniquePath, "trash-bin");
$endpoint = WebDavHelper::getDavPath($davPathVersion, $suffixPath, "trash-bin");
// filter out the collection itself, we only want to return the members
$files = \array_filter(
@@ -791,13 +791,13 @@ class TrashbinContext implements Context {
$baseUrl = $this->featureContext->getBaseUrl();
$davPathVersion = $this->featureContext->getDavPathVersion();
$uniquePath = $asUser;
$suffixPath = $asUser;
if ($davPathVersion === WebDavHelper::DAV_VERSION_SPACES) {
if (\str_starts_with($destinationPath, "Shares/")) {
$uniquePath = $this->featureContext->spacesContext->getSpaceIdByName($user, "Shares");
$suffixPath = $this->featureContext->spacesContext->getSpaceIdByName($user, "Shares");
$destinationPath = \str_replace("Shares/", "", $destinationPath);
} else {
$uniquePath = WebDavHelper::getPersonalSpaceIdForUser(
$suffixPath = WebDavHelper::getPersonalSpaceIdForUser(
$baseUrl,
$asUser,
$password,
@@ -805,8 +805,8 @@ class TrashbinContext implements Context {
);
}
}
$destinationDavPath = WebDavHelper::getDavPath($davPathVersion, $uniquePath);
$destination = "{$baseUrl}/{$destinationDavPath}/{$destinationPath}";
$destinationDavPath = WebDavHelper::getDavPath($davPathVersion, $suffixPath);
$destination = "$baseUrl/$destinationDavPath/$destinationPath";
$trashItemHRef = \ltrim($this->convertTrashbinHref($trashItemHRef), "/");
$headers['Destination'] = $destination;
+12 -12
View File
@@ -235,13 +235,13 @@ trait WebDav {
}
$davPathVersion = $this->getDavPathVersion();
$uniquePath = $user;
$suffixPath = $user;
if ($davPathVersion === WebDavHelper::DAV_VERSION_SPACES) {
$uniquePath = $spaceId;
$suffixPath = $spaceId;
}
$davPath = WebDavHelper::getDavPath($davPathVersion, $uniquePath);
$path = "{$this->getBasePath()}/{$davPath}";
$davPath = WebDavHelper::getDavPath($davPathVersion, $suffixPath);
$path = "{$this->getBasePath()}/$davPath";
$path = WebDavHelper::sanitizeUrl($path);
return \ltrim($path, "/");
}
@@ -253,7 +253,7 @@ trait WebDav {
*/
public function getPublicLinkDavPath(string $token):string {
$davPath = WebDavHelper::getDavPath($this->getDavPathVersion(), $token, "public-files");
$path = "{$this->getBasePath()}/{$davPath}";
$path = "{$this->getBasePath()}/$davPath";
$path = WebDavHelper::sanitizeUrl($path);
return \ltrim($path, "/");
}
@@ -484,12 +484,12 @@ trait WebDav {
}
$davPathVersion = $this->getDavPathVersion();
$uniquePath = $user;
$suffixPath = $user;
if ($davPathVersion === WebDavHelper::DAV_VERSION_SPACES) {
$uniquePath = $spaceId;
$suffixPath = $spaceId;
}
$davPath = WebDavHelper::getDavPath($davPathVersion, $uniquePath);
$davPath = WebDavHelper::getDavPath($davPathVersion, $suffixPath);
$fullUrl = $this->getBaseUrl() . "/$davPath";
return \rtrim($fullUrl, '/') . '/' . $fileDestination;
}
@@ -1114,7 +1114,7 @@ trait WebDav {
public function publicGetsSizeOfLastSharedPublicLinkUsingTheWebdavApi():void {
$token = ($this->isUsingSharingNG()) ? $this->shareNgGetLastCreatedLinkShareToken() : $this->getLastCreatedPublicShareToken();
$davPath = WebDavHelper::getDavPath($this->getDavPathVersion(), $token, "public-files");
$url = "{$this->getBaseUrl()}/{$davPath}";
$url = "{$this->getBaseUrl()}/$davPath";
$this->response = HttpRequestHelper::sendRequest(
$url,
$this->getStepLineRef(),
@@ -3849,13 +3849,13 @@ trait WebDav {
}
$davPathVersion = $this->getDavPathVersion();
$uniquePath = $user;
$suffixPath = $user;
if ($davPathVersion === WebDavHelper::DAV_VERSION_SPACES) {
$uniquePath = $this->getSharesMountPath($user, $path);
$suffixPath = $this->getSharesMountPath($user, $path);
$path = "";
}
$path = \ltrim($path, "/");
$davPath = WebDavHelper::getDavPath($this->getDavPathVersion(), $uniquePath);
$davPath = WebDavHelper::getDavPath($this->getDavPathVersion(), $suffixPath);
$davPath = \rtrim($davPath, "/");
$fullUrl = $this->getBaseUrl() . "/$davPath/$path?$urlParameter";
@@ -197,12 +197,12 @@ class WebDavLockingContext implements Context {
$spaceId = $this->spacesContext->getSpaceIdByName($user, $space);
$baseUrl = $this->featureContext->getBaseUrl();
$davPathVersion = $this->featureContext->getDavPathVersion();
$uniquePath = $user;
$suffixPath = $user;
if ($davPathVersion === WebDavHelper::DAV_VERSION_SPACES) {
$uniquePath = $spaceId;
$suffixPath = $spaceId;
}
$davPath = WebDavHelper::getDavPath($davPathVersion, $uniquePath);
$davPath = WebDavHelper::getDavPath($davPathVersion, $suffixPath);
$fullUrl = "$baseUrl/$davPath/$file";
return $this->lockFile($user, $file, $properties, $fullUrl, false, true, $spaceId);
}
@@ -236,12 +236,12 @@ class WebDavLockingContext implements Context {
public function userTriesToLockFileInProjectSpaceUsingWebDavAPI(string $user, string $file, string $space, TableNode $properties) {
$spaceId = $this->spacesContext->getSpaceIdByName($user, $space);
$davPathVersion = $this->featureContext->getDavPathVersion();
$uniquePath = $user;
$suffixPath = $user;
if ($davPathVersion === WebDavHelper::DAV_VERSION_SPACES) {
$uniquePath = $spaceId;
$suffixPath = $spaceId;
}
$davPath = WebdavHelper::getDavPath($davPathVersion, $uniquePath);
$davPath = WebdavHelper::getDavPath($davPathVersion, $suffixPath);
$fullUrl = $this->featureContext->getBaseUrl() . "/$davPath/$file";
$response = $this->lockFile($user, $file, $properties, $fullUrl, false, false, $spaceId);
$this->featureContext->setResponse($response);
@@ -728,7 +728,7 @@ class WebDavPropertiesContext implements Context {
public function valueOfItemOfPathShouldBe(string $user, string $xpath, string $path, string $expectedValue):void {
$path = $this->featureContext->substituteInLineCodes($path, $user);
$path = \ltrim($path, '/');
$path = "/" . WebdavHelper::withRemotePhp($path);
$path = "/" . WebdavHelper::prefixRemotePhp($path);
$fullXpath = "//d:response/d:href[.='$path']/following-sibling::d:propstat$xpath";
$this->assertValueOfItemInResponseAboutUserIs(
$fullXpath,
@@ -898,7 +898,7 @@ class WebDavPropertiesContext implements Context {
$user,
['preg_quote' => ['/']]
);
$expectedHref = WebdavHelper::withRemotePhp($expectedHref);
$expectedHref = WebdavHelper::prefixRemotePhp($expectedHref);
$index = 0;
while (true) {
@@ -959,8 +959,8 @@ class WebDavPropertiesContext implements Context {
$pattern = \preg_replace("/^\//", "", $pattern);
$pattern = \preg_replace("/^\^/", "", $pattern);
$pattern = \ltrim($pattern, "\/");
$withRemotePhp = \rtrim(WebdavHelper::withRemotePhp(""), "/");
$pattern = "/^\/{$withRemotePhp}\/{$pattern}";
$prefixRemotePhp = \rtrim(WebdavHelper::prefixRemotePhp(""), "/");
$pattern = "/^\/{$prefixRemotePhp}\/{$pattern}";
}
$pattern = $this->featureContext->substituteInLineCodes(
$pattern,