Update to Laravel 8
Co-authored-by: Matthew Penner <me@matthewp.io>
This commit is contained in:
parent
028921b42a
commit
a043071e3c
211 changed files with 4394 additions and 2933 deletions
|
@ -32,28 +32,28 @@ class ScheduleAuthorizationTest extends ClientApiIntegrationTestCase
|
|||
|
||||
// Set the API $user as a subuser of server 2, but with no permissions
|
||||
// to do anything with the schedules for that server.
|
||||
factory(Subuser::class)->create(['server_id' => $server2->id, 'user_id' => $user->id]);
|
||||
Subuser::factory()->create(['server_id' => $server2->id, 'user_id' => $user->id]);
|
||||
|
||||
$schedule1 = factory(Schedule::class)->create(['server_id' => $server1->id]);
|
||||
$schedule2 = factory(Schedule::class)->create(['server_id' => $server2->id]);
|
||||
$schedule3 = factory(Schedule::class)->create(['server_id' => $server3->id]);
|
||||
$schedule1 = Schedule::factory()->create(['server_id' => $server1->id]);
|
||||
$schedule2 = Schedule::factory()->create(['server_id' => $server2->id]);
|
||||
$schedule3 = Schedule::factory()->create(['server_id' => $server3->id]);
|
||||
|
||||
// This is the only valid call for this test, accessing the schedule for the same
|
||||
// server that the API user is the owner of.
|
||||
$response = $this->actingAs($user)->json($method, $this->link($server1, "/schedules/" . $schedule1->id . $endpoint));
|
||||
$response = $this->actingAs($user)->json($method, $this->link($server1, '/schedules/' . $schedule1->id . $endpoint));
|
||||
$this->assertTrue($response->status() <= 204 || $response->status() === 400 || $response->status() === 422);
|
||||
|
||||
// This request fails because the schedule is valid for that server but the user
|
||||
// making the request is not authorized to perform that action.
|
||||
$this->actingAs($user)->json($method, $this->link($server2, "/schedules/" . $schedule2->id . $endpoint))->assertForbidden();
|
||||
$this->actingAs($user)->json($method, $this->link($server2, '/schedules/' . $schedule2->id . $endpoint))->assertForbidden();
|
||||
|
||||
// Both of these should report a 404 error due to the schedules being linked to
|
||||
// servers that are not the same as the server in the request, or are assigned
|
||||
// to a server for which the user making the request has no access to.
|
||||
$this->actingAs($user)->json($method, $this->link($server1, "/schedules/" . $schedule2->id . $endpoint))->assertNotFound();
|
||||
$this->actingAs($user)->json($method, $this->link($server1, "/schedules/" . $schedule3->id . $endpoint))->assertNotFound();
|
||||
$this->actingAs($user)->json($method, $this->link($server2, "/schedules/" . $schedule3->id . $endpoint))->assertNotFound();
|
||||
$this->actingAs($user)->json($method, $this->link($server3, "/schedules/" . $schedule3->id . $endpoint))->assertNotFound();
|
||||
$this->actingAs($user)->json($method, $this->link($server1, '/schedules/' . $schedule2->id . $endpoint))->assertNotFound();
|
||||
$this->actingAs($user)->json($method, $this->link($server1, '/schedules/' . $schedule3->id . $endpoint))->assertNotFound();
|
||||
$this->actingAs($user)->json($method, $this->link($server2, '/schedules/' . $schedule3->id . $endpoint))->assertNotFound();
|
||||
$this->actingAs($user)->json($method, $this->link($server3, '/schedules/' . $schedule3->id . $endpoint))->assertNotFound();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -62,11 +62,11 @@ class ScheduleAuthorizationTest extends ClientApiIntegrationTestCase
|
|||
public function methodDataProvider(): array
|
||||
{
|
||||
return [
|
||||
["GET", ""],
|
||||
["POST", ""],
|
||||
["DELETE", ""],
|
||||
["POST", "/execute"],
|
||||
["POST", "/tasks"],
|
||||
['GET', ''],
|
||||
['POST', ''],
|
||||
['DELETE', ''],
|
||||
['POST', '/execute'],
|
||||
['POST', '/tasks'],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue