diff --git a/tests/acceptance/TestHelpers/UploadHelper.php b/tests/acceptance/TestHelpers/UploadHelper.php index 47849e798..553509262 100644 --- a/tests/acceptance/TestHelpers/UploadHelper.php +++ b/tests/acceptance/TestHelpers/UploadHelper.php @@ -46,8 +46,6 @@ class UploadHelper extends Assert { * @param string|null $xRequestId * @param array|null $headers * @param int|null $davPathVersionToUse (1|2) - * @param int|null $chunkingVersion (1|2|null) - * if set to null chunking will not be used * @param int|null $noOfChunks how many chunks to upload * @param bool|null $isGivenStep * @@ -63,12 +61,10 @@ class UploadHelper extends Assert { ?string $xRequestId = '', ?array $headers = [], ?int $davPathVersionToUse = 1, - ?int $chunkingVersion = null, ?int $noOfChunks = 1, ?bool $isGivenStep = false ): ResponseInterface { - //simple upload with no chunking - if ($chunkingVersion === null) { + if ($noOfChunks === 1) { $data = \file_get_contents($source); return WebDavHelper::makeDavRequest( $baseUrl, @@ -91,56 +87,16 @@ class UploadHelper extends Assert { null, $isGivenStep ); - } else { - //prepare chunking - $chunks = self::chunkFile($source, $noOfChunks); - $chunkingId = 'chunking-' . \rand(1000, 9999); - $v2ChunksDestination = '/uploads/' . $user . '/' . $chunkingId; } + //prepare chunking + $chunks = self::chunkFile($source, $noOfChunks); + $chunkingId = 'chunking-' . \rand(1000, 9999); $result = null; - //prepare chunking version specific stuff - if ($chunkingVersion === 1) { - $headers['OC-Chunked'] = '1'; - } elseif ($chunkingVersion === 2) { - $result = WebDavHelper::makeDavRequest( - $baseUrl, - $user, - $password, - 'MKCOL', - $v2ChunksDestination, - $headers, - null, - $xRequestId, - null, - $davPathVersionToUse, - "uploads", - null, - "basic", - false, - 0, - null, - [], - null, - $isGivenStep - ); - if ($result->getStatusCode() >= 400) { - return $result; - } - } - //upload chunks foreach ($chunks as $index => $chunk) { - if ($chunkingVersion === 1) { - $filename = $destination . "-" . $chunkingId . "-" . - \count($chunks) . '-' . $index; - $davRequestType = "files"; - } else { - // do chunking version 2 - $filename = $v2ChunksDestination . '/' . $index; - $davRequestType = "uploads"; - } + $filename = $destination . "-" . $chunkingId . "-" . \count($chunks) . '-' . $index; $result = WebDavHelper::makeDavRequest( $baseUrl, $user, @@ -152,7 +108,7 @@ class UploadHelper extends Assert { $xRequestId, $chunk, $davPathVersionToUse, - $davRequestType, + "files", null, "basic", false, @@ -166,38 +122,8 @@ class UploadHelper extends Assert { return $result; } } - //finish upload for new chunking - if ($chunkingVersion === 2) { - $source = $v2ChunksDestination . '/.file'; - $headers['Destination'] = $baseUrl . "/" . - WebDavHelper::getDavPath($davPathVersionToUse, $user) . - $destination; - $result = WebDavHelper::makeDavRequest( - $baseUrl, - $user, - $password, - 'MOVE', - $source, - $headers, - null, - $xRequestId, - null, - $davPathVersionToUse, - "uploads", - null, - "basic", - false, - 0, - null, - [], - null, - $isGivenStep - ); - if ($result->getStatusCode() >= 400) { - return $result; - } - } - self::assertNotNull($result, __METHOD__ . " chunking version $chunkingVersion was requested but no upload was done."); + + self::assertNotNull($result, __METHOD__ . " chunking was requested but no upload was done."); return $result; } @@ -212,7 +138,6 @@ class UploadHelper extends Assert { * @param string|null $xRequestId * @param bool $overwriteMode when false creates separate files to test uploading brand-new files, * when true it just overwrites the same file over and over again with the same name - * @param string|null $exceptChunkingType empty string or "old" or "new" * * @return array of ResponseInterface * @throws GuzzleException @@ -225,44 +150,15 @@ class UploadHelper extends Assert { ?string $destination, ?string $xRequestId = '', ?bool $overwriteMode = false, - ?string $exceptChunkingType = '' ):array { $responses = []; - foreach ([1, 2] as $davPathVersion) { - if ($davPathVersion === 1) { - $davHuman = 'old'; - } else { - $davHuman = 'new'; - } - - switch ($exceptChunkingType) { - case 'old': - $exceptChunkingVersion = 1; - break; - case 'new': - $exceptChunkingVersion = 2; - break; - default: - $exceptChunkingVersion = -1; - break; - } - - foreach ([null, 1, 2] as $chunkingVersion) { - if ($chunkingVersion === $exceptChunkingVersion) { - continue; - } - $valid = WebDavHelper::isValidDavChunkingCombination( - $davPathVersion, - $chunkingVersion - ); - if ($valid === false) { - continue; - } + foreach ([WebDavHelper::DAV_VERSION_OLD, WebDavHelper::DAV_VERSION_NEW, WebDavHelper::DAV_VERSION_SPACES] as $davPathVersion) { + foreach ([false, true] as $chunkingUse) { $finalDestination = $destination; - if (!$overwriteMode && $chunkingVersion !== null) { - $finalDestination .= "-{$davHuman}dav-{$davHuman}chunking"; - } elseif (!$overwriteMode && $chunkingVersion === null) { - $finalDestination .= "-{$davHuman}dav-regular"; + if (!$overwriteMode && $chunkingUse) { + $finalDestination .= "-{$davPathVersion}dav-{$davPathVersion}chunking"; + } elseif (!$overwriteMode && !$chunkingUse) { + $finalDestination .= "-{$davPathVersion}dav-regular"; } $responses[] = self::upload( $baseUrl, @@ -273,7 +169,6 @@ class UploadHelper extends Assert { $xRequestId, [], $davPathVersion, - $chunkingVersion, 2 ); } diff --git a/tests/acceptance/TestHelpers/WebDavHelper.php b/tests/acceptance/TestHelpers/WebDavHelper.php index 0676b941b..4297e18fe 100644 --- a/tests/acceptance/TestHelpers/WebDavHelper.php +++ b/tests/acceptance/TestHelpers/WebDavHelper.php @@ -816,34 +816,6 @@ class WebDavHelper { return \preg_replace("/([^:]\/)\/+/", '$1', $url); } - /** - * Decides if the proposed dav version and chunking version are - * a valid combination. - * If no chunkingVersion is specified, then any dav version is valid. - * If a chunkingVersion is specified, then it has to match the dav version. - * Note: in future, the dav and chunking versions might or might not - * move together and/or be supported together. So a more complex - * matrix could be needed here. - * - * @param string|int $davPathVersion - * @param string|int|null $chunkingVersion - * - * @return boolean is this a valid combination - */ - public static function isValidDavChunkingCombination( - $davPathVersion, - $chunkingVersion - ): bool { - if ($davPathVersion === self::DAV_VERSION_SPACES) { - // allow only old chunking version when using the spaces dav - return $chunkingVersion === 1; - } - return ( - ($chunkingVersion === 'no' || $chunkingVersion === null) || - ($davPathVersion === $chunkingVersion) - ); - } - /** * get Mtime of File in a public link share * diff --git a/tests/acceptance/bootstrap/WebDav.php b/tests/acceptance/bootstrap/WebDav.php index 99a625e9b..79fadba4e 100644 --- a/tests/acceptance/bootstrap/WebDav.php +++ b/tests/acceptance/bootstrap/WebDav.php @@ -1645,7 +1645,6 @@ trait WebDav { $this->getStepLineRef(), $headers, $this->getDavPathVersion(), - $noOfChunks <= 0 ? null : 1, $noOfChunks ); $this->lastUploadDeleteTime = \time(); @@ -1698,7 +1697,7 @@ trait WebDav { * Except do not do the new-DAV-new-chunking combination. That is not being * supported on all implementations. * - * @When user :user uploads file :source to filenames based on :destination with all mechanisms except new chunking using the WebDAV API + * @When user :user uploads file :source to filenames based on :destination with all mechanisms using the WebDAV API * * @param string $user * @param string $source @@ -1706,6 +1705,7 @@ trait WebDav { * * @return void * @throws Exception + * @throws GuzzleException */ public function userUploadsAFileToWithAllMechanismsExceptNewChunking( string $user, @@ -1721,7 +1721,6 @@ trait WebDav { $destination, $this->getStepLineRef(), false, - 'new' ); } @@ -2194,7 +2193,6 @@ trait WebDav { $this->getStepLineRef(), ["X-OC-Mtime" => $mtime], $this->getDavPathVersion(), - null, 1, $isGivenStep ); @@ -2229,7 +2227,6 @@ trait WebDav { $this->getStepLineRef(), ["X-OC-Mtime" => $mtime], $this->getDavPathVersion(), - null, 1, true ); diff --git a/tests/acceptance/features/coreApiVersions/fileVersions.feature b/tests/acceptance/features/coreApiVersions/fileVersions.feature index 16be0b516..6c5712cce 100644 --- a/tests/acceptance/features/coreApiVersions/fileVersions.feature +++ b/tests/acceptance/features/coreApiVersions/fileVersions.feature @@ -20,18 +20,12 @@ Feature: dav-versions | spaces | - Scenario Outline: upload file and no version is available using various chunking methods (except new chunking) - Given using DAV path - When user "Alice" uploads file "filesForUpload/davtest.txt" to filenames based on "/davtest.txt" with all mechanisms except new chunking using the WebDAV API + Scenario: upload file and no version is available using various chunking methods + When user "Alice" uploads file "filesForUpload/davtest.txt" to filenames based on "/davtest.txt" with all mechanisms using the WebDAV API Then the HTTP status code of all upload responses should be "201" - And the version folder of file "/davtest.txt-olddav-regular" for user "Alice" should contain "0" elements - And the version folder of file "/davtest.txt-newdav-regular" for user "Alice" should contain "0" elements - And the version folder of file "/davtest.txt-olddav-oldchunking" for user "Alice" should contain "0" elements - Examples: - | dav-path-version | - | old | - | new | - | spaces | + And the version folder of file "/davtest.txt-1dav-regular" for user "Alice" should contain "0" elements + And the version folder of file "/davtest.txt-2dav-regular" for user "Alice" should contain "0" elements + And the version folder of file "/davtest.txt-3dav-3chunking" for user "Alice" should contain "0" elements @smokeTest Scenario Outline: upload a file twice and versions are available @@ -48,19 +42,13 @@ Feature: dav-versions | spaces | - Scenario Outline: upload a file twice and versions are available using various chunking methods (except new chunking) - Given using DAV path - When user "Alice" uploads file "filesForUpload/davtest.txt" to filenames based on "/davtest.txt" with all mechanisms except new chunking using the WebDAV API - And user "Alice" uploads file "filesForUpload/davtest.txt" to filenames based on "/davtest.txt" with all mechanisms except new chunking using the WebDAV API + Scenario: upload a file twice and versions are available using various chunking methods + When user "Alice" uploads file "filesForUpload/davtest.txt" to filenames based on "/davtest.txt" with all mechanisms using the WebDAV API + And user "Alice" uploads file "filesForUpload/davtest.txt" to filenames based on "/davtest.txt" with all mechanisms using the WebDAV API Then the HTTP status code of all upload responses should be between "201" and "204" - And the version folder of file "/davtest.txt-olddav-regular" for user "Alice" should contain "1" element - And the version folder of file "/davtest.txt-newdav-regular" for user "Alice" should contain "1" element - And the version folder of file "/davtest.txt-olddav-oldchunking" for user "Alice" should contain "1" element - Examples: - | dav-path-version | - | old | - | new | - | spaces | + And the version folder of file "/davtest.txt-1dav-regular" for user "Alice" should contain "1" element + And the version folder of file "/davtest.txt-2dav-regular" for user "Alice" should contain "1" element + And the version folder of file "/davtest.txt-3dav-3chunking" for user "Alice" should contain "1" element @smokeTest Scenario Outline: remove a file