]> BookStack Code Mirror - bookstack/blobdiff - tests/Auth/OidcTest.php
ExportFormatter: Add book description and check for empty book and chapter descriptio...
[bookstack] / tests / Auth / OidcTest.php
index 9bde71c80ef19ff06c9a654b03fae4fa9204c3ea..201f67b533338057e13b405d611d21cd2c1b1ba6 100644 (file)
@@ -849,6 +849,26 @@ class OidcTest extends TestCase
         $this->assertSessionError('Userinfo endpoint response validation failed with error: No valid subject value found in userinfo data');
     }
 
+    public function test_userinfo_endpoint_not_called_if_empty_groups_array_provided_in_id_token()
+    {
+        config()->set([
+            'oidc.user_to_groups'     => true,
+            'oidc.groups_claim'       => 'groups',
+            'oidc.remove_from_groups' => false,
+        ]);
+
+        $this->post('/oidc/login');
+        $state = session()->get('oidc_state');
+        $client = $this->mockHttpClient([$this->getMockAuthorizationResponse([
+            'groups' => [],
+        ])]);
+
+        $resp = $this->get('/oidc/callback?code=SplxlOBeZQQYbYS6WxSbIA&state=' . $state);
+        $resp->assertRedirect('/');
+        $this->assertEquals(1, $client->requestCount());
+        $this->assertTrue(auth()->check());
+    }
+
     protected function withAutodiscovery(): void
     {
         config()->set([