Skip to content

Commit 1307e57

Browse files
committed
[Security] PassportInterface deprecations fixes
1 parent 57407ce commit 1307e57

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

Security/LdapAuthenticator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public function createAuthenticatedToken(PassportInterface $passport, string $fi
7272
return $this->createToken($passport, $firewallName);
7373
}
7474

75-
public function createToken(PassportInterface $passport, string $firewallName): TokenInterface
75+
public function createToken(Passport $passport, string $firewallName): TokenInterface
7676
{
7777
// @deprecated since Symfony 5.4, in 6.0 change to:
7878
// return $this->authenticator->createToken($passport, $firewallName);

Tests/Security/CheckLdapCredentialsListenerTest.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,23 @@ public function provideWrongPassportData()
116116

117117
// no password credentials
118118
yield [new SelfValidatingPassport(new UserBadge('test'), [new LdapBadge('app.ldap')])];
119+
}
120+
121+
/**
122+
* @group legacy
123+
*/
124+
public function testLegacyWrongPassport()
125+
{
126+
$this->expectException(\LogicException::class);
127+
$this->expectExceptionMessage('LDAP authentication requires a passport containing a user and password credentials, authenticator "'.TestAuthenticator::class.'" does not fulfill these requirements.');
119128

120129
// no user passport
121130
$passport = $this->createMock(PassportInterface::class);
122131
$passport->expects($this->any())->method('hasBadge')->with(LdapBadge::class)->willReturn(true);
123132
$passport->expects($this->any())->method('getBadge')->with(LdapBadge::class)->willReturn(new LdapBadge('app.ldap'));
124-
yield [$passport];
133+
134+
$listener = $this->createListener();
135+
$listener->onCheckPassport(new CheckPassportEvent(new TestAuthenticator(), $passport));
125136
}
126137

127138
public function testEmptyPasswordShouldThrowAnException()

0 commit comments

Comments
 (0)