Skip to content

Commit

Permalink
Tests fix 2
Browse files Browse the repository at this point in the history
  • Loading branch information
Al committed Dec 9, 2024
1 parent b00480d commit d9bc5bc
Showing 1 changed file with 21 additions and 10 deletions.
31 changes: 21 additions & 10 deletions tests/OAuth/ResourceOwner/AmazonCognitoResourceOwnerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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'),
]
Expand All @@ -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());
Expand All @@ -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),
Expand All @@ -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
);
}
}

0 comments on commit d9bc5bc

Please sign in to comment.