Add integration tests for "sharing:cleanup-remote-storages" OCC command

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
This commit is contained in:
Daniel Calviño Sánchez 2021-01-22 12:40:59 +01:00
parent 7a892a310d
commit 3aba5b27be
3 changed files with 68 additions and 1 deletions

View File

@ -769,7 +769,7 @@ steps:
- bash tests/drone-run-integration-tests.sh || exit 0 - bash tests/drone-run-integration-tests.sh || exit 0
- ./occ maintenance:install --admin-pass=admin - ./occ maintenance:install --admin-pass=admin
- cd build/integration - cd build/integration
- ./run.sh federation_features/federated.feature - ./run.sh federation_features/
trigger: trigger:
branch: branch:

View File

@ -37,6 +37,20 @@ require __DIR__ . '/../../vendor/autoload.php';
class FederationContext implements Context, SnippetAcceptingContext { class FederationContext implements Context, SnippetAcceptingContext {
use WebDav; use WebDav;
use AppConfiguration; use AppConfiguration;
use CommandLine;
/**
* @BeforeScenario
*/
public function cleanupRemoteStorages() {
// Ensure that dangling remote storages from previous tests will not
// interfere with the current scenario.
// The storages must be cleaned before each scenario; they can not be
// cleaned after each scenario, as this hook is executed before the hook
// that removes the users, so the shares would be still valid and thus
// the storages would not be dangling yet.
$this->runOcc(['sharing:cleanup-remote-storages']);
}
/** /**
* @Given /^User "([^"]*)" from server "(LOCAL|REMOTE)" shares "([^"]*)" with user "([^"]*)" from server "(LOCAL|REMOTE)"$/ * @Given /^User "([^"]*)" from server "(LOCAL|REMOTE)" shares "([^"]*)" with user "([^"]*)" from server "(LOCAL|REMOTE)"$/

View File

@ -0,0 +1,53 @@
Feature: cleanup-remote-storage
Background:
Given using api version "1"
Scenario: cleanup remote storage with active storages
Given Using server "LOCAL"
And user "user0" exists
Given Using server "REMOTE"
And user "user1" exists
# Rename file so it has a unique name in the target server (as the target
# server may have its own /textfile0.txt" file)
And User "user1" copies file "/textfile0.txt" to "/remote-share.txt"
And User "user1" from server "REMOTE" shares "/remote-share.txt" with user "user0" from server "LOCAL"
And Using server "LOCAL"
# Accept and download the file to ensure that a storage is created for the
# federated share
And User "user0" from server "LOCAL" accepts last pending share
And As an "user0"
And Downloading file "/remote-share.txt"
And the HTTP status code should be "200"
When invoking occ with "sharing:cleanup-remote-storage"
Then the command was successful
And the command output contains the text "1 remote storage(s) need(s) to be checked"
And the command output contains the text "1 remote share(s) exist"
And the command output contains the text "no storages deleted"
Scenario: cleanup remote storage with inactive storages
Given Using server "LOCAL"
And user "user0" exists
Given Using server "REMOTE"
And user "user1" exists
# Rename file so it has a unique name in the target server (as the target
# server may have its own /textfile0.txt" file)
And User "user1" copies file "/textfile0.txt" to "/remote-share.txt"
And User "user1" from server "REMOTE" shares "/remote-share.txt" with user "user0" from server "LOCAL"
And Using server "LOCAL"
# Accept and download the file to ensure that a storage is created for the
# federated share
And User "user0" from server "LOCAL" accepts last pending share
And As an "user0"
And Downloading file "/remote-share.txt"
And the HTTP status code should be "200"
And Using server "REMOTE"
And As an "user1"
And Deleting last share
And the OCS status code should be "100"
And the HTTP status code should be "200"
When Using server "LOCAL"
And invoking occ with "sharing:cleanup-remote-storage"
Then the command was successful
And the command output contains the text "1 remote storage(s) need(s) to be checked"
And the command output contains the text "0 remote share(s) exist"
And the command output contains the text "deleted 1 storage"