diff --git a/tests/acceptance/features/bootstrap/WebDav.php b/tests/acceptance/features/bootstrap/WebDav.php index a97d909562ea..c16c2e6bc21d 100644 --- a/tests/acceptance/features/bootstrap/WebDav.php +++ b/tests/acceptance/features/bootstrap/WebDav.php @@ -1708,6 +1708,47 @@ public function userOnUploadsAFileTo($user, $server, $source, $destination) { $this->usingServer($previousServer); } + /** + * Upload file as a user with different headers + * + * @param string $user + * @param string $source + * @param string $destination + * @param array $headers + * @param int $noOfChunks Only use for chunked upload when $this->chunkingToUse is not null + * + * @return void + */ + public function uploadFileWithHeaders( + $user, + $source, + $destination, + $headers=[], + $noOfChunks = 0 + ) { + $chunkingVersion = $this->chunkingToUse; + if ($noOfChunks <= 0) { + $chunkingVersion = null; + } + try { + $this->responseXml = []; + $this->response = UploadHelper::upload( + $this->getBaseUrl(), + $this->getActualUsername($user), + $this->getUserPassword($user), + $source, + $destination, + $headers, + ($this->usingOldDavPath) ? 1 : 2, + $chunkingVersion, + $noOfChunks + ); + } catch (BadResponseException $e) { + // 4xx and 5xx responses cause an exception + $this->response = $e->getResponse(); + } + } + /** * @When /^user "([^"]*)" uploads file "([^"]*)" to "([^"]*)" in (\d+) chunks (?:with (new|old|v1|v2) chunking and)?\s?using the WebDAV API$/ * @When user :user uploads file :source to :destination with chunks using the WebDAV API @@ -1748,25 +1789,12 @@ public function userUploadsAFileToWithChunks( if ($async === true) { $headers = ['OC-LazyOps' => 'true']; } - try { - $this->responseXml = []; - $this->pauseUpload(); - $this->response = UploadHelper::upload( - $this->getBaseUrl(), - $this->getActualUsername($user), - $this->getUserPassword($user), - $this->acceptanceTestsDirLocation() . $source, - $destination, - $headers, - ($this->usingOldDavPath) ? 1 : 2, - $this->chunkingToUse, - $noOfChunks - ); - $this->lastUploadTime = \time(); - } catch (BadResponseException $e) { - // 4xx and 5xx responses cause an exception - $this->response = $e->getResponse(); - } + $this->uploadFileWithHeaders( + $user, + $this->acceptanceTestsDirLocation() . $source, + $destination, + $headers + ); } /**