mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-03-13 18:00:34 -05:00
Merge pull request #4510 from owncloud/reuseCodeForLockFromCore
[tests-only][full-ci]Reuse locking method from core
This commit is contained in:
@@ -30,6 +30,8 @@ default:
|
||||
- PublicWebDavContext:
|
||||
- TrashbinContext:
|
||||
- WebDavPropertiesContext:
|
||||
- WebDavLockingContext:
|
||||
|
||||
apiSpaces:
|
||||
paths:
|
||||
- '%paths.base%/../features/apiSpaces'
|
||||
@@ -46,6 +48,7 @@ default:
|
||||
- SearchContext:
|
||||
- TrashbinContext:
|
||||
- WebDavPropertiesContext:
|
||||
- WebDavLockingContext:
|
||||
- TusContext:
|
||||
|
||||
apiArchiver:
|
||||
@@ -64,6 +67,7 @@ default:
|
||||
- FavoritesContext:
|
||||
- TrashbinContext:
|
||||
- WebDavPropertiesContext:
|
||||
- WebDavLockingContext:
|
||||
|
||||
apiGraph:
|
||||
paths:
|
||||
|
||||
@@ -65,6 +65,11 @@ class SpacesContext implements Context {
|
||||
*/
|
||||
private FavoritesContext $favoritesContext;
|
||||
|
||||
/**
|
||||
* @var WebDavLockingContext
|
||||
*/
|
||||
private WebDavLockingContext $webDavLockingContext;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
@@ -451,6 +456,7 @@ class SpacesContext implements Context {
|
||||
$this->trashbinContext = $environment->getContext('TrashbinContext');
|
||||
$this->webDavPropertiesContext = $environment->getContext('WebDavPropertiesContext');
|
||||
$this->favoritesContext = $environment->getContext('FavoritesContext');
|
||||
$this->webDavLockingContext = $environment->getContext('WebDavLockingContext');
|
||||
// Run the BeforeScenario function in OCSContext to set it up correctly
|
||||
$this->ocsContext->before($scope);
|
||||
$this->baseUrl = \trim($this->featureContext->getBaseUrl(), "/");
|
||||
@@ -2986,60 +2992,6 @@ class SpacesContext implements Context {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Request to lock the resource inside of space
|
||||
*
|
||||
* @param string $user
|
||||
* @param string $resource
|
||||
* @param TableNode $properties
|
||||
* @param string $spaceName
|
||||
*
|
||||
* @return void
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function sendRequestToLockResouceInsideOfSpace(string $user, string $resource, TableNode $properties, string $spaceName):void {
|
||||
$body
|
||||
= "<?xml version='1.0' encoding='UTF-8'?>" .
|
||||
"<d:lockinfo xmlns:d='DAV:'> ";
|
||||
$headers = [];
|
||||
$this->featureContext->verifyTableNodeRows($properties, [], ['lockscope', 'depth', 'timeout']);
|
||||
$propertiesRows = $properties->getRowsHash();
|
||||
foreach ($propertiesRows as $property => $value) {
|
||||
if ($property === "depth" || $property === "timeout") {
|
||||
//properties that are set in the header not in the xml
|
||||
$headers[$property] = $value;
|
||||
} else {
|
||||
$body .= "<d:$property><d:$value/></d:$property>";
|
||||
}
|
||||
}
|
||||
$body .= "</d:lockinfo>";
|
||||
$space = $this->getSpaceByName($user, $spaceName);
|
||||
$fullUrl = $space['root']['webDavUrl'] . '/' . ltrim($resource, '/');
|
||||
$this->featureContext->setResponse(
|
||||
HttpRequestHelper::sendRequest(
|
||||
$fullUrl,
|
||||
"",
|
||||
'LOCK',
|
||||
$user,
|
||||
$this->featureContext->getPasswordForUser($user),
|
||||
[],
|
||||
$body
|
||||
)
|
||||
);
|
||||
$this->featureContext->theHTTPStatusCodeShouldBe(
|
||||
200,
|
||||
__METHOD__ . " Failed to lock the resource $resource"
|
||||
);
|
||||
$responseXml = $this->featureContext->getResponseXml(null, __METHOD__);
|
||||
$this->featureContext->setResponseXmlObject($responseXml);
|
||||
$xmlPart = $responseXml->xpath("//d:locktoken/d:href");
|
||||
if (\is_array($xmlPart) && isset($xmlPart[0])) {
|
||||
$this->tokenOfLastLock[$user][$resource] = (string) $xmlPart[0];
|
||||
} else {
|
||||
Assert::fail("could not find lock token after trying to lock '$resource'");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @Given /^user "([^"]*)" has locked folder "([^"]*)" inside space "([^"]*)" setting the following properties$/
|
||||
*
|
||||
@@ -3051,7 +3003,8 @@ class SpacesContext implements Context {
|
||||
* @throws Exception | GuzzleException
|
||||
*/
|
||||
public function userHasLockedResourceOfSpace(string $user, string $resource, TableNode $properties, string $spaceName) {
|
||||
$this->sendRequestToLockResouceInsideOfSpace($user, $resource, $properties, $spaceName);
|
||||
$this->setSpaceIDByName($user, $spaceName);
|
||||
$this->webDavLockingContext->lockFileUsingWebDavAPI($user, $resource, $properties);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user