2019-01-02 04:02:18 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This file is part of Flarum.
|
|
|
|
*
|
2019-11-28 08:16:50 +08:00
|
|
|
* For detailed copyright and license information, please view the
|
|
|
|
* LICENSE file that was distributed with this source code.
|
2019-01-02 04:02:18 +08:00
|
|
|
*/
|
|
|
|
|
2019-09-14 19:09:56 +08:00
|
|
|
namespace Flarum\Tests\integration\api\users;
|
2019-01-02 04:02:18 +08:00
|
|
|
|
2019-09-14 19:09:56 +08:00
|
|
|
use Flarum\Tests\integration\RetrievesAuthorizedUsers;
|
|
|
|
use Flarum\Tests\integration\TestCase;
|
2019-01-02 04:02:18 +08:00
|
|
|
|
2019-09-14 19:09:56 +08:00
|
|
|
class ListTest extends TestCase
|
2019-01-02 04:02:18 +08:00
|
|
|
{
|
2019-09-14 19:09:56 +08:00
|
|
|
use RetrievesAuthorizedUsers;
|
2019-01-02 04:02:18 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @test
|
|
|
|
*/
|
|
|
|
public function disallows_index_for_guest()
|
|
|
|
{
|
2019-09-14 19:09:56 +08:00
|
|
|
$response = $this->send(
|
|
|
|
$this->request('GET', '/api/users')
|
|
|
|
);
|
2019-07-30 06:09:10 +08:00
|
|
|
|
2019-09-15 02:33:23 +08:00
|
|
|
$this->assertEquals(403, $response->getStatusCode());
|
2019-01-02 04:02:18 +08:00
|
|
|
}
|
|
|
|
|
2019-09-15 03:23:30 +08:00
|
|
|
/**
|
|
|
|
* @test
|
|
|
|
*/
|
|
|
|
public function shows_index_for_guest_when_they_have_permission()
|
|
|
|
{
|
2020-05-22 04:34:01 +08:00
|
|
|
$this->prepareDatabase([
|
|
|
|
'group_permission' => [
|
|
|
|
['permission' => 'viewUserList', 'group_id' => 2],
|
|
|
|
],
|
|
|
|
]);
|
2019-09-15 03:23:30 +08:00
|
|
|
|
|
|
|
$response = $this->send(
|
|
|
|
$this->request('GET', '/api/users')
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->assertEquals(200, $response->getStatusCode());
|
|
|
|
}
|
|
|
|
|
2019-01-02 04:02:18 +08:00
|
|
|
/**
|
|
|
|
* @test
|
|
|
|
*/
|
|
|
|
public function shows_index_for_admin()
|
|
|
|
{
|
2019-09-14 19:09:56 +08:00
|
|
|
$response = $this->send(
|
2020-03-21 01:28:28 +08:00
|
|
|
$this->request('GET', '/api/users', [
|
|
|
|
'authenticatedAs' => 1,
|
|
|
|
])
|
2019-09-14 19:09:56 +08:00
|
|
|
);
|
2019-01-02 04:02:18 +08:00
|
|
|
|
|
|
|
$this->assertEquals(200, $response->getStatusCode());
|
|
|
|
}
|
|
|
|
}
|