-
-
Notifications
You must be signed in to change notification settings - Fork 800
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Al
committed
Dec 9, 2024
1 parent
b00480d
commit d9bc5bc
Showing
1 changed file
with
21 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,9 +12,11 @@ | |
namespace HWI\Bundle\OAuthBundle\Tests\OAuth\ResourceOwner; | ||
|
||
use HWI\Bundle\OAuthBundle\OAuth\ResourceOwner\AmazonCognitoResourceOwner; | ||
use HWI\Bundle\OAuthBundle\OAuth\ResourceOwnerInterface; | ||
use HWI\Bundle\OAuthBundle\OAuth\Response\AbstractUserResponse; | ||
use HWI\Bundle\OAuthBundle\Test\OAuth\ResourceOwner\GenericOAuth2ResourceOwnerTestCase; | ||
use Symfony\Component\Security\Core\Exception\AuthenticationException; | ||
use Symfony\Component\Security\Http\HttpUtils; | ||
|
||
final class AmazonCognitoResourceOwnerTest extends GenericOAuth2ResourceOwnerTestCase | ||
{ | ||
|
@@ -37,11 +39,8 @@ final class AmazonCognitoResourceOwnerTest extends GenericOAuth2ResourceOwnerTes | |
public function testGetUserInformation(): void | ||
{ | ||
$resourceOwner = $this->createResourceOwner( | ||
[ | ||
'domain' => 'test.com', | ||
'region' => 'us-east-1', | ||
], | ||
$this->paths, | ||
[], | ||
[], | ||
[ | ||
$this->createMockResponse($this->userResponse, 'application/json; charset=utf-8'), | ||
] | ||
|
@@ -52,7 +51,6 @@ public function testGetUserInformation(): void | |
*/ | ||
$userResponse = $resourceOwner->getUserInformation(['access_token' => 'token']); | ||
|
||
$this->assertEquals('111', $userResponse->getUserIdentifier()); | ||
$this->assertEquals('[email protected]', $userResponse->getEmail()); | ||
$this->assertEquals('bar', $userResponse->getRealName()); | ||
$this->assertNull($userResponse->getFirstName()); | ||
|
@@ -65,10 +63,7 @@ public function testGetUserInformationFailure(): void | |
$this->expectException(AuthenticationException::class); | ||
|
||
$resourceOwner = $this->createResourceOwner( | ||
[ | ||
'domain' => 'test.com', | ||
'region' => 'us-east-1', | ||
], | ||
[], | ||
[], | ||
[ | ||
$this->createMockResponse('invalid', 'application/json; charset=utf-8', 401), | ||
|
@@ -77,4 +72,20 @@ public function testGetUserInformationFailure(): void | |
|
||
$resourceOwner->getUserInformation($this->tokenData); | ||
} | ||
|
||
protected function setUpResourceOwner(string $name, HttpUtils $httpUtils, array $options, array $responses): ResourceOwnerInterface | ||
{ | ||
return parent::setUpResourceOwner( | ||
$name, | ||
$httpUtils, | ||
array_merge( | ||
[ | ||
'domain' => 'test.com', | ||
'region' => 'us-west-2', | ||
], | ||
$options | ||
), | ||
$responses | ||
); | ||
} | ||
} |