diff options
author | Sergio Bertolin <sbertolin@solidgear.es> | 2016-09-27 11:09:55 +0000 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2016-11-02 22:49:44 +0100 |
commit | a642a40f3fb0a1d90df99578e78091dc7bf668ad (patch) | |
tree | c2b9dcb886e1361a525f12723b0d4e42a0368624 /build/integration/features/bootstrap/WebDav.php | |
parent | 39573e602d5e38e4b71b3d197d08798dd9558659 (diff) | |
download | nextcloud-server-a642a40f3fb0a1d90df99578e78091dc7bf668ad.tar.gz nextcloud-server-a642a40f3fb0a1d90df99578e78091dc7bf668ad.zip |
Adapted favorites and dav2 features
Adapted sharing and external features, random failures in sharing:857
Added weddav related feature
Removed forgotten leftovers
Diffstat (limited to 'build/integration/features/bootstrap/WebDav.php')
-rw-r--r-- | build/integration/features/bootstrap/WebDav.php | 66 |
1 files changed, 42 insertions, 24 deletions
diff --git a/build/integration/features/bootstrap/WebDav.php b/build/integration/features/bootstrap/WebDav.php index 69962a7282d..013afae4d5a 100644 --- a/build/integration/features/bootstrap/WebDav.php +++ b/build/integration/features/bootstrap/WebDav.php @@ -40,6 +40,8 @@ trait WebDav { /** @var string*/ private $davPath = "remote.php/webdav"; + /** @var boolean*/ + private $usingOldDavPath = true; /** @var ResponseInterface */ private $response; /** @var map with user as key and another map as value, which has path as key and etag as value */ @@ -53,19 +55,35 @@ trait WebDav { } /** - * @return string + * @Given /^using old dav path$/ */ - public function getFilesPath($user) { - if ($this->davPath === "remote.php/dav") { - $basePath = '/files/' . $user . '/'; + public function usingOldDavPath() { + $this->davPath = "remote.php/webdav"; + $this->usingOldDavPath = true; + } + + /** + * @Given /^using new dav path$/ + */ + public function usingNewDavPath() { + $this->davPath = "remote.php/dav"; + $this->usingOldDavPath = false; + } + + public function getDavFilesPath($user){ + if ($this->usingOldDavPath === true){ + return $this->davPath; } else { - $basePath = '/'; + return $this->davPath . '/files/' . $user; } - return $basePath; } - public function makeDavRequest($user, $method, $path, $headers, $body = null){ - $fullUrl = substr($this->baseUrl, 0, -4) . $this->davPath . "$path"; + public function makeDavRequest($user, $method, $path, $headers, $body = null, $type = "files"){ + if ( $type === "files" ){ + $fullUrl = substr($this->baseUrl, 0, -4) . $this->getDavFilesPath($user) . "$path"; + } else if ( $type === "uploads" ){ + $fullUrl = substr($this->baseUrl, 0, -4) . $this->davPath . "$path"; + } $client = new GClient(); $options = []; if ($user === 'admin') { @@ -95,7 +113,7 @@ trait WebDav { * @param string $fileDestination */ public function userMovedFile($user, $entry, $fileSource, $fileDestination){ - $fullUrl = substr($this->baseUrl, 0, -4) . $this->davPath; + $fullUrl = substr($this->baseUrl, 0, -4) . $this->getDavFilesPath($user); $headers['Destination'] = $fullUrl . $fileDestination; $this->response = $this->makeDavRequest($user, "MOVE", $fileSource, $headers); PHPUnit_Framework_Assert::assertEquals(201, $this->response->getStatusCode()); @@ -108,7 +126,7 @@ trait WebDav { * @param string $fileDestination */ public function userMovesFile($user, $entry, $fileSource, $fileDestination){ - $fullUrl = substr($this->baseUrl, 0, -4) . $this->davPath; + $fullUrl = substr($this->baseUrl, 0, -4) . $this->getDavFilesPath($user); $headers['Destination'] = $fullUrl . $fileDestination; $this->response = $this->makeDavRequest($user, "MOVE", $fileSource, $headers); } @@ -120,7 +138,7 @@ trait WebDav { * @param string $fileDestination */ public function userCopiesFileTo($user, $fileSource, $fileDestination) { - $fullUrl = substr($this->baseUrl, 0, -4) . $this->davPath; + $fullUrl = substr($this->baseUrl, 0, -4) . $this->getDavFilesPath($user); $headers['Destination'] = $fullUrl . $fileDestination; try { $this->response = $this->makeDavRequest($user, 'COPY', $fileSource, $headers); @@ -246,7 +264,7 @@ trait WebDav { } /** - * @Then /^as "([^"]*)" gets properties of folder "([^"]*)" with$/ + * @Then /^as "([^"]*)" gets properties of (file|folder|entry) "([^"]*)" with$/ * @param string $user * @param string $path * @param \Behat\Gherkin\Node\TableNode|null $propertiesTable @@ -371,7 +389,7 @@ trait WebDav { } public function makeSabrePath($user, $path) { - return $this->encodePath($this->davPath . $this->getFilesPath($user) . ltrim($path, '/')); + return $this->encodePath($this->getDavFilesPath($user) . $path); } public function getSabreClient($user) { @@ -402,7 +420,7 @@ trait WebDav { $elementRows = $expectedElements->getRows(); $elementsSimplified = $this->simplifyArray($elementRows); foreach($elementsSimplified as $expectedElement) { - $webdavPath = "/" . $this->davPath . $expectedElement; + $webdavPath = "/" . $this->getDavFilesPath($user) . $expectedElement; if (!array_key_exists($webdavPath,$elementList)){ PHPUnit_Framework_Assert::fail("$webdavPath" . " is not in propfind answer"); } @@ -478,7 +496,7 @@ trait WebDav { */ public function userCreatedAFolder($user, $destination) { try { - $this->response = $this->makeDavRequest($user, "MKCOL", $this->getFilesPath($user) . ltrim($destination, $this->getFilesPath($user)), []); + $this->response = $this->makeDavRequest($user, "MKCOL", $destination, []); } catch (\GuzzleHttp\Exception\ServerException $e) { // 4xx and 5xx responses cause an exception $this->response = $e->getResponse(); @@ -497,8 +515,8 @@ trait WebDav { { $num -= 1; $data = \GuzzleHttp\Stream\Stream::factory($data); - $file = $destination . '-chunking-42-'.$total.'-'.$num; - $this->makeDavRequest($user, 'PUT', $file, ['OC-Chunked' => '1'], $data); + $file = $destination . '-chunking-42-' . $total . '-' . $num; + $this->makeDavRequest($user, 'PUT', $file, ['OC-Chunked' => '1'], $data, "uploads"); } /** @@ -507,7 +525,7 @@ trait WebDav { public function userCreatesANewChunkingUploadWithId($user, $id) { $destination = '/uploads/'.$user.'/'.$id; - $this->makeDavRequest($user, 'MKCOL', $destination, []); + $this->makeDavRequest($user, 'MKCOL', $destination, [], null, "uploads"); } /** @@ -516,8 +534,8 @@ trait WebDav { public function userUploadsNewChunkFileOfWithToId($user, $num, $data, $id) { $data = \GuzzleHttp\Stream\Stream::factory($data); - $destination = '/uploads/'.$user.'/'.$id.'/'.$num; - $this->makeDavRequest($user, 'PUT', $destination, [], $data); + $destination = '/uploads/'. $user .'/'. $id .'/' . $num; + $this->makeDavRequest($user, 'PUT', $destination, [], $data, "uploads"); } /** @@ -525,11 +543,11 @@ trait WebDav { */ public function userMovesNewChunkFileWithIdToMychunkedfile($user, $id, $dest) { - $source = '/uploads/'.$user.'/'.$id.'/.file'; - $destination = substr($this->baseUrl, 0, -4) . $this->davPath . '/files/'.$user.$dest; + $source = '/uploads/' . $user . '/' . $id . '/.file'; + $destination = substr($this->baseUrl, 0, -4) . $this->getDavFilesPath($user) . $dest; $this->makeDavRequest($user, 'MOVE', $source, [ 'Destination' => $destination - ]); + ], null, "uploads"); } @@ -588,7 +606,7 @@ trait WebDav { ]; } - $response = $client->proppatch($this->davPath . $this->getFilesPath($user) . ltrim($path, '/'), $properties, $folderDepth); + $response = $client->proppatch($this->getDavFilesPath($user) . $path, $properties, $folderDepth); return $response; } |