]> BookStack Code Mirror - bookstack/blobdiff - tests/User/RoleManagementTest.php
respective book and chapter structure added.
[bookstack] / tests / User / RoleManagementTest.php
index 5722a0b08c8363a064f0bd49e19dae3f82ae8611..8683fcb6e86b7d914cea03d95b66c905e7fb9bc0 100644 (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 */
@@ -235,7 +260,7 @@ class RoleManagementTest extends TestCase
         /** @var Role $publicRole */
         $publicRole = Role::getSystemRole('public');
         $resp = $this->asAdmin()->delete('/settings/roles/delete/' . $publicRole->id);
-        $resp->assertRedirect('/');
+        $resp->assertRedirect('/settings/roles/delete/' . $publicRole->id);
 
         $this->get('/settings/roles/delete/' . $publicRole->id);
         $resp = $this->delete('/settings/roles/delete/' . $publicRole->id);