Skip to content

Commit

Permalink
update dependency on league/oauth2-client@1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenmaguire committed Aug 20, 2015
1 parent dafe032 commit 04d30e7
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 2 deletions.
81 changes: 81 additions & 0 deletions CHANGELOG.md
@@ -0,0 +1,81 @@
# Changelog
All Notable changes to `oauth2-linkedin` will be documented in this file

## 0.4.0 - 2015-08-20

### Added
- Upgrade to support version 1.0 release of core client

### Deprecated
- Nothing

### Fixed
- Nothing

### Removed
- Nothing

### Security
- Nothing

## 0.3.0 - 2015-06-11

### Added
- Array defined scope definition

### Deprecated
- Nothing

### Fixed
- Using abstract provider scope separator to format scopes

## 0.2.0 - 2015-05-26

### Added
- Depends on "league/oauth2-client": "0.10.*@dev"

### Deprecated
- Default scopes in provider; now requires explicit declaration by consuming applications.

### Fixed
- Nothing

### Removed
- Nothing

### Security
- Nothing

## 0.1.1 - 2015-03-23

### Added
- Nothing

### Deprecated
- Nothing

### Fixed
- Namespace issue

### Removed
- Nothing

### Security
- Nothing

## 0.1.0 - 2015-03-21

### Added
- Initial release!

### Deprecated
- Nothing

### Fixed
- Nothing

### Removed
- Nothing

### Security
- Nothing
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -19,7 +19,7 @@
],
"require": {
"php": ">=5.5.0",
"league/oauth2-client": "1.0.0-beta2"
"league/oauth2-client": "~1.0"
},
"require-dev": {
"phpunit/phpunit": "~4.0",
Expand Down
9 changes: 8 additions & 1 deletion src/Provider/LinkedIn.php
Expand Up @@ -2,6 +2,7 @@

namespace League\OAuth2\Client\Provider;

use League\OAuth2\Client\Provider\Exception\IdentityProviderException;
use League\OAuth2\Client\Token\AccessToken;
use League\OAuth2\Client\Tool\BearerAuthorizationTrait;
use Psr\Http\Message\ResponseInterface;
Expand Down Expand Up @@ -94,7 +95,13 @@ protected function getDefaultScopes()
*/
protected function checkResponse(ResponseInterface $response, $data)
{

if (isset($data['error'])) {
throw new IdentityProviderException(
$data['error_description'] ?: $response->getReasonPhrase(),
$response->getStatusCode(),
$response
);
}
}

/**
Expand Down
20 changes: 20 additions & 0 deletions test/src/Provider/LinkedInTest.php
Expand Up @@ -128,4 +128,24 @@ public function testUserData()
$this->assertEquals($description, $user->getDescription());
$this->assertEquals($description, $user->toArray()['headline']);
}

/**
* @expectedException League\OAuth2\Client\Provider\Exception\IdentityProviderException
**/
public function testExceptionThrownWhenErrorObjectReceived()
{
$message = uniqid();
$status = rand(400,600);
$postResponse = m::mock('Psr\Http\Message\ResponseInterface');
$postResponse->shouldReceive('getBody')->andReturn('{"error_description": "'.$message.'","error": "invalid_request"}');
$postResponse->shouldReceive('getHeader')->andReturn(['content-type' => 'json']);
$postResponse->shouldReceive('getStatusCode')->andReturn($status);

$client = m::mock('GuzzleHttp\ClientInterface');
$client->shouldReceive('send')
->times(1)
->andReturn($postResponse);
$this->provider->setHttpClient($client);
$token = $this->provider->getAccessToken('authorization_code', ['code' => 'mock_authorization_code']);
}
}

0 comments on commit 04d30e7

Please sign in to comment.