From 18593e0d7d4e528136d8e5965f7e89ad93c477ae Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Sat, 14 Sep 2019 21:23:30 +0200 Subject: [PATCH] Add a test for viewUserList guest permission This test would have failed without commit ea84fc4. Next, I will revert that commit and most of my PR #1854, so we need this test to ensure the API continues to behave as desired. --- tests/integration/api/users/ListTest.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/integration/api/users/ListTest.php b/tests/integration/api/users/ListTest.php index 789caf012..bbae90ecf 100644 --- a/tests/integration/api/users/ListTest.php +++ b/tests/integration/api/users/ListTest.php @@ -11,6 +11,7 @@ namespace Flarum\Tests\integration\api\users; +use Flarum\Group\Permission; use Flarum\Tests\integration\RetrievesAuthorizedUsers; use Flarum\Tests\integration\TestCase; @@ -28,7 +29,9 @@ class ListTest extends TestCase ], 'groups' => [ $this->adminGroup(), + $this->guestGroup(), ], + 'group_permission' => [], 'group_user' => [ ['user_id' => 1, 'group_id' => 1], ], @@ -50,6 +53,25 @@ class ListTest extends TestCase $this->assertEquals(401, $response->getStatusCode()); } + /** + * @test + */ + public function shows_index_for_guest_when_they_have_permission() + { + Permission::unguarded(function () { + Permission::create([ + 'permission' => 'viewUserList', + 'group_id' => 2, + ]); + }); + + $response = $this->send( + $this->request('GET', '/api/users') + ); + + $this->assertEquals(200, $response->getStatusCode()); + } + /** * @test */