Code coverage improvements in grant classes

This commit is contained in:
Alex Bilbie 2014-11-23 23:32:50 +00:00
parent 6157bd77ca
commit e1c0ff2685
4 changed files with 20 additions and 40 deletions

View File

@ -166,20 +166,15 @@ class AuthCodeGrant extends AbstractGrant
public function completeFlow() public function completeFlow()
{ {
// Get the required params // Get the required params
$clientId = $this->server->getRequest()->request->get('client_id', null); $clientId = $this->server->getRequest()->request->get('client_id', $this->server->getRequest()->getUser());
if (is_null($clientId)) { if (is_null($clientId)) {
$clientId = $this->server->getRequest()->getUser(); throw new Exception\InvalidRequestException('client_id');
if (is_null($clientId)) {
throw new Exception\InvalidRequestException('client_id');
}
} }
$clientSecret = $this->server->getRequest()->request->get('client_secret', null); $clientSecret = $this->server->getRequest()->request->get('client_secret',
$this->server->getRequest()->getPassword());
if (is_null($clientSecret)) { if (is_null($clientSecret)) {
$clientSecret = $this->server->getRequest()->getPassword(); throw new Exception\InvalidRequestException('client_secret');
if (is_null($clientSecret)) {
throw new Exception\InvalidRequestException('client_secret');
}
} }
$redirectUri = $this->server->getRequest()->request->get('redirect_uri', null); $redirectUri = $this->server->getRequest()->request->get('redirect_uri', null);

View File

@ -55,20 +55,15 @@ class ClientCredentialsGrant extends AbstractGrant
public function completeFlow() public function completeFlow()
{ {
// Get the required params // Get the required params
$clientId = $this->server->getRequest()->request->get('client_id', null); $clientId = $this->server->getRequest()->request->get('client_id', $this->server->getRequest()->getUser());
if (is_null($clientId)) { if (is_null($clientId)) {
$clientId = $this->server->getRequest()->getUser(); throw new Exception\InvalidRequestException('client_id');
if (is_null($clientId)) {
throw new Exception\InvalidRequestException('client_id');
}
} }
$clientSecret = $this->server->getRequest()->request->get('client_secret', null); $clientSecret = $this->server->getRequest()->request->get('client_secret',
$this->server->getRequest()->getPassword());
if (is_null($clientSecret)) { if (is_null($clientSecret)) {
$clientSecret = $this->server->getRequest()->getPassword(); throw new Exception\InvalidRequestException('client_secret');
if (is_null($clientSecret)) {
throw new Exception\InvalidRequestException('client_secret');
}
} }
// Validate client ID and client secret // Validate client ID and client secret

View File

@ -80,20 +80,15 @@ class PasswordGrant extends AbstractGrant
public function completeFlow() public function completeFlow()
{ {
// Get the required params // Get the required params
$clientId = $this->server->getRequest()->request->get('client_id', null); $clientId = $this->server->getRequest()->request->get('client_id', $this->server->getRequest()->getUser());
if (is_null($clientId)) { if (is_null($clientId)) {
$clientId = $this->server->getRequest()->getUser(); throw new Exception\InvalidRequestException('client_id');
if (is_null($clientId)) {
throw new Exception\InvalidRequestException('client_id');
}
} }
$clientSecret = $this->server->getRequest()->request->get('client_secret', null); $clientSecret = $this->server->getRequest()->request->get('client_secret',
$this->server->getRequest()->getPassword());
if (is_null($clientSecret)) { if (is_null($clientSecret)) {
$clientSecret = $this->server->getRequest()->getPassword(); throw new Exception\InvalidRequestException('client_secret');
if (is_null($clientSecret)) {
throw new Exception\InvalidRequestException('client_secret');
}
} }
// Validate client ID and client secret // Validate client ID and client secret

View File

@ -58,20 +58,15 @@ class RefreshTokenGrant extends AbstractGrant
*/ */
public function completeFlow() public function completeFlow()
{ {
$clientId = $this->server->getRequest()->request->get('client_id', null); $clientId = $this->server->getRequest()->request->get('client_id', $this->server->getRequest()->getUser());
if (is_null($clientId)) { if (is_null($clientId)) {
$clientId = $this->server->getRequest()->getUser(); throw new Exception\InvalidRequestException('client_id');
if (is_null($clientId)) {
throw new Exception\InvalidRequestException('client_id');
}
} }
$clientSecret = $this->server->getRequest()->request->get('client_secret', null); $clientSecret = $this->server->getRequest()->request->get('client_secret',
$this->server->getRequest()->getPassword());
if (is_null($clientSecret)) { if (is_null($clientSecret)) {
$clientSecret = $this->server->getRequest()->getPassword(); throw new Exception\InvalidRequestException('client_secret');
if (is_null($clientSecret)) {
throw new Exception\InvalidRequestException('client_secret');
}
} }
// Validate client ID and client secret // Validate client ID and client secret