From 302f9b5a62fa8359fcab6d41b803291ee314d255 Mon Sep 17 00:00:00 2001 From: Lukasz Bajsarowicz Date: Tue, 5 Nov 2024 13:52:41 +0100 Subject: [PATCH 1/5] SwiftOtter-SOP-348 Add missing REST methods to Curl Client --- .../Magento/Framework/HTTP/Client/Curl.php | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/lib/internal/Magento/Framework/HTTP/Client/Curl.php b/lib/internal/Magento/Framework/HTTP/Client/Curl.php index 7ba4fb915e294..f66bba8111eaa 100644 --- a/lib/internal/Magento/Framework/HTTP/Client/Curl.php +++ b/lib/internal/Magento/Framework/HTTP/Client/Curl.php @@ -246,6 +246,41 @@ public function post($uri, $params) $this->makeRequest("POST", $uri, $params); } + /** + * Make PUT request + * + * @param string $uri + * @param array|string $params + * @return void + */ + public function put($uri, $params) + { + $this->makeRequest("PUT", $uri, $params); + } + + /** + * Make DELETE request + * + * @param string $uri + * @return void + */ + public function delete($uri) + { + $this->makeRequest("DELETE", $uri); + } + + /** + * Make PATCH request + * + * @param string $uri + * @param array|string $params + * @return void + */ + public function patch($uri, $params) + { + $this->makeRequest("PATCH", $uri, $params); + } + /** * Get response headers * From e3668e8a3c50206b81a9b259015be15ae57a2716 Mon Sep 17 00:00:00 2001 From: Lukasz Bajsarowicz Date: Tue, 5 Nov 2024 14:00:10 +0100 Subject: [PATCH 2/5] SwiftOtter-SOP-348 Add missing REST methods: TRACE, HEAD, OPTIONS --- .../Magento/Framework/HTTP/Client/Curl.php | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/lib/internal/Magento/Framework/HTTP/Client/Curl.php b/lib/internal/Magento/Framework/HTTP/Client/Curl.php index f66bba8111eaa..559e80cbd8770 100644 --- a/lib/internal/Magento/Framework/HTTP/Client/Curl.php +++ b/lib/internal/Magento/Framework/HTTP/Client/Curl.php @@ -281,6 +281,39 @@ public function patch($uri, $params) $this->makeRequest("PATCH", $uri, $params); } + /** + * Make OPTIONS request + * + * @param string $uri + * @return void + */ + public function options($uri) + { + $this->makeRequest("OPTIONS", $uri); + } + + /** + * Make HEAD request + * + * @param string $uri + * @return void + */ + public function head($uri) + { + $this->makeRequest("HEAD", $uri); + } + + /** + * Make TRACE request + * + * @param string $uri + * @return void + */ + public function trace($uri) + { + $this->makeRequest("TRACE", $uri); + } + /** * Get response headers * From 064aa0450f19ec423efe89176e62478ee239b28d Mon Sep 17 00:00:00 2001 From: Lukasz Bajsarowicz Date: Tue, 5 Nov 2024 14:02:49 +0100 Subject: [PATCH 3/5] SwiftOtter-SOP-348 Replace redundant override --- .../Model/SearchEngineVersionReader.php | 2 +- .../Magento/TestFramework/Helper/Amqp.php | 2 ++ .../Magento/TestFramework/Helper/Curl.php | 30 ------------------- 3 files changed, 3 insertions(+), 31 deletions(-) delete mode 100644 dev/tests/integration/framework/Magento/TestFramework/Helper/Curl.php diff --git a/dev/tests/integration/_files/Magento/TestModuleCatalogSearch/Model/SearchEngineVersionReader.php b/dev/tests/integration/_files/Magento/TestModuleCatalogSearch/Model/SearchEngineVersionReader.php index b565caae4e3fc..8775556a90c61 100644 --- a/dev/tests/integration/_files/Magento/TestModuleCatalogSearch/Model/SearchEngineVersionReader.php +++ b/dev/tests/integration/_files/Magento/TestModuleCatalogSearch/Model/SearchEngineVersionReader.php @@ -9,7 +9,7 @@ use Magento\Framework\App\Config\ScopeConfigInterface; use Magento\TestFramework\Helper\Bootstrap; -use Magento\TestFramework\Helper\Curl; +use Magento\Framework\HTTP\Client\Curl; /** * Retrieve search engine version by curl request diff --git a/dev/tests/integration/framework/Magento/TestFramework/Helper/Amqp.php b/dev/tests/integration/framework/Magento/TestFramework/Helper/Amqp.php index 0aa9850e6a189..5cac41ae460cc 100644 --- a/dev/tests/integration/framework/Magento/TestFramework/Helper/Amqp.php +++ b/dev/tests/integration/framework/Magento/TestFramework/Helper/Amqp.php @@ -8,6 +8,8 @@ namespace Magento\TestFramework\Helper; +use Magento\Framework\HTTP\Client\Curl; + /** * Helper class to access RabbitMQ server configuration */ diff --git a/dev/tests/integration/framework/Magento/TestFramework/Helper/Curl.php b/dev/tests/integration/framework/Magento/TestFramework/Helper/Curl.php deleted file mode 100644 index 62b753cf5d344..0000000000000 --- a/dev/tests/integration/framework/Magento/TestFramework/Helper/Curl.php +++ /dev/null @@ -1,30 +0,0 @@ -makeRequest("DELETE", $uri); - } -} From 0ec2621986954cbf2d5905f574ee7804a984aa0c Mon Sep 17 00:00:00 2001 From: Lukasz Bajsarowicz Date: Tue, 5 Nov 2024 15:11:57 +0100 Subject: [PATCH 4/5] SwiftOtter-SOP-348 Resolve issues with Static checks --- .../framework/Magento/TestFramework/Helper/Amqp.php | 12 ++++++------ lib/internal/Magento/Framework/HTTP/Client/Curl.php | 1 - 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/dev/tests/integration/framework/Magento/TestFramework/Helper/Amqp.php b/dev/tests/integration/framework/Magento/TestFramework/Helper/Amqp.php index 5cac41ae460cc..f75b5a49503e9 100644 --- a/dev/tests/integration/framework/Magento/TestFramework/Helper/Amqp.php +++ b/dev/tests/integration/framework/Magento/TestFramework/Helper/Amqp.php @@ -15,12 +15,12 @@ */ class Amqp { - const CONFIG_PATH_HOST = 'queue/amqp/host'; - const CONFIG_PATH_USER = 'queue/amqp/user'; - const CONFIG_PATH_PASSWORD = 'queue/amqp/password'; - const DEFAULT_MANAGEMENT_PROTOCOL = 'http'; - const DEFAULT_MANAGEMENT_PORT = '15672'; - const DEFAULT_VIRTUALHOST = '/'; + public const CONFIG_PATH_HOST = 'queue/amqp/host'; + public const CONFIG_PATH_USER = 'queue/amqp/user'; + public const CONFIG_PATH_PASSWORD = 'queue/amqp/password'; + public const DEFAULT_MANAGEMENT_PROTOCOL = 'http'; + public const DEFAULT_MANAGEMENT_PORT = '15672'; + public const DEFAULT_VIRTUALHOST = '/'; /** * @var Curl diff --git a/lib/internal/Magento/Framework/HTTP/Client/Curl.php b/lib/internal/Magento/Framework/HTTP/Client/Curl.php index 559e80cbd8770..a88cc8362e555 100644 --- a/lib/internal/Magento/Framework/HTTP/Client/Curl.php +++ b/lib/internal/Magento/Framework/HTTP/Client/Curl.php @@ -11,7 +11,6 @@ /** * Class to work with HTTP protocol using curl library * - * @author Magento Core Team * @SuppressWarnings(PHPMD.ExcessiveClassComplexity) * @api */ From 4297a88be0b12755ef71cc79b8822796528afad2 Mon Sep 17 00:00:00 2001 From: engcom-Dash Date: Fri, 22 Nov 2024 16:30:47 +0530 Subject: [PATCH 5/5] 39330: Add optional payload support for DELETE, OPTIONS, HEAD, and add CONNECT method --- .../Model/SearchEngineVersionReader.php | 4 +-- .../Magento/TestFramework/Helper/Amqp.php | 5 ++- .../Magento/Framework/HTTP/Client/Curl.php | 34 +++++++++++++------ 3 files changed, 28 insertions(+), 15 deletions(-) diff --git a/dev/tests/integration/_files/Magento/TestModuleCatalogSearch/Model/SearchEngineVersionReader.php b/dev/tests/integration/_files/Magento/TestModuleCatalogSearch/Model/SearchEngineVersionReader.php index 8775556a90c61..40563d428ac28 100644 --- a/dev/tests/integration/_files/Magento/TestModuleCatalogSearch/Model/SearchEngineVersionReader.php +++ b/dev/tests/integration/_files/Magento/TestModuleCatalogSearch/Model/SearchEngineVersionReader.php @@ -1,7 +1,7 @@ makeRequest("DELETE", $uri); + $this->makeRequest("DELETE", $uri, $params); } /** @@ -284,22 +284,24 @@ public function patch($uri, $params) * Make OPTIONS request * * @param string $uri + * @param array|string $params * @return void */ - public function options($uri) + public function options(string $uri, array|string $params = []) { - $this->makeRequest("OPTIONS", $uri); + $this->makeRequest("OPTIONS", $uri, $params); } /** * Make HEAD request * * @param string $uri + * @param array|string $params * @return void */ - public function head($uri) + public function head(string $uri, array|string $params = []) { - $this->makeRequest("HEAD", $uri); + $this->makeRequest("HEAD", $uri, $params); } /** @@ -308,11 +310,23 @@ public function head($uri) * @param string $uri * @return void */ - public function trace($uri) + public function trace(string $uri) { $this->makeRequest("TRACE", $uri); } + /** + * Make CONNECT request + * + * @param string $uri + * @param array|string $params + * @return void + */ + public function connect(string $uri, array|string $params = []) + { + $this->makeRequest("CONNECT", $uri, $params); + } + /** * Get response headers *