From 51928303d37e8e6fcd0270b2a3a055ced6941cd8 Mon Sep 17 00:00:00 2001 From: Romina Suarez Date: Thu, 2 Apr 2020 15:56:11 -0300 Subject: [PATCH] Revert "test: gateway checker" --- tests/integration/bootstrap/RestContext.php | 36 +---------- tests/integration/gwchecker.feature | 68 --------------------- 2 files changed, 3 insertions(+), 101 deletions(-) delete mode 100644 tests/integration/gwchecker.feature diff --git a/tests/integration/bootstrap/RestContext.php b/tests/integration/bootstrap/RestContext.php index 7ce480fce6..e63af8300a 100644 --- a/tests/integration/bootstrap/RestContext.php +++ b/tests/integration/bootstrap/RestContext.php @@ -26,9 +26,6 @@ class RestContext implements Context private $restObjectType = null; private $restObjectMethod = 'get'; private $client = null; - /** - * @var \GuzzleHttp\Psr7\Response - */ private $response = null; private $requestUrl = null; private $apiUrl = 'api/v3'; @@ -40,8 +37,6 @@ class RestContext implements Context private $postFields = []; private $postFiles = []; - const DEBUG_MODE_SWITCH_FILE_PATH = __DIR__ . "/../../../bootstrap/install_debug_mode.enabled"; - /** * Initializes context. * Every scenario gets it's own context object. @@ -206,24 +201,6 @@ public function thatThePostFileIs($fieldName, $fieldValue) $this->postFiles[$fieldName] = $fieldValue; } - /** - * @Given /^that I have enabled debug mode$/ - */ - public function thatIHaveEnabledDebugMode() - { - fopen(self::DEBUG_MODE_SWITCH_FILE_PATH, "w"); - } - - /** - * @AfterScenario - * @Given /^that I have disabled debug mode$/ - */ - public function disableDebugModeAfterScenario() - { - if (file_exists(self::DEBUG_MODE_SWITCH_FILE_PATH)) { - unlink(self::DEBUG_MODE_SWITCH_FILE_PATH); - } - } /** * @When /^I request "([^"]*)"$/ */ @@ -234,9 +211,9 @@ public function iRequest($pageUrl) switch (strtoupper($this->restObjectMethod)) { case 'GET': $request = (array)$this->restObject; - $idAttachment = ( isset($request['id']) ) ? "/" . $request['id'] : ''; + $id = ( isset($request['id']) ) ? $request['id'] : ''; $response = $this->client - ->get($this->requestUrl.$idAttachment, [ + ->get($this->requestUrl.'/'.$id, [ 'query' => isset($request['query string']) ? trim($request['query string']) : null, 'headers' => $this->headers ]); @@ -426,13 +403,6 @@ public function theResponseIsJsonp() } } - /** - * @Then /^the response is empty/ - */ - public function theResponseIsEmpty() - { - \PHPUnit_Framework_Assert::assertEquals(0, $this->response->getBody()->getSize()); - } /** * @Given /^the response has a "([^"]*)" property$/ * @Given /^the response has an "([^"]*)" property$/ @@ -661,7 +631,7 @@ public function thePropertyIsEmpty($propertyName) $actualPropertyValue = array_get($data, $propertyName); if (!empty($actualPropertyValue)) { - throw new \Exception("Property '{$propertyName}' is not empty but '{$actualPropertyValue}'\n"); + throw new \Exception("Property '{$propertyName}' is not empty!\n"); } } diff --git a/tests/integration/gwchecker.feature b/tests/integration/gwchecker.feature deleted file mode 100644 index 63ee22c0a6..0000000000 --- a/tests/integration/gwchecker.feature +++ /dev/null @@ -1,68 +0,0 @@ -Feature: Gateway checker - - Scenario: normal API request should still work with enabled GW checker - Given that I have enabled debug mode - And that I want to get all "Configs" - When I request "/config" - Then the response is JSON - And the response has a "count" property - And the type of the "count" property is "numeric" - And the guzzle status code should be 200 - - Scenario Outline: get debug information with enabled GW checker - Given that I have enabled debug mode - And that I want to get all "Configs" - When I request "/?gwcheck=" - Then the response is JSON - And the response does not have a "count" property - And the "api.name" property equals "ushahidi:platform:gwcheck" - And the "api.version" property equals "0.1" - And the "data._GET.gwcheck" property equals "" - And the "data._REQUEST.gwcheck" property equals "" - And the "data._POST" property is empty - And the "data._SERVER.REQUEST_METHOD" property equals "GET" - And the "data._SERVER.QUERY_STRING" property equals "gwcheck=" - And the "data._SERVER.HTTP_ACCEPT" property equals "application/json" - And the "data._SERVER.SCRIPT_NAME" property contains "/index.php" - And the "data._SERVER.REQUEST_URI" property equals "/api/v3/?gwcheck=" - #the following line might fail when running tests on Apache - And the "data._SERVER.PATH_INFO" property equals "/api/v3/" - And the "data._SERVER.HTTP_USER_AGENT" property contains "GuzzleHttp" - And the "data._SERVER.DOCUMENT_ROOT" property contains "/platform" - And the "data._SERVER.SCRIPT_FILENAME" property contains "/platform/httpdocs/index.php" - And the "data._SERVER.HTTP_ACCEPT_CHARSET" property is empty - And the "data._SERVER.HTTP_ACCEPT_ENCODING" property is empty - And the "data._SERVER.HTTP_ACCEPT_LANGUAGE" property is empty - And the "data._SERVER.HTTP_AUTHORIZATION" property is empty - And the "data._SERVER.HTTP_CONNECTION" property is empty - And the "data._SERVER.HTTP_ORIGIN" property is empty - And the "data._SERVER.HTTP_REFERER" property is empty - And the "data._SERVER.ORIG_PATH_INFO" property is empty - And the guzzle status code should be 200 - Examples: - | endpoint | gwCheckValue | - | config | true | - | config | TRUE | - | config | 1 | - | config | anyString | - | config | false | - | does-not-exist | true | - | does-not-exist | TRUE | - | does-not-exist | 1 | - | does-not-exist | anyString | - | does-not-exist | false | - - Scenario Outline: debug information should not be visible with disabled GW checker - Given that I have disabled debug mode - And that I want to get all "Configs" - When I request "/config?gwcheck=" - Then the response is empty - And the guzzle status code should be 204 - And the "X-Ushahidi-Platform-Install-Debug-Mode" header should be "off" - Examples: - | gwCheckValue | - | true | - | TRUE | - | 1 | - | anyString | - | false |