mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-03 15:02:34 +00:00
Add site redirects (#552)
* feat(redirects): add redirects to sites * chore(style): fixed coding style issues * style: fix php-stan docblocks * style: pint cleanup * tests: fixed redirect test suite * feat: vhosts include additional configs * fix: use exact location matching * - add enums - use queues - use vhost rather than separate conf files - vhost formatter - cleanup * generate docs --------- Co-authored-by: Saeed Vaziry <mr.saeedvaziry@gmail.com>
This commit is contained in:
82
tests/Feature/API/RedirectsTest.php
Normal file
82
tests/Feature/API/RedirectsTest.php
Normal file
@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\API;
|
||||
|
||||
use App\Enums\RedirectStatus;
|
||||
use App\Facades\SSH;
|
||||
use App\Models\Redirect;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Laravel\Sanctum\Sanctum;
|
||||
use Tests\TestCase;
|
||||
|
||||
class RedirectsTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_create_redirect(): void
|
||||
{
|
||||
SSH::fake();
|
||||
|
||||
Sanctum::actingAs($this->user, ['read', 'write']);
|
||||
|
||||
$this->json('POST', route('api.projects.servers.sites.redirects.create', [
|
||||
'project' => $this->server->project,
|
||||
'server' => $this->server,
|
||||
'site' => $this->site,
|
||||
]), [
|
||||
'from' => 'testing/path',
|
||||
'to' => 'https://example.com',
|
||||
'mode' => 301,
|
||||
])
|
||||
->assertSuccessful()
|
||||
->assertJsonFragment([
|
||||
'from' => 'testing/path',
|
||||
'to' => 'https://example.com',
|
||||
'mode' => 301,
|
||||
'status' => RedirectStatus::READY,
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_see_redirects_list(): void
|
||||
{
|
||||
Sanctum::actingAs($this->user, ['read']);
|
||||
|
||||
/** @var Redirect $redirect */
|
||||
$redirect = Redirect::factory()->create([
|
||||
'site_id' => $this->site->id,
|
||||
]);
|
||||
|
||||
$this->json('GET', route('api.projects.servers.sites.redirects.index', [
|
||||
'project' => $this->server->project,
|
||||
'server' => $this->server,
|
||||
'site' => $this->site,
|
||||
]))
|
||||
->assertSuccessful()
|
||||
->assertJsonFragment([
|
||||
'from' => $redirect->from,
|
||||
'to' => $redirect->to,
|
||||
'mode' => $redirect->mode,
|
||||
'status' => $redirect->status,
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_delete_redirect(): void
|
||||
{
|
||||
SSH::fake();
|
||||
|
||||
Sanctum::actingAs($this->user, ['write']);
|
||||
|
||||
$this->json('DELETE', route('api.projects.servers.sites.redirects.delete', [
|
||||
'project' => $this->server->project,
|
||||
'server' => $this->server,
|
||||
'site' => $this->site,
|
||||
'redirect' => $this->redirect->id,
|
||||
]))
|
||||
->assertSuccessful()
|
||||
->assertNoContent();
|
||||
|
||||
$this->assertDatabaseMissing('redirects', [
|
||||
'id' => $this->redirect->id,
|
||||
]);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user