From 48eb99e3f0f797034494622002fb0b226410bd3b Mon Sep 17 00:00:00 2001 From: Parajuli Kiran Date: Thu, 16 Jul 2020 15:04:09 +0545 Subject: [PATCH] Updated exception message --- .../features/apiAuthWebDav/webDavLOCKAuth.feature | 5 ++++- .../features/apiAuthWebDav/webDavMKCOLAuth.feature | 1 - .../features/apiAuthWebDav/webDavPUTAuth.feature | 14 ++++++++------ .../acceptance/features/bootstrap/AuthContext.php | 5 ++++- tests/acceptance/features/bootstrap/OCSContext.php | 2 +- tests/acceptance/features/bootstrap/WebDav.php | 10 ++++++++-- 6 files changed, 25 insertions(+), 12 deletions(-) diff --git a/tests/acceptance/features/apiAuthWebDav/webDavLOCKAuth.feature b/tests/acceptance/features/apiAuthWebDav/webDavLOCKAuth.feature index 8dc5a822da94..3557947a7c8e 100644 --- a/tests/acceptance/features/apiAuthWebDav/webDavLOCKAuth.feature +++ b/tests/acceptance/features/apiAuthWebDav/webDavLOCKAuth.feature @@ -40,8 +40,11 @@ Feature: LOCK file/folder | endpoint | | /remote.php/dav/files/%username%/textfile0.txt | | /remote.php/dav/files/%username%/PARENT | + Then the HTTP status code of responses on all endpoints should be "403" + When user "Brian" requests these endpoints with "LOCK" to get property "d:shared" about user "Alice" + | endpoint | | /remote.php/dav/files/%username%/PARENT/parent.txt | - Then the HTTP status code of responses on all endpoints should be "403 404" + Then the HTTP status code of responses on all endpoints should be "404" @skipOnOcV10 @issue-ocis-reva-9 #after fixing all issues delete this Scenario and use the one above diff --git a/tests/acceptance/features/apiAuthWebDav/webDavMKCOLAuth.feature b/tests/acceptance/features/apiAuthWebDav/webDavMKCOLAuth.feature index 73aed4ef8a33..1869a724cebb 100644 --- a/tests/acceptance/features/apiAuthWebDav/webDavMKCOLAuth.feature +++ b/tests/acceptance/features/apiAuthWebDav/webDavMKCOLAuth.feature @@ -40,7 +40,6 @@ Feature: create folder using MKCOL | /remote.php/dav/files/%username%/textfile0.txt | | /remote.php/dav/files/%username%/PARENT | | /remote.php/dav/files/%username%/PARENT/parent.txt | - | /remote.php/dav/files/%username%/does-not-exist | Then the HTTP status code of responses on all endpoints should be "403" When user "Brian" requests these endpoints with "MKCOL" including body "" about user "Alice" | endpoint | diff --git a/tests/acceptance/features/apiAuthWebDav/webDavPUTAuth.feature b/tests/acceptance/features/apiAuthWebDav/webDavPUTAuth.feature index 5de9f09edd49..43e5882c0609 100644 --- a/tests/acceptance/features/apiAuthWebDav/webDavPUTAuth.feature +++ b/tests/acceptance/features/apiAuthWebDav/webDavPUTAuth.feature @@ -37,9 +37,9 @@ Feature: get file info using PUT @skipOnOcis @issue-ocis-reva-9 @issue-ocis-reva-197 Scenario: send PUT requests to another user's webDav endpoints as normal user When user "Brian" requests these endpoints with "PUT" including body "doesnotmatter" about user "Alice" - | endpoint | - | /remote.php/dav/files/%username%/textfile1.txt | - | /remote.php/dav/files/%username%/PARENTS | + | endpoint | + | /remote.php/dav/files/%username%/textfile1.txt | + | /remote.php/dav/files/%username%/PARENTS | Then the HTTP status code of responses on all endpoints should be "403" When user "Brian" requests these endpoints with "PUT" including body "doesnotmatter" about user "Alice" | endpoint | @@ -104,11 +104,13 @@ Feature: get file info using PUT | /remote.php/dav/files/%username%/PARENT/parent.txt | Then the HTTP status code of responses on all endpoints should be "204" When the user "Alice" requests these endpoints with "PUT" with body "doesnotmatter" using basic auth and generated app password about user "Alice" + | endpoint | # this folder is created, so gives 201 - CREATED - | /remote.php/webdav/PARENS | - | /remote.php/dav/files/%username%/FOLDERS | + | /remote.php/webdav/PARENS | + | /remote.php/dav/files/%username%/FOLDERS | Then the HTTP status code of responses on all endpoints should be "201" When the user "Alice" requests these endpoints with "PUT" with body "doesnotmatter" using basic auth and generated app password about user "Alice" + | endpoint | # this folder already exists so gives 409 - CONFLICT - | /remote.php/dav/files/%username%/FOLDER | + | /remote.php/dav/files/%username%/FOLDER | Then the HTTP status code of responses on all endpoints should be "409" diff --git a/tests/acceptance/features/bootstrap/AuthContext.php b/tests/acceptance/features/bootstrap/AuthContext.php index 4badf9eeae57..9367b2e326cf 100644 --- a/tests/acceptance/features/bootstrap/AuthContext.php +++ b/tests/acceptance/features/bootstrap/AuthContext.php @@ -308,7 +308,7 @@ public function requestEndpointsWithBasicAuthAndGeneratedPassword( $ofUser = \strtolower($this->featureContext->getActualUsername($ofUser)); $this->featureContext->verifyTableNodeColumns($table, ['endpoint']); $this->featureContext->emptyLastHTTPStatusCodesArray(); - if (\is_null($body) && !\is_null($property)) { + if ($body === null && $property !== null) { $body = $this->featureContext->getBodyForOCSRequest($method, $property); } @@ -382,6 +382,8 @@ public function adminRequestsEndpointsWithPassword( TableNode $table ) { $this->featureContext->verifyTableNodeColumns($table, ['endpoint']); + $this->featureContext->emptyLastHTTPStatusCodesArray(); + $this->featureContext->emptyLastOCSStatusCodesArray(); foreach ($table->getHash() as $row) { $this->administratorRequestsURLWithUsingBasicAuth( $row['endpoint'], @@ -466,6 +468,7 @@ public function userRequestsTheseEndpointsUsingNewBrowserSession($method, TableN public function userRequestsEndpointsUsingTheGeneratedAppPasswordThenStatusCodeAboutUser($method, $user, TableNode $table) { $user = \strtolower($this->featureContext->getActualUsername($user)); $this->featureContext->verifyTableNodeColumns($table, ['endpoint']); + $this->featureContext->emptyLastHTTPStatusCodesArray(); foreach ($table->getHash() as $row) { $row['endpoint'] = $this->featureContext->substituteInLineCodes( $row['endpoint'], $user diff --git a/tests/acceptance/features/bootstrap/OCSContext.php b/tests/acceptance/features/bootstrap/OCSContext.php index bfa21813bafc..9facd6c0a6b9 100644 --- a/tests/acceptance/features/bootstrap/OCSContext.php +++ b/tests/acceptance/features/bootstrap/OCSContext.php @@ -535,7 +535,7 @@ public function userSendsRequestToTheseEndpointsWithBody($user, $method, $body, } /** - * @When user "([^"]*)" requests these endpoints with "([^"]*)" to (?:get|set) property "([^"]*)" about user "([^"]*)"$/ + * @When /^user "([^"]*)" requests these endpoints with "([^"]*)" to (?:get|set) property "([^"]*)" about user "([^"]*)"$/ * * @param string $user * @param string $method diff --git a/tests/acceptance/features/bootstrap/WebDav.php b/tests/acceptance/features/bootstrap/WebDav.php index 43e1f654227f..2462a0ab6c31 100644 --- a/tests/acceptance/features/bootstrap/WebDav.php +++ b/tests/acceptance/features/bootstrap/WebDav.php @@ -1787,7 +1787,10 @@ public function theHTTPStatusCodeOfResponsesOnAllEndpointsShouldBe($statusCode) 'Responses did not return expected http status code' ); } else { - throw new \Exception('Expected same but found different http status codes of last requested responses'); + throw new \Exception( + 'Expected same but found different http status codes of last requested responses.' . + 'Found status codes: ' . \implode(',', $this->lastHttpStatusCodesArray) + ); } } @@ -1808,7 +1811,10 @@ public function theOCSStatusCodeOfResponsesOnAllEndpointsShouldBe($statusCode) { 'Responses did not return expected ocs status code' ); } else { - throw new \Exception('Expected same but found different ocs status codes of last requested responses'); + throw new \Exception( + 'Expected same but found different ocs status codes of last requested responses.' . + 'Found status codes: ' . \implode(',', $this->lastOCSStatusCodesArray) + ); } }