Skip to content
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
3 changes: 3 additions & 0 deletions tests/acceptance/features/bootstrap/Auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
29 changes: 29 additions & 0 deletions tests/acceptance/features/bootstrap/BasicStructure.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
78 changes: 78 additions & 0 deletions tests/acceptance/features/bootstrap/OccContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down
73 changes: 73 additions & 0 deletions tests/acceptance/features/cliMain/files.feature
Original file line number Diff line number Diff line change
@@ -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 "<? php :)" in local storage using the testing API
And user "user0" requests "/remote.php/dav/files/user0/local_storage" with "PROPFIND" using basic auth
Then the propfind result of "user0" should not contain these entries:
| /local_storage/hello1.txt |
When the administrator scans the filesystem for all users using the occ command
And the administrator creates file "hello2.txt" with content "<? php :(" in local storage using the testing API
And user "user0" requests "/remote.php/dav/files/user0/local_storage" with "PROPFIND" using basic auth
Then the propfind result of "user0" should contain these entries:
| /local_storage/hello1.txt |
But the propfind result of "user0" should not contain these entries:
| /local_storage/hello2.txt |

Scenario: Adding a file to local storage and running scan for a specific path should add files for only that path.
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
And user "user0" has created a folder "/local_storage/folder1"
And user "user0" has created a folder "/local_storage/folder2"
# 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 "folder1/hello1.txt" with content "<? php :)" in local storage using the testing API
And the administrator creates file "folder2/hello2.txt" with content "<? php :(" in local storage using the testing API
And user "user0" requests "/remote.php/dav/files/user0/local_storage/folder1" with "PROPFIND" using basic auth
Then the propfind result of "user0" should not contain these entries:
| /local_storage/folder1/hello1.txt |
When user "user0" requests "/remote.php/dav/files/user0/local_storage/folder2" with "PROPFIND" using basic auth
Then the propfind result of "user0" should not contain these entries:
| /local_storage/folder2/hello2.txt |
When the administrator scans the filesystem in path "/user0/files/local_storage/folder1" using the occ command
And user "user0" requests "/remote.php/dav/files/user0/local_storage/folder1" with "PROPFIND" using basic auth
Then the propfind result of "user0" should contain these entries:
| /local_storage/folder1/hello1.txt |
When user "user0" requests "/remote.php/dav/files/user0/local_storage/folder2" with "PROPFIND" using basic auth
Then the propfind result of "user0" should not contain these entries:
| /local_storage/folder2/hello2.txt |

Scenario: Adding a folder to local storage, sharing with groups and running scan for specific group should add files for users of that group
Given using new DAV path
And these users have been created with default attributes:
| username |
| user0 |
| user1 |
And group "newgroup" has been created
And user "user0" has been added to group "newgroup"
And user "user1" has been added to group "newgroup"
And user "user0" has created a folder "/local_storage/folder1"
And the administrator has set the external storage to be never scanned automatically
And user "user0" has shared folder "/local_storage/folder1" with group "newgroup"
And the administrator has scanned the filesystem for all users
And the administrator has scanned the filesystem for group "newgroup"
When the administrator creates file "folder1/hello1.txt" with content "<? php :)" in local storage using the testing API
And user "user0" requests "/remote.php/dav/files/user0/local_storage/folder1" with "PROPFIND" using basic auth
Then the propfind result of "user0" should not contain these entries:
| /local_storage/folder1/hello1.txt |
When user "user1" requests "/remote.php/dav/files/user1/local_storage/folder1" with "PROPFIND" using basic auth
Then the propfind result of "user0" should not contain these entries:
| /local_storage/folder1/hello1.txt |
When the administrator scans the filesystem for group "newgroup" using the occ command
And user "user0" requests "/remote.php/dav/files/user0/local_storage/folder1" with "PROPFIND" using basic auth
Then the propfind result of "user0" should contain these entries:
| /local_storage/folder1/hello1.txt |
When user "user1" requests "/remote.php/dav/files/user1/folder1" with "PROPFIND" using basic auth
Then the propfind result of "user1" should contain these entries:
| /folder1/hello1.txt |