Skip to content
This repository was archived by the owner on Jul 24, 2023. It is now read-only.

Commit 51601dd

Browse files
committed
Set LDAP connection when calling the auth provider
- Preserve BC and only use the connection property if set, otherwise retrieve it from the configuration - #712
1 parent 65fdb82 commit 51601dd

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

src/Resolvers/UserResolver.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,16 @@ class UserResolver implements ResolverInterface
2929
/**
3030
* The name of the LDAP connection to utilize.
3131
*
32-
* @var string
32+
* @var string|null
3333
*/
34-
protected $connection = 'default';
34+
protected $connection;
3535

3636
/**
3737
* {@inheritdoc}
3838
*/
3939
public function __construct(AdldapInterface $ldap)
4040
{
4141
$this->ldap = $ldap;
42-
43-
$this->setConnection($this->getLdapAuthConnectionName());
4442
}
4543

4644
/**
@@ -207,7 +205,7 @@ protected function getPasswordFromCredentials($credentials)
207205
*/
208206
protected function getLdapAuthProvider() : ProviderInterface
209207
{
210-
return $this->ldap->getProvider($this->connection);
208+
return $this->ldap->getProvider($this->connection ?? $this->getLdapAuthConnectionName());
211209
}
212210

213211
/**

tests/UserResolverTest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,17 @@ public function scopes_are_applied_when_query_is_called()
8888
}
8989

9090
/** @test */
91-
public function connection_is_set_upon_creation()
91+
public function connection_is_set_when_retrieving_provider()
9292
{
9393
Config::shouldReceive('get')->once()->with('ldap_auth.connection', 'default')->andReturn('other-test');
9494

9595
$ad = m::mock(AdldapInterface::class);
9696

97-
new UserResolver($ad);
97+
$ad->shouldReceive('getProvider')->andReturn(m::mock(ProviderInterface::class));
98+
99+
$r = m::mock(UserResolver::class, [$ad])->makePartial();
100+
101+
$r->getLdapAuthProvider();
98102
}
99103

100104
/** @test */

0 commit comments

Comments
 (0)