Environment:
- LDAP Server Type: ActiveDirectory
- LdapRecord-Laravel Major Version: 3
- PHP Version: 8.4
Describe the bug:
In a brand new laravel application, I installed ldap-record-laravel and followed the installation and configuration pages.
I updated my LoginRequest to authenticate using username instead of email.
I can connect successfully connect and authenticate to the ldap server.
The problem is with the test. I have copy/pasted the tests from the docs, and updated to pass the samaccountname as username instead of using the email.
That part of the test works, but i get the error SQLSTATE[HY000]: General error: 1 error in index users_guid_unique after drop column: no such column: guid (Connection: sqlite, SQL: alter table "users" drop column "guid").
I have ensured I have the "doctrine/dbal": "^4.3", package in composer.json as stated in the documentation.
The windows authentication test also fail with Expected response status code [200] but received 302., even if I provided the correct domain name.
<?php
namespace Tests\Feature;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Support\Facades\Auth;
use LdapRecord\Laravel\Middleware\WindowsAuthenticate;
use LdapRecord\Laravel\Testing\DirectoryEmulator;
use LdapRecord\Models\ActiveDirectory\User;
use Tests\TestCase;
class LdapAuthenticationTest extends TestCase
{
use DatabaseMigrations, WithFaker;
public function test_auth_works()
{
$fake = DirectoryEmulator::setup('default');
$ldapUser = User::create([
'cn' => $this->faker->name,
'mail' => $this->faker->email,
'objectguid' => $this->faker->uuid,
'samaccountname' => $this->faker->userName,
]);
$fake->actingAs($ldapUser);
$this->post('/login', [
'username' => $ldapUser->samaccountname[0],
'password' => 'secret',
])->assertRedirect('/dashboard');
$user = Auth::user();
$this->assertInstanceOf(\App\Models\User::class, $user);
$this->assertEquals($ldapUser->mail[0], $user->email);
$this->assertEquals($ldapUser->cn[0], $user->name);
}
public function test_windows_authentication_works()
{
DirectoryEmulator::setup('default');
$ldapUser = User::create([
'cn' => $this->faker->name,
'mail' => $this->faker->email,
'objectguid' => $this->faker->uuid,
'samaccountname' => $this->faker->userName,
]);
// Replace 'DOMAIN' with your domain from your configured LDAP
// `base_dn`. For example, if your `base_dn` is equal to
// 'dc=company,dc=com', then you would use 'COMPANY'.
$authUser = implode('\\', [
'ARMRECOUVREMENT', $ldapUser->getFirstAttribute('samaccountname')
]);
// Set the server variables for the upcoming request.
$this->withServerVariables([
WindowsAuthenticate::$serverKey => $authUser
]);
// Attempt accessing a protected page:
$this->get('/dashboard')->assertOk();
// Ensure the user was authenticated:
$this->assertTrue(Auth::check());
}
}
I ran the following statement at the start of my test dd(\Illuminate\Support\Facades\Schema::getColumnListing('users')); and I can see the guid column is still there.
Am I doing something wrong?
Environment:
Describe the bug:
In a brand new laravel application, I installed ldap-record-laravel and followed the installation and configuration pages.
I updated my LoginRequest to authenticate using username instead of email.
I can connect successfully connect and authenticate to the ldap server.
The problem is with the test. I have copy/pasted the tests from the docs, and updated to pass the samaccountname as username instead of using the email.
That part of the test works, but i get the error
SQLSTATE[HY000]: General error: 1 error in index users_guid_unique after drop column: no such column: guid (Connection: sqlite, SQL: alter table "users" drop column "guid").I have ensured I have the
"doctrine/dbal": "^4.3",package in composer.json as stated in the documentation.The windows authentication test also fail with
Expected response status code [200] but received 302., even if I provided the correct domain name.I ran the following statement at the start of my test
dd(\Illuminate\Support\Facades\Schema::getColumnListing('users'));and I can see the guid column is still there.Am I doing something wrong?