diff --git a/tests/acceptance/features/bootstrap/Auth.php b/tests/acceptance/features/bootstrap/Auth.php index 7c92529d1e67..3acc3412c6bd 100644 --- a/tests/acceptance/features/bootstrap/Auth.php +++ b/tests/acceptance/features/bootstrap/Auth.php @@ -100,6 +100,9 @@ public function userRequestsURLWith($url, $method) { public function sendRequest( $url, $method, $authHeader = null, $useCookies = false ) { + // reset responseXml + $this->responseXml = ''; + $fullUrl = $this->getBaseUrl() . $url; $cookies = null; diff --git a/tests/acceptance/features/bootstrap/BasicStructure.php b/tests/acceptance/features/bootstrap/BasicStructure.php index 11a6fb089e51..a1351f49052d 100644 --- a/tests/acceptance/features/bootstrap/BasicStructure.php +++ b/tests/acceptance/features/bootstrap/BasicStructure.php @@ -540,6 +540,13 @@ public function getOcsApiVersion() { public function getSourceIpAddress() { return $this->sourceIpAddress; } + + /** + * @return string|null + */ + public function getStorageId() { + return $this->storageId; + } /** * @param string $sourceIpAddress @@ -1642,6 +1649,28 @@ public function theAdministratorRequestsStatusPhp() { $this->response = $this->getStatusPhp(); } + /** + * @When the administrator creates file :path with content :content in local storage using the testing API + * + * @param string $path + * @param string $content + * + * @return void + */ + public function theAdministratorCreatesFileUsingTheTestingApi($path, $content) { + $user = $this->getAdminUsername(); + $response = OcsApiHelper::sendRequest( + $this->getBaseUrl(), + $user, + $this->getAdminPassword(), + 'POST', + "/apps/testing/api/v1/file", + ['file' => LOCAL_STORAGE_DIR_ON_REMOTE_SERVER . "/$path", 'content' => $content], + $this->getOcsApiVersion() + ); + $this->setResponse($response); + } + /** * * @return ResponseInterface diff --git a/tests/acceptance/features/bootstrap/OccContext.php b/tests/acceptance/features/bootstrap/OccContext.php index 79e07c1c0d13..68a3edcabf88 100644 --- a/tests/acceptance/features/bootstrap/OccContext.php +++ b/tests/acceptance/features/bootstrap/OccContext.php @@ -585,6 +585,84 @@ public function theAdministratorHasChangedTheBackgroundJobsModeTo($mode) { $this->featureContext->invokingTheCommand("background:$mode"); } + /** + * @Given the administrator has set the external storage to be never scanned automatically + * @When the administrator sets the external storage to be never scanned automatically using the occ command + * + * @return void + */ + public function theAdministratorHasSetTheExternalStorageToBeNeverScannedUsingTheOccCommand() { + $command = "files:external:option"; + + $mountId = $this->featureContext->getStorageId(); + + // $mountId should have been set. If not, @local_storage BeforeScenario never ran + \assert($mountId !== null); + + $key = "filesystem_check_changes"; + + // "0" is "Never", "1" is "Once every direct access" + $value = 0; + + $this->featureContext->invokingTheCommand( + "$command $mountId $key $value" + ); + } + + /** + * @When the administrator scans the filesystem for all users using the occ command + * @Given the administrator has scanned the filesystem for all users + * + * @return void + */ + public function theAdministratorScansTheFilesystemForAllUsersUsingTheOccCommand() { + $this->featureContext->invokingTheCommand( + "files:scan --all" + ); + } + + /** + * @When the administrator scans the filesystem for user :user using the occ command + * @Given the administrator has scanned the filesystem for user :user + * + * @param string $user + * + * @return void + */ + public function theAdministratorScansTheFilesystemForUserUsingTheOccCommand($user) { + $this->featureContext->invokingTheCommand( + "files:scan $user" + ); + } + + /** + * @When the administrator scans the filesystem in path :path using the occ command + * @Given the administrator scans the filesystem in path :path + * + * @param string $path + * + * @return void + */ + public function theAdministratorScansTheFilesystemInPathUsingTheOccCommand($path) { + $this->featureContext->invokingTheCommand( + "files:scan --path='$path'" + ); + } + + /** + * @When the administrator scans the filesystem for group :group using the occ command + * @Given the administrator has scanned the filesystem for group :group + * + * @param string $group + * + * @return void + */ + public function theAdministratorScansTheFilesystemForGroupUsingTheOccCommand($group) { + $this->featureContext->invokingTheCommand( + "files:scan --groups=$group" + ); + } + /** * @Then the app name returned by the occ command should be :appName * diff --git a/tests/acceptance/features/cliMain/files.feature b/tests/acceptance/features/cliMain/files.feature new file mode 100644 index 000000000000..812fe670b96e --- /dev/null +++ b/tests/acceptance/features/cliMain/files.feature @@ -0,0 +1,73 @@ +@cli @local_storage +Feature: Files Operations command + + Scenario: Adding a file to local storage and running scan should add files. + Given using new DAV path + And user "user0" has been created with default attributes + And the administrator has set the external storage to be never scanned automatically + # issue-33670: Need to re-scan. Config change doesn't come into effect until once scanned + And the administrator has scanned the filesystem for all users + When the administrator creates file "hello1.txt" with content "