mirror of
https://github.com/Kovah/LinkAce.git
synced 2025-01-18 05:38:40 +01:00
Fix issue with setup completed permissions, add first test for the setup
This commit is contained in:
parent
e67ffdee30
commit
9ec7060a96
@ -22,6 +22,11 @@ class SetupCheckMiddleware
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
if ($request->is('setup/*')) {
|
||||
if (config('app.setup_completed') === true) {
|
||||
// Do not allow access to setup after it was completed
|
||||
return redirect()->route('front');
|
||||
}
|
||||
|
||||
// Skip check if current route targets the setup
|
||||
return $next($request);
|
||||
}
|
||||
|
53
tests/Feature/Controller/Setup/MetaControllerTest.php
Normal file
53
tests/Feature/Controller/Setup/MetaControllerTest.php
Normal file
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\Controller\Setup;
|
||||
|
||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Tests\TestCase;
|
||||
|
||||
class MetaControllerTest extends TestCase
|
||||
{
|
||||
use DatabaseTransactions;
|
||||
use DatabaseMigrations;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
config(['app.setup_completed' => false]);
|
||||
}
|
||||
|
||||
public function testSetupCheckRedirect(): void
|
||||
{
|
||||
$response = $this->get('/');
|
||||
|
||||
$response->assertRedirect('setup/start');
|
||||
}
|
||||
|
||||
public function testSetupCheckWithoutRedirect(): void
|
||||
{
|
||||
config(['app.setup_completed' => true]);
|
||||
|
||||
$response = $this->get('/');
|
||||
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
public function testRedirectIfSetupCompleted(): void
|
||||
{
|
||||
config(['app.setup_completed' => true]);
|
||||
|
||||
$response = $this->get('setup/start');
|
||||
|
||||
$response->assertRedirect('/');
|
||||
}
|
||||
|
||||
public function testSetupWelcomeView(): void
|
||||
{
|
||||
$response = $this->get('setup/start');
|
||||
|
||||
$response->assertStatus(200)
|
||||
->assertSee('Welcome to the LinkAce setup');
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user