mirror of
https://github.com/snipe/snipe-it.git
synced 2025-03-05 20:52:15 -08:00
Add authentication and authorization tests for department index method
This commit is contained in:
parent
7c5a1b376e
commit
42055bb69d
|
@ -5,6 +5,7 @@ namespace Tests\Feature\Api\Departments;
|
|||
use App\Models\Company;
|
||||
use App\Models\Department;
|
||||
use App\Models\User;
|
||||
use Illuminate\Routing\Route;
|
||||
use Illuminate\Testing\Fluent\AssertableJson;
|
||||
use Tests\Support\InteractsWithSettings;
|
||||
use Tests\TestCase;
|
||||
|
@ -13,6 +14,18 @@ class DepartmentIndexTest extends TestCase
|
|||
{
|
||||
use InteractsWithSettings;
|
||||
|
||||
public function testViewingDepartmentIndexRequiresAuthentication()
|
||||
{
|
||||
$this->getJson(route('api.departments.index'))->assertRedirect();
|
||||
}
|
||||
|
||||
public function testViewingDepartmentIndexRequiresPermission()
|
||||
{
|
||||
$this->actingAsForApi(User::factory()->create())
|
||||
->getJson(route('api.departments.index'))
|
||||
->assertForbidden();
|
||||
}
|
||||
|
||||
public function testDepartmentIndexReturnsExpectedDepartments()
|
||||
{
|
||||
Department::factory()->count(3)->create();
|
||||
|
|
Loading…
Reference in a new issue