Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
38 changes: 36 additions & 2 deletions tests/acceptance/bootstrap/CliContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,38 @@ public function theAdministratorResumesOrRestartsUploadSessionOfFileUsingPostpro
$this->featureContext->setResponse(CliHelper::runCommand($body));
}

/**
* @When /^the administrator resumes all the uploads session using the post processing command$/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @When /^the administrator resumes all the uploads session using the post processing command$/
* @When the administrator resumes all the uploads session using the post processing command

*
* @return void
* @throws JsonException
*/
public function theAdministratorResumesAllUploadsSessionUsingPostprocessingCommand(): void {
$command = "postprocessing resume";
$body = [
"command" => $command,
];
$this->featureContext->setResponse(CliHelper::runCommand($body));
}

/**
* @When /^the administrator resumes all uploads session in (finished|virusscan) step using post processing command$/
*
* @param string $step
*
* @return void
* @throws JsonException
*/
public function theAdministratorResumesAllUploadsSessionInFinishedOrVirusScanStepUsingPostprocessingCommand(
string $step,
): void {
$command = "postprocessing resume -s $step";
$body = [
"command" => $command,
];
$this->featureContext->setResponse(CliHelper::runCommand($body));
}

/**
* @Then /^the CLI response (should|should not) contain these entries:$/
*
Expand Down Expand Up @@ -570,11 +602,13 @@ public function theCLIResponseShouldContainTheseEntries(string $shouldOrNot, Tab
*/
public function getJSONDecodedCliMessage(ResponseInterface $response): array {
$responseBody = $this->featureContext->getJsonDecodedResponse($response);

// $responseBody["message"] contains a message info with the array of output json of the upload sessions command
// Example Output: "INFO memory is not limited, skipping package=github.com/KimMachineGun/automemlimit/memlimit [{<output-json>}]"
// So, only extracting the array of output json from the message
\preg_match('/(\[.*\])/', $responseBody["message"], $matches);
\preg_match('/(\[.*?\])/', $responseBody["message"], $matches);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

- \preg_match('/(\[.*\])/', $responseBody["message"], $matches);
+ \preg_match('/(\[.*?\])/', $responseBody["message"], $matches);

making regex non-greedy

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but why was it required?

Copy link
Member Author

@nabim777 nabim777 Sep 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's not needed for current scenario, so I will leave it as is (no changes)

if (!isset($matches[1])) {
return [];
}
return \json_decode($matches[1], null, 512, JSON_THROW_ON_ERROR);
}

Expand Down
104 changes: 104 additions & 0 deletions tests/acceptance/features/cliCommands/uploadSessions.feature
Original file line number Diff line number Diff line change
Expand Up @@ -245,3 +245,107 @@ Feature: List upload sessions via CLI command
When the administrator waits for "3" seconds
Then for user "Alice" file "file2.txt" of space "Personal" should be in postprocessing
And the content of file "file1.txt" for user "Alice" should be "uploaded content"


Scenario: resume all failed upload but not for unfinished upload using postprocessing command
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

finding it difficult to understand the title

Suggested change
Scenario: resume all failed upload but not for unfinished upload using postprocessing command
Scenario: resume all upload sessions containing unfinished upload using postprocessing command

Given the config "POSTPROCESSING_DELAY" has been set to "3s"
And user "Alice" has created a new TUS resource in the space "Personal" with the following headers:
| Upload-Length | 10 |
# dGV4dEZpbGUudHh0 is the base64 encode of textFile.txt
| Upload-Metadata | filename dGV4dEZpbGUudHh0 |
| Tus-Resumable | 1.0.0 |
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
And user "Alice" has uploaded file with content "uploaded content" to "file.txt"
And the administrator has waited for "1" seconds
And the administrator has stopped the server
And the administrator has started the server
When the administrator resumes all the uploads session using the post processing command
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
When the administrator resumes all the uploads session using the post processing command
When the administrator resumes all the upload sessions using the postprocessing command

