1
0
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:
Kovah 2020-02-20 11:54:48 +01:00
parent e67ffdee30
commit 9ec7060a96
No known key found for this signature in database
GPG Key ID: AAAA031BA9830D7B
2 changed files with 58 additions and 0 deletions

View File

@ -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);
}

View 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');
}
}