Skip to content

Commit 3e6ccb2

Browse files
committed
tests fixes
1 parent ff4113b commit 3e6ccb2

2 files changed

Lines changed: 10 additions & 11 deletions

File tree

Tests/Security/Authentication/Provider/SamlProviderTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
use Hslavich\OneloginSamlBundle\Security\Authentication\Token\SamlTokenFactory;
99
use Hslavich\OneloginSamlBundle\Security\User\SamlUserFactoryInterface;
1010
use Hslavich\OneloginSamlBundle\Security\User\SamlUserInterface;
11+
use Hslavich\OneloginSamlBundle\Security\User\SamlUserProvider;
1112
use PHPUnit\Framework\TestCase;
1213
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
1314
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
1415
use Symfony\Component\Security\Core\User\UserInterface;
15-
use Symfony\Component\Security\Core\User\UserProviderInterface;
1616

1717
class SamlProviderTest extends TestCase
1818
{
@@ -140,7 +140,7 @@ protected function getSamlToken(): SamlToken
140140

141141
protected function getProvider($user = null, $userFactory = null, $entityManager = null, $persist = false): SamlProvider
142142
{
143-
$userProvider = $this->createMock(UserProviderInterface::class);
143+
$userProvider = $this->createMock(SamlUserProvider::class);
144144
if ($user) {
145145
$userProvider
146146
->method('loadUserByUsername')

Tests/Security/Http/Authenticator/SamlAuthenticatorTest.php

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Doctrine\ORM\EntityManagerInterface;
88
use Hslavich\OneloginSamlBundle\Security\Http\Authenticator\SamlAuthenticator;
99
use Hslavich\OneloginSamlBundle\Security\User\SamlUserFactoryInterface;
10+
use Hslavich\OneloginSamlBundle\Security\User\SamlUserProvider;
1011
use Hslavich\OneloginSamlBundle\Tests\TestUser;
1112
use PHPUnit\Framework\MockObject\MockObject;
1213
use PHPUnit\Framework\MockObject\Rule\InvokedCount;
@@ -16,12 +17,10 @@
1617
use Symfony\Component\Security\Core\Exception\AuthenticationException;
1718
use Symfony\Component\Security\Core\Exception\SessionUnavailableException;
1819
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
19-
use Symfony\Component\Security\Core\User\UserProviderInterface;
2020
use Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface;
2121
use Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface;
2222
use Symfony\Component\Security\Http\Authenticator\Passport\UserPassportInterface;
2323
use Symfony\Component\Security\Http\HttpUtils;
24-
use const false;
2524

2625
class SamlAuthenticatorTest extends TestCase
2726
{
@@ -40,7 +39,7 @@ public function testNoSessionException(Request $request, string $message): void
4039
{
4140
$authenticator = new SamlAuthenticator(
4241
$httpUtils = $this->createMock(HttpUtils::class),
43-
$this->createMock(UserProviderInterface::class),
42+
$this->createMock(SamlUserProvider::class),
4443
$this->createMock(\OneLogin\Saml2\Auth::class),
4544
$this->createMock(AuthenticationSuccessHandlerInterface::class),
4645
$this->createMock(AuthenticationFailureHandlerInterface::class),
@@ -73,7 +72,7 @@ public function testAuthenticationException(): void
7372

7473
$authenticator = new SamlAuthenticator(
7574
$httpUtils = $this->createMock(HttpUtils::class),
76-
$this->createMock(UserProviderInterface::class),
75+
$this->createMock(SamlUserProvider::class),
7776
$auth,
7877
$this->createMock(AuthenticationSuccessHandlerInterface::class),
7978
$this->createMock(AuthenticationFailureHandlerInterface::class),
@@ -88,7 +87,7 @@ public function testAuthenticationException(): void
8887

8988
public function testUsernameNotFound(): void
9089
{
91-
$userProvider = $this->createMock(UserProviderInterface::class);
90+
$userProvider = $this->createMock(SamlUserProvider::class);
9291
$userProvider
9392
->expects(self::once())
9493
->method('loadUserByUsername')
@@ -111,7 +110,7 @@ public function testUsernameNotFound(): void
111110

112111
public function testUserFactoryException(): void
113112
{
114-
$userProvider = $this->createMock(UserProviderInterface::class);
113+
$userProvider = $this->createMock(SamlUserProvider::class);
115114
$userProvider
116115
->expects(self::once())
117116
->method('loadUserByUsername')
@@ -137,7 +136,7 @@ public function testAuthenticationWithLoad(): void
137136
{
138137
$user = new TestUser('test', ['ROLE_USER']);
139138

140-
$userProvider = $this->createMock(UserProviderInterface::class);
139+
$userProvider = $this->createMock(SamlUserProvider::class);
141140
$userProvider
142141
->expects(self::once())
143142
->method('loadUserByUsername')
@@ -163,7 +162,7 @@ public function testAuthenticationWithGenerate(): void
163162
{
164163
$user = new TestUser('test', ['ROLE_USER']);
165164

166-
$userProvider = $this->createMock(UserProviderInterface::class);
165+
$userProvider = $this->createMock(SamlUserProvider::class);
167166
$userProvider
168167
->expects(self::once())
169168
->method('loadUserByUsername')
@@ -223,7 +222,7 @@ private function createSamlAuthenticatorForSupports(InvokedCount $checkRequestEx
223222

224223
return new SamlAuthenticator(
225224
$httpUtils,
226-
$this->createMock(UserProviderInterface::class),
225+
$this->createMock(SamlUserProvider::class),
227226
$this->createMock(\OneLogin\Saml2\Auth::class),
228227
$this->createMock(AuthenticationSuccessHandlerInterface::class),
229228
$this->createMock(AuthenticationFailureHandlerInterface::class),

0 commit comments

Comments
 (0)