X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/d795af04dfa69fe1fc95f13aa0b0d43f3bdac268..refs/pull/3593/head:/tests/Auth/GroupSyncServiceTest.php diff --git a/tests/Auth/GroupSyncServiceTest.php b/tests/Auth/GroupSyncServiceTest.php index ee8dee008..2fad53b26 100644 --- a/tests/Auth/GroupSyncServiceTest.php +++ b/tests/Auth/GroupSyncServiceTest.php @@ -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)); + } +}