Skip to content

Commit

Permalink
Merge pull request #37123 from owncloud/files-external-imports
Browse files Browse the repository at this point in the history
[Tests-Only] Acceptance tests to export the local storages mounts to a file
  • Loading branch information
phil-davis authored Mar 18, 2020
2 parents 4ddbf24 + 03db91e commit 534023d
Show file tree
Hide file tree
Showing 5 changed files with 123 additions and 2 deletions.
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()
);
$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:"

0 comments on commit 534023d

Please sign in to comment.