diff --git a/tests/acceptance/features/bootstrap/FeatureContext.php b/tests/acceptance/features/bootstrap/FeatureContext.php index f90b3645a45e..46485ea786cb 100644 --- a/tests/acceptance/features/bootstrap/FeatureContext.php +++ b/tests/acceptance/features/bootstrap/FeatureContext.php @@ -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 * diff --git a/tests/acceptance/features/bootstrap/OccContext.php b/tests/acceptance/features/bootstrap/OccContext.php index 36a09a80a1ed..7ac0044d04e3 100644 --- a/tests/acceptance/features/bootstrap/OccContext.php +++ b/tests/acceptance/features/bootstrap/OccContext.php @@ -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 * @@ -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 * diff --git a/tests/acceptance/features/bootstrap/Provisioning.php b/tests/acceptance/features/bootstrap/Provisioning.php index 97a885bfafd8..828d2ab58937 100644 --- a/tests/acceptance/features/bootstrap/Provisioning.php +++ b/tests/acceptance/features/bootstrap/Provisioning.php @@ -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 diff --git a/tests/acceptance/features/cliLocalStorage/exportLocalStorage.feature b/tests/acceptance/features/cliLocalStorage/exportLocalStorage.feature index 3d4c8eae8253..df02f9af947e 100644 --- a/tests/acceptance/features/cliLocalStorage/exportLocalStorage.feature +++ b/tests/acceptance/features/cliLocalStorage/exportLocalStorage.feature @@ -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 | | \ No newline at end of file + | /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 | | \ No newline at end of file diff --git a/tests/acceptance/features/cliLocalStorage/importLocalStorage.feature b/tests/acceptance/features/cliLocalStorage/importLocalStorage.feature new file mode 100644 index 000000000000..ca035c6a7216 --- /dev/null +++ b/tests/acceptance/features/cliLocalStorage/importLocalStorage.feature @@ -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:" \ No newline at end of file