Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Adjust checksum tests for new dav chunking
Don't send checksums for each chunk but for the final move.
Added test for the final move.
Removed test code for chunk checksum.
  • Loading branch information
Vincent Petry committed Aug 25, 2017
commit eef29c1b3e9a9768a641a148bbd193e874861bb6
59 changes: 23 additions & 36 deletions tests/integration/features/bootstrap/WebDav.php
Original file line number Diff line number Diff line change
Expand Up @@ -859,55 +859,42 @@ public function userUploadsNewChunkFileOfWithToId($user, $num, $data, $id)
}

/**
* @Given user :user uploads new chunk file :num with :data to id :id with checksum :checksum
* @Given user :user moves new chunk file with id :id to :dest
*/
public function userUploadsNewChunkFileOfWithToIdWithChecksum($user, $num, $data, $id, $checksum)
{
try {
$data = \GuzzleHttp\Stream\Stream::factory($data);
$destination = '/uploads/' . $user . '/' . $id . '/' . $num;
$this->makeDavRequest(
$user,
'PUT',
$destination,
['OC-Checksum' => $checksum],
$data,
"uploads"
);
} catch (\GuzzleHttp\Exception\BadResponseException $ex) {
$this->response = $ex->getResponse();
}
public function userMovesNewChunkFileWithIdToMychunkedfile($user, $id, $dest) {
$this->moveNewDavChunkToFinalFile($user, $id, $dest, []);
}

/**
* @Given user :user moves new chunk file with id :id to :dest
* @Then user :user moves new chunk file with id :id to :dest with size :size
*/
public function userMovesNewChunkFileWithIdToMychunkedfile($user, $id, $dest)
{
try {
$source = '/uploads/' . $user . '/' . $id . '/.file';
$destination = $this->baseUrlWithoutOCSAppendix() . $this->getDavFilesPath($user) . $dest;
$this->makeDavRequest($user, 'MOVE', $source, [
'Destination' => $destination
], null, "uploads");
} catch (\GuzzleHttp\Exception\RequestException $ex) {
$this->response = $ex->getResponse();
}
public function userMovesNewChunkFileWithIdToMychunkedfileWithSize($user, $id, $dest, $size) {
$this->moveNewDavChunkToFinalFile($user, $id, $dest, ['OC-Total-Length' => $size]);
}

/**
* @Then user :user moves new chunk file with id :id to :dest with size :size
* @Then user :user moves new chunk file with id :id to :dest with checksum :checksum
*/
public function userMovesNewChunkFileWithIdToMychunkedfileWithSize($user, $id, $dest, $size)
{
public function userMovesNewChunkFileWithIdToMychunkedfileWithChecksum($user, $id, $dest, $checksum) {
$this->moveNewDavChunkToFinalFile($user, $id, $dest, ['OC-Checksum' => $checksum]);
}

/**
* Move chunked new dav file to final file
*
* @param string $user user
* @param string $id upload id
* @param string $dest destination path
* @param array $headers extra headers
*/
private function moveNewDavChunkToFinalFile($user, $id, $dest, $headers) {
$source = '/uploads/' . $user . '/' . $id . '/.file';
$destination = $this->baseUrlWithoutOCSAppendix() . $this->getDavFilesPath($user) . $dest;

$headers['Destination'] = $destination;

try {
$this->response = $this->makeDavRequest($user, 'MOVE', $source, [
'Destination' => $destination,
'OC-Total-Length' => $size
], null, "uploads");
$this->response = $this->makeDavRequest($user, 'MOVE', $source, $headers, null, "uploads");
} catch(\GuzzleHttp\Exception\BadResponseException $ex) {
$this->response = $ex->getResponse();
}
Expand Down
14 changes: 12 additions & 2 deletions tests/integration/features/checksums.feature
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,22 @@ Feature: checksums
When user "user0" downloads the file "/local_storage/prueba_cksum.txt"
Then The header checksum should match "SHA1:a35b7605c8f586d735435535c337adc066c2ccb6"

Scenario: Upload chunked file where checksum does not match
Scenario: Upload new dav chunked file where checksum matches
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 "3" with "CCCCC" to id "chunking-42"
And user "user0" moves new chunk file with id "chunking-42" to "/myChunkedFile.txt" with checksum "SHA1:5d84d61b03fdacf813640f5242d309721e0629b1"
Then the HTTP status code should be "201"

Scenario: Upload new dav 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"
And user "user0" moves new chunk file with id "chunking-42" to "/myChunkedFile.txt" with checksum "SHA1:f005ba11"
Then the HTTP status code should be "400"

Scenario: Upload a file where checksum does not match
Expand Down