Skip to content

Commit 2f2177f

Browse files
Merge branch '6.2' into 6.3
* 6.2: [Security] remove deprecated conditions in supports and authenticate methods from AccessListener class [Tests] Replace `setMethods()` by `onlyMethods()` and `addMethods()`
2 parents bb7b547 + 210fc3f commit 2f2177f

File tree

4 files changed

+8
-12
lines changed

4 files changed

+8
-12
lines changed

Firewall/AccessListener.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,7 @@ public function supports(Request $request): ?bool
5050
[$attributes] = $this->map->getPatterns($request);
5151
$request->attributes->set('_access_control_attributes', $attributes);
5252

53-
if ($attributes && (
54-
(\defined(AuthenticatedVoter::class.'::IS_AUTHENTICATED_ANONYMOUSLY') ? [AuthenticatedVoter::IS_AUTHENTICATED_ANONYMOUSLY] !== $attributes : true)
55-
&& [AuthenticatedVoter::PUBLIC_ACCESS] !== $attributes
56-
)) {
53+
if ($attributes && [AuthenticatedVoter::PUBLIC_ACCESS] !== $attributes) {
5754
return true;
5855
}
5956

@@ -72,10 +69,9 @@ public function authenticate(RequestEvent $event)
7269
$attributes = $request->attributes->get('_access_control_attributes');
7370
$request->attributes->remove('_access_control_attributes');
7471

75-
if (!$attributes || ((
76-
(\defined(AuthenticatedVoter::class.'::IS_AUTHENTICATED_ANONYMOUSLY') ? [AuthenticatedVoter::IS_AUTHENTICATED_ANONYMOUSLY] === $attributes : false)
77-
|| [AuthenticatedVoter::PUBLIC_ACCESS] === $attributes
78-
) && $event instanceof LazyResponseEvent)) {
72+
if (!$attributes || (
73+
[AuthenticatedVoter::PUBLIC_ACCESS] === $attributes && $event instanceof LazyResponseEvent
74+
)) {
7975
return;
8076
}
8177

Tests/Authentication/DefaultAuthenticationFailureHandlerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ protected function setUp(): void
4747
$this->session = $this->createMock(SessionInterface::class);
4848
$this->request = $this->createMock(Request::class);
4949
$this->request->expects($this->any())->method('getSession')->willReturn($this->session);
50-
$this->exception = $this->getMockBuilder(AuthenticationException::class)->setMethods(['getMessage'])->getMock();
50+
$this->exception = $this->getMockBuilder(AuthenticationException::class)->onlyMethods(['getMessage'])->getMock();
5151
}
5252

5353
public function testForward()

Tests/EventListener/CheckCredentialsListenerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public function testAddsNoPasswordUpgradeBadgeIfItAlreadyExists()
134134
$this->hasherFactory->expects($this->any())->method('getPasswordHasher')->with($this->identicalTo($this->user))->willReturn($hasher);
135135

136136
$passport = $this->getMockBuilder(Passport::class)
137-
->setMethods(['addBadge'])
137+
->onlyMethods(['addBadge'])
138138
->setConstructorArgs([new UserBadge('wouter', fn () => $this->user), new PasswordCredentials('ThePa$$word'), [new PasswordUpgradeBadge('ThePa$$word')]])
139139
->getMock();
140140

@@ -151,7 +151,7 @@ public function testAddsNoPasswordUpgradeBadgeIfPasswordIsInvalid()
151151
$this->hasherFactory->expects($this->any())->method('getPasswordHasher')->with($this->identicalTo($this->user))->willReturn($hasher);
152152

153153
$passport = $this->getMockBuilder(Passport::class)
154-
->setMethods(['addBadge'])
154+
->onlyMethods(['addBadge'])
155155
->setConstructorArgs([new UserBadge('wouter', fn () => $this->user), new PasswordCredentials('ThePa$$word'), [new PasswordUpgradeBadge('ThePa$$word')]])
156156
->getMock();
157157

Tests/Firewall/ContextListenerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ public function testWithPreviousNotStartedSession()
307307

308308
public function testSessionIsNotReported()
309309
{
310-
$usageReporter = $this->getMockBuilder(\stdClass::class)->setMethods(['__invoke'])->getMock();
310+
$usageReporter = $this->getMockBuilder(\stdClass::class)->addMethods(['__invoke'])->getMock();
311311
$usageReporter->expects($this->never())->method('__invoke');
312312

313313
$session = new Session(new MockArraySessionStorage(), null, null, $usageReporter);

0 commit comments

Comments
 (0)