diff --git a/composer.json b/composer.json
index 37f0fddd7595..c60a2847b463 100644
--- a/composer.json
+++ b/composer.json
@@ -47,7 +47,7 @@
"nikic/php-parser": "1.4.1",
"icewind/Streams": "0.5.2",
"swiftmailer/swiftmailer": "^5.4",
- "guzzlehttp/guzzle": "^5.3",
+ "guzzlehttp/guzzle": "^6.3",
"league/flysystem": "^1.0",
"pear/pear-core-minimal": "^v1.10",
"interfasys/lognormalizer": "^v1.0",
diff --git a/composer.lock b/composer.lock
index a28c89bd0907..c408c4812b2c 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
- "content-hash": "b3430b12b915630c5f2e62914db5ec1a",
+ "content-hash": "a751804577669cf200c4c11d36f977d5",
"packages": [
{
"name": "bantu/ini-get-wrapper",
@@ -752,28 +752,41 @@
},
{
"name": "guzzlehttp/guzzle",
- "version": "5.3.1",
+ "version": "6.3.0",
"source": {
"type": "git",
"url": "https://github.com/guzzle/guzzle.git",
- "reference": "70f1fa53b71c4647bf2762c09068a95f77e12fb8"
+ "reference": "f4db5a78a5ea468d4831de7f0bf9d9415e348699"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/guzzle/guzzle/zipball/70f1fa53b71c4647bf2762c09068a95f77e12fb8",
- "reference": "70f1fa53b71c4647bf2762c09068a95f77e12fb8",
+ "url": "https://api.github.com/repos/guzzle/guzzle/zipball/f4db5a78a5ea468d4831de7f0bf9d9415e348699",
+ "reference": "f4db5a78a5ea468d4831de7f0bf9d9415e348699",
"shasum": ""
},
"require": {
- "guzzlehttp/ringphp": "^1.1",
- "php": ">=5.4.0"
+ "guzzlehttp/promises": "^1.0",
+ "guzzlehttp/psr7": "^1.4",
+ "php": ">=5.5"
},
"require-dev": {
"ext-curl": "*",
- "phpunit/phpunit": "^4.0"
+ "phpunit/phpunit": "^4.0 || ^5.0",
+ "psr/log": "^1.0"
+ },
+ "suggest": {
+ "psr/log": "Required for using the Log middleware"
},
"type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "6.2-dev"
+ }
+ },
"autoload": {
+ "files": [
+ "src/functions_include.php"
+ ],
"psr-4": {
"GuzzleHttp\\": "src/"
}
@@ -789,7 +802,7 @@
"homepage": "https://github.com/mtdowling"
}
],
- "description": "Guzzle is a PHP HTTP client library and framework for building RESTful web service clients",
+ "description": "Guzzle is a PHP HTTP client library",
"homepage": "http://guzzlephp.org/",
"keywords": [
"client",
@@ -800,44 +813,41 @@
"rest",
"web service"
],
- "time": "2016-07-15T19:28:39+00:00"
+ "time": "2017-06-22T18:50:49+00:00"
},
{
- "name": "guzzlehttp/ringphp",
- "version": "1.1.0",
+ "name": "guzzlehttp/promises",
+ "version": "v1.3.1",
"source": {
"type": "git",
- "url": "https://github.com/guzzle/RingPHP.git",
- "reference": "dbbb91d7f6c191e5e405e900e3102ac7f261bc0b"
+ "url": "https://github.com/guzzle/promises.git",
+ "reference": "a59da6cf61d80060647ff4d3eb2c03a2bc694646"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/guzzle/RingPHP/zipball/dbbb91d7f6c191e5e405e900e3102ac7f261bc0b",
- "reference": "dbbb91d7f6c191e5e405e900e3102ac7f261bc0b",
+ "url": "https://api.github.com/repos/guzzle/promises/zipball/a59da6cf61d80060647ff4d3eb2c03a2bc694646",
+ "reference": "a59da6cf61d80060647ff4d3eb2c03a2bc694646",
"shasum": ""
},
"require": {
- "guzzlehttp/streams": "~3.0",
- "php": ">=5.4.0",
- "react/promise": "~2.0"
+ "php": ">=5.5.0"
},
"require-dev": {
- "ext-curl": "*",
- "phpunit/phpunit": "~4.0"
- },
- "suggest": {
- "ext-curl": "Guzzle will use specific adapters if cURL is present"
+ "phpunit/phpunit": "^4.0"
},
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "1.1-dev"
+ "dev-master": "1.4-dev"
}
},
"autoload": {
"psr-4": {
- "GuzzleHttp\\Ring\\": "src/"
- }
+ "GuzzleHttp\\Promise\\": "src/"
+ },
+ "files": [
+ "src/functions_include.php"
+ ]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
@@ -850,25 +860,32 @@
"homepage": "https://github.com/mtdowling"
}
],
- "description": "Provides a simple API and specification that abstracts away the details of HTTP into a single PHP function.",
- "time": "2015-05-20T03:37:09+00:00"
+ "description": "Guzzle promises library",
+ "keywords": [
+ "promise"
+ ],
+ "time": "2016-12-20T10:07:11+00:00"
},
{
- "name": "guzzlehttp/streams",
- "version": "3.0.0",
+ "name": "guzzlehttp/psr7",
+ "version": "1.4.2",
"source": {
"type": "git",
- "url": "https://github.com/guzzle/streams.git",
- "reference": "47aaa48e27dae43d39fc1cea0ccf0d84ac1a2ba5"
+ "url": "https://github.com/guzzle/psr7.git",
+ "reference": "f5b8a8512e2b58b0071a7280e39f14f72e05d87c"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/guzzle/streams/zipball/47aaa48e27dae43d39fc1cea0ccf0d84ac1a2ba5",
- "reference": "47aaa48e27dae43d39fc1cea0ccf0d84ac1a2ba5",
+ "url": "https://api.github.com/repos/guzzle/psr7/zipball/f5b8a8512e2b58b0071a7280e39f14f72e05d87c",
+ "reference": "f5b8a8512e2b58b0071a7280e39f14f72e05d87c",
"shasum": ""
},
"require": {
- "php": ">=5.4.0"
+ "php": ">=5.4.0",
+ "psr/http-message": "~1.0"
+ },
+ "provide": {
+ "psr/http-message-implementation": "1.0"
},
"require-dev": {
"phpunit/phpunit": "~4.0"
@@ -876,13 +893,16 @@
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "3.0-dev"
+ "dev-master": "1.4-dev"
}
},
"autoload": {
"psr-4": {
- "GuzzleHttp\\Stream\\": "src/"
- }
+ "GuzzleHttp\\Psr7\\": "src/"
+ },
+ "files": [
+ "src/functions_include.php"
+ ]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
@@ -893,15 +913,23 @@
"name": "Michael Dowling",
"email": "mtdowling@gmail.com",
"homepage": "https://github.com/mtdowling"
+ },
+ {
+ "name": "Tobias Schultze",
+ "homepage": "https://github.com/Tobion"
}
],
- "description": "Provides a simple abstraction over streams of data",
- "homepage": "http://guzzlephp.org/",
+ "description": "PSR-7 message implementation that also provides common utility methods",
"keywords": [
- "Guzzle",
- "stream"
+ "http",
+ "message",
+ "request",
+ "response",
+ "stream",
+ "uri",
+ "url"
],
- "time": "2014-10-12T19:18:40+00:00"
+ "time": "2017-03-20T17:10:46+00:00"
},
{
"name": "icewind/streams",
@@ -1821,6 +1849,56 @@
],
"time": "2015-09-11T15:10:35+00:00"
},
+ {
+ "name": "psr/http-message",
+ "version": "1.0.1",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/php-fig/http-message.git",
+ "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363",
+ "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.0"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.0.x-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Psr\\Http\\Message\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "PHP-FIG",
+ "homepage": "http://www.php-fig.org/"
+ }
+ ],
+ "description": "Common interface for HTTP messages",
+ "homepage": "https://github.com/php-fig/http-message",
+ "keywords": [
+ "http",
+ "http-message",
+ "psr",
+ "psr-7",
+ "request",
+ "response"
+ ],
+ "time": "2016-08-06T14:39:51+00:00"
+ },
{
"name": "psr/log",
"version": "1.0.2",
@@ -1990,49 +2068,6 @@
],
"time": "2014-02-06T20:53:21+00:00"
},
- {
- "name": "react/promise",
- "version": "v2.5.0",
- "source": {
- "type": "git",
- "url": "https://github.com/reactphp/promise.git",
- "reference": "2760f3898b7e931aa71153852dcd48a75c9b95db"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/reactphp/promise/zipball/2760f3898b7e931aa71153852dcd48a75c9b95db",
- "reference": "2760f3898b7e931aa71153852dcd48a75c9b95db",
- "shasum": ""
- },
- "require": {
- "php": ">=5.4.0"
- },
- "type": "library",
- "autoload": {
- "psr-4": {
- "React\\Promise\\": "src/"
- },
- "files": [
- "src/functions_include.php"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Jan Sorgalla",
- "email": "jsorgalla@gmail.com"
- }
- ],
- "description": "A lightweight implementation of CommonJS Promises/A for PHP",
- "keywords": [
- "promise",
- "promises"
- ],
- "time": "2016-12-22T14:09:01+00:00"
- },
{
"name": "sabre/dav",
"version": "3.2.2",
@@ -3486,29 +3521,29 @@
},
{
"name": "fabpot/goutte",
- "version": "v2.0.4",
+ "version": "v3.2.1",
"source": {
"type": "git",
"url": "https://github.com/FriendsOfPHP/Goutte.git",
- "reference": "0ad3ee6dc2d0aaa832a80041a1e09bf394e99802"
+ "reference": "db5c28f4a010b4161d507d5304e28a7ebf211638"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/FriendsOfPHP/Goutte/zipball/0ad3ee6dc2d0aaa832a80041a1e09bf394e99802",
- "reference": "0ad3ee6dc2d0aaa832a80041a1e09bf394e99802",
+ "url": "https://api.github.com/repos/FriendsOfPHP/Goutte/zipball/db5c28f4a010b4161d507d5304e28a7ebf211638",
+ "reference": "db5c28f4a010b4161d507d5304e28a7ebf211638",
"shasum": ""
},
"require": {
- "guzzlehttp/guzzle": ">=4,<6",
- "php": ">=5.4.0",
- "symfony/browser-kit": "~2.1",
- "symfony/css-selector": "~2.1",
- "symfony/dom-crawler": "~2.1"
+ "guzzlehttp/guzzle": "^6.0",
+ "php": ">=5.5.0",
+ "symfony/browser-kit": "~2.1|~3.0",
+ "symfony/css-selector": "~2.1|~3.0",
+ "symfony/dom-crawler": "~2.1|~3.0"
},
"type": "application",
"extra": {
"branch-alias": {
- "dev-master": "2.0-dev"
+ "dev-master": "3.2-dev"
}
},
"autoload": {
@@ -3531,7 +3566,108 @@
"keywords": [
"scraper"
],
- "time": "2015-05-05T21:14:57+00:00"
+ "time": "2017-01-03T13:21:43+00:00"
+ },
+ {
+ "name": "guzzlehttp/ringphp",
+ "version": "1.1.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/guzzle/RingPHP.git",
+ "reference": "dbbb91d7f6c191e5e405e900e3102ac7f261bc0b"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/guzzle/RingPHP/zipball/dbbb91d7f6c191e5e405e900e3102ac7f261bc0b",
+ "reference": "dbbb91d7f6c191e5e405e900e3102ac7f261bc0b",
+ "shasum": ""
+ },
+ "require": {
+ "guzzlehttp/streams": "~3.0",
+ "php": ">=5.4.0",
+ "react/promise": "~2.0"
+ },
+ "require-dev": {
+ "ext-curl": "*",
+ "phpunit/phpunit": "~4.0"
+ },
+ "suggest": {
+ "ext-curl": "Guzzle will use specific adapters if cURL is present"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.1-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "GuzzleHttp\\Ring\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Michael Dowling",
+ "email": "mtdowling@gmail.com",
+ "homepage": "https://github.com/mtdowling"
+ }
+ ],
+ "description": "Provides a simple API and specification that abstracts away the details of HTTP into a single PHP function.",
+ "time": "2015-05-20T03:37:09+00:00"
+ },
+ {
+ "name": "guzzlehttp/streams",
+ "version": "3.0.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/guzzle/streams.git",
+ "reference": "47aaa48e27dae43d39fc1cea0ccf0d84ac1a2ba5"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/guzzle/streams/zipball/47aaa48e27dae43d39fc1cea0ccf0d84ac1a2ba5",
+ "reference": "47aaa48e27dae43d39fc1cea0ccf0d84ac1a2ba5",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.4.0"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "~4.0"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "3.0-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "GuzzleHttp\\Stream\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Michael Dowling",
+ "email": "mtdowling@gmail.com",
+ "homepage": "https://github.com/mtdowling"
+ }
+ ],
+ "description": "Provides a simple abstraction over streams of data",
+ "homepage": "http://guzzlephp.org/",
+ "keywords": [
+ "Guzzle",
+ "stream"
+ ],
+ "time": "2014-10-12T19:18:40+00:00"
},
{
"name": "instaclick/php-webdriver",
@@ -4563,6 +4699,49 @@
],
"time": "2017-02-14T16:28:37+00:00"
},
+ {
+ "name": "react/promise",
+ "version": "v2.5.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/reactphp/promise.git",
+ "reference": "2760f3898b7e931aa71153852dcd48a75c9b95db"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/reactphp/promise/zipball/2760f3898b7e931aa71153852dcd48a75c9b95db",
+ "reference": "2760f3898b7e931aa71153852dcd48a75c9b95db",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.4.0"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "React\\Promise\\": "src/"
+ },
+ "files": [
+ "src/functions_include.php"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Jan Sorgalla",
+ "email": "jsorgalla@gmail.com"
+ }
+ ],
+ "description": "A lightweight implementation of CommonJS Promises/A for PHP",
+ "keywords": [
+ "promise",
+ "promises"
+ ],
+ "time": "2016-12-22T14:09:01+00:00"
+ },
{
"name": "sebastian/code-unit-reverse-lookup",
"version": "1.0.1",
diff --git a/lib/private/Files/Storage/DAV.php b/lib/private/Files/Storage/DAV.php
index 36b39cfbfe37..3d1492b2936d 100644
--- a/lib/private/Files/Storage/DAV.php
+++ b/lib/private/Files/Storage/DAV.php
@@ -34,7 +34,6 @@
use Exception;
use GuzzleHttp\Exception\RequestException;
-use GuzzleHttp\Message\ResponseInterface;
use OC\Files\Filesystem;
use OC\Files\Stream\Close;
use Icewind\Streams\IteratorDirectory;
@@ -50,6 +49,7 @@
use Sabre\DAV\Xml\Property\ResourceType;
use Sabre\HTTP\ClientException;
use Sabre\HTTP\ClientHttpException;
+use Psr\Http\Message\ResponseInterface;
/**
* Class DAV
diff --git a/lib/private/Http/Client/Client.php b/lib/private/Http/Client/Client.php
index 7235117c3a5a..f4039b5b7b02 100644
--- a/lib/private/Http/Client/Client.php
+++ b/lib/private/Http/Client/Client.php
@@ -62,23 +62,24 @@ private function setDefaultOptions() {
return;
}
$this->configured = true;
+ $config = $this->client->getConfig();
// Either use user bundle or the system bundle if nothing is specified
if ($this->certificateManager->listCertificates() !== []) {
- $this->client->setDefaultOption('verify', $this->certificateManager->getAbsoluteBundlePath());
+ $config['verify'] = $this->certificateManager->getAbsoluteBundlePath();
} else {
// If the instance is not yet setup we need to use the static path as
// $this->certificateManager->getAbsoluteBundlePath() tries to instantiiate
// a view
if ($this->config->getSystemValue('installed', false) && !\OCP\Util::needUpgrade()) {
- $this->client->setDefaultOption('verify', $this->certificateManager->getAbsoluteBundlePath(null));
+ $config['verify'] = $this->certificateManager->getAbsoluteBundlePath(null);
} else {
- $this->client->setDefaultOption('verify', \OC::$SERVERROOT . '/resources/config/ca-bundle.crt');
+ $config['verify'] = \OC::$SERVERROOT . '/resources/config/ca-bundle.crt';
}
}
- $this->client->setDefaultOption('headers/User-Agent', 'ownCloud Server Crawler');
+ $config['headers/User-Agent'] = 'ownCloud Server Crawler';
if ($this->getProxyUri() !== '') {
- $this->client->setDefaultOption('proxy', $this->getProxyUri());
+ $config['proxy'] = $this->getProxyUri();
}
}
@@ -199,6 +200,10 @@ public function head($uri, $options = []) {
*/
public function post($uri, array $options = []) {
$this->setDefaultOptions();
+ if (isset($options['body']) && is_array($options['body'])) {
+ $options['form_params'] = $options['body'];
+ unset($options['body']);
+ }
$response = $this->client->post($uri, $options);
return new Response($response);
}
diff --git a/lib/private/Http/Client/Response.php b/lib/private/Http/Client/Response.php
index 64fbf6ea8ee3..696b76ba0ffc 100644
--- a/lib/private/Http/Client/Response.php
+++ b/lib/private/Http/Client/Response.php
@@ -23,7 +23,7 @@
namespace OC\Http\Client;
use OCP\Http\Client\IResponse;
-use GuzzleHttp\Message\Response as GuzzleResponse;
+use Psr\Http\Message\ResponseInterface;
/**
* Class Response
@@ -43,7 +43,7 @@ class Response implements IResponse {
* @param GuzzleResponse $response
* @param bool $stream
*/
- public function __construct(GuzzleResponse $response, $stream = false) {
+ public function __construct(ResponseInterface $response, $stream = false) {
$this->response = $response;
$this->stream = $stream;
}
diff --git a/tests/TestHelpers/SharingHelper.php b/tests/TestHelpers/SharingHelper.php
index dd82c2045551..280af0c5e042 100644
--- a/tests/TestHelpers/SharingHelper.php
+++ b/tests/TestHelpers/SharingHelper.php
@@ -22,6 +22,7 @@
namespace TestHelpers;
use GuzzleHttp\Client as GClient;
+use GuzzleHttp\Psr7\Request;
/**
* manage Shares via OCS API
@@ -127,6 +128,6 @@ public static function createShare(
$options['body'] = $fd;
- return $client->send($client->createRequest("POST", $fullUrl, $options));
+ return $client->send(new Request("POST", $fullUrl), $options);
}
-}
\ No newline at end of file
+}
diff --git a/tests/TestHelpers/WebDavHelper.php b/tests/TestHelpers/WebDavHelper.php
index dca845adeebb..13adb2cc5b15 100644
--- a/tests/TestHelpers/WebDavHelper.php
+++ b/tests/TestHelpers/WebDavHelper.php
@@ -27,6 +27,7 @@
use Sabre\DAV\Client as SClient;
use GuzzleHttp\Stream\StreamInterface;
use GuzzleHttp\Stream\Stream;
+use GuzzleHttp\Psr7\Request;
/**
* Helper to make WebDav Requests
@@ -117,21 +118,12 @@ public static function makeDavRequest(
= [ 'curl' => [ CURLOPT_INTERFACE => $sourceIpAddress ]];
}
- $request = $client->createRequest($method, $fullUrl, $options);
- if (!is_null($headers)) {
- foreach ($headers as $key => $value) {
- if ($request->hasHeader($key) === true) {
- $request->setHeader($key, $value);
- } else {
- $request->addHeader($key, $value);
- }
- }
- }
- if (!is_null($body)) {
- $request->setBody($body);
+ if (is_null($headers)) {
+ $headers = [];
}
-
- return $client->send($request);
+ $request = new Request($method, $fullUrl, $headers, $body);
+
+ return $client->send($request, $options);
}
/**
@@ -196,4 +188,4 @@ public static function sanitizeUrl($url, $trailingSlash = false) {
$url = preg_replace("/([^:]\/)\/+/", '$1', $url);
return $url;
}
-}
\ No newline at end of file
+}
diff --git a/tests/integration/features/bootstrap/AppConfiguration.php b/tests/integration/features/bootstrap/AppConfiguration.php
index 4269240f3a85..1d48d31477cc 100644
--- a/tests/integration/features/bootstrap/AppConfiguration.php
+++ b/tests/integration/features/bootstrap/AppConfiguration.php
@@ -1,6 +1,6 @@
baseUrl, 0, -5) . $url;
+ $options = [];
try {
+ $headers = [
+ 'OCS_APIREQUEST' => 'true',
+ 'requesttoken' => $this->requestToken
+ ];
+ if ($authHeader) {
+ $headers['Authorization'] = $authHeader;
+ }
if ($useCookies) {
- $request = $this->client->createRequest($method, $fullUrl, [
+ $options = [
'cookies' => $this->cookieJar,
- ]);
- } else {
- $request = $this->client->createRequest($method, $fullUrl);
+ ];
}
if ($authHeader) {
- $request->setHeader('Authorization', $authHeader);
+ $headers['Authorization'] = $authHeader;
}
- $request->setHeader('OCS_APIREQUEST', 'true');
- $request->setHeader('requesttoken', $this->requestToken);
- $this->response = $this->client->send($request);
+ $headers['OCS_APIREQUEST'] = 'true';
+ $headers['requesttoken'] = $this->requestToken;
+ $request = new Request($method, $fullUrl, $headers);
+ $this->response = $this->client->send($request, $options);
} catch (ClientException $ex) {
$this->response = $ex->getResponse();
}
@@ -103,12 +111,12 @@ public function aNewBrowserSessionIsStarted() {
$client = new Client();
$response = $client->post(
$loginUrl, [
- 'body' => [
- 'user' => 'user0',
- 'password' => '123456',
- 'requesttoken' => $this->requestToken,
- ],
- 'cookies' => $this->cookieJar,
+ 'form_params' => [
+ 'user' => 'user0',
+ 'password' => '123456',
+ 'requesttoken' => $this->requestToken,
+ ],
+ 'cookies' => $this->cookieJar,
]
);
$this->extracRequestTokenFromResponse($response);
diff --git a/tests/integration/features/bootstrap/BasicStructure.php b/tests/integration/features/bootstrap/BasicStructure.php
index ef4667ab8625..3917b8990a7c 100644
--- a/tests/integration/features/bootstrap/BasicStructure.php
+++ b/tests/integration/features/bootstrap/BasicStructure.php
@@ -1,7 +1,8 @@
xml()->meta[0]->statuscode;
+ return $this->getResponseXml($response)->meta[0]->statuscode;
+ }
+
+ /**
+ * Parses the response as XML
+ *
+ * @param ResponseInterface $response
+ * @return SimpleXMLElement
+ */
+ public function getResponseXml($response = null) {
+ if ($response === null) {
+ $response = $this->response;
+ }
+ // rewind just to make sure we can re-parse it in case it was parsed already...
+ $response->getBody()->rewind();
+ return new SimpleXMLElement($response->getBody()->getContents());
}
/**
@@ -153,11 +169,11 @@ public function sendingToWith($verb, $url, $body) {
}
if ($body instanceof \Behat\Gherkin\Node\TableNode) {
$fd = $body->getRowsHash();
- $options['body'] = $fd;
+ $options['form_params'] = $fd;
}
try {
- $this->response = $client->send($client->createRequest($verb, $fullUrl, $options));
+ $this->response = $client->send(new Request($verb, $fullUrl), $options);
} catch (\GuzzleHttp\Exception\ClientException $ex) {
$this->response = $ex->getResponse();
}
@@ -188,15 +204,16 @@ public function sendingToWithDirectUrl($verb, $url, $body) {
if ($body instanceof \Behat\Gherkin\Node\TableNode) {
$fd = $body->getRowsHash();
- $options['body'] = $fd;
+ $options['form_params'] = $fd;
}
try {
- $request = $client->createRequest($verb, $fullUrl, $options);
+ $headers = [];
if (isset($this->requestToken)) {
- $request->addHeader('requesttoken', $this->requestToken);
+ $headers['requesttoken'] = $this->requestToken;
}
- $this->response = $client->send($request);
+ $request = new Request($verb, $fullUrl, $headers);
+ $this->response = $client->send($request, $options);
} catch (\GuzzleHttp\Exception\ClientException $ex) {
$this->response = $ex->getResponse();
}
@@ -253,7 +270,7 @@ public function loggingInUsingWebAs($user) {
$response = $client->post(
$loginUrl,
[
- 'body' => [
+ 'form_params' => [
'user' => $user,
'password' => $password,
'requesttoken' => $this->requestToken,
@@ -273,16 +290,16 @@ public function sendingAToWithRequesttoken($method, $url) {
$baseUrl = substr($this->baseUrl, 0, -5);
$client = new Client();
- $request = $client->createRequest(
+ $request = new Request(
$method,
$baseUrl . $url,
- [
- 'cookies' => $this->cookieJar,
- ]
+ ['requesttoken' => $this->requestToken]
);
- $request->addHeader('requesttoken', $this->requestToken);
+ $options = [
+ 'cookies' => $this->cookieJar,
+ ];
try {
- $this->response = $client->send($request);
+ $this->response = $client->send($request, $options);
} catch (\GuzzleHttp\Exception\ClientException $e) {
$this->response = $e->getResponse();
}
@@ -297,15 +314,12 @@ public function sendingAToWithoutRequesttoken($method, $url) {
$baseUrl = substr($this->baseUrl, 0, -5);
$client = new Client();
- $request = $client->createRequest(
- $method,
- $baseUrl . $url,
- [
- 'cookies' => $this->cookieJar,
- ]
- );
+ $request = new Request($method, $baseUrl . $url);
+ $options = [
+ 'cookies' => $this->cookieJar,
+ ];
try {
- $this->response = $client->send($request);
+ $this->response = $client->send($request, $options);
} catch (\GuzzleHttp\Exception\ClientException $e) {
$this->response = $e->getResponse();
}
@@ -411,7 +425,7 @@ public static function useBigFileIDs() {
$client = new Client();
$options = [];
$options['auth'] = ['admin','admin'];
- $client->send($client->createRequest('post', $fullUrl, $options));
+ $client->send(new Request('POST', $fullUrl), $options);
}
}
diff --git a/tests/integration/features/bootstrap/CalDavContext.php b/tests/integration/features/bootstrap/CalDavContext.php
index 3598bda56fc1..d74fb6f2453f 100644
--- a/tests/integration/features/bootstrap/CalDavContext.php
+++ b/tests/integration/features/bootstrap/CalDavContext.php
@@ -22,7 +22,8 @@
require __DIR__ . '/../../../../lib/composer/autoload.php';
use GuzzleHttp\Client;
-use GuzzleHttp\Message\ResponseInterface;
+use Psr\Http\Message\ResponseInterface;
+use GuzzleHttp\Psr7\Request;
class CalDavContext implements \Behat\Behat\Context\Context {
/** @var string */
@@ -164,19 +165,20 @@ public function createsACalendarNamed($user, $name) {
$davUrl = $this->baseUrl . '/remote.php/dav/calendars/'.$user.'/'.$name;
$password = ($user === 'admin') ? 'admin' : '123456';
- $request = $this->client->createRequest(
+ $options = [
+ 'auth' => [
+ $user,
+ $password,
+ ],
+ ];
+ $request = new Request(
'MKCALENDAR',
$davUrl,
- [
- 'body' => 'test1#21213D',
- 'auth' => [
- $user,
- $password,
- ],
- ]
+ [],
+ 'test1#21213D'
);
- $this->response = $this->client->send($request);
+ $this->response = $this->client->send($request, $options);
}
}
diff --git a/tests/integration/features/bootstrap/CapabilitiesContext.php b/tests/integration/features/bootstrap/CapabilitiesContext.php
index 411550a28ac1..786acfb25e49 100644
--- a/tests/integration/features/bootstrap/CapabilitiesContext.php
+++ b/tests/integration/features/bootstrap/CapabilitiesContext.php
@@ -2,6 +2,7 @@
use Behat\Behat\Context\Context;
use Behat\Behat\Context\SnippetAcceptingContext;
+use GuzzleHttp\Client;
require __DIR__ . '/../../../../lib/composer/autoload.php';
@@ -17,7 +18,7 @@ class CapabilitiesContext implements Context, SnippetAcceptingContext {
* @param \Behat\Gherkin\Node\TableNode|null $formData
*/
public function checkCapabilitiesResponse(\Behat\Gherkin\Node\TableNode $formData) {
- $capabilitiesXML = $this->response->xml()->data->capabilities;
+ $capabilitiesXML = $this->getResponseXml()->data->capabilities;
foreach ($formData->getHash() as $row) {
$path_to_element = explode('@@@', $row['path_to_element']);
diff --git a/tests/integration/features/bootstrap/CardDavContext.php b/tests/integration/features/bootstrap/CardDavContext.php
index 0b7f5514d628..d8bf80c7903a 100644
--- a/tests/integration/features/bootstrap/CardDavContext.php
+++ b/tests/integration/features/bootstrap/CardDavContext.php
@@ -22,7 +22,8 @@
require __DIR__ . '/../../../../lib/composer/autoload.php';
use GuzzleHttp\Client;
-use GuzzleHttp\Message\ResponseInterface;
+use Psr\Http\Message\ResponseInterface;
+use GuzzleHttp\Psr7\Request;
class CardDavContext implements \Behat\Behat\Context\Context {
/** @var string */
@@ -123,11 +124,17 @@ public function createsAnAddressbookNamedWithStatuscode($user, $addressBook, $st
$davUrl = $this->baseUrl . '/remote.php/dav/addressbooks/users/'.$user.'/'.$addressBook;
$password = ($user === 'admin') ? 'admin' : '123456';
- $request = $this->client->createRequest(
+ $options = [
+ 'auth' => [
+ $user,
+ $password,
+ ],
+ ];
+ $request = new Request(
'MKCOL',
$davUrl,
- [
- 'body' => ' 'application/xml;charset=UTF-8'],
+ '
@@ -136,18 +143,10 @@ public function createsAnAddressbookNamedWithStatuscode($user, $addressBook, $st
,'.$addressBook.'
- ',
- 'auth' => [
- $user,
- $password,
- ],
- 'headers' => [
- 'Content-Type' => 'application/xml;charset=UTF-8',
- ],
- ]
+ '
);
- $this->response = $this->client->send($request);
+ $this->response = $this->client->send($request, $options);
if($this->response->getStatusCode() !== (int)$statusCode) {
throw new \Exception(
diff --git a/tests/integration/features/bootstrap/Checksums.php b/tests/integration/features/bootstrap/Checksums.php
index 4b8cc67e35f0..d135dc27a844 100644
--- a/tests/integration/features/bootstrap/Checksums.php
+++ b/tests/integration/features/bootstrap/Checksums.php
@@ -3,6 +3,7 @@
require __DIR__ . '/../../../../lib/composer/autoload.php';
use GuzzleHttp\Client;
+use GuzzleHttp\Psr7\Request;
trait Checksums {
@@ -14,7 +15,7 @@ trait Checksums {
* @param string $checksum
*/
public function userUploadsFileToWithChecksum($user, $source, $destination, $checksum) {
- $file = \GuzzleHttp\Stream\Stream::factory(fopen($source, 'r'));
+ $file = file_get_contents($source);
$this->response = $this->makeDavRequest($user,
'PUT',
$destination,
@@ -41,23 +42,24 @@ public function theWebdavResponseShouldHaveAStatusCode($statusCode) {
*/
public function userRequestsTheChecksumOfViaPropfind($user, $path) {
$client = new Client();
- $request = $client->createRequest(
+ $options = [
+ 'auth' => [
+ $user,
+ $this->getPasswordForUser($user),
+ ]
+ ];
+ $request = new Request(
'PROPFIND',
substr($this->baseUrl, 0, -4) . $this->getDavFilesPath($user) . $path,
- [
- 'body' => '
+ [],
+ '
-',
- 'auth' => [
- $user,
- $this->getPasswordForUser($user),
- ]
- ]
+'
);
- $this->response = $client->send($request);
+ $this->response = $client->send($request, $options);
}
/**
@@ -88,7 +90,7 @@ public function theWebdavChecksumShouldMatch($checksum)
*/
public function theHeaderChecksumShouldMatch($checksum)
{
- if ($this->response->getHeader('OC-Checksum') !== $checksum) {
+ if ($this->response->getHeader('OC-Checksum')[0] !== $checksum) {
throw new \Exception("Expected $checksum, got ".$this->response->getHeader('OC-Checksum'));
}
}
@@ -101,20 +103,18 @@ public function theHeaderChecksumShouldMatch($checksum)
*/
public function userCopiedFileTo($user, $source, $destination) {
$client = new Client();
- $request = $client->createRequest(
+ $options = [
+ 'auth' => [
+ $user,
+ $this->getPasswordForUser($user),
+ ],
+ ];
+ $request = new Request(
'COPY',
substr($this->baseUrl, 0, -4) . $this->davPath . $source,
- [
- 'auth' => [
- $user,
- $this->getPasswordForUser($user),
- ],
- 'headers' => [
- 'Destination' => substr($this->baseUrl, 0, -4) . $this->davPath . $destination,
- ],
- ]
+ ['Destination' => substr($this->baseUrl, 0, -4) . $this->davPath . $destination]
);
- $this->response = $client->send($request);
+ $this->response = $client->send($request, $options);
}
/**
@@ -158,7 +158,6 @@ public function theOcChecksumHeaderShouldNotBeThere()
public function userUploadsChunkFileOfWithToWithChecksum($user, $num, $total, $data, $destination, $checksum) {
try {
$num -= 1;
- $data = \GuzzleHttp\Stream\Stream::factory($data);
$file = $destination . '-chunking-42-' . $total . '-' . $num;
$this->response = $this->makeDavRequest($user,
'PUT',
diff --git a/tests/integration/features/bootstrap/FederationContext.php b/tests/integration/features/bootstrap/FederationContext.php
index b3b5fe49d648..934af75ce4ac 100644
--- a/tests/integration/features/bootstrap/FederationContext.php
+++ b/tests/integration/features/bootstrap/FederationContext.php
@@ -2,6 +2,7 @@
use Behat\Behat\Context\Context;
use Behat\Behat\Context\SnippetAcceptingContext;
+use GuzzleHttp\Client;
require __DIR__ . '/../../../../lib/composer/autoload.php';
require_once 'bootstrap.php';
@@ -44,7 +45,7 @@ public function acceptLastPendingShare($user, $server) {
$this->sendingToWith('GET', "/apps/files_sharing/api/v1/remote_shares/pending", null);
$this->theHTTPStatusCodeShouldBe('200');
$this->theOCSStatusCodeShouldBe('100');
- $share_id = $this->response->xml()->data[0]->element[0]->id;
+ $share_id = $this->getResponseXml()->data[0]->element[0]->id;
$this->sendingToWith('POST', "/apps/files_sharing/api/v1/remote_shares/pending/{$share_id}", null);
$this->theHTTPStatusCodeShouldBe('200');
$this->theOCSStatusCodeShouldBe('100');
diff --git a/tests/integration/features/bootstrap/MailTool.php b/tests/integration/features/bootstrap/MailTool.php
index 4814dc3767e5..4468dc88c4a0 100644
--- a/tests/integration/features/bootstrap/MailTool.php
+++ b/tests/integration/features/bootstrap/MailTool.php
@@ -21,6 +21,7 @@
require __DIR__ . '/../../../../lib/composer/autoload.php';
use GuzzleHttp\Client;
+use GuzzleHttp\Psr7\Request;
trait MailTool {
@@ -32,11 +33,13 @@ trait MailTool {
public function getEmails() {
$fullUrl = $this->mailhogUrl;
$client = new Client();
- $options = ['headers' => ['Content-Type' => 'application/json']];
try {
- $this->response = $client->send(
- $client->createRequest('GET', $fullUrl, $options)
+ $request = new Request(
+ 'GET',
+ $fullUrl,
+ ['Content-Type' => 'application/json']
);
+ $this->response = $client->send($request, $options);
} catch (\GuzzleHttp\Exception\ClientException $ex) {
$this->response = $ex->getResponse();
}
@@ -45,4 +48,4 @@ public function getEmails() {
}
-}
\ No newline at end of file
+}
diff --git a/tests/integration/features/bootstrap/Provisioning.php b/tests/integration/features/bootstrap/Provisioning.php
index 73499de9ea3a..bedf39696444 100644
--- a/tests/integration/features/bootstrap/Provisioning.php
+++ b/tests/integration/features/bootstrap/Provisioning.php
@@ -1,7 +1,8 @@
adminUser;
}
- $options['body'] = [
- 'userid' => $user,
- 'password' => '123456'
- ];
+ $options['form_params'] = [
+ 'userid' => $user,
+ 'password' => '123456'
+ ];
- $this->response = $client->send($client->createRequest("POST", $fullUrl, $options));
- if ($this->currentServer === 'LOCAL') {
+ $this->response = $client->send(new Request("POST", $fullUrl), $options);
+ if ($this->currentServer === 'LOCAL'){
$this->createdUsers[$user] = $user;
} elseif ($this->currentServer === 'REMOTE') {
$this->createdRemoteUsers[$user] = $user;
@@ -85,7 +86,7 @@ public function creatingTheUser($user) {
'auth' => [$user, '123456'],
];
$url = $fullUrl.'/'.$user;
- $client->send($client->createRequest('GET', $url, $options2));
+ $client->send(new Request('GET', $url), $options2);
}
public function createUser($user) {
@@ -236,12 +237,12 @@ public function creatingTheGroup($group) {
$options['auth'] = $this->adminUser;
}
- $options['body'] = [
- 'groupid' => $group,
- ];
+ $options['form_params'] = [
+ 'groupid' => $group,
+ ];
- $this->response = $client->send($client->createRequest("POST", $fullUrl, $options));
- if ($this->currentServer === 'LOCAL') {
+ $this->response = $client->send(new Request("POST", $fullUrl), $options);
+ if ($this->currentServer === 'LOCAL'){
$this->createdGroups[$group] = $group;
} elseif ($this->currentServer === 'REMOTE') {
$this->createdRemoteGroups[$group] = $group;
@@ -259,7 +260,7 @@ public function assureUserIsDisabled($user) {
$options['auth'] = $this->adminUser;
}
- $this->response = $client->send($client->createRequest("PUT", $fullUrl, $options));
+ $this->response = $client->send(new Request("PUT", $fullUrl), $options);
}
/**
@@ -274,7 +275,7 @@ public function deletingTheUser($user) {
$options['auth'] = $this->adminUser;
}
- $this->response = $client->send($client->createRequest("DELETE", $fullUrl, $options));
+ $this->response = $client->send(new Request("DELETE", $fullUrl), $options);
}
/**
@@ -289,7 +290,7 @@ public function deletingTheGroup($group) {
$options['auth'] = $this->adminUser;
}
- $this->response = $client->send($client->createRequest("DELETE", $fullUrl, $options));
+ $this->response = $client->send(new Request("DELETE", $fullUrl), $options);
}
/**
@@ -317,11 +318,11 @@ public function addingUserToGroup($user, $group) {
$options['auth'] = $this->adminUser;
}
- $options['body'] = [
- 'groupid' => $group,
- ];
+ $options['form_params'] = [
+ 'groupid' => $group,
+ ];
- $this->response = $client->send($client->createRequest("POST", $fullUrl, $options));
+ $this->response = $client->send(new Request("POST", $fullUrl), $options);
}
@@ -407,10 +408,10 @@ public function assureUserIsSubadminOfGroup($user, $group) {
if ($this->currentUser === 'admin') {
$options['auth'] = $this->adminUser;
}
- $options['body'] = [
- 'groupid' => $group
- ];
- $this->response = $client->send($client->createRequest("POST", $fullUrl, $options));
+ $options['form_params'] = [
+ 'groupid' => $group
+ ];
+ $this->response = $client->send(new Request("POST", $fullUrl), $options);
PHPUnit_Framework_Assert::assertEquals(200, $this->response->getStatusCode());
}
@@ -505,7 +506,7 @@ public function theSubadminUsersShouldBe($groupsList) {
* @return array
*/
public function getArrayOfUsersResponded($resp) {
- $listCheckedElements = $resp->xml()->data[0]->users[0]->element;
+ $listCheckedElements = $this->getResponseXml($resp)->data[0]->users[0]->element;
$extractedElementsArray = json_decode(json_encode($listCheckedElements), 1);
return $extractedElementsArray;
}
@@ -516,7 +517,7 @@ public function getArrayOfUsersResponded($resp) {
* @return array
*/
public function getArrayOfGroupsResponded($resp) {
- $listCheckedElements = $resp->xml()->data[0]->groups[0]->element;
+ $listCheckedElements = $this->getResponseXml($resp)->data[0]->groups[0]->element;
$extractedElementsArray = json_decode(json_encode($listCheckedElements), 1);
return $extractedElementsArray;
}
@@ -527,7 +528,7 @@ public function getArrayOfGroupsResponded($resp) {
* @return array
*/
public function getArrayOfAppsResponded($resp) {
- $listCheckedElements = $resp->xml()->data[0]->apps[0]->element;
+ $listCheckedElements = $this->getResponseXml($resp)->data[0]->apps[0]->element;
$extractedElementsArray = json_decode(json_encode($listCheckedElements), 1);
return $extractedElementsArray;
}
@@ -538,7 +539,7 @@ public function getArrayOfAppsResponded($resp) {
* @return array
*/
public function getArrayOfSubadminsResponded($resp) {
- $listCheckedElements = $resp->xml()->data[0]->element;
+ $listCheckedElements = $this->getResponseXml($resp)->data[0]->element;
$extractedElementsArray = json_decode(json_encode($listCheckedElements), 1);
return $extractedElementsArray;
}
@@ -593,7 +594,7 @@ public function userIsDisabled($user) {
}
$this->response = $client->get($fullUrl, $options);
- PHPUnit_Framework_Assert::assertEquals("false", $this->response->xml()->data[0]->enabled);
+ PHPUnit_Framework_Assert::assertEquals("false", $this->getResponseXml()->data[0]->enabled);
}
/**
@@ -609,7 +610,7 @@ public function userIsEnabled($user) {
}
$this->response = $client->get($fullUrl, $options);
- PHPUnit_Framework_Assert::assertEquals("true", $this->response->xml()->data[0]->enabled);
+ PHPUnit_Framework_Assert::assertEquals("true", $this->getResponseXml()->data[0]->enabled);
}
/**
@@ -647,7 +648,7 @@ public function getUserHome($user) {
$options = [];
$options['auth'] = $this->adminUser;
$this->response = $client->get($fullUrl, $options);
- return $this->response->xml()->data[0]->home;
+ return $this->getResponseXml()->data[0]->home;
}
/**
diff --git a/tests/integration/features/bootstrap/ShareesContext.php b/tests/integration/features/bootstrap/ShareesContext.php
index e70f6c51dc19..22b0f037f9e6 100644
--- a/tests/integration/features/bootstrap/ShareesContext.php
+++ b/tests/integration/features/bootstrap/ShareesContext.php
@@ -2,7 +2,7 @@
use Behat\Behat\Context\Context;
use Behat\Behat\Context\SnippetAcceptingContext;
-use GuzzleHttp\Message\ResponseInterface;
+use Psr\Http\Message\ResponseInterface;
require __DIR__ . '/../../../../lib/composer/autoload.php';
@@ -49,7 +49,7 @@ public function thenListOfSharees($shareeType, $isEmpty, $shareesList = null) {
}
public function getArrayOfShareesResponded(ResponseInterface $response, $shareeType) {
- $elements = $response->xml()->data;
+ $elements = $this->getResponseXml($response)->data;
$elements = json_decode(json_encode($elements), 1);
if (strpos($shareeType, 'exact ') === 0) {
$elements = $elements['exact'];
diff --git a/tests/integration/features/bootstrap/Sharing.php b/tests/integration/features/bootstrap/Sharing.php
index 19ba323ebf41..858648a19e75 100644
--- a/tests/integration/features/bootstrap/Sharing.php
+++ b/tests/integration/features/bootstrap/Sharing.php
@@ -2,6 +2,7 @@
use GuzzleHttp\Client;
use GuzzleHttp\Exception\ClientException;
+use GuzzleHttp\Psr7\Request;
use TestHelpers\SharingHelper;
require __DIR__ . '/../../../../lib/composer/autoload.php';
@@ -37,22 +38,23 @@ public function asCreatingAShareWith($user, $body) {
$options['auth'] = [$user, $this->regularUser];
}
+ $fd = '';
if ($body instanceof \Behat\Gherkin\Node\TableNode) {
$fd = $body->getRowsHash();
if (array_key_exists('expireDate', $fd)) {
$dateModification = $fd['expireDate'];
$fd['expireDate'] = date('Y-m-d', strtotime($dateModification));
}
- $options['body'] = $fd;
+ $options['form_params'] = $fd;
}
try {
- $this->response = $client->send($client->createRequest("POST", $fullUrl, $options));
+ $this->response = $client->send(new Request("POST", $fullUrl), $options);
} catch (\GuzzleHttp\Exception\ClientException $ex) {
$this->response = $ex->getResponse();
}
- $this->lastShareData = $this->response->xml();
+ $this->lastShareData = $this->getResponseXml();
}
/**
@@ -75,10 +77,10 @@ public function publicSharedFileCannotDownload($path) {
$options = [];
$options['auth'] = [$token, ""];
- $request = $client->createRequest('GET', $fullUrl, $options);
+ $request = new Request('GET', $fullUrl);
try {
- $this->response = $client->send($request);
+ $this->response = $client->send($request, $options);
PHPUnit_Framework_Assert::fail('download must fail');
} catch (ClientException $e) {
// expected
@@ -182,14 +184,14 @@ private function publicUploadContent($filename, $password = '', $body = 'test',
$token = $this->getLastShareToken();
$options['auth'] = [$token, $password];
$options['stream'] = true;
- $options['body'] = $body;
+ $headers = [];
if ($autorename) {
- $options['headers']['OC-Autorename'] = 1;
+ $headers['OC-Autorename'] = 1;
}
$client = new Client();
- $this->response = $client->send($client->createRequest('PUT', $url, $options));
+ $this->response = $client->send(new Request('PUT', $url, $headers, $body), $options);
PHPUnit_Framework_Assert::assertEquals(201, $this->response->getStatusCode());
}
@@ -207,8 +209,8 @@ public function addingExpirationDate() {
$options['auth'] = [$this->currentUser, $this->regularUser];
}
$date = date('Y-m-d', strtotime("+3 days"));
- $options['body'] = ['expireDate' => $date];
- $this->response = $client->send($client->createRequest("PUT", $fullUrl, $options));
+ $body = ['expireDate' => $date];
+ $this->response = $client->send(new Request("PUT", $fullUrl, [], $body), $options);
PHPUnit_Framework_Assert::assertEquals(200, $this->response->getStatusCode());
}
@@ -227,17 +229,18 @@ public function updatingLastShare($body) {
$options['auth'] = [$this->currentUser, $this->regularUser];
}
+ $fd = '';
if ($body instanceof \Behat\Gherkin\Node\TableNode) {
$fd = $body->getRowsHash();
if (array_key_exists('expireDate', $fd)) {
$dateModification = $fd['expireDate'];
$fd['expireDate'] = date('Y-m-d', strtotime($dateModification));
}
- $options['body'] = $fd;
+ $options['form_params'] = $fd;
}
try {
- $this->response = $client->send($client->createRequest("PUT", $fullUrl, $options));
+ $this->response = $client->send(new Request("PUT", $fullUrl), $options);
} catch (\GuzzleHttp\Exception\ClientException $ex) {
$this->response = $ex->getResponse();
}
@@ -268,14 +271,14 @@ public function createShare($user,
$linkName,
$this->apiVersion,
$this->sharingApiVersion);
- $this->lastShareData = $this->response->xml();
+ $this->lastShareData = $this->getResponseXml();
} catch (\GuzzleHttp\Exception\ClientException $ex) {
$this->response = $ex->getResponse();
}
}
public function isFieldInResponse($field, $contentExpected) {
- $data = $this->response->xml()->data[0];
+ $data = $this->getResponseXml()->data[0];
if ((string)$field == 'expiration') {
$contentExpected = date('Y-m-d', strtotime($contentExpected)) . " 00:00:00";
}
@@ -368,7 +371,7 @@ public function checkSharedUserNotInResponse($user) {
}
public function isUserOrGroupInSharedData($userOrGroup, $permissions = null) {
- $data = $this->response->xml()->data[0];
+ $data = $this->getResponseXml()->data[0];
foreach ($data as $element) {
if ($element->share_with == $userOrGroup && ($permissions === null || $permissions == $element->permissions)) {
return True;
@@ -479,7 +482,7 @@ public function checkingLastShareIDIsNotIncluded() {
* @Then /^the response contains ([0-9]+) entries$/
*/
public function checkingTheResponseEntriesCount($count) {
- $actualCount = count($this->response->xml()->data[0]);
+ $actualCount = count($this->responseXml()->data[0]);
PHPUnit_Framework_Assert::assertEquals($count, $actualCount);
}
@@ -583,8 +586,8 @@ public function getShares($user, $path) {
$options['auth'] = [$user, $this->regularUser];
}
- $this->response = $client->send($client->createRequest("GET", $fullUrl, $options));
- return $this->response->xml()->data->element;
+ $this->response = $client->send(new Request("GET", $fullUrl), $options);
+ return $this->getResponseXml()->data->element;
}
/**
diff --git a/tests/integration/features/bootstrap/Trashbin.php b/tests/integration/features/bootstrap/Trashbin.php
index 7b336fc3ef78..20eaa5520fda 100644
--- a/tests/integration/features/bootstrap/Trashbin.php
+++ b/tests/integration/features/bootstrap/Trashbin.php
@@ -19,6 +19,8 @@
*
*/
+use GuzzleHttp\Client;
+
require __DIR__ . '/../../../../lib/composer/autoload.php';
/**
diff --git a/tests/integration/features/bootstrap/WebDav.php b/tests/integration/features/bootstrap/WebDav.php
index eb2cdb931521..3827d9a110a7 100644
--- a/tests/integration/features/bootstrap/WebDav.php
+++ b/tests/integration/features/bootstrap/WebDav.php
@@ -1,10 +1,11 @@
createRequest("GET", $fullUrl, $options);
- $request->addHeader('Range', $range);
+ $request = new Request("GET", $fullUrl, ['Range' => $range]);
- $this->response = $client->send($request);
+ $this->response = $client->send($request, $options);
}
/**
@@ -179,10 +179,9 @@ public function downloadPublicFileInsideAFolderWithRange($path, $range) {
$options = [];
$options['auth'] = [$token, ""];
- $request = $client->createRequest("GET", $fullUrl, $options);
- $request->addHeader('Range', $range);
+ $request = new Request("GET", $fullUrl, ['Range' => $range]);
- $this->response = $client->send($request);
+ $this->response = $client->send($request, $options);
}
/**
@@ -239,7 +238,20 @@ public function theFollowingHeadersShouldBeSet(\Behat\Gherkin\Node\TableNode $ta
$headerName = $header[0];
$expectedHeaderValue = $header[1];
$returnedHeader = $this->response->getHeader($headerName);
- if ($returnedHeader !== $expectedHeaderValue) {
+ if (is_array($returnedHeader)) {
+ if (empty($returnedHeader)) {
+ throw new \Exception(
+ sprintf(
+ "Missing expected header '%s'",
+ $headerName
+ )
+ );
+ }
+ $headerValue = $returnedHeader[0];
+ } else {
+ $headerValue = $returnedHeader;
+ }
+ if ($headerValue !== $expectedHeaderValue) {
throw new \Exception(
sprintf(
"Expected value '%s' for header '%s', got '%s'",
@@ -524,7 +536,7 @@ public function reportFolder($user, $path, $properties, $filterRules, $offset =
$body .= '
';
- $response = $client->request('REPORT', $this->makeSabrePath($user, $path), $body);
+ $response = $client->request('REPORT', $this->makeSabrePath($user, $path), $body, []);
$parsedResponse = $client->parseMultistatus($response['body']);
return $parsedResponse;
}
@@ -544,7 +556,7 @@ public function reportElementComments($user, $path, $properties) {
';
- $response = $client->request('REPORT', $this->makeSabrePathNotForFiles($path), $body);
+ $response = $client->request('REPORT', $this->makeSabrePathNotForFiles($path), $body, []);
$parsedResponse = $client->parseMultistatus($response['body']);
return $parsedResponse;
@@ -590,8 +602,9 @@ public function checkElementList($user, $expectedElements) {
* @param string $source
* @param string $destination
*/
- public function userUploadsAFileTo($user, $source, $destination) {
- $file = \GuzzleHttp\Stream\Stream::factory(fopen($source, 'r'));
+ public function userUploadsAFileTo($user, $source, $destination)
+ {
+ $file = fopen($source, 'r');
try {
$this->response = $this->makeDavRequest($user, "PUT", $destination, [], $file);
} catch (\GuzzleHttp\Exception\BadResponseException $e) {
@@ -759,9 +772,8 @@ public function userAddsAFileTo($user, $bytes, $destination) {
*/
public function userUploadsAFileWithContentTo($user, $content, $destination)
{
- $file = \GuzzleHttp\Stream\Stream::factory($content);
try {
- $this->response = $this->makeDavRequest($user, "PUT", $destination, [], $file);
+ $this->response = $this->makeDavRequest($user, "PUT", $destination, [], $content);
} catch (\GuzzleHttp\Exception\ServerException $e) {
// 4xx and 5xx responses cause an exception
$this->response = $e->getResponse();
@@ -778,14 +790,13 @@ public function userUploadsAFileWithContentTo($user, $content, $destination)
*/
public function userUploadsAFileWithChecksumAndContentTo($user, $checksum, $content, $destination)
{
- $file = \GuzzleHttp\Stream\Stream::factory($content);
try {
$this->response = $this->makeDavRequest(
$user,
"PUT",
$destination,
['OC-Checksum' => $checksum],
- $file
+ $content
);
} catch (\GuzzleHttp\Exception\BadResponseException $e) {
// 4xx and 5xx responses cause an exception
@@ -852,7 +863,6 @@ public function userUploadsChunkedFile($user, $num, $total, $data, $destination)
{
try {
$num -= 1;
- $data = \GuzzleHttp\Stream\Stream::factory($data);
$file = $destination . '-chunking-42-' . $total . '-' . $num;
$this->makeDavRequest($user, 'PUT', $file, ['OC-Chunked' => '1'], $data, "uploads");
} catch (\GuzzleHttp\Exception\RequestException $ex) {
diff --git a/tests/integration/work/filespecificSize.txt b/tests/integration/work/filespecificSize.txt
new file mode 100644
index 000000000000..5d7412c0cafa
Binary files /dev/null and b/tests/integration/work/filespecificSize.txt differ
diff --git a/tests/lib/Http/Client/ResponseTest.php b/tests/lib/Http/Client/ResponseTest.php
index 685f34a0bafd..fc0079319fb9 100644
--- a/tests/lib/Http/Client/ResponseTest.php
+++ b/tests/lib/Http/Client/ResponseTest.php
@@ -9,8 +9,8 @@
namespace Test\Http\Client;
use Guzzle\Stream\Stream;
-use GuzzleHttp\Message\Response as GuzzleResponse;
use OC\Http\Client\Response;
+use Psr\Http\Message\ResponseInterface;
/**
* Class ResponseTest
@@ -23,16 +23,22 @@ class ResponseTest extends \Test\TestCase {
public function setUp() {
parent::setUp();
- $this->guzzleResponse = new GuzzleResponse(1337);
+ $this->guzzleResponse = $this->createMock(ResponseInterface::class);
$this->response = new Response($this->guzzleResponse);
}
public function testGetStatusCode() {
+ $this->guzzleResponse->expects($this->once())
+ ->method('getStatusCode')
+ ->willReturn(1337);
$this->assertEquals(1337, $this->response->getStatusCode());
}
public function testGetHeader() {
- $this->guzzleResponse->setHeader('bar', 'foo');
+ $this->guzzleResponse->expects($this->once())
+ ->method('getHeader')
+ ->with('bar')
+ ->willReturn('foo');
$this->assertEquals('foo', $this->response->getHeader('bar'));
}
}