Skip to content

Commit

Permalink
Merge pull request #10597 from owncloud/tests/upload-same-mtime-file
Browse files Browse the repository at this point in the history
[tests-only] add tests to check file uploads with same mtime and different content
  • Loading branch information
saw-jan authored Nov 21, 2024
2 parents 2ea9680 + 7c1c9dd commit fbb319f
Show file tree
Hide file tree
Showing 8 changed files with 94 additions and 10 deletions.
31 changes: 31 additions & 0 deletions tests/acceptance/bootstrap/TUSContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,37 @@ public function userUploadsAFileWithContentInChunksUsingTus(
\unlink($temporaryFileName);
}

/**
* @Given user :user has uploaded file :source to :destination with mtime :mtime using the TUS protocol
*
* @param string $user
* @param string $source
* @param string $destination
* @param string $mtime Time in human-readable format is taken as input which is converted into milliseconds that is used by API
*
* @return void
* @throws Exception
* @throws GuzzleException
*/
public function userHasUploadedFileWithMtimeUsingTUS(
string $user,
string $source,
string $destination,
string $mtime
): void {
$mtime = new DateTime($mtime);
$mtime = $mtime->format('U');
$user = $this->featureContext->getActualUsername($user);
$this->uploadFileUsingTus(
$user,
$source,
$destination,
null,
['mtime' => $mtime]
);
$this->featureContext->setLastUploadDeleteTime(\time());
}

