Skip to content

Commit

Permalink
Fix SF 7 compat
Browse files Browse the repository at this point in the history
  • Loading branch information
mbabker committed Nov 25, 2023
1 parent 58cb94c commit a005f48
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 33 deletions.
18 changes: 14 additions & 4 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
fail-fast: false
matrix:
php: ['7.4', '8.0', '8.1', '8.2']
symfony: ['4.4.*', '5.4.*', '6.0.*', '6.1.*', '6.2.*', '6.3.*']
symfony: ['4.4.*', '5.4.*', '6.0.*', '6.1.*', '6.2.*', '6.3.*', '6.4.*', '7.0.*']
composer-flags: ['--prefer-stable']
can-fail: [false]
extensions: ['curl, iconv, mbstring, mongodb, pdo, pdo_sqlite, sqlite, zip']
Expand All @@ -29,18 +29,28 @@ jobs:
symfony: '6.2.*'
- php: '7.4'
symfony: '6.3.*'
- php: '7.4'
symfony: '6.4.*'
- php: '7.4'
symfony: '7.0.*'
- php: '8.0'
symfony: '6.1.*'
- php: '8.0'
symfony: '6.2.*'
- php: '8.0'
symfony: '6.3.*'
- php: '8.0'
symfony: '6.4.*'
- php: '8.0'
symfony: '7.0.*'
- php: '8.1'
symfony: '7.0.*'

name: "PHP ${{ matrix.php }} - Symfony ${{ matrix.symfony }}${{ matrix.composer-flags != '' && format(' - Composer {0}', matrix.composer-flags) || '' }}"

steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Cache dependencies
uses: actions/cache@v3
Expand All @@ -63,8 +73,8 @@ jobs:
version: '5.0'
topology: server

- name: Remove Guard
if: contains(fromJSON('["6.0.*", "6.1.*", "6.2.*", "6.3.*"]'), matrix.symfony)
- name: Remove Guard (Symfony >=6.0)
if: contains(fromJSON('["6.0.*", "6.1.*", "6.2.*", "6.3.*", "6.4.*", "7.0.*"]'), matrix.symfony)
run: composer remove --dev --no-update symfony/security-guard

- name: Install dependencies
Expand Down
5 changes: 1 addition & 4 deletions Security/Exception/InvalidTokenException.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@

class InvalidTokenException extends AuthenticationException
{
/**
* @return string
*/
public function getMessageKey()
public function getMessageKey(): string
{
return 'Invalid JWT Refresh Token';
}
Expand Down
5 changes: 1 addition & 4 deletions Security/Exception/MissingTokenException.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@

class MissingTokenException extends AuthenticationException
{
/**
* @return string
*/
public function getMessageKey()
public function getMessageKey(): string
{
return 'Missing JWT Refresh Token';
}
Expand Down
5 changes: 1 addition & 4 deletions Security/Exception/TokenNotFoundException.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@

class TokenNotFoundException extends AuthenticationException
{
/**
* @return string
*/
public function getMessageKey()
public function getMessageKey(): string
{
return 'JWT Refresh Token Not Found';
}
Expand Down
9 changes: 2 additions & 7 deletions Security/Provider/RefreshTokenProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,7 @@ public function loadUserByIdentifier(string $identifier): UserInterface
);
}

/**
* @return UserInterface
*/
public function refreshUser(UserInterface $user)
public function refreshUser(UserInterface $user): UserInterface
{
if (null !== $this->customUserProvider) {
return $this->customUserProvider->refreshUser($user);
Expand All @@ -116,10 +113,8 @@ public function refreshUser(UserInterface $user)

/**
* @param class-string<UserInterface> $class
*
* @return bool
*/
public function supportsClass($class)
public function supportsClass(string $class): bool
{
if (null !== $this->customUserProvider) {
return $this->customUserProvider->supportsClass($class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,10 @@ public function testAttachesTheTokenToTheResponseBodyOnCredentialsAuth()

public function testDoesNothingWhenThereIsNotAUser()
{
if ((new \ReflectionClass(AuthenticationSuccessEvent::class))->getMethod('getUser')->hasReturnType()) {
$this->markTestSkipped(sprintf('%s::getUser() has a non-nullable return type in LexikJWTAuthenticationBundle 3.x', AuthenticationSuccessEvent::class));
}

/** @var AuthenticationSuccessEvent|MockObject $event */
$event = $this->createMock(AuthenticationSuccessEvent::class);

Expand Down
11 changes: 4 additions & 7 deletions Tests/Unit/Request/Extractor/RequestCookieExtractorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Gesdinet\JWTRefreshTokenBundle\Request\Extractor\RequestCookieExtractor;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpFoundation\InputBag;
use Symfony\Component\HttpFoundation\ParameterBag;
use Symfony\Component\HttpFoundation\Request;

Expand All @@ -29,13 +30,9 @@ public function testGetsTheTokenFromTheRequestCookies(): void
{
$token = 'my-refresh-token';

/** @var ParameterBag|MockObject $cookieBag */
$cookieBag = $this->createMock(ParameterBag::class);
$cookieBag
->expects($this->once())
->method('get')
->with(self::PARAMETER_NAME)
->willReturn($token);
/** @var ParameterBag|InputBag $cookieBag */
$cookieBag = class_exists(InputBag::class) ? new InputBag() : new ParameterBag();
$cookieBag->set(self::PARAMETER_NAME, $token);

/** @var Request|MockObject $request */
$request = $this->createMock(Request::class);
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@
"doctrine/cache": "^1.11|^2.0",
"doctrine/mongodb-odm": "^2.2",
"doctrine/orm": "^2.7",
"matthiasnoback/symfony-config-test": "^4.2",
"matthiasnoback/symfony-dependency-injection-test": "^4.2",
"matthiasnoback/symfony-config-test": "^4.2|^5.0",
"matthiasnoback/symfony-dependency-injection-test": "^4.2|^5.0",
"phpunit/phpunit": "^9.5",
"symfony/cache": "^4.4|^5.4|^6.0|^7.0",
"symfony/security-guard": "^4.4|^5.4|^6.0|^7.0"
"symfony/security-guard": "^4.4|^5.4"
},
"conflict": {
"doctrine/mongodb-odm": "<2.2",
Expand Down

0 comments on commit a005f48

Please sign in to comment.