use guzzle globally through a helper#32505
Conversation
| public static function sendRequest( | ||
| $url, $method='GET', $user=null, $password=null, $headers=null, $body = null, $config = null, $cookies = null | ||
| ) { | ||
| $client = new Client(); |
There was a problem hiding this comment.
Can we inject parameters from behat.yml into the helper?
There was a problem hiding this comment.
Maybe, but what for?
The only thing that I can see that would make sense is the base part of the URL
There was a problem hiding this comment.
Yes exactly - how do we define the server url currently?
There was a problem hiding this comment.
Environment variable TEST_SERVER_URL and/or TEST_SERVER_FED_URL is set before running run.sh Then that is used to pass base_url in to Behat, and also BasicStructure constructor checks the 2 environment variables so it can set localBaseUrl and remoteBaseUrl to know where to find the local and remote (federated) server(s).
There was a problem hiding this comment.
from wherever sendRequest() is called is responsible to create the complete URL
|
Wondering if we should add a unit test to ensure the clientHelper works as designed? |
Codecov Report
@@ Coverage Diff @@
## master #32505 +/- ##
=========================================
Coverage 64.12% 64.12%
Complexity 18643 18643
=========================================
Files 1176 1176
Lines 70189 70189
Branches 1270 1270
=========================================
Hits 45007 45007
Misses 24812 24812
Partials 370 370
Continue to review full report at Codecov.
|
4d7d01c to
be88feb
Compare
| $responseHeaders = $response->getHeaders(); | ||
| $tagUrl = $responseHeaders['Content-Location'][0]; | ||
| $lastTagId = \substr($tagUrl, \strrpos($tagUrl, '/') + 1); | ||
| return ['lastTagId' => $lastTagId, 'HTTPResponse' => $response]; |
There was a problem hiding this comment.
moved to Tags.php, so we always just return the response the whole way up till the place that cares
|
|
||
| $client = new Client(); | ||
| $this->response = $client->get($url, $options); | ||
| private function checkDownload( |
There was a problem hiding this comment.
had to change that function to get the nice username & password
|
@phil-davis @patrickjahns please review |
| 'user' => $user, | ||
| 'password' => $this->getPasswordForUser($user), | ||
| ]); | ||
| $headers = ['Content-Type' => 'application/json']; |
There was a problem hiding this comment.
I guess the previous $client->post() with that json array of values had been automagically setting this header.
phil-davis
left a comment
There was a problem hiding this comment.
This looks like a great thing. It should help with the Guzzle6 PR, reducing the diff list a lot.
|
I pushed a commit with code style changes to make our "informal" I couldn't see any issues with the actual code refactoring - good work. |
| $body = | ||
| '<c:mkcalendar xmlns:c="urn:ietf:params:xml:ns:caldav" ' . | ||
| $body | ||
| = '<c:mkcalendar xmlns:c="urn:ietf:params:xml:ns:caldav" ' . |
There was a problem hiding this comment.
I think the previous code looks fine, but phpcs has a different idea.
e74c4ab to
77279b0
Compare
|
squashed and pushed again. |
|
backport in #32528 |

Description
Related Issue
owncloud/QA#586
Motivation and Context
have only one place where guzzle can be configured globally
How Has This Been Tested?
🤖
Types of changes
Checklist:
Open tasks: