Adding integration tests to checksums#27345
Conversation
|
@SergioBertolinSG, thanks for your PR! By analyzing the history of the files in this pull request, we identified @DeepDiver1975, @PVince81 and @bartv2 to be potential reviewers. |
|
These tests are removed and will be added when copy returns the checksum. Currently they fail. They require #26584 to be done before. Scenario: Copying a file with checksum should return the checksum in the propfind
Given using old dav path
And user "user0" exists
And user "user0" uploads file "data/textfile.txt" to "/myChecksumFile.txt" with checksum "MD5:d70b40f177b14b470d1756a3c12b963a"
When User "user0" copies file "/myChecksumFile.txt" to "/myChecksumFileCopy.txt"
And user "user0" request the checksum of "/myChecksumFileCopy.txt" via propfind
Then The webdav checksum should match "SHA1:3ee962b839762adb0ad8ba6023a4690be478de6f"
Scenario: Copying file with checksum should return the checksum in the download header
Given using old dav path
And user "user0" exists
And user "user0" uploads file "data/textfile.txt" to "/myChecksumFile.txt" with checksum "MD5:d70b40f177b14b470d1756a3c12b963a"
When User "user0" copies file "/myChecksumFile.txt" to "/myChecksumFileCopy.txt"
And user "user0" downloads the file "/myChecksumFileCopy.txt"
Then The header checksum should match "SHA1:3ee962b839762adb0ad8ba6023a4690be478de6f"
|
|
These tests where removed from webdav-related.feature and needs to be added here: Scenario: Upload chunked file where checksum does not match
Given using new dav path
And user "user0" exists
And user "user0" creates a new chunking upload with id "chunking-42"
And user "user0" uploads new chunk file "2" with "BBBBB" to id "chunking-42"
And user "user0" uploads new chunk file "3" with "CCCCC" to id "chunking-42" with checksum "SHA1:f005ba11"
And user "user0" uploads new chunk file "1" with "AAAAA" to id "chunking-42"
And user "user0" moves new chunk file with id "chunking-42" to "/myChunkedFile.txt"
Then the HTTP status code should be "400"
Scenario: Upload a file where checksum does not match
Given user "user0" exists
And file "/chksumtst.txt" does not exist for user "user0"
And user "user0" uploads file with checksum "SHA1:f005ba11" and content "Some Text" to "/chksumtst.txt"
Then the HTTP status code should be "400"
Scenario: Upload a file where checksum does match
Given user "user0" exists
And file "/chksumtst.txt" does not exist for user "user0"
And user "user0" uploads file with checksum "SHA1:ce5582148c6f0c1282335b87df5ed4be4b781399" and content "Some Text" to "/chksumtst.txt"
Then the HTTP status code should be "201"
Scenario: Uploaded file should have the same checksum when downloaded
Given user "user0" exists
And file "/chksumtst.txt" does not exist for user "user0"
And user "user0" uploads file with checksum "SHA1:ce5582148c6f0c1282335b87df5ed4be4b781399" and content "Some Text" to "/chksumtst.txt"
When Downloading file "/chksumtst.txt" as "user0"
Then The following headers should be set
| OC-Checksum | SHA1:ce5582148c6f0c1282335b87df5ed4be4b781399 | |
e545b5f to
7b5fc8b
Compare
|
7b5fc8b to
2ba31b6
Compare
| public function userCopiedFileTo($user, $source, $destination) { | ||
| $client = new Client(); | ||
| $request = $client->createRequest( | ||
| 'MOVE', |
There was a problem hiding this comment.
Yes, thats why I removed copy tests #27345 (comment)
There was a problem hiding this comment.
I'll modify this function.
| public function userUploadsChunkFileOfWithToWithChecksum($user, $num, $total, $data, $destination, $checksum) | ||
| { | ||
| public function userUploadsChunkFileOfWithToWithChecksum($user, $num, $total, $data, $destination, $checksum) { | ||
| //$client = new Client(); |
| And user "user0" uploads chunk file "2" of "3" with "BBBBB" to "/myChecksumFile.txt" with checksum "MD5:45a72715acdd5019c5be30bdbb75233e" | ||
| And user "user0" uploads chunk file "3" of "3" with "CCCCC" to "/myChecksumFile.txt" with checksum "MD5:45a72715acdd5019c5be30bdbb75233e" | ||
| When user "user0" downloads the file "/myChecksumFile.txt" | ||
| Then The header checksum should match "SHA1:acfa6b1565f9710d4d497c6035d5c069bd35a8e8" |
There was a problem hiding this comment.
also check the MD5 ? I see it's passed at upload time ?
There was a problem hiding this comment.
Do you mean add another check there?
Then The header checksum should match "MD5:45a72715acdd5019c5be30bdbb75233e"
This fails.
There was a problem hiding this comment.
Yes. Why does this fail ? Is the MD5 wrong ? Please investigate.
Or alternatively remove the MD5 from this test as you are testing the computed checksum, not the passed checksum.
Then make a separate test that checks if the stored checksum as passed from the client works.
There was a problem hiding this comment.
Well it fails because the sha1 works:
Expected MD5:45a72715acdd5019c5be30bdbb75233e, got SHA1:acfa6b1565f9710d4d497c6035d5c069bd35a8e8
There was a problem hiding this comment.
Don't we return multiple checksums anyway ? Maybe you need to adjust the checking code to pick the matching type and compare that one ?
There was a problem hiding this comment.
No, just one:
[oc-checksum] => Array
│ (
│ [0] => SHA1:acfa6b1565f9710d4d497c6035d5c069bd35a8e8
│ )
There was a problem hiding this comment.
But aren't we computing three different checksum types ? Why only return one then ?
cc @IljaN
There was a problem hiding this comment.
@PVince81
Yeah we are computing three different sums. But I decided to return one. Actually I am not sure anymore what my reasoning was. I think because existing tests expected one sum in the webdav body and I was afraid to break some protocols.
I suppose we could easily change that to have multiple checksums (space seperated) returned on a PROPFIND.
There was a problem hiding this comment.
@SergioBertolinSG PROPFIND nows returns all checksums, I also modified the tests in checksums.feature accordingly
There was a problem hiding this comment.
@IljaN Great, thanks.
(It is really needed to compute three checksums? I guess you already discuss that, but seems weird)
|
👍 for last changes |
| And user "user0" exists | ||
| And file "prueba_cksum.txt" with text "Test file for checksums" is created in local storage | ||
| When user "user0" downloads the file "/local_storage/prueba_cksum.txt" | ||
| When user "user0" downloads the file "/local_storage/prueba_cksum.txt" |
There was a problem hiding this comment.
@SergioBertolinSG I am doing some refactoring and noticed that this line is duplicated.
When I remove 1 copy, the check for header checksum below fails (it cannot find the file).
Do you remember why this download needs to be done twice?
There was a problem hiding this comment.
@phil-davis It might be because checksum is computed on first download for files which have none.
There was a problem hiding this comment.
Ah yes, thanks. I see that the previous test step creates the file directly on the local storage (bypassing ownCloud). So the first download triggers the checksum calculation.
I will make a comment in the feature file while refactoring so the next person does not have to research this.
|
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Requires #27097