Skip to content

Commit

Permalink
Merge pull request #9578 from owncloud/backup-consistency-cli-test
Browse files Browse the repository at this point in the history
[tests-only][full-ci]adding test for backup consistency cli command
  • Loading branch information
saw-jan authored Jul 11, 2024
2 parents 0b8559f + 735b24f commit 4696417
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tests/acceptance/config/behat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,8 @@ default:
contexts:
- FeatureContext: *common_feature_context_params
- CliContext:
- OcisConfigContext:
- SharingNgContext:

extensions:
rdx\behatvars\BehatVariablesExtension: ~
Expand Down
15 changes: 15 additions & 0 deletions tests/acceptance/features/bootstrap/CliContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,20 @@ public function theAdministratorResetsThePasswordOfUserUsingTheCLI(string $statu
$this->featureContext->updateUserPassword($user, $password);
}

/**
* @When the administrator checks the backup consistency using the CLI
*
* @return void
*/
public function theAdministratorChecksTheBackupConsistencyUsingTheCli():void {
$path = $this->featureContext->getStorageUsersRoot();
$command = "backup consistency -p $path";
$body = [
"command" => $command
];
$this->featureContext->setResponse(CliHelper::runCommand($body));
}

/**
* @Then the command should be successful
*
Expand All @@ -115,6 +129,7 @@ public function theCommandShouldBeSuccessful(): void {
public function theCommandOutputShouldContain(string $shouldOrNot, string $output): void {
$response = $this->featureContext->getResponse();
$jsonResponse = $this->featureContext->getJsonDecodedResponse($response);
$output = $this->featureContext->substituteInLineCodes($output);

if ($shouldOrNot === "should") {
Assert::assertStringContainsString($output, $jsonResponse["message"]);
Expand Down
16 changes: 16 additions & 0 deletions tests/acceptance/features/bootstrap/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,14 @@ public function getBaseUrl(): string {
return $this->baseUrl;
}

/**
* @return string
*/
public function getStorageUsersRoot(): string {
$ocisDataPath = getenv("OCIS_BASE_DATA_PATH") ? getenv("OCIS_BASE_DATA_PATH") : getenv("HOME") . '/.ocis';
return getenv("STORAGE_USERS_OCIS_ROOT") ? getenv("STORAGE_USERS_OCIS_ROOT") : $ocisDataPath . "/storage/users";
}

/**
* returns the path of the base URL
* e.g. owncloud-core/10 if the baseUrl is http://localhost/owncloud-core/10
Expand Down Expand Up @@ -2072,6 +2080,14 @@ public function substituteInLineCodes(
],
"parameter" => []
],
[
"code" => "%storage_path%",
"function" => [
$this,
"getStorageUsersRoot"
],
"parameter" => []
],
[
"code" => "%base_url_without_scheme%",
"function" => [
Expand Down
26 changes: 26 additions & 0 deletions tests/acceptance/features/cliCommands/backupConsistency.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
@env-config
Feature: backup consistency
As a user
I want to check my data for inconsistencies
So that I can backup my data


Scenario: check backup consistency via CLI command
Given these users have been created with default attributes and without skeleton files:
| username |
| Alice |
| Brian |
| Carol |
And user "Alice" has created folder "/uploadFolder"
And user "Carol" has created folder "/uploadFolder"
And user "Alice" has sent the following resource share invitation:
| resource | uploadFolder |
| space | Personal |
| sharee | Brian |
| shareType | user |
| permissionsRole | Editor |
And user "Carol" has deleted file "/uploadFolder"
And the administrator has stopped the server
When the administrator checks the backup consistency using the CLI
Then the command should be successful
And the command output should contain "💚 No inconsistency found. The backup in '%storage_path%' seems to be valid."

0 comments on commit 4696417

Please sign in to comment.