1
0
mirror of https://github.com/ovh/php-ovh.git synced 2023-11-05 03:20:26 +01:00

Merge pull request #94 from carsso/master

Sending authentication headers on requestCredentials
This commit is contained in:
Romain Beuque 2019-11-16 18:12:55 +01:00 committed by GitHub
commit c473b3d67e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 1 deletions

View File

@ -205,7 +205,7 @@ class Api
'POST', 'POST',
'/auth/credential', '/auth/credential',
$parameters, $parameters,
false true
) )
); );

View File

@ -492,4 +492,32 @@ class ApiTest extends \PHPUnit_Framework_TestCase
$api->get('/me/api/credential'); $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([]);
}
} }