Skip to content

Commit

Permalink
Merge pull request #33743 from owncloud/fileVersionsChunkUpload
Browse files Browse the repository at this point in the history
Test file_versions with chunking upload
  • Loading branch information
Vincent Petry authored Dec 4, 2018
2 parents 7626c11 + 7d5395f commit 2c554e0
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 11 deletions.
47 changes: 47 additions & 0 deletions tests/acceptance/features/apiMain/fileVersions.feature
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,39 @@ Feature: dav-versions
When user "user0" uploads file "filesForUpload/davtest.txt" to "/davtest.txt" using the WebDAV API
Then the version folder of file "/davtest.txt" for user "user0" should contain "0" elements

Scenario: Upload file and no version is available using various chunking methods
When user "user0" uploads file "filesForUpload/davtest.txt" to "/davtest.txt" with all mechanisms using the WebDAV API
Then the version folder of file "/davtest.txt-olddav-regular" for user "user0" should contain "0" elements
Then the version folder of file "/davtest.txt-newdav-regular" for user "user0" should contain "0" elements
Then the version folder of file "/davtest.txt-olddav-oldchunking" for user "user0" should contain "0" elements
Then the version folder of file "/davtest.txt-newdav-newchunking" for user "user0" should contain "0" elements

Scenario: Upload file and no version is available using async upload
Given the administrator has enabled async operations
When user "user0" uploads file "filesForUpload/davtest.txt" asynchronously to "/davtest.txt" in 3 chunks with new chunking and using the WebDAV API
Then the version folder of file "/davtest.txt" for user "user0" should contain "0" elements

@smokeTest
Scenario: Upload a file twice and versions are available
When user "user0" uploads file "filesForUpload/davtest.txt" to "/davtest.txt" using the WebDAV API
And user "user0" uploads file "filesForUpload/davtest.txt" to "/davtest.txt" using the WebDAV API
Then the version folder of file "/davtest.txt" for user "user0" should contain "1" element
And the content length of file "/davtest.txt" with version index "1" for user "user0" in versions folder should be "8"

Scenario: Upload a file twice and versions are available using various chunking methods
When user "user0" uploads file "filesForUpload/davtest.txt" to "/davtest.txt" with all mechanisms using the WebDAV API
And user "user0" uploads file "filesForUpload/davtest.txt" to "/davtest.txt" with all mechanisms using the WebDAV API
Then the version folder of file "/davtest.txt-olddav-regular" for user "user0" should contain "1" element
Then the version folder of file "/davtest.txt-newdav-regular" for user "user0" should contain "1" element
Then the version folder of file "/davtest.txt-olddav-oldchunking" for user "user0" should contain "1" element
Then the version folder of file "/davtest.txt-newdav-newchunking" for user "user0" should contain "1" element

Scenario: Upload a file twice and versions are available using async upload
Given the administrator has enabled async operations
When user "user0" uploads file "filesForUpload/davtest.txt" asynchronously to "/davtest.txt" in 2 chunks with new chunking and using the WebDAV API
And user "user0" uploads file "filesForUpload/davtest.txt" asynchronously to "/davtest.txt" in 3 chunks with new chunking and using the WebDAV API
Then the version folder of file "/davtest.txt" for user "user0" should contain "1" element

@smokeTest
Scenario: Remove a file
Given user "user0" has uploaded file "filesForUpload/davtest.txt" to "/davtest.txt"
Expand All @@ -36,6 +62,27 @@ Feature: dav-versions
When user "user0" restores version index "1" of file "/davtest.txt" using the WebDAV API
Then the content of file "/davtest.txt" for user "user0" should be "123"

@smokeTest
Scenario Outline: Uploading a chunked file does create the correct version that can be restored
Given using <dav-path> DAV path
When user "user0" uploads file "filesForUpload/davtest.txt" to "/textfile0.txt" in 2 chunks using the WebDAV API
And user "user0" uploads file "filesForUpload/lorem.txt" to "/textfile0.txt" in 3 chunks using the WebDAV API
Then the version folder of file "/textfile0.txt" for user "user0" should contain "2" elements
When user "user0" restores version index "1" of file "/textfile0.txt" using the WebDAV API
Then the content of file "/textfile0.txt" for user "user0" should be "Dav-Test"
Examples:
| dav-path |
| new |
| old |

