1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-07-31 15:24:31 +03:00

Roles: Added max validation for role external auth id field

For #5037
This commit is contained in:
Dan Brown
2024-06-08 20:33:34 +01:00
parent 6019d2ee14
commit bddc6ae66b
3 changed files with 29 additions and 4 deletions

View File

@ -96,6 +96,31 @@ class RoleManagementTest extends TestCase
$this->assertActivityExists(ActivityType::ROLE_DELETE);
}
public function test_role_external_auth_id_validation()
{
config()->set('auth.method', 'oidc');
$role = Role::query()->first();
$routeByMethod = [
'post' => '/settings/roles/new',
'put' => "/settings/roles/{$role->id}",
];
foreach ($routeByMethod as $method => $route) {
$resp = $this->asAdmin()->get($route);
$resp->assertDontSee('The external auth id');
$resp = $this->asAdmin()->call($method, $route, [
'display_name' => 'Test role for auth id validation',
'description' => '',
'external_auth_id' => str_repeat('a', 181),
]);
$resp->assertRedirect($route);
$resp = $this->followRedirects($resp);
$resp->assertSee('The external auth id may not be greater than 180 characters.');
}
}
public function test_admin_role_cannot_be_removed_if_user_last_admin()
{
/** @var Role $adminRole */