Then the command should be successful
When the administrator waits for "3" seconds
Then the content of file "file.txt" for user "Alice" should be "uploaded content"
When the administrator lists all the upload sessions
Then the command should be successful
And the CLI response should contain these entries:
| textFile.txt |
And the CLI response should not contain these entries:
| file.txt |


Scenario: resume all failed upload on finished step but not for unfinished upload using postprocessing command
Given the config "POSTPROCESSING_DELAY" has been set to "3s"
And user "Alice" has created a new TUS resource in the space "Personal" with the following headers:
| Upload-Length | 10 |
# dGV4dEZpbGUudHh0 is the base64 encode of textFile.txt
| Upload-Metadata | filename dGV4dEZpbGUudHh0 |
| Tus-Resumable | 1.0.0 |
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
And user "Alice" has uploaded file with content "uploaded content" to "file.txt"
And the administrator has waited for "1" seconds
And the administrator has stopped the server
And the administrator has started the server
When the administrator resumes all uploads session in finished step using post processing command
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what constitutes a finished step? the test flow is same creating failed uploads

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
When the administrator resumes all uploads session in finished step using post processing command
When the administrator resumes all upload sessions in finished step using postprocessing command

Then the command should be successful
When the administrator waits for "3" seconds
Then the content of file "file.txt" for user "Alice" should be "uploaded content"
When the administrator lists all the upload sessions
Then the command should be successful
And the CLI response should contain these entries:
| textFile.txt |
And the CLI response should not contain these entries:
| file.txt |


Scenario: resume all failed upload on virus scan steps but not for unfinished upload step using postprocessing command
Given the following configs have been set:
| config | value |
| POSTPROCESSING_STEPS | delay,virusscan |
| ANTIVIRUS_INFECTED_FILE_HANDLING | abort |
| POSTPROCESSING_DELAY | 10s |
And user "Alice" has created a new TUS resource in the space "Personal" with the following headers:
| Upload-Length | 10 |
# dGV4dEZpbGUudHh0 is the base64 encode of textFile.txt
| Upload-Metadata | filename dGV4dEZpbGUudHh0 |
| Tus-Resumable | 1.0.0 |
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
And user "Alice" has uploaded file "filesForUpload/filesWithVirus/eicar.com" to "/virusFile.txt"
And user "Alice" has uploaded file with content "uploaded content" to "file.txt"
And the administrator has waited for "1" seconds
And the administrator has stopped the server
Comment on lines +301 to +313
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with this flow, the file upload doesn't fail on virusscan, it fails on delay step

And the administrator has started the server
When the administrator resumes all uploads session in virusscan step using post processing command
Then the command should be successful
When the administrator waits for "3" seconds
Then the content of file "file.txt" for user "Alice" should be "uploaded content"
When the administrator lists all the upload sessions
Then the command should be successful
And the CLI response should contain these entries:
| textFile.txt |
| virusFile.txt |
And the CLI response should not contain these entries:
| file.txt |


Scenario: resume virus file upload failed on virus scan step using postprocessing command
Given the following configs have been set:
| config | value |
| POSTPROCESSING_STEPS | delay,virusscan |
Comment on lines +328 to +331
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The above scenario should cover this as well

| ANTIVIRUS_INFECTED_FILE_HANDLING | continue |
| POSTPROCESSING_DELAY | 10s |
And user "Alice" has uploaded file "filesForUpload/filesWithVirus/eicar.com" to "/virusFile.txt"
And the administrator has waited for "1" seconds
And the administrator has stopped the server
And the administrator has started the server
When the administrator waits for "3" seconds
Then for user "Alice" file "virusFile.txt" of space "Personal" should be in postprocessing
When the administrator lists all the upload sessions
Then the command should be successful
And the CLI response should contain these entries:
| virusFile.txt |
When the administrator resumes all uploads session in virusscan step using post processing command
Then the command should be successful
When the administrator waits for "3" seconds
Then as "Alice" file "/virusFile.txt" should exist
When the administrator lists all the upload sessions
Then the command should be successful
And the CLI response should not contain these entries:
| virusFile.txt |