From aacbb560ae5bbae3541e901915937cc3384353ef Mon Sep 17 00:00:00 2001 From: Lukas Reschke Date: Tue, 11 Apr 2017 00:57:31 +0200 Subject: [PATCH 1/3] Add missing maintenance plugin to new DAV endpoint The `/remote.php/dav/` endpoint was not implementing the MaintenancePlugin. Thus when the instance was put into maintenance mode the endpoints were still accessible and delivered empty content. Sync clients really do love this. Signed-off-by: Lukas Reschke --- apps/dav/lib/Server.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apps/dav/lib/Server.php b/apps/dav/lib/Server.php index a5c1379eb7e..e0517477488 100644 --- a/apps/dav/lib/Server.php +++ b/apps/dav/lib/Server.php @@ -74,6 +74,9 @@ class Server { $root = new RootCollection(); $this->server = new \OCA\DAV\Connector\Sabre\Server($root); + // Add maintenance plugin + $this->server->addPlugin(new \OCA\DAV\Connector\Sabre\MaintenancePlugin(\OC::$server->getConfig())); + // Backends $authBackend = new Auth( \OC::$server->getSession(), From b882f65fbb408aaf820bdd37420efb1dcbbfaba3 Mon Sep 17 00:00:00 2001 From: Lukas Reschke Date: Tue, 11 Apr 2017 01:30:32 +0200 Subject: [PATCH 2/3] Add integration tests Signed-off-by: Lukas Reschke --- build/integration/features/bootstrap/Auth.php | 3 ++ .../features/bootstrap/CommandLineContext.php | 14 ++++++++ .../features/maintenance-mode.feature | 34 +++++++++++++++++++ 3 files changed, 51 insertions(+) create mode 100644 build/integration/features/maintenance-mode.feature diff --git a/build/integration/features/bootstrap/Auth.php b/build/integration/features/bootstrap/Auth.php index fd1b2e05a80..7addcab5f97 100644 --- a/build/integration/features/bootstrap/Auth.php +++ b/build/integration/features/bootstrap/Auth.php @@ -22,6 +22,7 @@ use GuzzleHttp\Client; use GuzzleHttp\Exception\ClientException; +use GuzzleHttp\Exception\ServerException; use GuzzleHttp\Cookie\CookieJar; require __DIR__ . '/../../vendor/autoload.php'; @@ -68,6 +69,8 @@ trait Auth { $this->response = $this->client->send($request); } catch (ClientException $ex) { $this->response = $ex->getResponse(); + } catch (ServerException $ex) { + $this->response = $ex->getResponse(); } } diff --git a/build/integration/features/bootstrap/CommandLineContext.php b/build/integration/features/bootstrap/CommandLineContext.php index c8253966cdb..9a48c8517c7 100644 --- a/build/integration/features/bootstrap/CommandLineContext.php +++ b/build/integration/features/bootstrap/CommandLineContext.php @@ -36,6 +36,20 @@ class CommandLineContext implements \Behat\Behat\Context\Context { $this->remoteBaseUrl = $baseUrl; } + /** + * @Given Maintenance mode is enabled + */ + public function maintenanceModeIsEnabled() { + $this->runOcc(['maintenance:mode', '--on']); + } + + /** + * @Then Maintenance mode is disabled + */ + public function maintenanceModeIsDisabled() { + $this->runOcc(['maintenance:mode', '--off']); + } + /** @BeforeScenario */ public function gatherContexts(BeforeScenarioScope $scope) { $environment = $scope->getEnvironment(); diff --git a/build/integration/features/maintenance-mode.feature b/build/integration/features/maintenance-mode.feature new file mode 100644 index 00000000000..a2e61a7e605 --- /dev/null +++ b/build/integration/features/maintenance-mode.feature @@ -0,0 +1,34 @@ +Feature: maintenance-mode + + Background: + Given Maintenance mode is enabled + + Scenario: Accessing /index.php with maintenance mode enabled + When requesting "/index.php" with "GET" + Then the HTTP status code should be "503" + Then Maintenance mode is disabled + + Scenario: Accessing /remote.php/webdav with maintenance mode enabled + When requesting "/remote.php/webdav" with "GET" + Then the HTTP status code should be "503" + Then Maintenance mode is disabled + + Scenario: Accessing /remote.php/dav with maintenance mode enabled + When requesting "/remote.php/dav" with "GET" + Then the HTTP status code should be "503" + Then Maintenance mode is disabled + + Scenario: Accessing /ocs/v1.php with maintenance mode enabled + When requesting "/ocs/v1.php" with "GET" + Then the HTTP status code should be "503" + Then Maintenance mode is disabled + + Scenario: Accessing /ocs/v2.php with maintenance mode enabled + When requesting "/ocs/v2.php" with "GET" + Then the HTTP status code should be "503" + Then Maintenance mode is disabled + + Scenario: Accessing /public.php/webdav with maintenance mode enabled + When requesting "/public.php/webdav" with "GET" + Then the HTTP status code should be "503" + Then Maintenance mode is disabled From 2f748f625c3942d5427045a10adf8e43abcf535f Mon Sep 17 00:00:00 2001 From: Lukas Reschke Date: Tue, 11 Apr 2017 01:34:26 +0200 Subject: [PATCH 3/3] Run maintenance mode tests on Drone Signed-off-by: Lukas Reschke --- .drone.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.drone.yml b/.drone.yml index dd4ec404209..b20d43ecc73 100644 --- a/.drone.yml +++ b/.drone.yml @@ -268,6 +268,15 @@ pipeline: when: matrix: TESTS: integration-auth + integration-maintenance-mode: + image: nextcloudci/integration-php7.0:integration-php7.0-3 + commands: + - ./occ maintenance:install --admin-pass=admin + - cd build/integration + - ./run.sh features/maintenance-mode.feature + when: + matrix: + TESTS: integration-maintenance-mode integration-carddav: image: nextcloudci/integration-php7.0:integration-php7.0-3 commands: @@ -497,6 +506,7 @@ matrix: - TESTS: db-codecov - TESTS: integration-capabilities_features - TESTS: integration-federation_features + - TESTS: integration-maintenance-mode - TESTS: integration-auth - TESTS: integration-carddav - TESTS: integration-dav-v2