Skip to content

Commit 24f9651

Browse files
authored
Merge pull request nextcloud#8259 from nextcloud/guzzle6
update guzzlehttp/guzzle to 6.3.0
2 parents 236086c + a815185 commit 24f9651

26 files changed

+412
-425
lines changed

3rdparty

Submodule 3rdparty updated 95 files

build/integration/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"require-dev": {
33
"phpunit/phpunit": "~4.6",
44
"behat/behat": "^3.0",
5-
"guzzlehttp/guzzle": "~5.0",
5+
"guzzlehttp/guzzle": "6.3.0",
66
"jarnaiz/behat-junit-formatter": "^1.3",
77
"sabre/dav": "3.2"
88
}

build/integration/features/bootstrap/Auth.php

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -59,18 +59,20 @@ private function sendRequest($url, $method, $authHeader = null, $useCookies = fa
5959
$fullUrl = substr($this->baseUrl, 0, -5) . $url;
6060
try {
6161
if ($useCookies) {
62-
$request = $this->client->createRequest($method, $fullUrl, [
62+
$options = [
6363
'cookies' => $this->cookieJar,
64-
]);
64+
];
6565
} else {
66-
$request = $this->client->createRequest($method, $fullUrl);
66+
$options = [];
6767
}
6868
if ($authHeader) {
69-
$request->setHeader('Authorization', $authHeader);
69+
$options['headers'] = [
70+
'Authorization' => $authHeader
71+
];
7072
}
71-
$request->setHeader('OCS_APIREQUEST', 'true');
72-
$request->setHeader('requesttoken', $this->requestToken);
73-
$this->response = $this->client->send($request);
73+
$options['headers']['OCS_APIREQUEST'] = 'true';
74+
$options['headers']['requesttoken'] = $this->requestToken;
75+
$this->response = $this->client->request($method, $fullUrl, $options);
7476
} catch (ClientException $ex) {
7577
$this->response = $ex->getResponse();
7678
} catch (ServerException $ex) {
@@ -90,7 +92,7 @@ public function theCsrfTokenIsExtractedFromThePreviousResponse() {
9092
* @return object
9193
*/
9294
private function createClientToken($loginViaWeb = true) {
93-
if($loginViaWeb) {
95+
if ($loginViaWeb) {
9496
$this->loggingInUsingWebAs('user0');
9597
}
9698

@@ -101,15 +103,15 @@ private function createClientToken($loginViaWeb = true) {
101103
'user0',
102104
$loginViaWeb ? '123456' : $this->restrictedClientToken,
103105
],
104-
'body' => [
106+
'form_params' => [
105107
'requesttoken' => $this->requestToken,
106108
'name' => md5(microtime()),
107109
],
108110
'cookies' => $this->cookieJar,
109111
];
110112

111113
try {
112-
$this->response = $client->send($client->createRequest('POST', $fullUrl, $options));
114+
$this->response = $client->request('POST', $fullUrl, $options);
113115
} catch (\GuzzleHttp\Exception\ServerException $e) {
114116
$this->response = $e->getResponse();
115117
}
@@ -119,7 +121,7 @@ private function createClientToken($loginViaWeb = true) {
119121
/**
120122
* @Given a new restricted client token is added
121123
*/
122-
public function aNewRestrictedClientTokenIsAdded() {
124+
public function aNewRestrictedClientTokenIsAdded() {
123125
$tokenObj = $this->createClientToken();
124126
$newCreatedTokenId = $tokenObj->deviceToken->id;
125127
$fullUrl = substr($this->baseUrl, 0, -5) . '/index.php/settings/personal/authtokens/' . $newCreatedTokenId;
@@ -136,7 +138,7 @@ public function aNewRestrictedClientTokenIsAdded() {
136138
],
137139
'cookies' => $this->cookieJar,
138140
];
139-
$this->response = $client->send($client->createRequest('PUT', $fullUrl, $options));
141+
$this->response = $client->request('PUT', $fullUrl, $options);
140142
$this->restrictedClientToken = $tokenObj->token;
141143
}
142144

@@ -232,13 +234,13 @@ public function aNewBrowserSessionIsStarted($remember = false) {
232234
$client = new Client();
233235
$response = $client->post(
234236
$loginUrl, [
235-
'body' => [
236-
'user' => 'user0',
237-
'password' => '123456',
238-
'remember_login' => $remember ? '1' : '0',
239-
'requesttoken' => $this->requestToken,
240-
],
241-
'cookies' => $this->cookieJar,
237+
'form_params' => [
238+
'user' => 'user0',
239+
'password' => '123456',
240+
'remember_login' => $remember ? '1' : '0',
241+
'requesttoken' => $this->requestToken,
242+
],
243+
'cookies' => $this->cookieJar,
242244
]
243245
);
244246
$this->extracRequestTokenFromResponse($response);

build/integration/features/bootstrap/BasicStructure.php

Lines changed: 50 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
use GuzzleHttp\Client;
3333
use GuzzleHttp\Cookie\CookieJar;
3434
use GuzzleHttp\Exception\ClientException;
35-
use GuzzleHttp\Message\ResponseInterface;
35+
use Psr\Http\Message\ResponseInterface;
3636

3737
require __DIR__ . '/../../vendor/autoload.php';
3838

@@ -97,7 +97,7 @@ public function __construct($baseUrl, $admin, $regular_user_password) {
9797
* @param string $version
9898
*/
9999
public function usingApiVersion($version) {
100-
$this->apiVersion = (int) $version;
100+
$this->apiVersion = (int)$version;
101101
}
102102

103103
/**
@@ -115,7 +115,7 @@ public function asAn($user) {
115115
*/
116116
public function usingServer($server) {
117117
$previousServer = $this->currentServer;
118-
if ($server === 'LOCAL'){
118+
if ($server === 'LOCAL') {
119119
$this->baseUrl = $this->localBaseUrl;
120120
$this->currentServer = 'LOCAL';
121121
return $previousServer;
@@ -138,20 +138,24 @@ public function sendingTo($verb, $url) {
138138
/**
139139
* Parses the xml answer to get ocs response which doesn't match with
140140
* http one in v1 of the api.
141+
*
141142
* @param ResponseInterface $response
142143
* @return string
143144
*/
144145
public function getOCSResponse($response) {
145-
return $response->xml()->meta[0]->statuscode;
146+
return simplexml_load_string($response->getBody())->meta[0]->statuscode;
146147
}
147148

148149
/**
149150
* This function is needed to use a vertical fashion in the gherkin tables.
151+
*
150152
* @param array $arrayOfArrays
151153
* @return array
152154
*/
153-
public function simplifyArray($arrayOfArrays){
154-
$a = array_map(function($subArray) { return $subArray[0]; }, $arrayOfArrays);
155+
public function simplifyArray($arrayOfArrays) {
156+
$a = array_map(function ($subArray) {
157+
return $subArray[0];
158+
}, $arrayOfArrays);
155159
return $a;
156160
}
157161

@@ -175,18 +179,18 @@ public function sendingToWith($verb, $url, $body) {
175179
];
176180
if ($body instanceof \Behat\Gherkin\Node\TableNode) {
177181
$fd = $body->getRowsHash();
178-
$options['body'] = $fd;
182+
$options['form_params'] = $fd;
179183
}
180184

181185
// TODO: Fix this hack!
182186
if ($verb === 'PUT' && $body === null) {
183-
$options['body'] = [
187+
$options['form_params'] = [
184188
'foo' => 'bar',
185189
];
186190
}
187191

188192
try {
189-
$this->response = $client->send($client->createRequest($verb, $fullUrl, $options));
193+
$this->response = $client->request($verb, $fullUrl, $options);
190194
} catch (ClientException $ex) {
191195
$this->response = $ex->getResponse();
192196
}
@@ -212,20 +216,20 @@ public function sendingToWithDirectUrl($verb, $url, $body) {
212216
}
213217
if ($body instanceof \Behat\Gherkin\Node\TableNode) {
214218
$fd = $body->getRowsHash();
215-
$options['body'] = $fd;
219+
$options['form_params'] = $fd;
216220
}
217221

218222
try {
219-
$this->response = $client->send($client->createRequest($verb, $fullUrl, $options));
223+
$this->response = $client->request($verb, $fullUrl, $options);
220224
} catch (ClientException $ex) {
221225
$this->response = $ex->getResponse();
222226
}
223227
}
224228

225-
public function isExpectedUrl($possibleUrl, $finalPart){
229+
public function isExpectedUrl($possibleUrl, $finalPart) {
226230
$baseUrlChopped = substr($this->baseUrl, 0, -4);
227231
$endCharacter = strlen($baseUrlChopped) + strlen($finalPart);
228-
return (substr($possibleUrl,0,$endCharacter) == "$baseUrlChopped" . "$finalPart");
232+
return (substr($possibleUrl, 0, $endCharacter) == "$baseUrlChopped" . "$finalPart");
229233
}
230234

231235
/**
@@ -249,7 +253,7 @@ public function theHTTPStatusCodeShouldBe($statusCode) {
249253
* @param string $contentType
250254
*/
251255
public function theContentTypeShouldbe($contentType) {
252-
PHPUnit_Framework_Assert::assertEquals($contentType, $this->response->getHeader('Content-Type'));
256+
PHPUnit_Framework_Assert::assertEquals($contentType, $this->response->getHeader('Content-Type')[0]);
253257
}
254258

255259
/**
@@ -281,7 +285,7 @@ public function loggingInUsingWebAs($user) {
281285
$response = $client->post(
282286
$loginUrl,
283287
[
284-
'body' => [
288+
'form_params' => [
285289
'user' => $user,
286290
'password' => $password,
287291
'requesttoken' => $this->requestToken,
@@ -301,16 +305,17 @@ public function sendingAToWithRequesttoken($method, $url) {
301305
$baseUrl = substr($this->baseUrl, 0, -5);
302306

303307
$client = new Client();
304-
$request = $client->createRequest(
305-
$method,
306-
$baseUrl . $url,
307-
[
308-
'cookies' => $this->cookieJar,
309-
]
310-
);
311-
$request->addHeader('requesttoken', $this->requestToken);
312308
try {
313-
$this->response = $client->send($request);
309+
$this->response = $client->request(
310+
$method,
311+
$baseUrl . $url,
312+
[
313+
'cookies' => $this->cookieJar,
314+
'headers' => [
315+
'requesttoken' => $this->requestToken
316+
]
317+
]
318+
);
314319
} catch (ClientException $e) {
315320
$this->response = $e->getResponse();
316321
}
@@ -325,21 +330,20 @@ public function sendingAToWithoutRequesttoken($method, $url) {
325330
$baseUrl = substr($this->baseUrl, 0, -5);
326331

327332
$client = new Client();
328-
$request = $client->createRequest(
329-
$method,
330-
$baseUrl . $url,
331-
[
332-
'cookies' => $this->cookieJar,
333-
]
334-
);
335333
try {
336-
$this->response = $client->send($request);
334+
$this->response = $client->request(
335+
$method,
336+
$baseUrl . $url,
337+
[
338+
'cookies' => $this->cookieJar
339+
]
340+
);
337341
} catch (ClientException $e) {
338342
$this->response = $e->getResponse();
339343
}
340344
}
341345

342-
public static function removeFile($path, $filename){
346+
public static function removeFile($path, $filename) {
343347
if (file_exists("$path" . "$filename")) {
344348
unlink("$path" . "$filename");
345349
}
@@ -358,12 +362,12 @@ public function modifyTextOfFile($user, $filename, $text) {
358362

359363
public function createFileSpecificSize($name, $size) {
360364
$file = fopen("work/" . "$name", 'w');
361-
fseek($file, $size - 1 ,SEEK_CUR);
362-
fwrite($file,'a'); // write a dummy char at SIZE position
365+
fseek($file, $size - 1, SEEK_CUR);
366+
fwrite($file, 'a'); // write a dummy char at SIZE position
363367
fclose($file);
364368
}
365369

366-
public function createFileWithText($name, $text){
370+
public function createFileWithText($name, $text) {
367371
$file = fopen("work/" . "$name", 'w');
368372
fwrite($file, $text);
369373
fclose($file);
@@ -398,8 +402,8 @@ public function sleepForSeconds($seconds) {
398402
/**
399403
* @BeforeSuite
400404
*/
401-
public static function addFilesToSkeleton(){
402-
for ($i=0; $i<5; $i++){
405+
public static function addFilesToSkeleton() {
406+
for ($i = 0; $i < 5; $i++) {
403407
file_put_contents("../../core/skeleton/" . "textfile" . "$i" . ".txt", "Nextcloud test text file\n");
404408
}
405409
if (!file_exists("../../core/skeleton/FOLDER")) {
@@ -418,8 +422,8 @@ public static function addFilesToSkeleton(){
418422
/**
419423
* @AfterSuite
420424
*/
421-
public static function removeFilesFromSkeleton(){
422-
for ($i=0; $i<5; $i++){
425+
public static function removeFilesFromSkeleton() {
426+
for ($i = 0; $i < 5; $i++) {
423427
self::removeFile("../../core/skeleton/", "textfile" . "$i" . ".txt");
424428
}
425429
if (is_dir("../../core/skeleton/FOLDER")) {
@@ -438,24 +442,24 @@ public static function removeFilesFromSkeleton(){
438442
/**
439443
* @BeforeScenario @local_storage
440444
*/
441-
public static function removeFilesFromLocalStorageBefore(){
445+
public static function removeFilesFromLocalStorageBefore() {
442446
$dir = "./work/local_storage/";
443447
$di = new RecursiveDirectoryIterator($dir, FilesystemIterator::SKIP_DOTS);
444448
$ri = new RecursiveIteratorIterator($di, RecursiveIteratorIterator::CHILD_FIRST);
445-
foreach ( $ri as $file ) {
446-
$file->isDir() ? rmdir($file) : unlink($file);
449+
foreach ($ri as $file) {
450+
$file->isDir() ? rmdir($file) : unlink($file);
447451
}
448452
}
449453

450454
/**
451455
* @AfterScenario @local_storage
452456
*/
453-
public static function removeFilesFromLocalStorageAfter(){
457+
public static function removeFilesFromLocalStorageAfter() {
454458
$dir = "./work/local_storage/";
455459
$di = new RecursiveDirectoryIterator($dir, FilesystemIterator::SKIP_DOTS);
456460
$ri = new RecursiveIteratorIterator($di, RecursiveIteratorIterator::CHILD_FIRST);
457-
foreach ( $ri as $file ) {
458-
$file->isDir() ? rmdir($file) : unlink($file);
461+
foreach ($ri as $file) {
462+
$file->isDir() ? rmdir($file) : unlink($file);
459463
}
460464
}
461465
}

0 commit comments

Comments
 (0)