Merge pull request #10087 from owncloud/remove-spaceidfromocis-env

[test-only][full-ci] removing SPACE_ID_FROM_OCIS from test code
This commit is contained in:
Sawjan Gurung
2024-10-03 13:13:50 +05:45
committed by GitHub
15 changed files with 249 additions and 130 deletions

View File

@@ -149,6 +149,7 @@ class OcisHelper {
"MKCOL",
$destination,
[],
null,
$xRequestId
);
if ($response->getStatusCode() !== 201) {

View File

@@ -77,6 +77,7 @@ class UploadHelper extends Assert {
"PUT",
$destination,
$headers,
null,
$xRequestId,
$data,
$davPathVersionToUse,
@@ -110,6 +111,7 @@ class UploadHelper extends Assert {
'MKCOL',
$v2ChunksDestination,
$headers,
null,
$xRequestId,
null,
$davPathVersionToUse,
@@ -146,6 +148,7 @@ class UploadHelper extends Assert {
"PUT",
$filename,
$headers,
null,
$xRequestId,
$chunk,
$davPathVersionToUse,
@@ -176,6 +179,7 @@ class UploadHelper extends Assert {
'MOVE',
$source,
$headers,
null,
$xRequestId,
null,
$davPathVersionToUse,

View File

@@ -40,7 +40,6 @@ class WebDavHelper {
public const DAV_VERSION_OLD = 1;
public const DAV_VERSION_NEW = 2;
public const DAV_VERSION_SPACES = 3;
public static string $SPACE_ID_FROM_OCIS = '';
/**
* @var array of users with their different space ids
@@ -82,6 +81,7 @@ class WebDavHelper {
* @param string|null $user
* @param string|null $password
* @param string|null $path
* @param string|null $spaceId
* @param string|null $xRequestId
* @param int|null $davPathVersionToUse
*
@@ -93,6 +93,7 @@ class WebDavHelper {
?string $user,
?string $password,
?string $path,
?string $spaceId = null,
?string $xRequestId = '',
?int $davPathVersionToUse = self::DAV_VERSION_NEW
): string {
@@ -110,6 +111,7 @@ class WebDavHelper {
"PROPFIND",
$path,
null,
$spaceId,
$xRequestId,
$body,
$davPathVersionToUse
@@ -190,6 +192,7 @@ class WebDavHelper {
* if an associative array is used, then the key will be used as namespace
* @param string|null $xRequestId
* @param string|null $folderDepth
* @param string|null $spaceId
* @param string|null $type
* @param int|null $davPathVersionToUse
* @param string|null $doDavRequestAsUser
@@ -207,6 +210,7 @@ class WebDavHelper {
?array $properties,
?string $xRequestId = '',
?string $folderDepth = '1',
?string $spaceId = null,
?string $type = "files",
?int $davPathVersionToUse = self::DAV_VERSION_NEW,
?string $doDavRequestAsUser = null,
@@ -228,6 +232,7 @@ class WebDavHelper {
"PROPFIND",
$path,
$headers,
$spaceId,
$xRequestId,
$body,
$davPathVersionToUse,
@@ -255,6 +260,7 @@ class WebDavHelper {
* e.g "x1='http://whatever.org/ns'"
* @param int|null $davPathVersionToUse
* @param string|null $type
* @param string|null $spaceId
*
* @return ResponseInterface
* @throws GuzzleException
@@ -269,7 +275,8 @@ class WebDavHelper {
?string $xRequestId = '',
?string $namespaceString = null,
?int $davPathVersionToUse = self::DAV_VERSION_NEW,
?string $type="files"
?string $type="files",
?string $spaceId = null,
):ResponseInterface {
if ($namespaceString !== null) {
$ns = self::parseNamespace($namespaceString);
@@ -294,6 +301,7 @@ class WebDavHelper {
"PROPPATCH",
$path,
[],
$spaceId,
$xRequestId,
$body,
$davPathVersionToUse,
@@ -392,6 +400,7 @@ class WebDavHelper {
"PROPPATCH",
$path,
[],
null,
$xRequestId,
$body,
$davPathVersion,
@@ -407,6 +416,7 @@ class WebDavHelper {
* @param string|null $password
* @param string|null $path
* @param string|null $folderDepth
* @param string|null $spaceId
* @param string|null $xRequestId
* @param string[] $properties
* @param string|null $type
@@ -421,6 +431,7 @@ class WebDavHelper {
?string $password,
?string $path,
?string $folderDepth,
?string $spaceId = null,
?string $xRequestId = '',
?array $properties = null,
?string $type = "files",
@@ -439,6 +450,7 @@ class WebDavHelper {
$properties,
$xRequestId,
$folderDepth,
$spaceId,
$type,
$davPathVersionToUse
);
@@ -641,6 +653,7 @@ class WebDavHelper {
* @param string|null $method PUT, GET, DELETE, etc.
* @param string|null $path
* @param array|null $headers
* @param string|null $spaceId
* @param string|null $xRequestId
* @param string|null|resource|StreamInterface $body
* @param int|null $davPathVersionToUse (1|2|3)
@@ -666,6 +679,7 @@ class WebDavHelper {
?string $method,
?string $path,
?array $headers,
?string $spaceId = null,
?string $xRequestId = '',
$body = null,
?int $davPathVersionToUse = self::DAV_VERSION_OLD,
@@ -677,7 +691,7 @@ class WebDavHelper {
?Client $client = null,
?array $urlParameter = [],
?string $doDavRequestAsUser = null,
?bool $isGivenStep = false
?bool $isGivenStep = false,
):ResponseInterface {
$baseUrl = self::sanitizeUrl($baseUrl, true);
@@ -688,7 +702,7 @@ class WebDavHelper {
}
// get space id if testing with spaces dav
if (self::$SPACE_ID_FROM_OCIS === '' && $davPathVersionToUse === self::DAV_VERSION_SPACES) {
if ($spaceId === null && $davPathVersionToUse === self::DAV_VERSION_SPACES) {
$path = \ltrim($path, "/");
if (\str_starts_with($path, "Shares/")) {
$spaceId = self::getSharesSpaceIdForUser(
@@ -706,8 +720,6 @@ class WebDavHelper {
$xRequestId
);
}
} else {
$spaceId = self::$SPACE_ID_FROM_OCIS;
}
$davPath = self::getDavPath($doDavRequestAsUser ?? $user, $davPathVersionToUse, $type, $spaceId);
@@ -753,8 +765,6 @@ class WebDavHelper {
}
}
//Clear the space ID from ocis after each request
self::$SPACE_ID_FROM_OCIS = '';
return HttpRequestHelper::sendRequest(
$fullUrl,
$xRequestId,
@@ -911,6 +921,7 @@ class WebDavHelper {
['d:getlastmodified'],
$xRequestId,
'1',
'',
null,
$davVersionToUse
);
@@ -932,6 +943,7 @@ class WebDavHelper {
* @param string|null $resource
* @param string|null $xRequestId
* @param int|null $davPathVersionToUse
* @param string|null $spaceId
*
* @return string
* @throws Exception
@@ -943,7 +955,8 @@ class WebDavHelper {
?string $baseUrl,
?string $resource,
?string $xRequestId = '',
?int $davPathVersionToUse = self::DAV_VERSION_NEW
?int $davPathVersionToUse = self::DAV_VERSION_NEW,
?string $spaceId = null,
):string {
$response = self::propfind(
$baseUrl,
@@ -953,6 +966,7 @@ class WebDavHelper {
["d:getlastmodified"],
$xRequestId,
"0",
$spaceId,
"files",
$davPathVersionToUse
);

View File

@@ -163,10 +163,11 @@ class ChecksumContext implements Context {
/**
* @param string $user
* @param string $path
* @param string|null $spaceId
*
* @return ResponseInterface
*/
public function propfindResourceChecksum(string $user, string $path) : 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">
@@ -182,6 +183,7 @@ class ChecksumContext implements Context {
'PROPFIND',
$path,
null,
$spaceId,
$this->featureContext->getStepLineRef(),
$body,
$this->featureContext->getDavPathVersion()

View File

@@ -38,14 +38,16 @@ class FavoritesContext implements Context {
/**
* @param string$user
* @param string $path
* @param string|null $spaceId
*
* @return ResponseInterface
*/
public function userFavoritesElement(string $user, string $path):ResponseInterface {
public function userFavoritesElement(string $user, string $path, string $spaceId = null):ResponseInterface {
return $this->changeFavStateOfAnElement(
$user,
$path,
1
1,
$spaceId
);
}
@@ -83,7 +85,8 @@ class FavoritesContext implements Context {
return $this->changeFavStateOfAnElement(
$user,
$path,
0
0,
null,
);
}
@@ -154,6 +157,7 @@ class FavoritesContext implements Context {
"REPORT",
"/",
null,
null,
$this->featureContext->getStepLineRef(),
$body,
$this->featureContext->getDavPathVersion()
@@ -167,16 +171,19 @@ class FavoritesContext implements Context {
* @param string $user
* @param string $path
* @param integer $expectedValue 0|1
* @param string|null $spaceId
*
* @return void
*/
public function asUserFileOrFolderShouldBeFavorited(string $user, string $path, int $expectedValue = 1):void {
public function asUserFileOrFolderShouldBeFavorited(string $user, string $path, int $expectedValue = 1, string $spaceId = null):void {
$property = "oc:favorite";
$this->webDavPropertiesContext->checkPropertyOfAFolder(
$user,
$path,
$property,
(string)$expectedValue
(string)$expectedValue,
null,
$spaceId,
);
}
@@ -198,13 +205,15 @@ class FavoritesContext implements Context {
* @param string $user
* @param string $path
* @param int|null $favOrUnfav 1 = favorite, 0 = unfavorite
* @param string|null $spaceId
*
* @return ResponseInterface
*/
public function changeFavStateOfAnElement(
string $user,
string $path,
?int $favOrUnfav
?int $favOrUnfav,
?string $spaceId,
):ResponseInterface {
$renamedUser = $this->featureContext->getActualUsername($user);
return WebDavHelper::proppatch(
@@ -216,7 +225,9 @@ class FavoritesContext implements Context {
(string)$favOrUnfav,
$this->featureContext->getStepLineRef(),
"oc='http://owncloud.org/ns'",
$this->featureContext->getDavPathVersion()
$this->featureContext->getDavPathVersion(),
'files',
$spaceId
);
}

View File

@@ -2758,7 +2758,6 @@ class FeatureContext extends BehatVariablesContext {
if (\count(WebDavHelper::$spacesIdRef) > 0) {
WebDavHelper::$spacesIdRef = [];
}
WebDavHelper::$SPACE_ID_FROM_OCIS = '';
}
/**

View File

@@ -90,6 +90,7 @@ class FilesVersionsContext implements Context {
$endpoint,
null,
null,
'',
"versions",
(string)$this->featureContext->getDavPathVersion(),
false,
@@ -102,6 +103,7 @@ class FilesVersionsContext implements Context {
* @param string $user
* @param string $file
* @param string|null $fileOwner
* @param string|null $spaceId
*
* @return ResponseInterface
* @throws JsonException
@@ -110,11 +112,12 @@ class FilesVersionsContext implements Context {
public function getFileVersions(
string $user,
string $file,
?string $fileOwner = null
?string $fileOwner = null,
?string $spaceId = null,
): ResponseInterface {
$user = $this->featureContext->getActualUsername($user);
$fileOwner = $fileOwner ? $this->featureContext->getActualUsername($fileOwner) : $user;
$fileId = $this->featureContext->getFileIdForPath($fileOwner, $file);
$fileId = $this->featureContext->getFileIdForPath($fileOwner, $file, $spaceId);
Assert::assertNotNull($fileId, __METHOD__ . " fileid of file $file user $fileOwner not found (the file may not exist)");
return $this->featureContext->makeDavRequest(
$user,
@@ -122,6 +125,7 @@ class FilesVersionsContext implements Context {
$this->getVersionsPathForFileId($fileId),
null,
null,
$spaceId,
null,
'2'
);
@@ -144,6 +148,7 @@ class FilesVersionsContext implements Context {
$endpoint,
null,
null,
'',
"versions",
(string)$this->featureContext->getDavPathVersion()
)
@@ -187,6 +192,7 @@ class FilesVersionsContext implements Context {
$this->getVersionsPathForFileId($fileId),
null,
$body,
'',
null,
'2'
);
@@ -394,13 +400,14 @@ class FilesVersionsContext implements Context {
* @param string $user
* @param string $path
* @param string $index
* @param string|NullCpuCoreFinder $spaceId
*
* @return ResponseInterface
* @throws Exception
*/
public function downloadVersion(string $user, string $path, string $index):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);
$fileId = $this->featureContext->getFileIdForPath($user, $path, $spaceId);
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);
@@ -497,6 +504,7 @@ class FilesVersionsContext implements Context {
"PROPFIND",
$metaPath,
['Content-Type' => 'text/xml','Depth' => '0'],
null,
$this->featureContext->getStepLineRef(),
$body,
$this->featureContext->getDavPathVersion(),
@@ -543,6 +551,7 @@ class FilesVersionsContext implements Context {
$properties,
$this->featureContext->getStepLineRef(),
(string) $folderDepth,
'',
"versions"
);
return $response;

View File

@@ -104,7 +104,7 @@ class SearchContext implements Context {
}
$body .= " </oc:search-files>";
$davPathVersionToUse = $this->featureContext->getDavPathVersion();
$davPath = WebDavHelper::getDavPath($doDavRequestAsUser ?? $user, $davPathVersionToUse, 'files');
$davPath = WebDavHelper::getDavPath($doDavRequestAsUser ?? $user, $davPathVersionToUse, 'files', null);
if ($davPathVersionToUse == WebDavHelper::DAV_VERSION_NEW) {
// Removes the last component('username' in this case) from the WebDAV path by going up one level in the directory structure.

View File

@@ -260,14 +260,14 @@ class SpacesContext implements Context {
* @param string $user
* @param string $spaceName
*
* @return void
* @return string
* @throws GuzzleException
*/
public function setSpaceIDByName(string $user, string $spaceName): void {
public function setSpaceIDByName(string $user, string $spaceName): string {
$space = $this->getSpaceByName($user, $spaceName);
Assert::assertIsArray($space, "Space with name '$spaceName' not found");
Assert::assertNotEmpty($space["root"]["webDavUrl"], "WebDavUrl for space with name $spaceName not found");
WebDavHelper::$SPACE_ID_FROM_OCIS = $space['id'];
return $space["id"];
}
/**
@@ -371,7 +371,7 @@ class SpacesContext implements Context {
* @throws JsonException
*/
public function getPrivateLink(string $user, string $spaceName): string {
$this->setSpaceIDByName($user, $spaceName);
$spaceId = $this->setSpaceIDByName($user, $spaceName);
$response = WebDavHelper::propfind(
$this->featureContext->getBaseUrl(),
$this->featureContext->getActualUsername($user),
@@ -380,6 +380,7 @@ class SpacesContext implements Context {
['oc:privatelink'],
$this->featureContext->getStepLineRef(),
"0",
$spaceId,
"files",
WebDavHelper::DAV_VERSION_SPACES
);
@@ -754,7 +755,7 @@ class SpacesContext implements Context {
* @throws GuzzleException
*/
public function propfindSpace(string $user, string $spaceName, string $foldersPath = ''): ResponseInterface {
$this->setSpaceIDByName($user, $spaceName);
$spaceId = $this->setSpaceIDByName($user, $spaceName);
return WebDavHelper::propfind(
$this->featureContext->getBaseUrl(),
$user,
@@ -763,6 +764,7 @@ class SpacesContext implements Context {
[],
$this->featureContext->getStepLineRef(),
null,
$spaceId,
'files',
WebDavHelper::DAV_VERSION_SPACES
);
@@ -833,7 +835,6 @@ class SpacesContext implements Context {
$shouldOrNot,
$expectedFiles,
);
WebDavHelper::$SPACE_ID_FROM_OCIS = '';
}
/**
@@ -856,9 +857,7 @@ class SpacesContext implements Context {
): void {
$space = $this->getSpaceByName($user, $spaceName);
$this->featureContext->setResponse($this->propfindSpace($user, $spaceName));
WebDavHelper::$SPACE_ID_FROM_OCIS = $space['id'];
$this->featureContext->propfindResultShouldContainEntries($shouldOrNot, $expectedFiles, $user, 'PROPFIND');
WebDavHelper::$SPACE_ID_FROM_OCIS = '';
$this->featureContext->propfindResultShouldContainEntries($shouldOrNot, $expectedFiles, $user, 'PROPFIND', '', $space['id']);
}
/**
@@ -883,15 +882,14 @@ class SpacesContext implements Context {
): void {
$space = $this->getSpaceByName($user, $spaceName);
$this->featureContext->setResponse($this->propfindSpace($user, $spaceName, $folderPath));
WebDavHelper::$SPACE_ID_FROM_OCIS = $space['id'];
$this->featureContext->propfindResultShouldContainEntries(
$shouldOrNot,
$expectedFiles,
$this->featureContext->getActualUsername($user),
'PROPFIND',
$folderPath
$folderPath,
$space['id']
);
WebDavHelper::$SPACE_ID_FROM_OCIS = '';
}
/**
@@ -1275,8 +1273,8 @@ class SpacesContext implements Context {
if ($ownerUser === '') {
$ownerUser = $user;
}
$this->setSpaceIDByName($ownerUser, $spaceName);
return $this->featureContext->createFolder($user, $folder);
$spaceId = $this->setSpaceIDByName($ownerUser, $spaceName);
return $this->featureContext->createFolder($user, $folder, false, null, $spaceId);
}
/**
@@ -1319,8 +1317,8 @@ class SpacesContext implements Context {
string $content,
string $destination
): void {
$this->setSpaceIDByName($user, $spaceName);
$response = $this->featureContext->uploadFileWithContent($user, $content, $destination);
$spaceId = $this->setSpaceIDByName($user, $spaceName);
$response = $this->featureContext->uploadFileWithContent($user, $content, $destination, $spaceId);
$this->featureContext->setResponse($response);
}
@@ -1342,8 +1340,8 @@ class SpacesContext implements Context {
string $destination,
string $spaceName
): void {
$this->setSpaceIDByName($user, $spaceName);
$response = $this->featureContext->uploadFile($user, $source, $destination);
$spaceId = $this->setSpaceIDByName($user, $spaceName);
$response = $this->featureContext->uploadFile($user, $source, $destination, $spaceId);
$this->featureContext->setResponse($response);
}
@@ -1360,8 +1358,8 @@ class SpacesContext implements Context {
* @throws Exception
*/
public function userHasUploadedAFileToInSpaceUsingTheWebdavApi(string $user, string $source, string $destination, string $spaceName): void {
$this->setSpaceIDByName($user, $spaceName);
$response = $this->featureContext->uploadFile($user, $source, $destination);
$spaceId = $this->setSpaceIDByName($user, $spaceName);
$response = $this->featureContext->uploadFile($user, $source, $destination, $spaceId);
$this->featureContext->theHTTPStatusCodeShouldBe(
201,
"Expected response status code should be 201",
@@ -1389,8 +1387,8 @@ class SpacesContext implements Context {
string $content,
string $destination
): void {
$this->setSpaceIDByName($ownerUser, $spaceName);
$response = $this->featureContext->uploadFileWithContent($user, $content, $destination);
$spaceId = $this->setSpaceIDByName($ownerUser, $spaceName);
$response = $this->featureContext->uploadFileWithContent($user, $content, $destination, $spaceId);
$this->featureContext->setResponse($response);
}
@@ -2121,8 +2119,8 @@ class SpacesContext implements Context {
): array {
$response = $this->listAllAvailableSpacesOfUser($user);
$this->featureContext->theHTTPStatusCodeShouldBe(200, "", $response);
$this->setSpaceIDByName($user, $spaceName);
$response = $this->featureContext->uploadFileWithContent($user, $fileContent, $destination, true);
$spaceId = $this->setSpaceIDByName($user, $spaceName);
$response = $this->featureContext->uploadFileWithContent($user, $fileContent, $destination, $spaceId, true);
$this->featureContext->theHTTPStatusCodeShouldBe(['201', '204'], "", $response);
return $response->getHeader('oc-fileid');
}
@@ -3101,8 +3099,8 @@ class SpacesContext implements Context {
string $fileName,
string $spaceName
): void {
$this->setSpaceIDByName($user, $spaceName);
$response = $this->featureContext->downloadFileAsUserUsingPassword($user, $fileName, $this->featureContext->getPasswordForUser($user));
$spaceId = $this->setSpaceIDByName($user, $spaceName);
$response = $this->featureContext->downloadFileAsUserUsingPassword($user, $fileName, $this->featureContext->getPasswordForUser($user), [], $spaceId);
$this->featureContext->setResponse($response);
}
@@ -3121,8 +3119,8 @@ class SpacesContext implements Context {
string $path,
string $spaceName
): void {
$this->setSpaceIDByName($user, $spaceName);
$this->featureContext->setResponse($this->checksumContext->propfindResourceChecksum($user, $path));
$spaceId = $this->setSpaceIDByName($user, $spaceName);
$this->featureContext->setResponse($this->checksumContext->propfindResourceChecksum($user, $path, $spaceId));
}
/**
@@ -3144,9 +3142,9 @@ class SpacesContext implements Context {
string $destination,
string $spaceName
): void {
$this->setSpaceIDByName($user, $spaceName);
$spaceId = $this->setSpaceIDByName($user, $spaceName);
$this->featureContext->setResponse(
$this->featureContext->uploadFileWithChecksumAndContent($user, $checksum, $content, $destination)
$this->featureContext->uploadFileWithChecksumAndContent($user, $checksum, $content, $destination, false, $spaceId)
);
}
@@ -3168,9 +3166,8 @@ class SpacesContext implements Context {
string $index,
string $spaceName
): void {
$this->setSpaceIDByName($user, $spaceName);
$this->featureContext->setResponse($this->filesVersionsContext->downloadVersion($user, $fileName, $index));
WebDavHelper::$SPACE_ID_FROM_OCIS = '';
$spaceId = $this->setSpaceIDByName($user, $spaceName);
$this->featureContext->setResponse($this->filesVersionsContext->downloadVersion($user, $fileName, $index, $spaceId));
}
/**
@@ -3184,9 +3181,9 @@ class SpacesContext implements Context {
* @throws Exception
*/
public function userTriesToDownloadFileVersions(string $user, string $file, string $spaceName):void {
$this->setSpaceIDByName($user, $spaceName);
$spaceId = $this->setSpaceIDByName($user, $spaceName);
$this->featureContext->setResponse(
$this->filesVersionsContext->getFileVersions($user, $file)
$this->filesVersionsContext->getFileVersions($user, $file, null, $spaceId)
);
}
@@ -3201,8 +3198,8 @@ class SpacesContext implements Context {
* @throws GuzzleException
*/
public function userGetsEtagOfElementInASpace(string $user, string $space, string $path): string {
$this->setSpaceIDByName($user, $space);
$xmlObject = $this->webDavPropertiesContext->storeEtagOfElement($user, $path);
$spaceId = $this->setSpaceIDByName($user, $space);
$xmlObject = $this->webDavPropertiesContext->storeEtagOfElement($user, $path, '', $spaceId);
return $this->featureContext->getEtagFromResponseXmlObject($xmlObject);
}
@@ -3507,8 +3504,8 @@ class SpacesContext implements Context {
string $spaceName,
TableNode $propertiesTable
):void {
$this->setSpaceIDByName($user, $spaceName);
$response = $this->webDavPropertiesContext->getPropertiesOfFolder($user, $resourceName, $propertiesTable);
$spaceId = $this->setSpaceIDByName($user, $spaceName);
$response = $this->webDavPropertiesContext->getPropertiesOfFolder($user, $resourceName, $spaceId, $propertiesTable);
$this->featureContext->setResponse($response);
}
@@ -3533,8 +3530,8 @@ class SpacesContext implements Context {
// NOTE: extracting properties occurs asynchronously
// short wait is necessary before getting those properties
sleep(2);
$this->setSpaceIDByName($user, $spaceName);
$response = $this->webDavPropertiesContext->getPropertiesOfFolder($user, $resourceName, $propertiesTable);
$spaceId = $this->setSpaceIDByName($user, $spaceName);
$response = $this->webDavPropertiesContext->getPropertiesOfFolder($user, $resourceName, $spaceId, $propertiesTable);
$this->featureContext->setResponse($response);
}
@@ -3558,8 +3555,8 @@ class SpacesContext implements Context {
string $property,
string $value
):void {
$this->setSpaceIDByName($user, $spaceName);
$this->webDavPropertiesContext->checkPropertyOfAFolder($user, $resourceName, $property, $value);
$spaceId = $this->setSpaceIDByName($user, $spaceName);
$this->webDavPropertiesContext->checkPropertyOfAFolder($user, $resourceName, $property, $value, null, $spaceId);
}
/**
@@ -3573,8 +3570,8 @@ class SpacesContext implements Context {
* @return void
*/
public function asUserFileOrFolderInsideSpaceShouldOrNotBeFavorited(string $user, string $path, string $spaceName, string $shouldOrNot):void {
$this->setSpaceIDByName($user, $spaceName);
$this->favoritesContext->asUserFileOrFolderShouldBeFavorited($user, $path, ($shouldOrNot === 'should') ? 1 : 0);
$spaceId = $this->setSpaceIDByName($user, $spaceName);
$this->favoritesContext->asUserFileOrFolderShouldBeFavorited($user, $path, ($shouldOrNot === 'should') ? 1 : 0, $spaceId);
}
/**
@@ -3588,8 +3585,8 @@ class SpacesContext implements Context {
* @throws GuzzleException
*/
public function userFavoritesElementInSpaceUsingTheWebdavApi(string $user, string $path, string $spaceName): void {
$this->setSpaceIDByName($user, $spaceName);
$this->featureContext->setResponse($this->favoritesContext->userFavoritesElement($user, $path));
$spaceId = $this->setSpaceIDByName($user, $spaceName);
$this->featureContext->setResponse($this->favoritesContext->userFavoritesElement($user, $path, $spaceId));
}
/**
@@ -3747,7 +3744,7 @@ class SpacesContext implements Context {
* @throws JsonException
*/
public function sendPropfindRequestToSpace(string $user, string $spaceName, ?string $resource = "", ?array $headers = [], ?string $folderDepth = "1"): ResponseInterface {
$this->setSpaceIDByName($user, $spaceName);
$spaceId = $this->setSpaceIDByName($user, $spaceName);
$properties = [
'oc:id',
'oc:fileid',
@@ -3788,6 +3785,7 @@ class SpacesContext implements Context {
$properties,
$this->featureContext->getStepLineRef(),
$folderDepth,
$spaceId,
"files",
$davPathVersion,
null,

View File

@@ -59,8 +59,8 @@ class SpacesTUSContext implements Context {
* @throws GuzzleException
*/
public function userHasUploadedFileViaTusInSpace(string $user, string $source, string $destination, string $spaceName): void {
$this->spacesContext->setSpaceIDByName($user, $spaceName);
$this->tusContext->uploadFileUsingTus($user, $source, $destination);
$spaceId = $this->spacesContext->setSpaceIDByName($user, $spaceName);
$this->tusContext->uploadFileUsingTus($user, $source, $destination, $spaceId);
$this->featureContext->setLastUploadDeleteTime(\time());
}
@@ -82,8 +82,8 @@ class SpacesTUSContext implements Context {
string $destination,
string $spaceName
): void {
$this->spacesContext->setSpaceIDByName($user, $spaceName);
$this->tusContext->uploadFileUsingTus($user, $source, $destination);
$spaceId = $this->spacesContext->setSpaceIDByName($user, $spaceName);
$this->tusContext->uploadFileUsingTus($user, $source, $destination, $spaceId);
$this->featureContext->setLastUploadDeleteTime(\time());
}
@@ -106,8 +106,8 @@ class SpacesTUSContext implements Context {
string $content,
TableNode $headers
): void {
$this->spacesContext->setSpaceIDByName($user, $spaceName);
$response = $this->tusContext->createNewTUSResourceWithHeaders($user, $headers, $content);
$spaceId = $this->spacesContext->setSpaceIDByName($user, $spaceName);
$response = $this->tusContext->createNewTUSResourceWithHeaders($user, $headers, $content, $spaceId);
$this->featureContext->theHTTPStatusCodeShouldBe(201, "Expected response status code should be 201", $response);
}
@@ -130,8 +130,8 @@ class SpacesTUSContext implements Context {
string $content,
TableNode $headers
): void {
$this->spacesContext->setSpaceIDByName($user, $spaceName);
$response = $this->tusContext->createNewTUSResourceWithHeaders($user, $headers, $content);
$spaceId = $this->spacesContext->setSpaceIDByName($user, $spaceName);
$response = $this->tusContext->createNewTUSResourceWithHeaders($user, $headers, $content, $spaceId);
$this->featureContext->setResponse($response);
}
@@ -147,13 +147,14 @@ class SpacesTUSContext implements Context {
* @throws Exception|GuzzleException
*/
private function uploadFileViaTus(string $user, string $content, string $resource, string $spaceName): void {
$this->spacesContext->setSpaceIDByName($user, $spaceName);
$spaceId = $this->spacesContext->setSpaceIDByName($user, $spaceName);
$tmpFile = $this->tusContext->writeDataToTempFile($content);
try {
$this->tusContext->uploadFileUsingTus(
$user,
\basename($tmpFile),
$resource
$resource,
$spaceId
);
$this->featureContext->setLastUploadDeleteTime(\time());
} catch (Exception $e) {
@@ -241,7 +242,7 @@ class SpacesTUSContext implements Context {
break;
default:
}
$this->spacesContext->setSpaceIDByName($user, $spaceName);
$spaceId = $this->spacesContext->setSpaceIDByName($user, $spaceName);
$mtime = new DateTime($mtime);
$mtime = $mtime->format('U');
$user = $this->featureContext->getActualUsername($user);
@@ -249,6 +250,7 @@ class SpacesTUSContext implements Context {
$user,
$source,
$destination,
$spaceId,
['mtime' => $mtime]
);
$this->featureContext->setLastUploadDeleteTime(\time());
@@ -297,7 +299,7 @@ class SpacesTUSContext implements Context {
string $content,
string $spaceName
): void {
$this->spacesContext->setSpaceIDByName($user, $spaceName);
$spaceId = $this->spacesContext->setSpaceIDByName($user, $spaceName);
$response = $this->tusContext->sendsAChunkToTUSLocationWithOffsetAndData($user, $offset, $content, $checksum);
$this->featureContext->setResponse($response);
}
@@ -370,8 +372,8 @@ class SpacesTUSContext implements Context {
string $spaceName,
TableNode $headers
): void {
$this->spacesContext->setSpaceIDByName($user, $spaceName);
$createResponse = $this->tusContext->createNewTUSResource($user, $headers);
$spaceId = $this->spacesContext->setSpaceIDByName($user, $spaceName);
$createResponse = $this->tusContext->createNewTUSResource($user, $headers, $spaceId);
$this->featureContext->theHTTPStatusCodeShouldBe(201, "", $createResponse);
$response = $this->tusContext->sendsAChunkToTUSLocationWithOffsetAndData($user, $offset, $data, $checksum);
$this->featureContext->setResponse($response);
@@ -394,7 +396,7 @@ class SpacesTUSContext implements Context {
string $spaceName,
string $mtime
): void {
$this->spacesContext->setSpaceIDByName($user, $spaceName);
$spaceId = $this->spacesContext->setSpaceIDByName($user, $spaceName);
$mtime = new DateTime($mtime);
Assert::assertEquals(
$mtime->format('U'),
@@ -404,7 +406,8 @@ class SpacesTUSContext implements Context {
$this->featureContext->getBaseUrl(),
$resource,
$this->featureContext->getStepLineRef(),
$this->featureContext->getDavPathVersion()
$this->featureContext->getDavPathVersion(),
$spaceId,
)
);
}

View File

@@ -53,13 +53,14 @@ class TUSContext implements Context {
* @param string $user
* @param TableNode $headers
* @param string $content
* @param string|null $spaceId
*
* @return ResponseInterface
*
* @throws Exception
* @throws GuzzleException
*/
public function createNewTUSResourceWithHeaders(string $user, TableNode $headers, string $content = ''): ResponseInterface {
public function createNewTUSResourceWithHeaders(string $user, TableNode $headers, string $content = '', ?string $spaceId = null): ResponseInterface {
$this->featureContext->verifyTableNodeColumnsCount($headers, 2);
$user = $this->featureContext->getActualUsername($user);
$password = $this->featureContext->getUserPassword($user);
@@ -71,6 +72,7 @@ class TUSContext implements Context {
null,
$headers->getRowsHash(),
$content,
$spaceId,
"files",
null,
false,
@@ -119,13 +121,14 @@ class TUSContext implements Context {
/**
* @param string $user
* @param TableNode $headers
* @param string|null $spaceId
*
* @return ResponseInterface
*/
public function createNewTUSResource(string $user, TableNode $headers):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));
return $this->createNewTUSResourceWithHeaders($user, new TableNode($rows), '', $spaceId);
}
/**
@@ -209,7 +212,7 @@ class TUSContext implements Context {
int $bytes = null,
string $checksum = ''
): void {
$this->uploadFileUsingTus($user, $source, $destination, $uploadMetadata, $noOfChunks, $bytes, $checksum);
$this->uploadFileUsingTus($user, $source, $destination, null, $uploadMetadata, $noOfChunks, $bytes, $checksum);
$this->featureContext->setLastUploadDeleteTime(\time());
}
@@ -217,6 +220,7 @@ class TUSContext implements Context {
* @param string $user
* @param string $source
* @param string $destination
* @param string|null $spaceId
* @param array $uploadMetadata
* @param integer $noOfChunks
* @param integer $bytes
@@ -228,6 +232,7 @@ class TUSContext implements Context {
?string $user,
string $source,
string $destination,
?string $spaceId = null,
array $uploadMetadata = [],
int $noOfChunks = 1,
int $bytes = null,
@@ -265,11 +270,9 @@ class TUSContext implements Context {
$user,
$this->featureContext->getDavPathVersion(),
"files",
WebDavHelper::$SPACE_ID_FROM_OCIS
?: $this->featureContext->getPersonalSpaceIdForUser($user)
$spaceId ?: $this->featureContext->getPersonalSpaceIdForUser($user)
)
);
WebDavHelper::$SPACE_ID_FROM_OCIS = '';
$client->setMetadata($uploadMetadata);
$sourceFile = $this->featureContext->acceptanceTestsDirLocation() . $source;
$client->setKey((string)rand())->file($sourceFile, $destination);
@@ -347,6 +350,7 @@ class TUSContext implements Context {
$user,
\basename($temporaryFileName),
$destination,
null,
[],
$noOfChunks
);
@@ -379,6 +383,7 @@ class TUSContext implements Context {
$user,
$source,
$destination,
null,
['mtime' => $mtime]
);
$this->featureContext->setLastUploadDeleteTime(\time());
@@ -461,6 +466,7 @@ class TUSContext implements Context {
$user,
\basename($temporaryFileName),
$source,
null,
[],
1,
-1

View File

@@ -51,6 +51,7 @@ class TrashbinContext implements Context {
'DELETE',
null,
[],
null,
$this->featureContext->getStepLineRef(),
null,
$davPathVersion,
@@ -152,6 +153,7 @@ class TrashbinContext implements Context {
$password,
"",
$depth,
null,
$this->featureContext->getStepLineRef(),
[
'oc:trashbin-original-filename',
@@ -220,6 +222,7 @@ class TrashbinContext implements Context {
$password,
$collectionPath,
$depth,
null,
$this->featureContext->getStepLineRef(),
[
'oc:trashbin-original-filename',
@@ -246,7 +249,7 @@ class TrashbinContext implements Context {
// set endpoint according to webdav request (2 = new, 3 = spaces)
$endpoint = "/remote.php/dav/trash-bin/$user";
if ($davPathVersion === 3) {
$space_id = (WebDavHelper::$SPACE_ID_FROM_OCIS) ?: WebDavHelper::getPersonalSpaceIdForUser(
$space_id = WebDavHelper::getPersonalSpaceIdForUser(
$this->featureContext->getBaseUrl(),
$user,
$this->featureContext->getPasswordForUser($user),
@@ -403,6 +406,7 @@ class TrashbinContext implements Context {
],
$this->featureContext->getStepLineRef(),
'1',
null,
'trash-bin',
$davPathVersion,
$user
@@ -793,6 +797,7 @@ class TrashbinContext implements Context {
$trashItemHRef,
$headers,
null,
null,
'trash-bin',
'2',
false,
@@ -863,6 +868,7 @@ class TrashbinContext implements Context {
$trashItemHRef,
[],
null,
'',
'trash-bin'
);
$this->featureContext->setResponse($response);

View File

@@ -282,14 +282,14 @@ trait WebDav {
* this function will return `owncloud/remote.php/webdav/prueba.txt`
*
* @param string $user
* @param string $spaceId
*
* @return string
* @throws GuzzleException
*/
public function getFullDavFilesPath(string $user):string {
$spaceId = null;
if ($this->getDavPathVersion() === WebDavHelper::DAV_VERSION_SPACES) {
$spaceId = (WebDavHelper::$SPACE_ID_FROM_OCIS) ?: WebDavHelper::getPersonalSpaceIdForUser(
public function getFullDavFilesPath(string $user, ?string $spaceId = null):string {
if ($spaceId === null && $this->getDavPathVersion() === WebDavHelper::DAV_VERSION_SPACES) {
$spaceId = WebDavHelper::getPersonalSpaceIdForUser(
$this->getBaseUrl(),
$user,
$this->getPasswordForUser($user),
@@ -373,6 +373,7 @@ trait WebDav {
* @param string|null $path
* @param array|null $headers
* @param StreamInterface|null $body
* @param string|null $spaceId
* @param string|null $type
* @param string|null $davPathVersion
* @param bool $stream Set to true to stream a response rather
@@ -393,6 +394,7 @@ trait WebDav {
?string $path,
?array $headers,
$body = null,
?string $spaceId = null,
?string $type = "files",
?string $davPathVersion = null,
bool $stream = false,
@@ -423,6 +425,7 @@ trait WebDav {
$method,
$path,
$headers,
$spaceId,
$this->getStepLineRef(),
$body,
$davPathVersion,
@@ -444,12 +447,13 @@ trait WebDav {
* @param string $folder
* @param bool|null $isGivenStep
* @param string|null $password
* @param string|null $spaceId
*
* @return ResponseInterface
* @throws JsonException | GuzzleException
* @throws GuzzleException | JsonException
*/
public function createFolder(string $user, string $folder, ?bool $isGivenStep = false, ?string $password = null): ResponseInterface {
public function createFolder(string $user, string $folder, ?bool $isGivenStep = false, ?string $password = null, ?string $spaceId=null): ResponseInterface {
$folder = '/' . \ltrim($folder, '/');
return $this->makeDavRequest(
$user,
@@ -457,6 +461,7 @@ trait WebDav {
$folder,
[],
null,
$spaceId,
"files",
null,
false,
@@ -492,6 +497,7 @@ trait WebDav {
$path,
[],
null,
null,
"files",
null,
false,
@@ -1158,6 +1164,7 @@ trait WebDav {
* @param string $fileName
* @param string|null $password
* @param array|null $headers
* @param string|null $spaceId
*
* @return ResponseInterface
*/
@@ -1165,7 +1172,8 @@ trait WebDav {
string $user,
string $fileName,
?string $password = null,
?array $headers = []
?array $headers = [],
?string $spaceId = null,
):ResponseInterface {
$user = $this->getActualUsername($user);
$password = $this->getActualPassword($password);
@@ -1175,6 +1183,7 @@ trait WebDav {
$fileName,
$headers,
null,
$spaceId,
"files",
null,
false,
@@ -1218,6 +1227,7 @@ trait WebDav {
[],
$this->getStepLineRef(),
"0",
null,
"files",
$this->getDavPathVersion()
);
@@ -1344,6 +1354,7 @@ trait WebDav {
$path,
'0',
null,
null,
$type
);
$statusCode = $response->getStatusCode();
@@ -1507,6 +1518,7 @@ trait WebDav {
* @param string $path
* @param string $folderDepth requires 1 to see elements without children
* @param array|null $properties
* @param string|null $spaceId
* @param string $type
*
* @return ResponseInterface
@@ -1517,6 +1529,7 @@ trait WebDav {
string $path,
string $folderDepth,
?array $properties = null,
?string $spaceId = null,
string $type = "files"
):ResponseInterface {
if ($this->customDavPath !== null) {
@@ -1529,6 +1542,7 @@ trait WebDav {
$this->getPasswordForUser($user),
$path,
$folderDepth,
$spaceId,
$this->getStepLineRef(),
$properties,
$type,
@@ -1560,6 +1574,7 @@ trait WebDav {
$path,
$folderDepth,
$properties,
null,
$type
),
__METHOD__
@@ -1681,6 +1696,7 @@ trait WebDav {
* @param string $user
* @param string $source
* @param string $destination
* @param string $spaceId
* @param bool|null $isGivenStep
*
* @return ResponseInterface
@@ -1689,6 +1705,7 @@ trait WebDav {
string $user,
string $source,
string $destination,
string $spaceId = null,
?bool $isGivenStep = false
):ResponseInterface {
$user = $this->getActualUsername($user);
@@ -1700,6 +1717,7 @@ trait WebDav {
$destination,
[],
$file,
$spaceId,
"files",
null,
false,
@@ -1746,7 +1764,7 @@ trait WebDav {
* @return array
*/
public function userHasUploadedAFileTo(string $user, string $source, string $destination):array {
$response = $this->uploadFile($user, $source, $destination, true);
$response = $this->uploadFile($user, $source, $destination, null, true);
$this->theHTTPStatusCodeShouldBe(
["201", "204"],
"HTTP status code was not 201 or 204 while trying to upload file '$source' to '$destination' for user '$user'",
@@ -2263,6 +2281,7 @@ trait WebDav {
* @param string $user
* @param string|null $content
* @param string $destination
* @param string $spaceId
* @param bool|null $isGivenStep
*
* @return ResponseInterface
@@ -2273,7 +2292,8 @@ trait WebDav {
string $user,
?string $content,
string $destination,
?bool $isGivenStep = false
?string $spaceId = null,
?bool $isGivenStep = false,
): ResponseInterface {
$user = $this->getActualUsername($user);
$this->pauseUploadDelete();
@@ -2283,13 +2303,14 @@ trait WebDav {
$destination,
[],
$content,
$spaceId,
"files",
null,
false,
null,
[],
null,
$isGivenStep
$isGivenStep,
);
$this->lastUploadDeleteTime = \time();
return $response;
@@ -2468,7 +2489,7 @@ trait WebDav {
string $destination
):array {
$user = $this->getActualUsername($user);
$response = $this->uploadFileWithContent($user, $content, $destination, true);
$response = $this->uploadFileWithContent($user, $content, $destination, null, true);
$this->theHTTPStatusCodeShouldBe(
["201", "204"],
"HTTP status code was not 201 or 204 while trying to upload file '$destination' for user '$user'",
@@ -2498,7 +2519,7 @@ trait WebDav {
foreach ($files as $destination) {
$destination = $destination['path'];
$user = $this->getActualUsername($user);
$response = $this->uploadFileWithContent($user, $content, $destination, true);
$response = $this->uploadFileWithContent($user, $content, $destination, null, true);
$this->theHTTPStatusCodeShouldBe(
["201", "204"],
"HTTP status code was not 201 or 204 while trying to upload file '$destination' for user '$user'",
@@ -2566,6 +2587,7 @@ trait WebDav {
* @param string|null $content
* @param string $destination
* @param bool|null $isGivenStep
* @param string|null $spaceId
*
* @return ResponseInterface
*/
@@ -2574,7 +2596,8 @@ trait WebDav {
string $checksum,
?string $content,
string $destination,
?bool $isGivenStep = false
?bool $isGivenStep = false,
?string $spaceId = null
):ResponseInterface {
$this->pauseUploadDelete();
$response = $this->makeDavRequest(
@@ -2583,6 +2606,7 @@ trait WebDav {
$destination,
['OC-Checksum' => $checksum],
$content,
$spaceId,
"files",
null,
false,
@@ -3091,6 +3115,7 @@ trait WebDav {
$file,
['OC-Chunked' => '1'],
$data,
null,
"uploads",
null,
false,
@@ -3220,6 +3245,7 @@ trait WebDav {
$destination,
[],
null,
'',
"uploads",
null,
false,
@@ -3254,6 +3280,7 @@ trait WebDav {
$destination,
[],
$data,
'',
"uploads",
null,
false,
@@ -3419,6 +3446,7 @@ trait WebDav {
$source,
$headers,
null,
'',
"uploads",
null,
false,
@@ -3446,6 +3474,7 @@ trait WebDav {
$source,
$headers,
null,
'',
"uploads"
);
}
@@ -3714,6 +3743,7 @@ trait WebDav {
$path,
[],
null,
null,
"files",
null,
false,
@@ -3766,6 +3796,7 @@ trait WebDav {
$path,
[],
null,
null,
"files",
null,
false,
@@ -3842,7 +3873,7 @@ trait WebDav {
if ($this->getDavPathVersion() === 3) {
$this->setResponse($this->uploadToSharedFolder($user, $destination, $content));
} else {
$this->setResponse($this->uploadFileWithContent($user, $content, $destination));
$this->setResponse($this->uploadFileWithContent($user, $content, $destination, ''));
}
}
@@ -4071,10 +4102,11 @@ trait WebDav {
/**
* @param string $user
* @param string $path
* @param string $spaceId
*
* @return string|null
*/
public function getFileIdForPath(string $user, string $path): ?string {
public function getFileIdForPath(string $user, string $path, string $spaceId = null): ?string {
$user = $this->getActualUsername($user);
try {
return WebDavHelper::getFileIdForPath(
@@ -4082,6 +4114,7 @@ trait WebDav {
$user,
$this->getPasswordForUser($user),
$path,
$spaceId,
$this->getStepLineRef(),
$this->getDavPathVersion()
);
@@ -4105,7 +4138,7 @@ trait WebDav {
/**
* @Then /^user "([^"]*)" (file|folder) "([^"]*)" should have the previously stored id$/
*
* @param string $user
* @param string370 $user
* @param string $fileOrFolder
* @param string $path
*
@@ -4147,6 +4180,7 @@ trait WebDav {
* @param string|null $user
* @param string|null $method
* @param string|null $folderpath
* @param string|null $spaceId
*
* @return void
* @throws GuzzleException
@@ -4156,7 +4190,8 @@ trait WebDav {
TableNode $expectedFiles,
?string $user = null,
?string $method = 'REPORT',
?string $folderpath = ''
?string $folderpath = '',
?string $spaceId = null
):void {
if ($folderpath === "/") {
$folderpath = "";
@@ -4172,7 +4207,9 @@ trait WebDav {
}
if ($method === "REPORT") {
$fileFound = $this->findEntryFromSearchResponse(
$resource
$resource,
false,
$spaceId,
);
if (\is_object($fileFound)) {
$fileFound = $fileFound->xpath("d:propstat//oc:name");
@@ -4182,7 +4219,8 @@ trait WebDav {
$resource,
$user,
"files",
$folderpath
$folderpath,
$spaceId
);
}
if ($should) {
@@ -4482,6 +4520,7 @@ trait WebDav {
'/',
$depth,
null,
null,
$this->usingOldDavPath ? "public-files" : "public-files-new"
);
$this->setResponse($response);
@@ -4585,6 +4624,7 @@ trait WebDav {
* @param string|null $user
* @param string $type
* @param string $folderPath
* @param string|null $spaceId
*
* @return string|array|boolean
*
@@ -4598,7 +4638,8 @@ trait WebDav {
?string $entryNameToSearch = null,
?string $user = null,
string $type = "files",
string $folderPath = ''
string $folderPath = '',
?string $spaceId = null
) {
$trimmedEntryNameToSearch = '';
// trim any leading "/" passed by the caller, we can just match the "raw" name
@@ -4609,7 +4650,7 @@ trait WebDav {
$folderPath = $this->escapePath($folderPath);
// topWebDavPath should be something like /remote.php/webdav/ or
// /remote.php/dav/files/alice/
$topWebDavPath = "/" . $this->getFullDavFilesPath($user) . "/" . $folderPath;
$topWebDavPath = "/" . $this->getFullDavFilesPath($user, $spaceId) . "/" . $folderPath;
switch ($type) {
case "files":
break;
@@ -4645,6 +4686,7 @@ trait WebDav {
*
* @param string|null $entryNameToSearch
* @param bool|null $searchForHighlightString
* @param string|null $spaceId
*
* @return string|array|boolean
*
@@ -4656,13 +4698,14 @@ trait WebDav {
*/
public function findEntryFromSearchResponse(
?string $entryNameToSearch = null,
?bool $searchForHighlightString = false
?bool $searchForHighlightString = false,
?string $spaceId = null
) {
// trim any leading "/" passed by the caller, we can just match the "raw" name
if ($entryNameToSearch !== null) {
$entryNameToSearch = \trim($entryNameToSearch, "/");
}
$spacesBaseUrl = "/" . webDavHelper::getDavPath(null, webDavHelper::DAV_VERSION_SPACES);
$spacesBaseUrl = "/" . webDavHelper::getDavPath(null, webDavHelper::DAV_VERSION_SPACES, 'files', $spaceId);
$searchResults = $this->getResponseXml()->xpath("//d:multistatus/d:response");
$results = [];
foreach ($searchResults as $item) {

View File

@@ -54,6 +54,7 @@ class WebDavLockingContext implements Context {
* @param string|null $fullUrl
* @param boolean $public if the file is in a public share or not
* @param boolean $expectToSucceed
* @param string|null $spaceId
*
* @return void
* @throws GuzzleException
@@ -65,7 +66,8 @@ class WebDavLockingContext implements Context {
TableNode $properties,
string $fullUrl = null,
bool $public = false,
bool $expectToSucceed = true
bool $expectToSucceed = true,
?string $spaceId = null
):ResponseInterface {
$user = $this->featureContext->getActualUsername($user);
$baseUrl = $this->featureContext->getBaseUrl();
@@ -112,6 +114,7 @@ class WebDavLockingContext implements Context {
"LOCK",
$file,
$headers,
$spaceId,
$this->featureContext->getStepLineRef(),
$body,
$this->featureContext->getDavPathVersion(),
@@ -187,7 +190,7 @@ class WebDavLockingContext implements Context {
public function userLocksFileInProjectSpace(string $user, string $file, string $space, TableNode $properties): ?ResponseInterface {
$spaceId = $this->spacesContext->getSpaceIdByName($user, $space);
$fullUrl = $this->featureContext->getBaseUrl() . '/dav/spaces/' . $spaceId . '/' . $file;
return $this->lockFile($user, $file, $properties, $fullUrl);
return $this->lockFile($user, $file, $properties, $fullUrl, false, true, $spaceId);
}
/**
@@ -219,7 +222,7 @@ class WebDavLockingContext implements Context {
public function userTriesToLockFileInProjectSpaceUsingWebDavAPI(string $user, string $file, string $space, TableNode $properties) {
$spaceId = $this->spacesContext->getSpaceIdByName($user, $space);
$fullUrl = $this->featureContext->getBaseUrl() . '/dav/spaces/' . $spaceId . '/' . $file;
$response = $this->lockFile($user, $file, $properties, $fullUrl, false, false);
$response = $this->lockFile($user, $file, $properties, $fullUrl, false, false, $spaceId);
$this->featureContext->setResponse($response);
}
@@ -280,8 +283,8 @@ class WebDavLockingContext implements Context {
* @return void
*/
public function userHasLockedFileInsideSpaceSettingTheFollowingProperties(string $user, string $file, string $spaceName, TableNode $properties) {
$this->spacesContext->setSpaceIDByName($this->featureContext->getActualUsername($user), $spaceName);
$response = $this->lockFile($user, $file, $properties);
$spaceId = $this->spacesContext->setSpaceIDByName($this->featureContext->getActualUsername($user), $spaceName);
$response = $this->lockFile($user, $file, $properties, null, false, true, $spaceId);
$this->featureContext->theHTTPStatusCodeShouldBe(200, '', $response);
}
@@ -418,12 +421,15 @@ class WebDavLockingContext implements Context {
* @return void
*/
public function userUnlocksTheLastCreatedLockOfFileInsideSpaceUsingTheWebdavApi(string $user, string $spaceName, string $file) {
$this->spacesContext->setSpaceIDByName($this->featureContext->getActualUsername($user), $spaceName);
$spaceId = $this->spacesContext->setSpaceIDByName($this->featureContext->getActualUsername($user), $spaceName);
$response = $this->unlockItemWithLastLockOfUserAndItemUsingWebDavAPI(
$user,
$file,
$user,
$file
$file,
false,
null,
$spaceId
);
$this->featureContext->setResponse($response);
}
@@ -518,6 +524,7 @@ class WebDavLockingContext implements Context {
"PROPFIND",
$itemToUnlock,
null,
null,
$this->featureContext->getStepLineRef(),
$body,
$this->featureContext->getDavPathVersion()
@@ -577,6 +584,7 @@ class WebDavLockingContext implements Context {
* @param string $itemToUseLockOf
* @param boolean $public
* @param string|null $fullUrl
* @param string|null $spaceId
*
* @return ResponseInterface
* @throws GuzzleException
@@ -588,7 +596,8 @@ class WebDavLockingContext implements Context {
string $lockOwner,
string $itemToUseLockOf,
bool $public = false,
string $fullUrl = null
string $fullUrl = null,
?string $spaceId = null,
):ResponseInterface {
$user = $this->featureContext->getActualUsername($user);
$lockOwner = $this->featureContext->getActualUsername($lockOwner);
@@ -626,6 +635,7 @@ class WebDavLockingContext implements Context {
"UNLOCK",
$itemToUnlock,
$headers,
$spaceId,
$this->featureContext->getStepLineRef(),
null,
$this->featureContext->getDavPathVersion(),

View File

@@ -89,6 +89,7 @@ class WebDavPropertiesContext implements Context {
/**
* @param string $user
* @param string $path
* @param string|null $spaceId
* @param TableNode|null $propertiesTable
*
* @return ResponseInterface
@@ -97,6 +98,7 @@ class WebDavPropertiesContext implements Context {
public function getPropertiesOfFolder(
string $user,
string $path,
?string $spaceId,
TableNode $propertiesTable
): ResponseInterface {
$user = $this->featureContext->getActualUsername($user);
@@ -110,7 +112,8 @@ class WebDavPropertiesContext implements Context {
$user,
$path,
"1",
$properties
$properties,
$spaceId,
);
}
@@ -129,7 +132,7 @@ class WebDavPropertiesContext implements Context {
string $path,
TableNode $propertiesTable
):void {
$response = $this->getPropertiesOfFolder($user, $path, $propertiesTable);
$response = $this->getPropertiesOfFolder($user, $path, null, $propertiesTable);
$this->featureContext->setResponse($response);
$this->featureContext->pushToLastStatusCodesArrays();
}
@@ -147,6 +150,7 @@ class WebDavPropertiesContext implements Context {
$response = $this->getPropertiesOfFolder(
$this->featureContext->getCurrentUser(),
$path,
null,
$propertiesTable
);
$this->featureContext->setResponse($response);
@@ -205,6 +209,7 @@ class WebDavPropertiesContext implements Context {
$properties,
$this->featureContext->getStepLineRef(),
"0",
null,
"files",
$this->featureContext->getDavPathVersion()
);
@@ -264,6 +269,7 @@ class WebDavPropertiesContext implements Context {
$path,
'0',
$properties,
'',
$this->featureContext->getDavPathVersion() === 1 ? "public-files" : "public-files-new"
);
}
@@ -1000,6 +1006,7 @@ class WebDavPropertiesContext implements Context {
$response = $this->getPropertiesOfFolder(
$user,
$path,
null,
$propertiesTable
);
$this->featureContext->theHTTPStatusCodeShouldBe('207', '', $response);
@@ -1055,6 +1062,7 @@ class WebDavPropertiesContext implements Context {
* @param string $property
* @param string $expectedValue
* @param string|null $altExpectedValue
* @param string|null $spaceId
*
* @return void
*/
@@ -1063,13 +1071,15 @@ class WebDavPropertiesContext implements Context {
string $path,
string $property,
string $expectedValue,
?string $altExpectedValue = null
?string $altExpectedValue = null,
?string $spaceId = null,
):void {
$response = $this->featureContext->listFolder(
$user,
$path,
'0',
[$property]
[$property],
$spaceId,
);
if ($altExpectedValue === null) {
$altExpectedValue = $expectedValue;
@@ -1153,11 +1163,12 @@ class WebDavPropertiesContext implements Context {
* @param string $user
* @param string $path
* @param string|null $storePath
* @param string|null $spaceId
*
* @return SimpleXMLElement
* @throws Exception
*/
public function storeEtagOfElement(string $user, string $path, ?string $storePath = ""):SimpleXMLElement {
public function storeEtagOfElement(string $user, string $path, ?string $storePath = "", ?string $spaceId = null):SimpleXMLElement {
if ($storePath === "") {
$storePath = $path;
}
@@ -1166,6 +1177,7 @@ class WebDavPropertiesContext implements Context {
$response = $this->getPropertiesOfFolder(
$user,
$path,
$spaceId,
$propertiesTable
);
$xmlObject = $this->featureContext->getResponseXml($response);
@@ -1315,6 +1327,7 @@ class WebDavPropertiesContext implements Context {
$response = $this->getPropertiesOfFolder(
$user,
$path,
null,
$propertiesTable
);
return $this->featureContext->getEtagFromResponseXmlObject($this->featureContext->getResponseXml($response));