Skip to content

Commit

Permalink
Merge pull request #94 from carsso/master
Browse files Browse the repository at this point in the history
Sending authentication headers on requestCredentials
  • Loading branch information
rbeuque74 authored Nov 16, 2019
2 parents 45c9b80 + 73ffcf6 commit c473b3d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ public function requestCredentials(
'POST',
'/auth/credential',
$parameters,
false
true
)
);

Expand Down
28 changes: 28 additions & 0 deletions tests/ApiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -492,4 +492,32 @@ public function testProvidedHttpsEndPoint()
$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([]);
}
}

0 comments on commit c473b3d

Please sign in to comment.