/**
* @When user :user uploads file :source to :destination with mtime :mtime using the TUS protocol on the WebDAV API
*
Expand Down
2 changes: 1 addition & 1 deletion tests/acceptance/bootstrap/WebDav.php
Original file line number Diff line number Diff line change
Expand Up @@ -2278,7 +2278,7 @@ public function userUploadsFileToWithMtimeUsingTheWebdavApi(
}

/**
* @Given user :user has uploaded file :source to :destination with mtime :mtime using the WebDAV API
* @Given user :user has uploaded file :source to :destination with mtime :mtime
*
* @param string $user
* @param string $source
Expand Down
9 changes: 9 additions & 0 deletions tests/acceptance/expected-failures-API-on-OCIS-storage.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,15 @@ _ocdav: api compatibility, return correct status code_

- [coreApiTrashbin/trashbinSharingToShares.feature:277](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiTrashbin/trashbinSharingToShares.feature#L277)

#### [Uploading with the same mtime and filename causes "internal server errors"](https://github.com/owncloud/ocis/issues/10496)

- [coreApiWebdavUpload/uploadFile.feature:400](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiWebdavUpload/uploadFile.feature#L400)
- [coreApiWebdavUpload/uploadFile.feature:401](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiWebdavUpload/uploadFile.feature#L401)
- [coreApiWebdavUpload/uploadFile.feature:402](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiWebdavUpload/uploadFile.feature#L402)
- [coreApiWebdavUploadTUS/uploadFileMtime.feature:79](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiWebdavUploadTUS/uploadFileMtime.feature#L79)
- [coreApiWebdavUploadTUS/uploadFileMtime.feature:80](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiWebdavUploadTUS/uploadFileMtime.feature#L80)
- [coreApiWebdavUploadTUS/uploadFileMtime.feature:81](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiWebdavUploadTUS/uploadFileMtime.feature#L81)

### Won't fix

Not everything needs to be implemented for ocis. While the oc10 testsuite covers these things we are not looking at them right now.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ Feature: create a public link share
Scenario Outline: get the mtime of a file shared by public link
Given the config "OCIS_SHARING_PUBLIC_SHARE_MUST_HAVE_PASSWORD" has been set to "false"
And using <dav-path-version> DAV path
And user "Alice" has uploaded file "filesForUpload/textfile.txt" to "file.txt" with mtime "Thu, 08 Aug 2019 04:18:13 GMT" using the WebDAV API
And user "Alice" has uploaded file "filesForUpload/textfile.txt" to "file.txt" with mtime "Thu, 08 Aug 2019 04:18:13 GMT"
When user "Alice" creates a public link share using the sharing API with settings
| path | file.txt |
| permissions | read |
Expand All @@ -333,7 +333,7 @@ Feature: create a public link share
Given the config "OCIS_SHARING_PUBLIC_SHARE_MUST_HAVE_PASSWORD" has been set to "false"
And using <dav-path-version> DAV path
And user "Alice" has created folder "testFolder"
And user "Alice" has uploaded file "filesForUpload/textfile.txt" to "testFolder/file.txt" with mtime "Thu, 08 Aug 2019 04:18:13 GMT" using the WebDAV API
And user "Alice" has uploaded file "filesForUpload/textfile.txt" to "testFolder/file.txt" with mtime "Thu, 08 Aug 2019 04:18:13 GMT"
When user "Alice" creates a public link share using the sharing API with settings
| path | /testFolder |
| permissions | read |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ Feature: files and folders exist in the trashbin after being deleted
@issue-541
Scenario Outline: deleted file has appropriate deletion time information
Given using <dav-path-version> DAV path
And user "Alice" has uploaded file "filesForUpload/textfile.txt" to "file.txt" with mtime "Thu, 08 Aug 2018 04:18:13 GMT" using the WebDAV API
And user "Alice" has uploaded file "filesForUpload/textfile.txt" to "file.txt" with mtime "Thu, 08 Aug 2018 04:18:13 GMT"
And user "Alice" has deleted file "file.txt"
When user "Alice" tries to list the trashbin content for user "Alice"
Then the HTTP status code should be "207"
Expand Down
13 changes: 7 additions & 6 deletions tests/acceptance/features/coreApiVersions/fileVersions.feature
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ Feature: dav-versions

Scenario Outline: upload the same file twice with the same mtime and a version is available
Given using <dav-path-version> DAV path
And user "Alice" has uploaded file "filesForUpload/textfile.txt" to "file.txt" with mtime "Thu, 08 Aug 2019 04:18:13 GMT" using the WebDAV API
And user "Alice" has uploaded file "filesForUpload/textfile.txt" to "file.txt" with mtime "Thu, 08 Aug 2019 04:18:13 GMT"
When user "Alice" uploads file "filesForUpload/textfile.txt" to "file.txt" with mtime "Thu, 08 Aug 2019 04:18:13 GMT" using the WebDAV API
Then the HTTP status code should be "204"
And the version folder of file "/file.txt" for user "Alice" should contain "1" element
Expand All @@ -287,14 +287,15 @@ Feature: dav-versions
| new |
| spaces |


@issue-10496
Scenario Outline: upload the same file more than twice with the same mtime and only one version is available
Given using <dav-path-version> DAV path
And user "Alice" has uploaded file "filesForUpload/textfile.txt" to "file.txt" with mtime "Thu, 08 Aug 2019 04:18:13 GMT" using the WebDAV API
And user "Alice" has uploaded file "filesForUpload/textfile.txt" to "file.txt" with mtime "Thu, 08 Aug 2019 04:18:13 GMT" using the WebDAV API
And user "Alice" has uploaded file "filesForUpload/textfile.txt" to "file.txt" with mtime "Thu, 08 Aug 2019 04:18:13 GMT"
And user "Alice" has uploaded file "filesForUpload/textfile.txt" to "file.txt" with mtime "Thu, 08 Aug 2019 04:18:13 GMT"
When user "Alice" uploads file "filesForUpload/textfile.txt" to "file.txt" with mtime "Thu, 08 Aug 2019 04:18:13 GMT" using the WebDAV API
Then the HTTP status code should be "204"
And the version folder of file "/file.txt" for user "Alice" should contain "1" element
And as "Alice" the mtime of the file "file.txt" should be "Thu, 08 Aug 2019 04:18:13 GMT"
Examples:
| dav-path-version |
| old |
Expand All @@ -303,8 +304,8 @@ Feature: dav-versions


Scenario: upload the same file twice with the same mtime and no version after restoring
Given user "Alice" has uploaded file "filesForUpload/textfile.txt" to "file.txt" with mtime "Thu, 08 Aug 2019 04:18:13 GMT" using the WebDAV API
And user "Alice" has uploaded file "filesForUpload/textfile.txt" to "file.txt" with mtime "Thu, 08 Aug 2019 04:18:13 GMT" using the WebDAV API
Given user "Alice" has uploaded file "filesForUpload/textfile.txt" to "file.txt" with mtime "Thu, 08 Aug 2019 04:18:13 GMT"
And user "Alice" has uploaded file "filesForUpload/textfile.txt" to "file.txt" with mtime "Thu, 08 Aug 2019 04:18:13 GMT"
When user "Alice" restores version index "1" of file "/file.txt" using the WebDAV API
Then the HTTP status code should be "204"
And the version folder of file "/file.txt" for user "Alice" should contain "0" element
Expand Down
15 changes: 15 additions & 0 deletions tests/acceptance/features/coreApiWebdavUpload/uploadFile.feature
Original file line number Diff line number Diff line change
Expand Up @@ -385,3 +385,18 @@ Feature: upload file
When the public uploads file "test.txt" with password "%public%" and content "test-file" using the public WebDAV API
Then the HTTP status code should be "201"
And for user "Alice" the content of the file "/test.txt" of the space "new-space" should be "test-file"

@issue-10496
Scenario Outline: upload a file with the same mtime and different content multiple times (atleast 3 times)
Given using <dav-path-version> DAV path
And user "Alice" has uploaded file "filesForUpload/textfile.txt" to "file.txt" with mtime "Thu, 08 Aug 2019 04:18:13 GMT"
And user "Alice" has uploaded file "filesForUpload/davtest.txt" to "file.txt" with mtime "Thu, 08 Aug 2019 04:18:13 GMT"
When user "Alice" uploads file "filesForUpload/lorem.txt" to "file.txt" with mtime "Thu, 08 Aug 2019 04:18:13 GMT" using the WebDAV API
Then the HTTP status code should be "204"
And as "Alice" the mtime of the file "file.txt" should be "Thu, 08 Aug 2019 04:18:13 GMT"
And the version folder of file "file.txt" for user "Alice" should contain "2" element
Examples:
| dav-path-version |
| old |
| new |
| spaces |
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,31 @@ Feature: upload file
| old |
| new |
| spaces |

@issue-10346
Scenario Outline: upload a file with the same mtime and same content multiple times (atleast 3 times)
Given using <dav-path-version> DAV path
And user "Alice" has uploaded file "filesForUpload/textfile.txt" to "file.txt" with mtime "Thu, 08 Aug 2019 04:18:13 GMT" using the TUS protocol
And user "Alice" has uploaded file "filesForUpload/textfile.txt" to "file.txt" with mtime "Thu, 08 Aug 2019 04:18:13 GMT" using the TUS protocol
When user "Alice" uploads file "filesForUpload/textfile.txt" to "file.txt" with mtime "Thu, 08 Aug 2019 04:18:13 GMT" using the TUS protocol on the WebDAV API
Then as "Alice" the mtime of the file "file.txt" should be "Thu, 08 Aug 2019 04:18:13 GMT"
And the version folder of file "file.txt" for user "Alice" should contain "1" element
Examples:
| dav-path-version |
| old |
| new |
| spaces |

@issue-10346
Scenario Outline: upload a file with the same mtime and different content multiple times (atleast 3 times)
Given using <dav-path-version> DAV path
And user "Alice" has uploaded file "filesForUpload/textfile.txt" to "file.txt" with mtime "Thu, 08 Aug 2019 04:18:13 GMT" using the TUS protocol
And user "Alice" has uploaded file "filesForUpload/davtest.txt" to "file.txt" with mtime "Thu, 08 Aug 2019 04:18:13 GMT" using the TUS protocol
When user "Alice" uploads file "filesForUpload/lorem.txt" to "file.txt" with mtime "Thu, 08 Aug 2019 04:18:13 GMT" using the TUS protocol on the WebDAV API
Then as "Alice" the mtime of the file "file.txt" should be "Thu, 08 Aug 2019 04:18:13 GMT"
And the version folder of file "file.txt" for user "Alice" should contain "2" element
Examples:
| dav-path-version |
| old |
| new |
| spaces |

0 comments on commit fbb319f

Please sign in to comment.