Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 7m25s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 6m46s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 7m52s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 8m5s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 10m33s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 10m53s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 9m1s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 8m49s
CI / Bekannte Sicherheitslücken in Paketen (pull_request) Successful in 54s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m4s
- /uploads nur über das Portal: UploadController prüft Sitzung bzw. App-Token; frei nur die Dateien der Anmeldeseite (Logos, Symbole, Anmeldehintergrund, Stylesheet, Schrift); public/uploads/.htaccess leitet alles an index.php (Migration schreibt sie, da der Ordner vor dem Updater geschützt ist); Systemzustand prüft die Regel; nginx-Hinweis in docs/SECURITY.md - Passwort-Anmeldung abschaltbar (PasswordLogin): Login-Formular, Passwort vergessen, App-Token und /api/v1/config; nur mit verknüpftem Konto abschaltbar, automatische Rückkehr ohne nutzbaren Dienst, Notausgang INHAUS_PASSWORD_LOGIN - Titelbilder: profile_covers (bis 12), zufällig je Seitenaufruf - ImageCompressor: Uploads im Backend (SafeUpload) und WordPress-Import auf ≤ 2400 px komprimiert, Format bleibt Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
65 lines
2.8 KiB
PHP
65 lines
2.8 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature\Auth;
|
|
|
|
use App\Filament\Resources\IdentityProviders\Pages\ListIdentityProviders;
|
|
use App\Models\Role;
|
|
use App\Models\User;
|
|
use App\Support\PasswordLogin;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Inertia\Testing\AssertableInertia as Assert;
|
|
use Livewire\Livewire;
|
|
use Tests\Support\FakeEntra;
|
|
use Tests\TestCase;
|
|
|
|
class PasswordLoginSwitchTest extends TestCase
|
|
{
|
|
use FakeEntra;
|
|
use RefreshDatabase;
|
|
|
|
private function admin(): User
|
|
{
|
|
return User::factory()->withRoles([Role::query()->where('slug', Role::ADMINISTRATION)->firstOrFail()])->create(['password' => 'geheim123']);
|
|
}
|
|
|
|
public function test_only_linked_admins_can_switch_off_and_everything_follows(): void
|
|
{
|
|
$provider = $this->entraProvider();
|
|
$admin = $this->admin();
|
|
|
|
// Nicht verknüpft: würde sich aussperren
|
|
Livewire::actingAs($admin)->test(ListIdentityProviders::class)->callAction('passwordOff');
|
|
$this->assertTrue(app(PasswordLogin::class)->enabled());
|
|
|
|
DB::table('user_identities')->insert(['user_id' => $admin->id, 'identity_provider_id' => $provider->id, 'subject' => 'oid-1', 'created_at' => now(), 'updated_at' => now()]);
|
|
Livewire::actingAs($admin)->test(ListIdentityProviders::class)->callAction('passwordOff');
|
|
$this->assertFalse(app(PasswordLogin::class)->enabled());
|
|
auth()->logout();
|
|
|
|
$this->get('/login')->assertInertia(fn (Assert $p) => $p->where('passwordLogin', false)->where('canResetPassword', false)->has('providers', 1));
|
|
$this->post('/login', ['email' => $admin->email, 'password' => 'geheim123'])->assertSessionHasErrors('email');
|
|
$this->assertGuest();
|
|
$this->get('/forgot-password')->assertRedirect('/login');
|
|
$this->post('/forgot-password', ['email' => $admin->email])->assertRedirect('/login');
|
|
|
|
$this->getJson('/api/v1/config')->assertJsonPath('login.password', false);
|
|
$this->postJson('/api/v1/token', ['email' => $admin->email, 'password' => 'geheim123', 'device_name' => 'iPhone'])->assertUnprocessable();
|
|
|
|
// Notausgang in der .env
|
|
config(['inhaus.password_login_override' => 'true']);
|
|
$this->post('/login', ['email' => $admin->email, 'password' => 'geheim123'])->assertRedirect();
|
|
$this->assertAuthenticatedAs($admin);
|
|
}
|
|
|
|
public function test_password_login_returns_when_no_provider_is_usable(): void
|
|
{
|
|
$provider = $this->entraProvider();
|
|
app(PasswordLogin::class)->set(false);
|
|
$this->assertFalse(app(PasswordLogin::class)->enabled());
|
|
|
|
$provider->update(['enabled' => false]);
|
|
$this->assertTrue(app(PasswordLogin::class)->enabled(), 'Sonst käme niemand mehr hinein');
|
|
$this->get('/login')->assertInertia(fn (Assert $p) => $p->where('passwordLogin', true));
|
|
}
|
|
}
|