From 0eed6b518967868f7837225be1db0f698c09b685 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Fri, 8 Apr 2016 17:06:53 +0200 Subject: [PATCH] Integration test for a disabled user --- .../features/bootstrap/Provisioning.php | 16 +++++++++++++++- build/integration/features/bootstrap/WebDav.php | 10 ++++++++++ .../integration/features/webdav-related.feature | 8 ++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/build/integration/features/bootstrap/Provisioning.php b/build/integration/features/bootstrap/Provisioning.php index feeb850ae7..ff090f5abb 100644 --- a/build/integration/features/bootstrap/Provisioning.php +++ b/build/integration/features/bootstrap/Provisioning.php @@ -35,7 +35,6 @@ trait Provisioning { } $this->userExists($user); PHPUnit_Framework_Assert::assertEquals(200, $this->response->getStatusCode()); - } /** @@ -230,6 +229,20 @@ trait Provisioning { } } + /** + * @When /^user "([^"]*)" is disabled$/ + */ + public function userIsDisabled($user) { + $fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/cloud/users/$user/disable"; + $client = new Client(); + $options = []; + if ($this->currentUser === 'admin') { + $options['auth'] = $this->adminUser; + } + + $this->response = $client->send($client->createRequest("PUT", $fullUrl, $options)); + } + /** * @When /^Deleting the user "([^"]*)"$/ * @param string $user @@ -588,4 +601,5 @@ trait Provisioning { } $this->usingServer($previousServer); } + } diff --git a/build/integration/features/bootstrap/WebDav.php b/build/integration/features/bootstrap/WebDav.php index 79c447ac57..cd9584ad18 100644 --- a/build/integration/features/bootstrap/WebDav.php +++ b/build/integration/features/bootstrap/WebDav.php @@ -424,5 +424,15 @@ trait WebDav { } + /** + * @Given /^Downloading file "([^"]*)" as "([^"]*)"$/ + */ + public function downloadingFileAs($fileName, $user) { + try { + $this->response = $this->makeDavRequest($user, 'GET', $fileName, []); + } catch (\GuzzleHttp\Exception\ServerException $ex) { + $this->response = $ex->getResponse(); + } + } } diff --git a/build/integration/features/webdav-related.feature b/build/integration/features/webdav-related.feature index abdc63935e..f2343b6254 100644 --- a/build/integration/features/webdav-related.feature +++ b/build/integration/features/webdav-related.feature @@ -286,3 +286,11 @@ Feature: webdav-related When As an "user0" And Downloading file "/files/user0/myChunkedFile.txt" Then Downloaded content should be "AAAAABBBBBCCCCC" + + Scenario: A disabled user cannot use webdav + Given user "userToBeDisabled" exists + And As an "admin" + And user "userToBeDisabled" is disabled + When Downloading file "/welcome.txt" as "userToBeDisabled" + Then the HTTP status code should be "503" +