Skip to content

Commit

Permalink
Merge pull request #722 from biigle/update-volume-validation
Browse files Browse the repository at this point in the history
Update volume validation
  • Loading branch information
mzur authored Dec 15, 2023
2 parents 9e18403 + ded7660 commit 26e8618
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/Http/Requests/UpdateVolume.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function rules()
{
return [
'name' => 'filled|max:512',
'url' => ['filled', new VolumeUrl],
'url' => ['filled', 'max:256', new VolumeUrl],
'handle' => ['nullable', 'max:256', new Handle],
];
}
Expand Down
19 changes: 19 additions & 0 deletions tests/php/Http/Controllers/Api/VolumeControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,25 @@ public function testUpdateUrl()
Queue::assertPushed(ProcessNewVolumeFiles::class);
}

public function testUpdateInvalidUrl()
{
$volume = $this->volume();

config(['volumes.admin_storage_disks' => ['admin-test']]);
$disk = Storage::fake('admin-test');
$disk->put('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/file.txt', 'abc');

$this->beGlobalAdmin();

// invalid url (>256 characters)
$response = $this->json('PUT', '/api/v1/volumes/'.$volume->id, [
'url' => 'admin-test://aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
])->assertStatus(422);

$this->assertEquals('The url must not be greater than 256 characters.', $response->exception->getMessage());
Queue::assertNothingPushed();
}

public function testUpdateUrlProviderDenylist()
{
$this->beAdmin();
Expand Down

0 comments on commit 26e8618

Please sign in to comment.