This commit is contained in:
Saeed Vaziry
2024-10-13 12:33:12 +02:00
parent 386d8e73a7
commit 224e0ac2b0
49 changed files with 3668 additions and 766 deletions

View File

@ -6,7 +6,10 @@
use App\Enums\SslType;
use App\Facades\SSH;
use App\Models\Ssl;
use App\Web\Pages\Servers\Sites\Pages\SSL\Index;
use App\Web\Pages\Servers\Sites\Pages\SSL\Widgets\SslsList;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Livewire\Livewire;
use Tests\TestCase;
class SslTest extends TestCase
@ -21,7 +24,7 @@ public function test_see_ssls_list()
'site_id' => $this->site->id,
]);
$this->get(route('servers.sites.ssl', [
$this->get(Index::getUrl([
'server' => $this->server,
'site' => $this->site,
]))
@ -29,30 +32,20 @@ public function test_see_ssls_list()
->assertSee($ssl->type);
}
public function test_see_ssls_list_with_no_ssls()
{
$this->actingAs($this->user);
$this->get(route('servers.sites.ssl', [
'server' => $this->server,
'site' => $this->site,
]))
->assertSuccessful()
->assertSeeText(__("You don't have any SSL certificates yet!"));
}
public function test_letsencrypt_ssl()
{
SSH::fake('Successfully received certificate');
$this->actingAs($this->user);
$this->post(route('servers.sites.ssl.store', [
Livewire::test(Index::class, [
'server' => $this->server,
'site' => $this->site,
]), [
'type' => SslType::LETSENCRYPT,
])->assertSessionDoesntHaveErrors();
])
->callAction('create', [
'type' => SslType::LETSENCRYPT,
])
->assertSuccessful();
$this->assertDatabaseHas('ssls', [
'site_id' => $this->site->id,
@ -68,13 +61,15 @@ public function test_letsencrypt_ssl_with_aliases()
$this->actingAs($this->user);
$this->post(route('servers.sites.ssl.store', [
Livewire::test(Index::class, [
'server' => $this->server,
'site' => $this->site,
]), [
'type' => SslType::LETSENCRYPT,
'aliases' => '1',
])->assertSessionDoesntHaveErrors();
])
->callAction('create', [
'type' => SslType::LETSENCRYPT,
'aliases' => true,
])
->assertSuccessful();
$this->assertDatabaseHas('ssls', [
'site_id' => $this->site->id,
@ -90,15 +85,17 @@ public function test_custom_ssl()
$this->actingAs($this->user);
$this->post(route('servers.sites.ssl.store', [
Livewire::test(Index::class, [
'server' => $this->server,
'site' => $this->site,
]), [
'type' => SslType::CUSTOM,
'certificate' => 'certificate',
'private' => 'private',
'expires_at' => now()->addYear()->format('Y-m-d'),
])->assertSessionDoesntHaveErrors();
])
->callAction('create', [
'type' => SslType::CUSTOM,
'certificate' => 'certificate',
'private' => 'private',
'expires_at' => now()->addYear()->format('Y-m-d'),
])
->assertSuccessful();
$this->assertDatabaseHas('ssls', [
'site_id' => $this->site->id,
@ -117,11 +114,11 @@ public function test_delete_ssl()
'site_id' => $this->site->id,
]);
$this->delete(route('servers.sites.ssl.destroy', [
'server' => $this->server,
Livewire::test(SslsList::class, [
'site' => $this->site,
'ssl' => $ssl,
]))->assertRedirect();
])
->callTableAction('delete', $ssl->id)
->assertSuccessful();
$this->assertDatabaseMissing('ssls', [
'id' => $ssl->id,