mirror of
https://github.com/flarum/framework.git
synced 2024-12-01 05:53:45 +08:00
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.
This commit is contained in:
parent
04b2cf4462
commit
ab0ba707e7
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
namespace Flarum\Tests\integration\api\users;
|
namespace Flarum\Tests\integration\api\users;
|
||||||
|
|
||||||
|
use Flarum\Group\Permission;
|
||||||
use Flarum\Tests\integration\RetrievesAuthorizedUsers;
|
use Flarum\Tests\integration\RetrievesAuthorizedUsers;
|
||||||
use Flarum\Tests\integration\TestCase;
|
use Flarum\Tests\integration\TestCase;
|
||||||
|
|
||||||
|
@ -26,7 +27,9 @@ class ListTest extends TestCase
|
||||||
],
|
],
|
||||||
'groups' => [
|
'groups' => [
|
||||||
$this->adminGroup(),
|
$this->adminGroup(),
|
||||||
|
$this->guestGroup(),
|
||||||
],
|
],
|
||||||
|
'group_permission' => [],
|
||||||
'group_user' => [
|
'group_user' => [
|
||||||
['user_id' => 1, 'group_id' => 1],
|
['user_id' => 1, 'group_id' => 1],
|
||||||
],
|
],
|
||||||
|
@ -48,6 +51,25 @@ class ListTest extends TestCase
|
||||||
$this->assertEquals(401, $response->getStatusCode());
|
$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
|
* @test
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue
Block a user