]> BookStack Code Mirror - bookstack/blobdiff - tests/Auth/GroupSyncServiceTest.php
Added language list favourites sorting, updated styles
[bookstack] / tests / Auth / GroupSyncServiceTest.php
index ee8dee00826da408fc58616d49e0a1f63f9f50d5..2fad53b261943fc2fb6b8544ae6ab53170700a52 100644 (file)
@@ -9,7 +9,6 @@ use Tests\TestCase;
 
 class GroupSyncServiceTest extends TestCase
 {
-
     public function test_user_is_assigned_to_matching_roles()
     {
         $user = $this->getViewer();
@@ -19,7 +18,7 @@ class GroupSyncServiceTest extends TestCase
         $roleC = Role::factory()->create(['display_name' => 'ABC123', 'external_auth_id' => 'sales']);
         $roleD = Role::factory()->create(['display_name' => 'DEF456', 'external_auth_id' => 'admin-team']);
 
-        foreach([$roleA, $roleB, $roleC, $roleD] as $role) {
+        foreach ([$roleA, $roleB, $roleC, $roleD] as $role) {
             $this->assertFalse($user->hasRole($role->id));
         }
 
@@ -56,4 +55,15 @@ class GroupSyncServiceTest extends TestCase
         $this->assertTrue($user->hasRole($role->id));
     }
 
-}
\ No newline at end of file
+    public function test_external_auth_id_matches_ignoring_case()
+    {
+        $user = $this->getViewer();
+        $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));
+    }
+}