From ab0ba707e7651aeb2b1769f46ef4a0950eef7901 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 b11a1d41f..dcef4a702 100644 --- a/tests/integration/api/users/ListTest.php +++ b/tests/integration/api/users/ListTest.php @@ -9,6 +9,7 @@ namespace Flarum\Tests\integration\api\users; +use Flarum\Group\Permission; use Flarum\Tests\integration\RetrievesAuthorizedUsers; use Flarum\Tests\integration\TestCase; @@ -26,7 +27,9 @@ class ListTest extends TestCase ], 'groups' => [ $this->adminGroup(), + $this->guestGroup(), ], + 'group_permission' => [], 'group_user' => [ ['user_id' => 1, 'group_id' => 1], ], @@ -48,6 +51,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 */