1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2026-01-03 23:42:28 +03:00

Uploads: Added user-facing message for Laravel post limit handling

Uploads over the post max size Would previously error without a
clean user facing message. This catches that error to provide a
user friendly message, compatible with our common error handling.

Tested on image manager handling.
Added test to cover.
This commit is contained in:
Dan Brown
2023-09-25 13:48:23 +01:00
parent 21badde4ef
commit 59da7666b5
3 changed files with 20 additions and 1 deletions

View File

@@ -2,6 +2,7 @@
namespace Tests;
use Illuminate\Foundation\Http\Middleware\ValidatePostSize;
use Illuminate\Support\Facades\Log;
class ErrorTest extends TestCase
@@ -45,4 +46,16 @@ class ErrorTest extends TestCase
$resp->assertStatus(404);
$resp->assertSeeText('Image Not Found');
}
public function test_posts_above_php_limit_shows_friendly_error()
{
// Fake super large JSON request
$resp = $this->asEditor()->call('GET', '/books', [], [], [], [
'CONTENT_LENGTH' => '10000000000',
'HTTP_ACCEPT' => 'application/json',
]);
$resp->assertStatus(413);
$resp->assertJson(['error' => 'The server cannot receive the provided amount of data. Try again with less data or a smaller file.']);
}
}