Scenario: Uploading a file asynchronously does create the correct version that can be restored
Given the administrator has enabled async operations
When user "user0" uploads file "filesForUpload/davtest.txt" asynchronously to "textfile0.txt" in 2 chunks using the WebDAV API
And user "user0" uploads file "filesForUpload/lorem.txt" asynchronously to "textfile0.txt" in 2 chunks using the WebDAV API
Then the version folder of file "/textfile0.txt" for user "user0" should contain "2" elements
When user "user0" restores version index "1" of file "/textfile0.txt" using the WebDAV API
Then the content of file "/textfile0.txt" for user "user0" should be "Dav-Test"

@skipOnStorage:ceph @files_primary_s3-issue-156
Scenario: Restore a file and check, if the content and correct checksum is now in the current file
Given user "user0" has uploaded file with content "AAAAABBBBBCCCCC" and checksum "MD5:45a72715acdd5019c5be30bdbb75233e" to "/davtest.txt"
Expand Down
27 changes: 16 additions & 11 deletions tests/acceptance/features/bootstrap/WebDav.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,10 @@ public function getDavPathVersion($for = null) {
// systemtags only exists since dav v2
return 2;
}

if ($for === 'file_versions') {
// file_versions only exists since dav v2
return 2;
}
if ($this->usingOldDavPath === true) {
return 1;
} else {
Expand Down Expand Up @@ -1533,10 +1536,10 @@ public function listVersionFolder(
'{DAV:}getetag'
];
}

try {
$response = $client->propfind(
$this->makeSabrePathNotForFiles($path), $properties, $folderDepth
$this->makeSabrePathNotForFiles($path, 'file_versions'),
$properties, $folderDepth
);
} catch (Sabre\HTTP\ClientHttpException $e) {
$response = $e->getResponse();
Expand All @@ -1557,6 +1560,7 @@ public function theVersionFolderOfFileShouldContainElements(
$path, $user, $count
) {
$fileId = $this->getFileIdForPath($user, $path);
PHPUnit_Framework_Assert::assertNotNull($fileId, "file $path not found");
$elements = $this->listVersionFolder($user, "/meta/$fileId/v", 1);
PHPUnit_Framework_Assert::assertEquals($count, \count($elements) - 1);
}
Expand Down Expand Up @@ -1690,11 +1694,12 @@ public function makeSabrePath($user, $path) {

/**
* @param string $path
* @param string $for the category of endpoint that the dav path will be used for
*
* @return string
*/
public function makeSabrePathNotForFiles($path) {
return $this->encodePath($this->getDavPath() . $path);
public function makeSabrePathNotForFiles($path, $for = null) {
return $this->encodePath($this->getDavPath($for) . $path);
}

/**
Expand Down Expand Up @@ -3103,15 +3108,15 @@ public function theDavResponseElementShouldBe($element, $expectedValue, $respons
*/
public function userRestoresVersionIndexOfFile($user, $versionIndex, $path) {
$fileId = $this->getFileIdForPath($user, $path);
$client = $this->getSabreClient($user);
$versions = \array_keys(
$this->listVersionFolder($user, "/meta/$fileId/v", 1)
);
$client->request(
'COPY',
$versions[$versionIndex],
null,
['Destination' => $this->makeSabrePath($user, $path)]
//restoring the version only works with dav path v2
$destinationUrl = $this->getBaseUrl() . "/" .
WebDavHelper::getDavPath($user, 2) . \trim($path, "/");
HttpRequestHelper::sendRequest(
$this->getBaseUrlWithoutPath() . $versions[$versionIndex],
'COPY', $user, $this->getPasswordForUser($user), ['Destination' => $destinationUrl]
);
}

Expand Down

0 comments on commit 2c554e0

Please sign in to comment.