]> BookStack Code Mirror - bookstack/blobdiff - tests/Auth/GroupSyncServiceTest.php
respective book and chapter structure added.
[bookstack] / tests / Auth / GroupSyncServiceTest.php
index 74d2c7e2ab119709b2eafdd7c522c9fc457c23c8..fee2ae40686d9763b91a80974544ba251b6f8bdd 100644 (file)
@@ -2,16 +2,16 @@
 
 namespace Tests\Auth;
 
-use BookStack\Auth\Access\GroupSyncService;
-use BookStack\Auth\Role;
-use BookStack\Auth\User;
+use BookStack\Access\GroupSyncService;
+use BookStack\Users\Models\Role;
+use BookStack\Users\Models\User;
 use Tests\TestCase;
 
 class GroupSyncServiceTest extends TestCase
 {
     public function test_user_is_assigned_to_matching_roles()
     {
-        $user = $this->getViewer();
+        $user = $this->users->viewer();
 
         $roleA = Role::factory()->create(['display_name' => 'Wizards']);
         $roleB = Role::factory()->create(['display_name' => 'Gremlins']);
@@ -33,7 +33,7 @@ class GroupSyncServiceTest extends TestCase
 
     public function test_multiple_values_in_role_external_auth_id_handled()
     {
-        $user = $this->getViewer();
+        $user = $this->users->viewer();
         $role = Role::factory()->create(['display_name' => 'ABC123', 'external_auth_id' => 'sales, engineering, developers, marketers']);
         $this->assertFalse($user->hasRole($role->id));
 
@@ -45,7 +45,7 @@ class GroupSyncServiceTest extends TestCase
 
     public function test_commas_can_be_used_in_external_auth_id_if_escaped()
     {
-        $user = $this->getViewer();
+        $user = $this->users->viewer();
         $role = Role::factory()->create(['display_name' => 'ABC123', 'external_auth_id' => 'sales\,-developers, marketers']);
         $this->assertFalse($user->hasRole($role->id));
 
@@ -54,4 +54,16 @@ class GroupSyncServiceTest extends TestCase
         $user = User::query()->find($user->id);
         $this->assertTrue($user->hasRole($role->id));
     }
+
+    public function test_external_auth_id_matches_ignoring_case()
+    {
+        $user = $this->users->viewer();
+        $role = Role::factory()->create(['display_name' => 'ABC123', 'external_auth_id' => 'WaRRioRs']);
+        $this->assertFalse($user->hasRole($role->id));
+
+        (new GroupSyncService())->syncUserWithFoundGroups($user, ['wArriors', 'penguiNs'], false);
+
+        $user = User::query()->find($user->id);
+        $this->assertTrue($user->hasRole($role->id));
+    }
 }