From 8c39467dd6407f603870cb8b84e329771f3f232a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Germain=20Carr=C3=A9?= Date: Sat, 6 Jul 2019 17:10:27 +0200 Subject: [PATCH 1/2] Sending authentication headers on requestCredentials MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Germain Carré --- src/Api.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Api.php b/src/Api.php index 4da9d91..77b189e 100644 --- a/src/Api.php +++ b/src/Api.php @@ -205,7 +205,7 @@ class Api 'POST', '/auth/credential', $parameters, - false + true ) ); From 73ffcf672e2f03628e97745c22b4764795c8d441 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Germain=20Carr=C3=A9?= Date: Mon, 8 Jul 2019 23:14:41 +0200 Subject: [PATCH 2/2] Adding unit test testMissingOvhApplicationHeaderOnRequestCredentials MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Germain Carré --- tests/ApiTest.php | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tests/ApiTest.php b/tests/ApiTest.php index e9790b8..970fb6d 100644 --- a/tests/ApiTest.php +++ b/tests/ApiTest.php @@ -492,4 +492,32 @@ class ApiTest extends \PHPUnit_Framework_TestCase $api->get('/me/api/credential'); } + /** + * Test missing header X-OVH-Application on requestCredentials + */ + public function testMissingOvhApplicationHeaderOnRequestCredentials() + { + $handlerStack = $this->client->getConfig('handler'); + $handlerStack->push(Middleware::mapRequest(function (Request $request) { + if($request->getUri()->getPath() == "/1.0/auth/time") { + return $request; + } + + $ovhApplication = $request->getHeader('X-OVH-Application'); + $this->assertNotNull($ovhApplication); + $this->assertEquals($ovhApplication, array($this->application_key)); + + $request = $request->withUri($request->getUri() + ->withHost('httpbin.org') + ->withPath('/') + ->withQuery('')); + return $request; + })); + $handlerStack->push(Middleware::mapResponse(function (Response $response) { + return $response->withStatus(200); + })); + + $api = new Api($this->application_key, $this->application_secret, $this->endpoint, $this->consumer_key, $this->client); + $api->requestCredentials([]); + } }