mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-26 15:24:05 +02:00
test: Roles have permissions, not users
This commit is contained in:
parent
c0541d70e9
commit
b2f7c3788d
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
namespace Tests\Icinga;
|
namespace Tests\Icinga;
|
||||||
|
|
||||||
|
use Icinga\Authentication\Role;
|
||||||
use Mockery;
|
use Mockery;
|
||||||
use DateTimeZone;
|
use DateTimeZone;
|
||||||
use Icinga\User;
|
use Icinga\User;
|
||||||
@ -62,14 +63,18 @@ class UserTest extends BaseTestCase
|
|||||||
|
|
||||||
public function testPermissions()
|
public function testPermissions()
|
||||||
{
|
{
|
||||||
$user = new User('test');
|
$role = new Role();
|
||||||
$user->setPermissions(array(
|
$role->setPermissions([
|
||||||
'test',
|
'test',
|
||||||
'test/some/specific',
|
'test/some/specific',
|
||||||
'test/more/*',
|
'test/more/*',
|
||||||
'test/wildcard-with-wildcard/*',
|
'test/wildcard-with-wildcard/*',
|
||||||
'test/even-more/specific-with-wildcard/*'
|
'test/even-more/specific-with-wildcard/*'
|
||||||
));
|
]);
|
||||||
|
|
||||||
|
$user = new User('test');
|
||||||
|
$user->setRoles([$role]);
|
||||||
|
|
||||||
$this->assertTrue($user->can('test'));
|
$this->assertTrue($user->can('test'));
|
||||||
$this->assertTrue($user->can('test/some/specific'));
|
$this->assertTrue($user->can('test/some/specific'));
|
||||||
$this->assertTrue($user->can('test/more/everything'));
|
$this->assertTrue($user->can('test/more/everything'));
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
namespace Tests\Icinga\Web;
|
namespace Tests\Icinga\Web;
|
||||||
|
|
||||||
|
use Icinga\Authentication\Role;
|
||||||
use Mockery;
|
use Mockery;
|
||||||
use Icinga\Test\BaseTestCase;
|
use Icinga\Test\BaseTestCase;
|
||||||
use Icinga\User;
|
use Icinga\User;
|
||||||
@ -47,8 +48,12 @@ class SearchDashboardTest extends BaseTestCase
|
|||||||
|
|
||||||
public function testWhetherSearchLoadsSearchDashletsFromModules()
|
public function testWhetherSearchLoadsSearchDashletsFromModules()
|
||||||
{
|
{
|
||||||
|
$role = new Role();
|
||||||
|
$role->setPermissions(['*']);
|
||||||
|
|
||||||
$user = new User('test');
|
$user = new User('test');
|
||||||
$user->setPermissions(array('*' => '*'));
|
$user->setRoles([$role]);
|
||||||
|
|
||||||
$dashboard = new SearchDashboard();
|
$dashboard = new SearchDashboard();
|
||||||
$dashboard->setUser($user);
|
$dashboard->setUser($user);
|
||||||
$dashboard = $dashboard->search('pending');
|
$dashboard = $dashboard->search('pending');
|
||||||
@ -60,8 +65,12 @@ class SearchDashboardTest extends BaseTestCase
|
|||||||
|
|
||||||
public function testWhetherSearchProvidesHintWhenSearchStringIsEmpty()
|
public function testWhetherSearchProvidesHintWhenSearchStringIsEmpty()
|
||||||
{
|
{
|
||||||
|
$role = new Role();
|
||||||
|
$role->setPermissions(['*']);
|
||||||
|
|
||||||
$user = new User('test');
|
$user = new User('test');
|
||||||
$user->setPermissions(array('*' => '*'));
|
$user->setRoles([$role]);
|
||||||
|
|
||||||
$dashboard = new SearchDashboard();
|
$dashboard = new SearchDashboard();
|
||||||
$dashboard->setUser($user);
|
$dashboard->setUser($user);
|
||||||
$dashboard = $dashboard->search();
|
$dashboard = $dashboard->search();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user