diff --git a/tests/acceptance/config/behat.yml b/tests/acceptance/config/behat.yml index 2ec0d263056..2559504c3c2 100644 --- a/tests/acceptance/config/behat.yml +++ b/tests/acceptance/config/behat.yml @@ -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: diff --git a/tests/acceptance/features/bootstrap/SpacesContext.php b/tests/acceptance/features/bootstrap/SpacesContext.php index bba15fba5cb..60e805aa7d9 100644 --- a/tests/acceptance/features/bootstrap/SpacesContext.php +++ b/tests/acceptance/features/bootstrap/SpacesContext.php @@ -65,6 +65,11 @@ class SpacesContext implements Context { */ private FavoritesContext $favoritesContext; + /** + * @var WebDavLockingContext + */ + private WebDavLockingContext $webDavLockingContext; + /** * @var string */ @@ -451,6 +456,7 @@ public function setUpScenario(BeforeScenarioScope $scope): void { $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 @@ public function userHasStoredEtagOfElementOnPathFromSpace($user, $path, $storePa } } - /** - * 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 - = "" . - " "; - $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 .= ""; - } - } - $body .= ""; - $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 @@ public function sendRequestToLockResouceInsideOfSpace(string $user, string $reso * @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); } /**