use BookStack\Auth\Access\LdapService;
use BookStack\Auth\Role;
use BookStack\Auth\User;
+use Illuminate\Testing\TestResponse;
use Mockery\MockInterface;
use Tests\TestCase;
-use Tests\TestResponse;
class LdapTest extends TestCase
{
$resp->assertSee($this->mockUser->name);
$resp = $this->followingRedirects()->mockUserLogin($this->mockUser->email);
- $resp->assertElementExists('#home-default');
+ $this->withHtml($resp)->assertElementExists('#home-default');
$resp->assertSee($this->mockUser->name);
$this->assertDatabaseHas('users', [
'email' => $this->mockUser->email,
public function test_registration_disabled()
{
- $this->followingRedirects()->get('/register')->assertElementContains('#content', 'Log In');
+ $resp = $this->followingRedirects()->get('/register');
+ $this->withHtml($resp)->assertElementContains('#content', 'Log In');
}
public function test_non_admins_cannot_change_auth_id()
$this->mockLdap->shouldReceive('searchAndGetEntries')->times(4)
->with($this->resourceId, config('services.ldap.base_dn'), \Mockery::type('string'), \Mockery::type('array'))
->andReturn($userResp, ['count' => 1,
- 0 => [
+ 0 => [
'dn' => 'dc=test,' . config('services.ldap.base_dn'),
'memberof' => [
'count' => 1,
],
], [
'count' => 1,
- 0 => [
- 'dn' => 'cn=ldaptester,ou=groups,dc=example,dc=com',
+ 0 => [
+ 'dn' => 'cn=ldaptester,ou=groups,dc=example,dc=com',
'memberof' => [
'count' => 1,
0 => 'cn=monsters,ou=groups,dc=example,dc=com',
],
- ]
+ ],
], ['count' => 0]);
$resp = $this->mockUserLogin();
'details_from_ldap' => [
'dn' => 'dc=test,' . config('services.ldap.base_dn'),
'memberof' => [
- 0 => 'cn=ldaptester,ou=groups,dc=example,dc=com',
+ 0 => 'cn=ldaptester,ou=groups,dc=example,dc=com',
'count' => 1,
- ]
+ ],
],
'parsed_direct_user_groups' => [
'ldaptester',
public function test_dump_user_details_option_works()
{
- config()->set(['services.ldap.dump_user_details' => true]);
+ config()->set(['services.ldap.dump_user_details' => true, 'services.ldap.thumbnail_attribute' => 'jpegphoto']);
$this->commonLdapMocks(1, 1, 1, 1, 1);
$this->mockLdap->shouldReceive('searchAndGetEntries')->times(1)
->andReturn(['count' => 1, 0 => [
'uid' => [$this->mockUser->name],
'cn' => [$this->mockUser->name],
- 'dn' => ['dc=test' . config('services.ldap.base_dn')],
+ // Test dumping binary data for avatar responses
+ 'jpegphoto' => base64_decode('/9j/4AAQSkZJRg=='),
+ 'dn' => ['dc=test' . config('services.ldap.base_dn')],
]]);
$resp = $this->post('/login', [