Skip to content

Commit d1d300b

Browse files
committed
refactor for adding not upload tests
Signed-off-by: nabim777 <[email protected]>
1 parent d9deb78 commit d1d300b

File tree

2 files changed

+91
-42
lines changed

2 files changed

+91
-42
lines changed

tests/acceptance/bootstrap/CliContext.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,6 @@ public function theAdministratorResumesOrRestartsUploadSessionOfFileUsingPostpro
464464
*/
465465
public function theAdministratorResumesAllUploadsSessionUsingPostprocessingCommand(): void {
466466
$command = "postprocessing resume";
467-
var_dump($command);
468467
$body = [
469468
"command" => $command,
470469
];
@@ -483,7 +482,6 @@ public function theAdministratorResumesAllUploadsSessionInFinishedOrVirusScanSte
483482
string $step,
484483
): void {
485484
$command = "postprocessing resume -s $step";
486-
var_dump($command);
487485
$body = [
488486
"command" => $command,
489487
];
@@ -535,12 +533,14 @@ public function theCLIResponseShouldContainTheseEntries(string $shouldOrNot, Tab
535533
*/
536534
public function getJSONDecodedCliMessage(ResponseInterface $response): array {
537535
$responseBody = $this->featureContext->getJsonDecodedResponse($response);
538-
539536
// $responseBody["message"] contains a message info with the array of output json of the upload sessions command
540537
// Example Output: "INFO memory is not limited, skipping package=github.com/KimMachineGun/automemlimit/memlimit [{<output-json>}]"
541538
// So, only extracting the array of output json from the message
542-
\preg_match('/(\[.*\])/', $responseBody["message"], $matches);
543-
return \json_decode($matches[1], null, 512, JSON_THROW_ON_ERROR);
539+
\preg_match('/(\[.*?\])/', $responseBody["message"], $matches);
540+
if (!isset($matches[1])) {
541+
return [];
542+
}
543+
return \json_decode($matches[1], null, 512, JSON_THROW_ON_ERROR);
544544
}
545545

546546
/**

tests/acceptance/features/cliCommands/uploadSessions.feature

Lines changed: 86 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -247,56 +247,105 @@ Feature: List upload sessions via CLI command
247247
And the content of file "file1.txt" for user "Alice" should be "uploaded content"
248248

249249

250-
Scenario: resume all failed upload using postprocessing command
250+
Scenario: resume all failed upload but not for unfinished upload using postprocessing command
251251
Given the config "POSTPROCESSING_DELAY" has been set to "3s"
252-
And user "Alice" has uploaded file with content "uploaded content" to "file1.txt"
253-
And user "Alice" has uploaded file with content "uploaded content" to "file2.txt"
252+
And user "Alice" has created a new TUS resource in the space "Personal" with the following headers:
253+
| Upload-Length | 10 |
254+
# dGV4dEZpbGUudHh0 is the base64 encode of textFile.txt
255+
| Upload-Metadata | filename dGV4dEZpbGUudHh0 |
256+
| Tus-Resumable | 1.0.0 |
257+
And user "Alice" has uploaded file with checksum "SHA1 8cb2237d0679ca88db6464eac60da96345513964" to the last created TUS Location with offset "0" and content "12345" via TUS inside of the space "Personal" using the WebDAV API
258+
And user "Alice" has uploaded file with content "uploaded content" to "file.txt"
254259
And the administrator has waited for "1" seconds
255260
And the administrator has stopped the server
256261
And the administrator has started the server
257-
When the administrator waits for "3" seconds
258-
Then for user "Alice" file "file1.txt" of space "Personal" should be in postprocessing
259-
And for user "Alice" file "file2.txt" of space "Personal" should be in postprocessing
260262
When the administrator resumes all uploads session using post processing command
261263
Then the command should be successful
262264
When the administrator waits for "3" seconds
263-
And the content of file "file1.txt" for user "Alice" should be "uploaded content"
264-
And the content of file "file2.txt" for user "Alice" should be "uploaded content"
265+
Then the content of file "file.txt" for user "Alice" should be "uploaded content"
266+
When the administrator lists all the upload sessions
267+
Then the command should be successful
268+
And the CLI response should contain these entries:
269+
| textFile.txt |
270+
And the CLI response should not contain these entries:
271+
| file.txt |
265272

266273

267-
Scenario: resume all failed upload on finished step using postprocessing command
274+
Scenario: resume all failed upload on finished step but not for unfinished upload using postprocessing command
268275
Given the config "POSTPROCESSING_DELAY" has been set to "3s"
269-
And user "Alice" has uploaded file with content "uploaded content" to "file1.txt"
270-
And user "Alice" has uploaded file with content "uploaded content" to "file2.txt"
276+
And user "Alice" has created a new TUS resource in the space "Personal" with the following headers:
277+
| Upload-Length | 10 |
278+
# dGV4dEZpbGUudHh0 is the base64 encode of textFile.txt
279+
| Upload-Metadata | filename dGV4dEZpbGUudHh0 |
280+
| Tus-Resumable | 1.0.0 |
281+
And user "Alice" has uploaded file with checksum "SHA1 8cb2237d0679ca88db6464eac60da96345513964" to the last created TUS Location with offset "0" and content "12345" via TUS inside of the space "Personal" using the WebDAV API
282+
And user "Alice" has uploaded file with content "uploaded content" to "file.txt"
271283
And the administrator has waited for "1" seconds
272284
And the administrator has stopped the server
273285
And the administrator has started the server
274-
When the administrator waits for "3" seconds
275-
Then for user "Alice" file "file1.txt" of space "Personal" should be in postprocessing
276-
And for user "Alice" file "file2.txt" of space "Personal" should be in postprocessing
277286
When the administrator resumes all uploads session in finished step using post processing command
278287
Then the command should be successful
279288
When the administrator waits for "3" seconds
280-
And the content of file "file1.txt" for user "Alice" should be "uploaded content"
281-
And the content of file "file2.txt" for user "Alice" should be "uploaded content"
282-
283-
284-
# Scenario: resume all failed upload on virus scan step using postprocessing command
285-
# Given the following configs have been set:
286-
# | config | value |
287-
# | POSTPROCESSING_STEPS | virusscan |
288-
# | ANTIVIRUS_INFECTED_FILE_HANDLING | abort |
289-
# | POSTPROCESSING_DELAY | 10s |
290-
# And user "Alice" has uploaded file with content "uploaded content" to "file1.txt"
291-
# And user "Alice" has uploaded file with content "uploaded content" to "file2.txt"
292-
# And the administrator has waited for "1" seconds
293-
# And the administrator has stopped the server
294-
# And the administrator has started the server
295-
# When the administrator waits for "3" seconds
296-
# Then for user "Alice" file "file1.txt" of space "Personal" should be in postprocessing
297-
# And for user "Alice" file "file2.txt" of space "Personal" should be in postprocessing
298-
# When the administrator resumes all uploads session in virusscan step using post processing command
299-
# Then the command should be successful
300-
# When the administrator waits for "3" seconds
301-
# And the content of file "file1.txt" for user "Alice" should be "uploaded content"
302-
# And the content of file "file2.txt" for user "Alice" should be "uploaded content"
289+
Then the content of file "file.txt" for user "Alice" should be "uploaded content"
290+
When the administrator lists all the upload sessions
291+
Then the command should be successful
292+
And the CLI response should contain these entries:
293+
| textFile.txt |
294+
And the CLI response should not contain these entries:
295+
| file.txt |
296+
297+
298+
Scenario: resume all failed upload on virus scan steps but not for unfinished upload step using postprocessing command
299+
Given the following configs have been set:
300+
| config | value |
301+
| POSTPROCESSING_STEPS | delay,virusscan |
302+
| ANTIVIRUS_INFECTED_FILE_HANDLING | abort |
303+
| POSTPROCESSING_DELAY | 10s |
304+
And user "Alice" has created a new TUS resource in the space "Personal" with the following headers:
305+
| Upload-Length | 10 |
306+
# dGV4dEZpbGUudHh0 is the base64 encode of textFile.txt
307+
| Upload-Metadata | filename dGV4dEZpbGUudHh0 |
308+
| Tus-Resumable | 1.0.0 |
309+
And user "Alice" has uploaded file with checksum "SHA1 8cb2237d0679ca88db6464eac60da96345513964" to the last created TUS Location with offset "0" and content "12345" via TUS inside of the space "Personal" using the WebDAV API
310+
And user "Alice" has uploaded file "filesForUpload/filesWithVirus/eicar.com" to "/virusFile.txt"
311+
And user "Alice" has uploaded file with content "uploaded content" to "file.txt"
312+
And the administrator has waited for "1" seconds
313+
And the administrator has stopped the server
314+
And the administrator has started the server
315+
When the administrator resumes all uploads session in virusscan step using post processing command
316+
Then the command should be successful
317+
When the administrator waits for "3" seconds
318+
Then the content of file "file.txt" for user "Alice" should be "uploaded content"
319+
When the administrator lists all the upload sessions
320+
Then the command should be successful
321+
And the CLI response should contain these entries:
322+
| textFile.txt |
323+
| virusFile.txt |
324+
And the CLI response should not contain these entries:
325+
| file.txt |
326+
327+
328+
Scenario: resume virus file upload failed on virus scan step using postprocessing command
329+
Given the following configs have been set:
330+
| config | value |
331+
| POSTPROCESSING_STEPS | delay,virusscan |
332+
| ANTIVIRUS_INFECTED_FILE_HANDLING | continue |
333+
| POSTPROCESSING_DELAY | 10s |
334+
And user "Alice" has uploaded file "filesForUpload/filesWithVirus/eicar.com" to "/virusFile.txt"
335+
And the administrator has waited for "1" seconds
336+
And the administrator has stopped the server
337+
And the administrator has started the server
338+
When the administrator waits for "3" seconds
339+
Then for user "Alice" file "virusFile.txt" of space "Personal" should be in postprocessing
340+
When the administrator lists all the upload sessions
341+
Then the command should be successful
342+
And the CLI response should contain these entries:
343+
| virusFile.txt |
344+
When the administrator resumes all uploads session in virusscan step using post processing command
345+
Then the command should be successful
346+
When the administrator waits for "3" seconds
347+
Then as "Alice" file "/virusFile.txt" should exist
348+
When the administrator lists all the upload sessions
349+
Then the command should be successful
350+
And the CLI response should not contain these entries:
351+
| virusFile.txt |

0 commit comments

Comments
 (0)