Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Tests-Only] Acceptance tests to export the local storages mounts to a file #37123

Merged
merged 4 commits into from
Mar 18, 2020
Merged
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
28 changes: 28 additions & 0 deletions tests/acceptance/features/bootstrap/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -1912,6 +1912,34 @@ public function theAdministratorCreatesFileWithContentInLocalStorageUsingTheTest
$this->setResponse($response);
}

/**
* @Given the administrator has created a file :path with the last exported content using the testing API
*
* @param string $path
*
* @return void
*/
public function theAdministratorHasCreatedAFileWithLastExportedContent(
$path
) {
$commandOutput = $this->getStdOutOfOccCommand();
$user = $this->getAdminUsername();
$response = OcsApiHelper::sendRequest(
$this->getBaseUrl(),
$user,
$this->getAdminPassword(),
'POST',
"/apps/testing/api/v1/file",
[
'file' => "/$path",
'content' => $commandOutput
],
$this->getOcsApiVersion()
);
jasson99 marked this conversation as resolved.
Show resolved Hide resolved
$lastExportedContent = $this->getStdOutOfOccCommand();
$this->theFileWithContentShouldExistInTheServerRoot($path, $lastExportedContent);
}

/**
* @Given the administrator has created file :path with content :content in local storage :mountPount
*
Expand Down
51 changes: 51 additions & 0 deletions tests/acceptance/features/bootstrap/OccContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -1890,6 +1890,34 @@ public function administratorDeletesFolder($folder) {
return (int) $mount_id;
}

/**
* @When the administrator has deleted local storage :folder using the occ command
*
* @param string $folder
*
* @return integer
* @throws Exception
*/
public function administratorHasDeletedFolder($folder) {
$createdLocalStorage = [];
$this->listLocalStorageMount();
$commandOutput = \json_decode($this->featureContext->getStdOutOfOccCommand());
foreach ($commandOutput as $i) {
$createdLocalStorage[$i->mount_id] = \ltrim($i->mount_point, '/');
}
foreach ($createdLocalStorage as $key => $value) {
if ($value === $folder) {
$mount_id = $key;
}
}
if (!isset($mount_id)) {
throw new Exception("Id not found for folder to be deleted");
}
$this->invokingTheCommand('files_external:delete --yes ' . $mount_id);
$this->theCommandShouldHaveBeenSuccessful();
return (int) $mount_id;
}

/**
* @When the administrator exports the local storage mounts using the occ command
*
Expand All @@ -1900,6 +1928,29 @@ public function theAdministratorExportsTheMountsUsingTheOccCommand() {
$this->invokingTheCommand('files_external:export');
}

/**
* @When the administrator imports the local storage mount from file :file using the occ command
*
* @param $file
*
* @return void
* @throws Exception
*/
public function theAdministratorImportsTheMountFromFileUsingTheOccCommand($file) {
$this->invokingTheCommand('files_external:import ' . $file);
}

/**
* @When the administrator has exported the local storage mounts using the occ command
*
* @return void
* @throws Exception
*/
public function theAdministratorHasExportedTheMountsUsingTheOccCommand() {
$this->invokingTheCommand('files_external:export');
$this->theCommandShouldHaveBeenSuccessful();
}

/**
* @When the administrator verifies the mount configuration for local storage :localStorage using the occ command
*
Expand Down
14 changes: 14 additions & 0 deletions tests/acceptance/features/bootstrap/Provisioning.php
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,20 @@ public function theseUsersHaveBeenCreatedWithoutSkeletonFiles(TableNode $table)
}
}

/**
* @Given the administrator has set the system language to :defaultLanguage
*
* @param $defaultLanguage
*
* @return void
* @throws Exception
*/
public function theAdministratorHasSetTheSystemLanguagaeTo($defaultLanguage) {
$this->runOcc(
["config:system:set default_language --value $defaultLanguage"]
);
}

/**
*
* @param string $path
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,26 @@ Feature: export created local storage mounts from the command line
I want to export all created local storage mounts from the command line
So that I can view available local storage mounts

Scenario: export the created mounts
Background:
Given the administrator has created the local storage mount "local_storage2"
And the administrator has created the local storage mount "new_local_storage"
And the administrator has uploaded file with content "this is a file in local storage" to "/local_storage2/file-in-local-storage.txt"
And the administrator has uploaded file with content "new file" to "/new_local_storage/new-file"

Scenario: export the created mounts
When the administrator exports the local storage mounts using the occ command
Then the following local storage should be listed:
| MountPoint | Storage | AuthenticationType | Configuration | Options | ApplicableUsers | ApplicableGroups |
| /local_storage2 | Local | None | datadir: | | All | |
| /new_local_storage | Local | None | datadir: | | All | |
| /local_storage | Local | None | datadir: | enable_sharing: true | All | |
| /local_storage | Local | None | datadir: | enable_sharing: true | All | |

@issue-37054
Scenario: export the created mounts when the system language is "de"
Given the administrator has set the system language to "de"
When the administrator exports the local storage mounts using the occ command
Then the following local storage should be listed:
| MountPoint | Storage | AuthenticationType | Configuration | Options | ApplicableUsers | ApplicableGroups |
| /local_storage2 | Lokal | Keine | datadir: | | All | |
| /new_local_storage | Lokal | Keine | datadir: | | All | |
| /local_storage | Lokal | Keine | datadir: | enable_sharing: true | All | |
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
@cli @skipOnLDAP @local_storage
Feature: import exported local storage mounts from the command line
As an admin
I want to import exported local storage mounts from the command line
So that I can create previously exported local storage mounts

@issue-37054
Scenario: import local storage mounts from a file
Given the administrator has created the local storage mount "local_storage2"
And the administrator has uploaded file with content "this is a file in local storage" to "/local_storage2/file-in-local-storage.txt"
And the administrator has exported the local storage mounts using the occ command
And the administrator has created a file "data/exportedMounts.json" with the last exported content using the testing API
And the administrator has deleted local storage "local_storage2" using the occ command
When the administrator imports the local storage mount from file "data/exportedMounts.json" using the occ command
# change the then step once the issue is fixed, and the import works well
Then the command output should contain the text "An unhandled exception has been thrown:"