mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-09 23:24:06 -08:00
Added tests
Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
parent
3df2a4a70b
commit
33d5d5e24f
|
@ -15,7 +15,7 @@ class GroupStoreTest extends TestCase
|
||||||
->assertForbidden();
|
->assertForbidden();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCanStoreGroup()
|
public function testCanStoreGroupWithPermissionsPassed()
|
||||||
{
|
{
|
||||||
$this->actingAsForApi(User::factory()->superuser()->create())
|
$this->actingAsForApi(User::factory()->superuser()->create())
|
||||||
->postJson(route('api.groups.store'), [
|
->postJson(route('api.groups.store'), [
|
||||||
|
@ -35,4 +35,42 @@ class GroupStoreTest extends TestCase
|
||||||
$this->assertEquals('1', $group->decodePermissions()['import']);
|
$this->assertEquals('1', $group->decodePermissions()['import']);
|
||||||
$this->assertEquals('0', $group->decodePermissions()['reports.view']);
|
$this->assertEquals('0', $group->decodePermissions()['reports.view']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testStoringGroupWithoutPermissionPassed()
|
||||||
|
{
|
||||||
|
$superuser = User::factory()->superuser()->create();
|
||||||
|
$this->actingAsForApi($superuser)
|
||||||
|
->postJson(route('api.groups.store'), [
|
||||||
|
'name' => 'My Awesome Group'
|
||||||
|
])
|
||||||
|
->assertOk();
|
||||||
|
|
||||||
|
$group = Group::where('name', 'My Awesome Group')->first();
|
||||||
|
|
||||||
|
$this->assertNotNull($group);
|
||||||
|
|
||||||
|
$this->actingAsForApi($superuser)
|
||||||
|
->getJson(route('api.groups.show', ['group' => $group]))
|
||||||
|
->assertOk();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testStoringGroupWithInvalidPermissionDropsBadPermission()
|
||||||
|
{
|
||||||
|
$this->actingAsForApi(User::factory()->superuser()->create())
|
||||||
|
->postJson(route('api.groups.store'), [
|
||||||
|
'name' => 'My Awesome Group',
|
||||||
|
'permissions' => [
|
||||||
|
'admin' => '1',
|
||||||
|
'snipe_is_awesome' => '1',
|
||||||
|
],
|
||||||
|
])
|
||||||
|
->assertOk();
|
||||||
|
|
||||||
|
$group = Group::where('name', 'My Awesome Group')->first();
|
||||||
|
$this->assertNotNull($group);
|
||||||
|
$this->assertEquals('1', $group->decodePermissions()['admin']);
|
||||||
|
$this->assertNotContains('snipe_is_awesome', $group->decodePermissions());
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue