-
-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix request validation for request only having uploaded file (#182)
- Loading branch information
1 parent
ae3cfdb
commit 388dc3b
Showing
3 changed files
with
57 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
openapi: 3.0.0 | ||
info: | ||
title: Upload.v1 | ||
version: '1.0' | ||
servers: | ||
- url: 'http://localhost:3000' | ||
paths: | ||
/upload: | ||
post: | ||
requestBody: | ||
required: true | ||
content: | ||
multipart/form-data: | ||
schema: | ||
type: object | ||
properties: | ||
file: | ||
type: string | ||
format: binary | ||
required: | ||
- file | ||
responses: | ||
'204': | ||
description: No Content | ||
|
||
components: | ||
schemas: {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -565,7 +565,11 @@ public function test_handles_form_data(): void | |
|
||
$this->post( | ||
'/users', | ||
['name' => 'Adam Campbell', 'email' => '[email protected]', 'picture' => UploadedFile::fake()->image('test.jpg')], | ||
[ | ||
'name' => 'Adam Campbell', | ||
'email' => '[email protected]', | ||
'picture' => UploadedFile::fake()->image('test.jpg'), | ||
], | ||
['Content-Type' => 'multipart/form-data'] | ||
) | ||
->assertValidRequest(); | ||
|
@@ -838,6 +842,18 @@ public static function enumProvider(): array | |
], | ||
]; | ||
} | ||
|
||
public function test_validates_upload_file(): void | ||
{ | ||
Spectator::using('Upload.yml'); | ||
|
||
Route::post('/upload', function () { | ||
return response()->noContent(); | ||
})->middleware(Middleware::class); | ||
|
||
$this->post('/upload', ['file' => UploadedFile::fake()->createWithContent('test.xlsx', 'Content')], ['Content-Type' => 'multipart/form-data']) | ||
->assertValidRequest(); | ||
} | ||
} | ||
|
||
class TestUser extends Model | ||
|