Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/Http/Requests/SetupDatabaseRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,23 @@ public function rules(): array
],
'db_host' => [
'required_unless:connection,sqlite',
'not_regex:/[\r\n]/',
],
'db_port' => [
'required_unless:connection,sqlite',
'numeric',
],
'db_name' => [
'required_unless:connection,sqlite',
'not_regex:/[\r\n]/',
],
'db_user' => [
'required_unless:connection,sqlite',
'not_regex:/[\r\n]/',
],
'db_password' => [
'nullable',
'not_regex:/[\r\n]/',
],
];
}
Expand Down
32 changes: 32 additions & 0 deletions tests/Controller/SetupDatabaseControllerTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

namespace Tests\Controller;

use App\Settings\SystemSettings;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;

class SetupDatabaseControllerTest extends TestCase
{
use RefreshDatabase;

public function test_database_setup_rejects_multiline_passwords(): void
{
SystemSettings::fake([
'setup_completed' => false,
]);

$response = $this->from('/setup/database')->post('/setup/database', [
'connection' => 'mysql',
'db_host' => '127.0.0.1',
'db_port' => 3306,
'db_name' => 'linkace',
'db_user' => 'linkace',
'db_password' => "secret\nMAIL_MAILER=sendmail",
]);

$response
->assertRedirect('/setup/database')
->assertSessionHasErrors('db_password');
}
}
Loading