From c7efbfea6050af755921077e7be878e65706f6cc Mon Sep 17 00:00:00 2001 From: Witold Wasiczko Date: Tue, 18 Aug 2015 13:08:08 +0200 Subject: [PATCH 1/6] Update README.md Fix composer.json format and small improvements --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index e657b4b..644f51b 100644 --- a/README.md +++ b/README.md @@ -21,14 +21,14 @@ For others requirements please see the [composer.json](composer.json) file. "type": "vcs", "url": "git@github.com:rstgroup/behat-oauth2-context.git" } - } + ] ``` 2. Run `composer update rstgroup/behat-oauth2-context` to ensure the library is installed. ## Configuration -Copy behat.yml.dist file as behat.yml to your home project directory or copy contents from this file to your yml file with Behat tests. +Copy `behat.yml.dist` file as `behat.yml` to your home project directory or copy contents from this file to your yml file with Behat tests. You must replace sample content to right option: ```php paths: @@ -41,8 +41,8 @@ for example: - %paths.base%/vendor/rstgroup/behat-oauth2-context/features/ ``` And next you must replace parameters option: -- token_url - your url to token -- oauth2 - your data for OAuth2 authorization +- `token_url` - your url to token +- `oauth2` - your data for OAuth2 authorization ### Recommended and optional parameters From 56e600d94ef9346e03c470c2e12f09178e182ed2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Kopacz?= Date: Thu, 1 Oct 2015 09:06:36 +0200 Subject: [PATCH 2/6] add namespace separator at the end of path --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 115af5b..06600fb 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ "guzzlehttp/guzzle": "^5.1" }, "autoload":{ - "psr-4" : {"RstGroup\\Behat\\OAuth2\\Context": "src/"} + "psr-4" : {"RstGroup\\Behat\\OAuth2\\Context\\": "src/"} } } From 7c220f0d81559efcdc5688d7b3f721d63a5ee335 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Kopacz?= Date: Thu, 1 Oct 2015 09:27:54 +0200 Subject: [PATCH 3/6] add guzzle parameters --- src/OAuth2Context.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/OAuth2Context.php b/src/OAuth2Context.php index 295af59..7c1be72 100644 --- a/src/OAuth2Context.php +++ b/src/OAuth2Context.php @@ -16,6 +16,8 @@ */ class OAuth2Context implements SnippetAcceptingContext { + const GUZZLE_PARAMETERS = 'guzzle_parameters'; + protected $headers = []; /** @@ -56,7 +58,9 @@ public function __construct(array $parameters) { // Initialize your context here $this->parameters = $parameters; - $this->client = new GuzzleHttpClient(); + + $guzzleParameters = $this->getGuzzleParameters(); + $this->client = new GuzzleHttpClient($guzzleParameters); $timezone = ini_get('date.timezone'); @@ -308,6 +312,11 @@ protected function setHeaders(array $headers) } } + protected function getGuzzleParameters() + { + return isset($this->parameters[self::GUZZLE_PARAMETERS]) && is_array($this->parameters[self::GUZZLE_PARAMETERS]) ? $this->parameters[self::GUZZLE_PARAMETERS] : []; + } + /** * Prints beautified debug string. * From 143558b9237bec7b323be9a699898537f838cabf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Kopacz?= Date: Thu, 1 Oct 2015 09:39:31 +0200 Subject: [PATCH 4/6] add request to debug --- src/OAuth2Context.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/OAuth2Context.php b/src/OAuth2Context.php index 7c1be72..3538570 100644 --- a/src/OAuth2Context.php +++ b/src/OAuth2Context.php @@ -226,7 +226,7 @@ public function theResponseHasAPropertyAndItIsEquals($propertyName, $propertyVal */ public function echoLastResponse() { - $this->printDebug(sprintf("Request:\n %s Response:\n %s", $this->request, $this->response)); + $this->printDebug(sprintf("Request:\n %s \n\n Response:\n %s", $this->request, $this->response)); } /** @@ -254,7 +254,8 @@ public function theResponseHasTheOAuth2Format() */ protected function getPostResponseFromUrl($url, $body) { - return $this->client->post($url, ['body' => $body, 'verify' => false, 'exceptions' => false]); + $this->request = $this->client->createRequest('POST', $url, ['body' => $body, 'verify' => false, 'exceptions' => false]); + return $this->client->send($this->request); } /** From 3875817a8790b8784c59d733ed854ce15c58edf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Kopacz?= Date: Thu, 1 Oct 2015 09:44:31 +0200 Subject: [PATCH 5/6] document guzzle parameters --- behat.yml.dist | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/behat.yml.dist b/behat.yml.dist index 8291d5c..dc2440e 100644 --- a/behat.yml.dist +++ b/behat.yml.dist @@ -4,7 +4,7 @@ default: paths: - %paths.base%/features contexts: - - RstGroup\Behat\OAuth2\Context: + - RstGroup\Behat\OAuth2\Context\OAuth2Context: parameters: token_url: some_url oauth2: @@ -18,3 +18,4 @@ default: refresh_token : true error_description : true scope : true + guzzle_parameters: #configuration for guzzle http client From fddf3436da0aa886dd78438f9eabc3fbc66cf90a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Kopacz?= Date: Thu, 1 Oct 2015 10:26:24 +0200 Subject: [PATCH 6/6] add changlog notes --- CHANGELOG.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 112b28b..dd646a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,13 @@ This project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased][unreleased] +## [1.1.0] - 2015-10-01 +### Added +- Guzzle http client is configurable +### Fixed +- psr-4 namespace end with a namespace separator in composer.json + ## [1.0.0] - 2015-08-13 -### Changed +### Added - Password grant type feature and implemented steps - Refresh token grant type feature and implemented steps \ No newline at end of file