mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-08-09 10:22:51 +03:00
Added tests to cover ldap group mapping
Also updated .env.example formatting. Updated how LdapRepo uses Ldap so can be mocked by testing.
This commit is contained in:
@@ -6,6 +6,7 @@ use BookStack\Exceptions\AuthException;
|
||||
use BookStack\Http\Controllers\Controller;
|
||||
use BookStack\Repos\UserRepo;
|
||||
use BookStack\Repos\LdapRepo;
|
||||
use BookStack\Services\LdapService;
|
||||
use BookStack\Services\SocialAuthService;
|
||||
use Illuminate\Contracts\Auth\Authenticatable;
|
||||
use Illuminate\Foundation\Auth\AuthenticatesUsers;
|
||||
@@ -99,7 +100,7 @@ class LoginController extends Controller
|
||||
|
||||
// ldap groups refresh
|
||||
if (config('services.ldap.user_to_groups') !== false && $request->filled('username')) {
|
||||
$ldapRepo = new LdapRepo($this->userRepo);
|
||||
$ldapRepo = new LdapRepo($this->userRepo, app(LdapService::class));
|
||||
$ldapRepo->syncGroups($user, $request->input('username'));
|
||||
}
|
||||
|
||||
|
@@ -1,9 +1,7 @@
|
||||
<?php namespace BookStack\Repos;
|
||||
|
||||
use BookStack\Services\Ldap;
|
||||
use BookStack\Services\LdapService;
|
||||
use BookStack\Role;
|
||||
use BookStack\Repos\UserRepo;
|
||||
|
||||
class LdapRepo
|
||||
{
|
||||
@@ -16,8 +14,9 @@ class LdapRepo
|
||||
/**
|
||||
* LdapRepo constructor.
|
||||
* @param \BookStack\Repos\UserRepo $userRepo
|
||||
* @param LdapService $ldapService
|
||||
*/
|
||||
public function __construct(UserRepo $userRepo)
|
||||
public function __construct(UserRepo $userRepo, LdapService $ldapService)
|
||||
{
|
||||
$this->config = config('services.ldap');
|
||||
|
||||
@@ -25,7 +24,7 @@ class LdapRepo
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->ldapService = new LdapService(new Ldap);
|
||||
$this->ldapService = $ldapService;
|
||||
$this->userRepo = $userRepo;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user