ci: make remote.php default

docs: add documentation

test: rename uniquePath to suffixPath
This commit is contained in:
Saw-jan
2024-10-21 12:24:50 +05:45
parent f86d137f87
commit 766ad4b40c
15 changed files with 151 additions and 109 deletions
+21 -12
View File
@@ -915,7 +915,7 @@ def localApiTestPipeline(ctx):
(ocisServer(storage, params["accounts_hash_difficulty"], deploy_type = "federation", extra_server_environment = params["extraServerEnvironment"]) if params["federationServer"] else []) +
((wopiCollaborationService("fakeoffice") + wopiCollaborationService("collabora") + wopiCollaborationService("onlyoffice")) if params["collaborationServiceNeeded"] else []) +
(waitForServices("wopi", ["wopi-collabora:9300", "wopi-onlyoffice:9300", "wopi-fakeoffice:9300"]) if params["collaborationServiceNeeded"] else []) +
localApiTests(suite, storage, params["extraEnvironment"]) +
localApiTests(ctx, suite, storage, params["extraEnvironment"]) +
logRequests(),
"services": (emailService() if params["emailNeeded"] else []) +
(clamavService() if params["antivirusNeeded"] else []) +
@@ -931,8 +931,9 @@ def localApiTestPipeline(ctx):
pipelines.append(pipeline)
return pipelines
def localApiTests(suite, storage, extra_environment = {}):
expectedFailuresFile = "%s/tests/acceptance/expected-failures-localAPI-on-%s-storage.md" % (dirs["base"], storage.upper())
def localApiTests(ctx, suite, storage, extra_environment = {}):
test_dir = "%s/tests/acceptance" % dirs["base"]
expected_failures_file = "%s/expected-failures-localAPI-on-%s-storage.md" % (test_dir, storage.upper())
environment = {
"PATH_TO_OCIS": dirs["base"],
@@ -944,10 +945,10 @@ def localApiTests(suite, storage, extra_environment = {}):
"STORAGE_DRIVER": storage,
"BEHAT_SUITE": suite,
"BEHAT_FILTER_TAGS": "~@skip&&~@skipOnGraph&&~@skipOnOcis-%s-Storage" % ("OC" if storage == "owncloud" else "OCIS"),
"EXPECTED_FAILURES_FILE": "%s/tests/acceptance/expected-failures-localAPI-on-%s-storage.md" % (dirs["base"], storage.upper()),
"EXPECTED_FAILURES_FILE": expected_failures_file,
"UPLOAD_DELETE_WAIT_TIME": "1" if storage == "owncloud" else 0,
"OCIS_WRAPPER_URL": "http://ocis-server:5200",
"WITH_REMOTE_PHP": False,
"WITH_REMOTE_PHP": get_remotephp_config(ctx),
}
for item in extra_environment:
@@ -958,9 +959,9 @@ def localApiTests(suite, storage, extra_environment = {}):
"image": OC_CI_PHP % DEFAULT_PHP_VERSION,
"environment": environment,
"commands": [
"cat %s/tests/acceptance/expected-failures-without-remotephp.md >> %s" % (dirs["base"], expectedFailuresFile),
# merge the expected failures
"" if get_remotephp_config(ctx) else "cat %s/expected-failures-without-remotephp.md >> %s" % (test_dir, expected_failures_file),
"make -C %s test-acceptance-api" % (dirs["base"]),
"cat %s" % expectedFailuresFile,
],
}]
@@ -1117,7 +1118,8 @@ def wopiValidatorTests(ctx, storage, wopiServerType, accounts_hash_difficulty =
def coreApiTests(ctx, part_number = 1, number_of_parts = 1, storage = "ocis", accounts_hash_difficulty = 4):
filterTags = "~@skipOnGraph&&~@skipOnOcis-%s-Storage" % ("OC" if storage == "owncloud" else "OCIS")
expectedFailuresFile = "%s/tests/acceptance/expected-failures-API-on-%s-storage.md" % (dirs["base"], storage.upper())
test_dir = "%s/tests/acceptance" % dirs["base"]
expected_failures_file = "%s/expected-failures-API-on-%s-storage.md" % (test_dir, storage.upper())
return {
"kind": "pipeline",
@@ -1145,15 +1147,15 @@ def coreApiTests(ctx, part_number = 1, number_of_parts = 1, storage = "ocis", ac
"DIVIDE_INTO_NUM_PARTS": number_of_parts,
"RUN_PART": part_number,
"ACCEPTANCE_TEST_TYPE": "core-api",
"EXPECTED_FAILURES_FILE": expectedFailuresFile,
"EXPECTED_FAILURES_FILE": expected_failures_file,
"UPLOAD_DELETE_WAIT_TIME": "1" if storage == "owncloud" else 0,
"OCIS_WRAPPER_URL": "http://ocis-server:5200",
"WITH_REMOTE_PHP": False,
"WITH_REMOTE_PHP": get_remotephp_config(ctx),
},
"commands": [
"cat %s/tests/acceptance/expected-failures-without-remotephp.md >> %s" % (dirs["base"], expectedFailuresFile),
# merge the expected failures
"" if get_remotephp_config(ctx) else "cat %s/expected-failures-without-remotephp.md >> %s" % (test_dir, expected_failures_file),
"make -C %s test-acceptance-api" % (dirs["base"]),
"cat %s" % expectedFailuresFile,
],
},
] +
@@ -1178,6 +1180,13 @@ def apiTests(ctx):
return pipelines
def get_remotephp_config(ctx):
# run tests with remote.php for PRs and commit push
# run tests without remote.php for cron jobs
if ctx.build.event == "cron":
return False
return True
def e2eTestPipeline(ctx):
defaults = {
"skip": False,
+31 -3
View File
@@ -13,7 +13,7 @@ To run tests in the test suite you have two options. You may go the easy way and
Both ways to run tests with the test suites are described here.
## Testing With Test Suite in Docker
## Running Test Suite in Docker
Let's see what is available. Invoke the following command from within the root of the oCIS repository.
@@ -194,7 +194,7 @@ During testing we start a redis and oCIS docker container. These will not be sto
make -C tests/acceptance/docker clean
```
## Testing With Test Suite Natively Installed
## Running Test Suite in Local Environment
### Run oCIS
@@ -284,6 +284,16 @@ If you want to work on a specific issue
5. remove those tests from the expected failures file
6. make a PR that has the fixed code, and the relevant lines removed from the expected failures file.
## Running Tests With And Without `remote.php`
By default, the tests are run with `remote.php` enabled. If you want to run the tests without `remote.php`, you can disable it by setting the environment variable `WITH_REMOTE_PHP=false` while running the tests.
```bash
WITH_REMOTE_PHP=false \
TEST_SERVER_URL="https://localhost:9200" \
make test-acceptance-api
```
## Running ENV Config Tests (@env-Config)
Test suites tagged with `@env-config` are used to test the environment variables that are used to configure oCIS. These tests are special tests that require the oCIS server to be run using [ociswrapper](https://github.com/owncloud/ocis/blob/master/tests/ociswrapper/README.md).
@@ -407,40 +417,52 @@ make test-acceptance-api
```
## Running Test Suite With Antivirus Service (@antivirus)
Test suites that are tagged with `@antivirus` require antivirus service. The available antivirus and the configuration related to them can be found [here](https://doc.owncloud.com/ocis/next/deployment/services/s-list/antivirus.html). This documentation is only going to use `clamAv` as antivirus.
### Setup clamAV
#### 1. Setup Locally
##### Linux OS user
Run the following command to set up calmAV and clamAV daemon
```bash
sudo apt install clamav clamav-daemon -y
```
Make sure that the clamAV daemon is up and running
Make sure that the clamAV daemon is up and running
```bash
sudo service clamav-daemon status
```
{{< hint info >}}
The commands are ubuntu specific and may differ according to your system. You can find information related to installation of clamAV in their official documentation [here](https://docs.clamav.net/manual/Installing/Packages.html).
{{< /hint>}}
##### Mac OS user
Install ClamAV using [here](https://gist.github.com/mendozao/3ea393b91f23a813650baab9964425b9)
Start ClamAV daemon
```bash
/your/location/to/brew/Cellar/clamav/1.1.0/sbin/clamd
```
#### 2. Setup clamAV With Docker
##### Linux OS user
Run `clamAV` through docker
```bash
docker run -d -p 3310:3310 owncloudci/clamavd
```
##### Mac OS user
```bash
docker run -d -p 3310:3310 -v /your/local/filesystem/path/to/clamav/:/var/lib/clamav mkodockx/docker-clamav:alpine
```
@@ -459,6 +481,7 @@ OCIS_ASYNC_UPLOADS=true \
OCIS_ADD_RUN_SERVICES="antivirus"
ocis/bin/ocis server
```
{{< hint info >}}
The value for `ANTIVIRUS_CLAMAV_SOCKET` is an example which needs adaption according your OS.
@@ -478,13 +501,16 @@ make test-acceptance-api
```
## Running Test Suite With Federated Sharing (@ocm)
Test suites that are tagged with `@ocm` require running two different ocis instances. More detailed information and configuration related to it can be found [here](https://doc.owncloud.com/ocis/5.0/deployment/services/s-list/ocm.html).
Put
```bash
127.0.0.1 ocis-server
127.0.0.1 federation-ocis-server
```
in the `/etc/hosts` file
### Setup first ocis instance
@@ -505,6 +531,7 @@ ocis/bin/ocis server
The first oCIS instance should be available at: https://ocis-server:9200/
### Setup second ocis instance
#### Using .vscode/launch.json
#### Using .env file
@@ -547,6 +574,7 @@ ocis/bin/ocis server
```
The sample `fontsMap.json` file is located in `tests/config/drone/fontsMap.json`.
```json
{
"defaultFont": "/path/to/ocis/tests/config/drone/NotoSans.ttf"
@@ -106,20 +106,19 @@ class HttpRequestHelper {
}
if (WebdavHelper::isDAVRequest($url) && \str_starts_with($url, OcisHelper::getServerUrl())) {
$withRemotePhp = \getenv("WITH_REMOTE_PHP") === "true";
$urlHasRemotePhp = \str_contains($url, 'remote.php');
if (!$withRemotePhp && $urlHasRemotePhp) {
if (!WebDavHelper::withRemotePhp() && $urlHasRemotePhp) {
throw new Exception("remote.php is disabled but found in the URL: $url");
}
if ($withRemotePhp && !$urlHasRemotePhp) {
if (WebDavHelper::withRemotePhp() && !$urlHasRemotePhp) {
throw new Exception("remote.php is enabled but not found in the URL: $url");
}
if ($headers && \array_key_exists("Destination", $headers)) {
if (!$withRemotePhp && $urlHasRemotePhp) {
if (!WebDavHelper::withRemotePhp() && $urlHasRemotePhp) {
throw new Exception("remote.php is disabled but found in the URL: $url");
}
if ($withRemotePhp && !$urlHasRemotePhp) {
if (WebDavHelper::withRemotePhp() && !$urlHasRemotePhp) {
throw new Exception("remote.php is enabled but not found in the URL: $url");
}
}
+29 -23
View File
@@ -47,14 +47,20 @@ class WebDavHelper {
public static array $spacesIdRef = [];
/**
* clear space id reference for user
*
* @return bool
*/
public static function withRemotePhp(): bool {
// use remote.php by default
return \getenv("WITH_REMOTE_PHP") !== "false";
}
/**
* @param string $urlPath
*
* @return string
*/
public static function withRemotePhp(string $urlPath): string {
if (\getenv("WITH_REMOTE_PHP") === "true") {
public static function prefixRemotePhp(string $urlPath): string {
if (self::withRemotePhp()) {
return "remote.php/$urlPath";
}
return $urlPath;
@@ -746,15 +752,15 @@ class WebDavHelper {
}
}
$uniquePath = $user;
$suffixPath = $user;
if ($davPathVersionToUse === self::DAV_VERSION_SPACES && !\in_array($type, ["archive", "versions", "public-files"])) {
$uniquePath = $spaceId;
$suffixPath = $spaceId;
} elseif ($type === "versions") {
// $path is file-id in case of versions
$uniquePath = $path;
$suffixPath = $path;
}
$davPath = self::getDavPath($davPathVersionToUse, $uniquePath, $type);
$davPath = self::getDavPath($davPathVersionToUse, $suffixPath, $type);
//replace %, # and ? and in the path, Guzzle will not encode them
$urlSpecialChar = [['%', '#', '?'], ['%25', '%23', '%3F']];
@@ -764,7 +770,7 @@ class WebDavHelper {
$urlParameter = \http_build_query($urlParameter, '', '&');
$path .= '?' . $urlParameter;
}
$fullUrl = self::sanitizeUrl("{$baseUrl}/{$davPath}");
$fullUrl = self::sanitizeUrl("$baseUrl/$davPath");
// NOTE: no need to append path for archive and versions endpoints
if (!\in_array($type, ["archive", "versions"])) {
$fullUrl .= "/" . \ltrim($path, "/");
@@ -834,11 +840,11 @@ class WebDavHelper {
):string {
switch ($type) {
case 'archive':
return self::withRemotePhp("dav/archive/$userOrItemIdOrSpaceIdOrToken/files");
return self::prefixRemotePhp("dav/archive/$userOrItemIdOrSpaceIdOrToken/files");
case 'versions':
return self::withRemotePhp("dav/meta/$userOrItemIdOrSpaceIdOrToken/v");
return self::prefixRemotePhp("dav/meta/$userOrItemIdOrSpaceIdOrToken/v");
case 'comments':
return self::withRemotePhp("dav/comments/files");
return self::prefixRemotePhp("dav/comments/files");
default:
break;
}
@@ -848,37 +854,37 @@ class WebDavHelper {
if ($userOrItemIdOrSpaceIdOrToken === null) {
throw new InvalidArgumentException("Space ID is required for trash-bin endpoint");
}
return self::withRemotePhp("dav/spaces/trash-bin/$userOrItemIdOrSpaceIdOrToken");
return self::prefixRemotePhp("dav/spaces/trash-bin/$userOrItemIdOrSpaceIdOrToken");
} elseif ($type === "public-files") {
// spaces DAV path doesn't have own public-files endpoint
return self::withRemotePhp("dav/public-files/$userOrItemIdOrSpaceIdOrToken");
return self::prefixRemotePhp("dav/public-files/$userOrItemIdOrSpaceIdOrToken");
}
// return spaces root path if spaceid is null
// REPORT request uses spaces root path
if ($userOrItemIdOrSpaceIdOrToken === null) {
return self::withRemotePhp("dav/spaces");
return self::prefixRemotePhp("dav/spaces");
}
return self::withRemotePhp("dav/spaces/$userOrItemIdOrSpaceIdOrToken");
return self::prefixRemotePhp("dav/spaces/$userOrItemIdOrSpaceIdOrToken");
} else {
if ($type === "trash-bin") {
// Since there is no trash bin endpoint for old dav version,
// new dav version's endpoint is used here.
return self::withRemotePhp("dav/trash-bin/$userOrItemIdOrSpaceIdOrToken");
return self::prefixRemotePhp("dav/trash-bin/$userOrItemIdOrSpaceIdOrToken");
}
if ($davPathVersion === self::DAV_VERSION_OLD) {
if ($type === "public-files") {
// TODO: cleanup
// this endpoint does not exist
return self::withRemotePhp("public.php/webdav");
return self::prefixRemotePhp("public.php/webdav");
}
return self::withRemotePhp("webdav");
return self::prefixRemotePhp("webdav");
} elseif ($davPathVersion === self::DAV_VERSION_NEW) {
if ($type === "files") {
return self::withRemotePhp("dav/files/$userOrItemIdOrSpaceIdOrToken");
return self::prefixRemotePhp("dav/files/$userOrItemIdOrSpaceIdOrToken");
} elseif ($type === "public-files") {
return self::withRemotePhp("dav/public-files/$userOrItemIdOrSpaceIdOrToken");
return self::prefixRemotePhp("dav/public-files/$userOrItemIdOrSpaceIdOrToken");
}
return self::withRemotePhp("dav");
return self::prefixRemotePhp("dav");
}
throw new InvalidArgumentException("Invalid DAV path: $davPathVersion");
}
@@ -952,7 +958,7 @@ class WebDavHelper {
$baseUrl,
null,
null,
"{$token}/{$fileName}",
"$token/$fileName",
['d:getlastmodified'],
$xRequestId,
'1',
+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,
@@ -185,7 +185,7 @@ _ocdav: api compatibility, return correct status code_
- [coreApiWebdavOperations/search.feature:229](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiWebdavOperations/search.feature#L229)
- [coreApiWebdavOperations/search.feature:230](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiWebdavOperations/search.feature#L230)
#### [Trying to restore personal file to share received folder deletes shared file]()
#### [Trying to restore personal file to file of share received folder returns 403 but the share file is deleted (new dav path)](https://github.com/owncloud/ocis/issues/10356)
- [coreApiTrashbin/trashbinSharingToShares.feature:271](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiTrashbin/trashbinSharingToShares.feature#L271)
@@ -246,7 +246,7 @@ Feature: using trashbin together with sharing
| new | 403 |
| spaces | 400 |
@issue-10356
Scenario Outline: try to restore personal file to a shared folder as an editor
Given using <dav-path-version> DAV path
And user "Brian" has been created with default attributes and without skeleton files