mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-12 14:27:33 -08:00
Normalize the tests between UI and API
Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
parent
3825f5fb61
commit
9f5b264e04
|
@ -96,31 +96,29 @@ class DeleteUserTest extends TestCase
|
|||
->json();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public function testPermissionsForDeletingIfNotInSameCompanyAndNotSuperadmin()
|
||||
{
|
||||
$this->settings->enableMultipleFullCompanySupport();
|
||||
|
||||
[$companyA, $companyB] = Company::factory()->count(2)->create();
|
||||
|
||||
$superUser = $companyA->users()->save(User::factory()->superuser()->make());
|
||||
$userInCompanyA = $companyA->users()->save(User::factory()->deleteUsers()->make());
|
||||
$userInCompanyB = $companyB->users()->save(User::factory()->deleteUsers()->make());
|
||||
$superuser = User::factory()->superuser()->create();
|
||||
$userFromA = User::factory()->deleteUsers()->for($companyA)->create();
|
||||
$userFromB = User::factory()->deleteUsers()->for($companyB)->create();
|
||||
|
||||
|
||||
$this->actingAsForApi($userInCompanyA)
|
||||
->deleteJson(route('api.users.destroy', $userInCompanyB))
|
||||
$this->actingAsForApi($userFromA)
|
||||
->deleteJson(route('api.users.destroy', ['user' => $userFromB->id]))
|
||||
->assertStatus(403)
|
||||
->json();
|
||||
|
||||
$this->actingAsForApi($userInCompanyB)
|
||||
->deleteJson(route('api.users.destroy', $userInCompanyA))
|
||||
$this->actingAsForApi($userFromB)
|
||||
->deleteJson(route('api.users.destroy', ['user' => $userFromA->id]))
|
||||
->assertStatus(403)
|
||||
->json();
|
||||
|
||||
$this->actingAsForApi($superUser)
|
||||
->deleteJson(route('api.users.destroy', $userInCompanyA))
|
||||
$this->actingAsForApi($superuser)
|
||||
->deleteJson(route('api.users.destroy', ['user' => $userFromA->id]))
|
||||
->assertOk()
|
||||
->assertStatus(200)
|
||||
->assertStatusMessageIs('success')
|
||||
|
|
|
@ -57,15 +57,15 @@ class DeleteUserTest extends TestCase
|
|||
[$companyA, $companyB] = Company::factory()->count(2)->create();
|
||||
|
||||
$superuser = User::factory()->superuser()->create();
|
||||
$userFromA = User::factory()->for($companyA)->create();
|
||||
$userFromB = User::factory()->for($companyB)->create();
|
||||
$userFromA = User::factory()->deleteUsers()->for($companyA)->create();
|
||||
$userFromB = User::factory()->deleteUsers()->for($companyB)->create();
|
||||
|
||||
$response = $this->followingRedirects()->actingAs(User::factory()->deleteUsers()->for($companyA)->create())
|
||||
$response = $this->followingRedirects()->actingAs($userFromA)
|
||||
->delete(route('users.destroy', ['user' => $userFromB->id]))
|
||||
->assertStatus(403);
|
||||
$this->followRedirects($response)->assertSee('sad-panda.png');
|
||||
|
||||
$response = $this->actingAs(User::factory()->deleteUsers()->for($companyA)->create())
|
||||
$response = $this->actingAs($userFromB)
|
||||
->delete(route('users.destroy', ['user' => $userFromA->id]))
|
||||
->assertStatus(302)
|
||||
->assertRedirect(route('users.index'));
|
||||
|
|
Loading…
Reference in a new issue