DirectoryTree / LdapRecord-Laravel

Multi-domain LDAP Authentication & Management for Laravel.
https://ldaprecord.com/docs/laravel/v3
MIT License
483 stars 51 forks source link

[Question] LdapRecord DirectoryEmulator driver error #614

Closed LucasJustine closed 7 months ago

LucasJustine commented 7 months ago

Environment:

Describe the bug: Hello, I'm working on an application that uses Ldaprecord and to be able to test the authentication part, I wanted to use the Testing part with DirectoryEmulator. However, I'm getting an error about a driver that can't be found. I used the example in the documentation.

public function test_auth_works()
{
        $fake = DirectoryEmulator::setup('default');

        $ldapUser = User::create([
            'cn' => $this->faker->name,
            'mail' => $this->faker->email,
            'objectguid' => $this->faker->uuid,
        ]);

        $fake->actingAs($ldapUser);

        $this->post('/login', [
            'email' => $ldapUser->mail[0],
            'password' => 'secret',
        ])->assertRedirect('/home');

        $user = Auth::user();

        $this->assertInstanceOf(\App\Models\User::class, $user);
        $this->assertEquals($ldapUser->mail[0], $user->email);
        $this->assertEquals($ldapUser->cn[0], $user->name);
    }

The error

• Tests\Feature\Auth\LdapLoginTest > auth works
   Illuminate\Database\QueryException

  could not find driver (SQL: select * from sqlite_master where type = 'table' and name = ldap_objects)

 vendor\laravel\framework\src\Illuminate\Database\Connection.php:760
    756▕         // If an exception occurs when attempting to run a query, we'll format the error
    757▕         // message to include the bindings with SQL, which will make this exception a
    758▕         // lot more helpful to the developer instead of just the database's errors.
    759▕         catch (Exception $e) {
  ➜ 760▕             throw new QueryException(
    761▕                 $query, $this->prepareBindings($bindings), $e
    762▕             );
    763▕         }
    764▕     
1
vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:70
      PDOException::("could not find driver")

  2   vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:70
      PDO::__construct("sqlite::memory:", [])