1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-07-28 17:02:04 +03:00

Users: Changed name validation to min:1 instead of 2

Would cause scenarios where users could be created with 1 char, but then
fail to update due to validation differences.
Added test to cover.
For #5263
This commit is contained in:
Dan Brown
2024-10-15 11:07:41 +01:00
parent 4dc75bad05
commit 6f1c54d018
3 changed files with 13 additions and 4 deletions

View File

@ -11,7 +11,6 @@ use BookStack\Users\Models\User;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Str;
use Mockery\MockInterface;
use RuntimeException;
use Tests\TestCase;
class UserManagementTest extends TestCase
@ -86,6 +85,16 @@ class UserManagementTest extends TestCase
$this->assertTrue(Hash::check('newpassword', $userPassword));
}
public function test_user_can_be_updated_with_single_char_name()
{
$user = $this->users->viewer();
$this->asAdmin()->put("/settings/users/{$user->id}", [
'name' => 'b'
])->assertRedirect('/settings/users');
$this->assertEquals('b', $user->refresh()->name);
}
public function test_user_cannot_be_deleted_if_last_admin()
{
$adminRole = Role::getRole('admin');