-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #83 from arodu/feature/openid-connect-linkedin
Feature/openid connect linkedin
- Loading branch information
Showing
3 changed files
with
403 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
tests/TestCase/Social/Mapper/LinkedInOpenIDConnectTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
/** | ||
* Copyright 2010 - 2019, Cake Development Corporation (https://www.cakedc.com) | ||
* | ||
* Licensed under The MIT License | ||
* Redistributions of files must retain the above copyright notice. | ||
* | ||
* @copyright Copyright 2010 - 2019, Cake Development Corporation (https://www.cakedc.com) | ||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php) | ||
*/ | ||
|
||
namespace CakeDC\Auth\Test\TestCase\Social\Mapper; | ||
|
||
use Cake\TestSuite\TestCase; | ||
use CakeDC\Auth\Social\Mapper\LinkedIn; | ||
use CakeDC\Auth\Social\Mapper\LinkedInOpenIDConnect; | ||
|
||
class LinkedInOpenIDConnectTest extends TestCase | ||
{ | ||
public function setUp(): void | ||
{ | ||
parent::setUp(); | ||
} | ||
|
||
public function tearDown(): void | ||
{ | ||
parent::tearDown(); | ||
} | ||
|
||
public function testMap() | ||
{ | ||
$token = new \League\OAuth2\Client\Token\AccessToken([ | ||
'access_token' => 'test-token', | ||
'expires' => 1490988496, | ||
]); | ||
$rawData = [ | ||
'sub' => '1', | ||
'token' => $token, | ||
'email' => '[email protected]', | ||
'given_name' => 'Test', | ||
'family_name' => 'User', | ||
'industry' => 'Computer Software', | ||
'location' => [ | ||
'country' => [ | ||
'code' => 'es', | ||
], | ||
'name' => 'Spain', | ||
], | ||
'picture' => 'https://media.licdn.com/mpr/mprx/test.jpg', | ||
|
||
|
||
'bio' => 'The best test user in the world.', | ||
'publicProfileUrl' => 'https://www.linkedin.com/in/test', | ||
]; | ||
$providerMapper = new LinkedInOpenIDConnect(); | ||
$user = $providerMapper($rawData); | ||
|
||
$this->assertEquals([ | ||
'id' => '1', | ||
'username' => null, | ||
'full_name' => null, | ||
'first_name' => 'Test', | ||
'last_name' => 'User', | ||
'email' => '[email protected]', | ||
'avatar' => 'https://media.licdn.com/mpr/mprx/test.jpg', | ||
'gender' => null, | ||
'link' => 'https://www.linkedin.com', | ||
'bio' => 'The best test user in the world.', | ||
'locale' => null, | ||
'validated' => true, | ||
'credentials' => [ | ||
'token' => 'test-token', | ||
'secret' => null, | ||
'expires' => 1490988496, | ||
], | ||
'raw' => $rawData, | ||
], $user); | ||
} | ||
} |
Oops, something went wrong.