mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-02 22:46:16 +00:00
refactoring (#116)
- refactoring architecture - fix incomplete ssh logs - code editor for scripts in the app - remove Jobs and SSHCommands
This commit is contained in:
@ -2,10 +2,10 @@
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Jobs\Site\UpdateBranch;
|
||||
use App\Enums\DeploymentStatus;
|
||||
use App\Facades\SSH;
|
||||
use App\Models\GitHook;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Bus;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Tests\TestCase;
|
||||
|
||||
@ -47,9 +47,64 @@ public function test_update_deployment_script()
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_deploy(): void
|
||||
{
|
||||
SSH::fake();
|
||||
Http::fake([
|
||||
'github.com/*' => Http::response([
|
||||
'sha' => '123',
|
||||
'commit' => [
|
||||
'message' => 'test commit message',
|
||||
'name' => 'test commit name',
|
||||
'email' => 'test@example.com',
|
||||
'url' => 'https://github.com/commit-url',
|
||||
],
|
||||
], 200),
|
||||
]);
|
||||
|
||||
$this->site->deploymentScript->update([
|
||||
'content' => 'git pull',
|
||||
]);
|
||||
|
||||
$this->actingAs($this->user);
|
||||
|
||||
$response = $this->post(route('servers.sites.application.deploy', [
|
||||
'server' => $this->server,
|
||||
'site' => $this->site,
|
||||
]))->assertSessionDoesntHaveErrors();
|
||||
|
||||
$response->assertSessionHas('toast.type', 'success');
|
||||
$response->assertSessionHas('toast.message', 'Deployment started!');
|
||||
|
||||
$this->assertDatabaseHas('deployments', [
|
||||
'site_id' => $this->site->id,
|
||||
'status' => DeploymentStatus::FINISHED,
|
||||
]);
|
||||
|
||||
SSH::assertExecutedContains('cd /home/vito/'.$this->site->domain);
|
||||
SSH::assertExecutedContains('git pull');
|
||||
|
||||
$this->get(route('servers.sites.show', [
|
||||
'server' => $this->server,
|
||||
'site' => $this->site,
|
||||
]))
|
||||
->assertOk()
|
||||
->assertSee('test commit message');
|
||||
|
||||
$deployment = $this->site->deployments()->first();
|
||||
|
||||
$this->get(route('servers.sites.application.deployment.log', [
|
||||
'server' => $this->server,
|
||||
'site' => $this->site,
|
||||
'deployment' => $deployment,
|
||||
]))
|
||||
->assertRedirect()
|
||||
->assertSessionHas('content', 'fake output');
|
||||
}
|
||||
|
||||
public function test_change_branch()
|
||||
{
|
||||
Bus::fake();
|
||||
SSH::fake();
|
||||
|
||||
$this->actingAs($this->user);
|
||||
|
||||
@ -58,9 +113,14 @@ public function test_change_branch()
|
||||
'site' => $this->site,
|
||||
]), [
|
||||
'branch' => 'master',
|
||||
])->assertSessionDoesntHaveErrors();
|
||||
])
|
||||
->assertSessionDoesntHaveErrors()
|
||||
->assertSessionHas('toast.type', 'success');
|
||||
|
||||
Bus::assertDispatched(UpdateBranch::class);
|
||||
$this->site->refresh();
|
||||
$this->assertEquals('master', $this->site->branch);
|
||||
|
||||
SSH::assertExecutedContains('git checkout -f master');
|
||||
}
|
||||
|
||||
public function test_enable_auto_deployment()
|
||||
@ -68,7 +128,7 @@ public function test_enable_auto_deployment()
|
||||
Http::fake([
|
||||
'github.com/*' => Http::response([
|
||||
'id' => '123',
|
||||
], 201),
|
||||
], 200),
|
||||
]);
|
||||
|
||||
$this->actingAs($this->user);
|
||||
@ -80,18 +140,21 @@ public function test_enable_auto_deployment()
|
||||
|
||||
$this->site->refresh();
|
||||
|
||||
$this->assertTrue($this->site->auto_deployment);
|
||||
$this->assertTrue($this->site->isAutoDeployment());
|
||||
}
|
||||
|
||||
public function test_disable_auto_deployment()
|
||||
{
|
||||
Http::fake([
|
||||
'github.com/*' => Http::response([], 204),
|
||||
'api.github.com/repos/organization/repository' => Http::response([
|
||||
'id' => '123',
|
||||
], 200),
|
||||
'api.github.com/repos/organization/repository/hooks/*' => Http::response([], 204),
|
||||
]);
|
||||
|
||||
$this->actingAs($this->user);
|
||||
|
||||
GitHook::factory()->create([
|
||||
$hook = GitHook::factory()->create([
|
||||
'site_id' => $this->site->id,
|
||||
'source_control_id' => $this->site->source_control_id,
|
||||
]);
|
||||
@ -103,6 +166,22 @@ public function test_disable_auto_deployment()
|
||||
|
||||
$this->site->refresh();
|
||||
|
||||
$this->assertFalse($this->site->auto_deployment);
|
||||
$this->assertFalse($this->site->isAutoDeployment());
|
||||
}
|
||||
|
||||
public function test_update_env_file(): void
|
||||
{
|
||||
SSH::fake();
|
||||
|
||||
$this->actingAs($this->user);
|
||||
|
||||
$this->post(route('servers.sites.application.env', [
|
||||
'server' => $this->server,
|
||||
'site' => $this->site,
|
||||
]), [
|
||||
'env' => 'APP_ENV=production',
|
||||
])->assertSessionDoesntHaveErrors();
|
||||
|
||||
SSH::assertExecutedContains('echo "APP_ENV=production" | tee /home/vito/'.$this->site->domain.'/.env');
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,6 @@
|
||||
namespace Tests\Feature\Auth;
|
||||
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use JsonException;
|
||||
use Tests\TestCase;
|
||||
|
||||
class PasswordConfirmationTest extends TestCase
|
||||
@ -19,9 +18,6 @@ public function test_confirm_password_screen_can_be_rendered(): void
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws JsonException
|
||||
*/
|
||||
public function test_password_can_be_confirmed(): void
|
||||
{
|
||||
$this->actingAs($this->user);
|
||||
@ -31,7 +27,7 @@ public function test_password_can_be_confirmed(): void
|
||||
]);
|
||||
|
||||
$response->assertRedirect();
|
||||
$response->assertSessionHasNoErrors();
|
||||
$response->assertSessionDoesntHaveErrors();
|
||||
}
|
||||
|
||||
public function test_password_is_not_confirmed_with_invalid_password(): void
|
||||
|
@ -56,7 +56,7 @@ public function test_password_can_be_reset_with_valid_token(): void
|
||||
'password_confirmation' => 'password',
|
||||
]);
|
||||
|
||||
$response->assertSessionHasNoErrors();
|
||||
$response->assertSessionDoesntHaveErrors();
|
||||
|
||||
return true;
|
||||
});
|
||||
|
@ -22,7 +22,7 @@ public function test_see_cronjobs_list()
|
||||
]);
|
||||
|
||||
$this->get(route('servers.cronjobs', $this->server))
|
||||
->assertSeeText($cronjob->frequency_label);
|
||||
->assertSeeText($cronjob->frequencyLabel());
|
||||
}
|
||||
|
||||
public function test_delete_cronjob()
|
||||
@ -34,16 +34,20 @@ public function test_delete_cronjob()
|
||||
/** @var CronJob $cronjob */
|
||||
$cronjob = CronJob::factory()->create([
|
||||
'server_id' => $this->server->id,
|
||||
'user' => 'vito',
|
||||
]);
|
||||
|
||||
$this->delete(route('servers.cronjobs.destroy', [
|
||||
'server' => $this->server,
|
||||
'cronJob' => $cronjob,
|
||||
]))->assertSessionHasNoErrors();
|
||||
]))->assertSessionDoesntHaveErrors();
|
||||
|
||||
$this->assertDatabaseMissing('cron_jobs', [
|
||||
'id' => $cronjob->id,
|
||||
]);
|
||||
|
||||
SSH::assertExecutedContains("echo '' | sudo -u vito crontab -");
|
||||
SSH::assertExecutedContains('sudo -u vito crontab -l');
|
||||
}
|
||||
|
||||
public function test_create_cronjob()
|
||||
@ -56,7 +60,7 @@ public function test_create_cronjob()
|
||||
'command' => 'ls -la',
|
||||
'user' => 'vito',
|
||||
'frequency' => '* * * * *',
|
||||
])->assertSessionHasNoErrors();
|
||||
])->assertSessionDoesntHaveErrors();
|
||||
|
||||
$this->assertDatabaseHas('cron_jobs', [
|
||||
'server_id' => $this->server->id,
|
||||
@ -65,5 +69,33 @@ public function test_create_cronjob()
|
||||
'frequency' => '* * * * *',
|
||||
'status' => CronjobStatus::READY,
|
||||
]);
|
||||
|
||||
SSH::assertExecutedContains("echo '* * * * * ls -la' | sudo -u vito crontab -");
|
||||
SSH::assertExecutedContains('sudo -u vito crontab -l');
|
||||
}
|
||||
|
||||
public function test_create_custom_cronjob()
|
||||
{
|
||||
SSH::fake();
|
||||
|
||||
$this->actingAs($this->user);
|
||||
|
||||
$this->post(route('servers.cronjobs.store', $this->server), [
|
||||
'command' => 'ls -la',
|
||||
'user' => 'vito',
|
||||
'frequency' => 'custom',
|
||||
'custom' => '* * * 1 1',
|
||||
])->assertSessionDoesntHaveErrors();
|
||||
|
||||
$this->assertDatabaseHas('cron_jobs', [
|
||||
'server_id' => $this->server->id,
|
||||
'command' => 'ls -la',
|
||||
'user' => 'vito',
|
||||
'frequency' => '* * * 1 1',
|
||||
'status' => CronjobStatus::READY,
|
||||
]);
|
||||
|
||||
SSH::assertExecutedContains("echo '* * * 1 1 ls -la' | sudo -u vito crontab -");
|
||||
SSH::assertExecutedContains('sudo -u vito crontab -l');
|
||||
}
|
||||
}
|
||||
|
@ -2,14 +2,14 @@
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Enums\BackupFileStatus;
|
||||
use App\Enums\BackupStatus;
|
||||
use App\Facades\SSH;
|
||||
use App\Jobs\Backup\RunBackup;
|
||||
use App\Models\Backup;
|
||||
use App\Models\Database;
|
||||
use App\Models\StorageProvider;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Bus;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Tests\TestCase;
|
||||
|
||||
class DatabaseBackupTest extends TestCase
|
||||
@ -18,12 +18,11 @@ class DatabaseBackupTest extends TestCase
|
||||
|
||||
public function test_create_backup(): void
|
||||
{
|
||||
SSH::fake();
|
||||
Http::fake();
|
||||
|
||||
$this->actingAs($this->user);
|
||||
|
||||
Bus::fake();
|
||||
|
||||
SSH::fake()->outputShouldBe('test');
|
||||
|
||||
$database = Database::factory()->create([
|
||||
'server_id' => $this->server,
|
||||
]);
|
||||
@ -38,13 +37,15 @@ public function test_create_backup(): void
|
||||
'backup_storage' => $storage->id,
|
||||
'backup_interval' => '0 * * * *',
|
||||
'backup_keep' => '10',
|
||||
])->assertSessionHasNoErrors();
|
||||
|
||||
Bus::assertDispatched(RunBackup::class);
|
||||
])->assertSessionDoesntHaveErrors();
|
||||
|
||||
$this->assertDatabaseHas('backups', [
|
||||
'status' => BackupStatus::RUNNING,
|
||||
]);
|
||||
|
||||
$this->assertDatabaseHas('backup_files', [
|
||||
'status' => BackupFileStatus::CREATED,
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_see_backups_list(): void
|
||||
@ -70,7 +71,7 @@ public function test_see_backups_list(): void
|
||||
->assertSee($backup->database->name);
|
||||
}
|
||||
|
||||
public function test_delete_database(): void
|
||||
public function test_delete_backup(): void
|
||||
{
|
||||
$this->actingAs($this->user);
|
||||
|
||||
@ -90,7 +91,7 @@ public function test_delete_database(): void
|
||||
]);
|
||||
|
||||
$this->delete(route('servers.databases.backups.destroy', [$this->server, $backup]))
|
||||
->assertSessionHasNoErrors();
|
||||
->assertSessionDoesntHaveErrors();
|
||||
|
||||
$this->assertDatabaseMissing('backups', [
|
||||
'id' => $backup->id,
|
||||
|
@ -16,11 +16,11 @@ public function test_create_database(): void
|
||||
{
|
||||
$this->actingAs($this->user);
|
||||
|
||||
SSH::fake()->outputShouldBe('test');
|
||||
SSH::fake();
|
||||
|
||||
$this->post(route('servers.databases.store', $this->server), [
|
||||
'name' => 'database',
|
||||
])->assertSessionHasNoErrors();
|
||||
])->assertSessionDoesntHaveErrors();
|
||||
|
||||
$this->assertDatabaseHas('databases', [
|
||||
'name' => 'database',
|
||||
@ -44,14 +44,14 @@ public function test_delete_database(): void
|
||||
{
|
||||
$this->actingAs($this->user);
|
||||
|
||||
SSH::fake()->outputShouldBe('test');
|
||||
SSH::fake();
|
||||
|
||||
$database = Database::factory()->create([
|
||||
'server_id' => $this->server,
|
||||
]);
|
||||
|
||||
$this->delete(route('servers.databases.destroy', [$this->server, $database]))
|
||||
->assertSessionHasNoErrors();
|
||||
->assertSessionDoesntHaveErrors();
|
||||
|
||||
$this->assertDatabaseMissing('databases', [
|
||||
'id' => $database->id,
|
||||
|
@ -21,7 +21,7 @@ public function test_create_database_user(): void
|
||||
$this->post(route('servers.databases.users.store', $this->server), [
|
||||
'username' => 'user',
|
||||
'password' => 'password',
|
||||
])->assertSessionHasNoErrors();
|
||||
])->assertSessionDoesntHaveErrors();
|
||||
|
||||
$this->assertDatabaseHas('database_users', [
|
||||
'username' => 'user',
|
||||
@ -52,7 +52,7 @@ public function test_delete_database_user(): void
|
||||
]);
|
||||
|
||||
$this->delete(route('servers.databases.users.destroy', [$this->server, $databaseUser]))
|
||||
->assertSessionHasNoErrors();
|
||||
->assertSessionDoesntHaveErrors();
|
||||
|
||||
$this->assertDatabaseMissing('database_users', [
|
||||
'id' => $databaseUser->id,
|
||||
|
@ -24,7 +24,7 @@ public function test_create_firewall_rule(): void
|
||||
'port' => '1234',
|
||||
'source' => '0.0.0.0',
|
||||
'mask' => '0',
|
||||
])->assertSessionHasNoErrors();
|
||||
])->assertSessionDoesntHaveErrors();
|
||||
|
||||
$this->assertDatabaseHas('firewall_rules', [
|
||||
'port' => '1234',
|
||||
@ -58,7 +58,7 @@ public function test_delete_firewall_rule(): void
|
||||
$this->delete(route('servers.firewall.destroy', [
|
||||
'server' => $this->server,
|
||||
'firewallRule' => $rule,
|
||||
]))->assertSessionHasNoErrors();
|
||||
]))->assertSessionDoesntHaveErrors();
|
||||
|
||||
$this->assertDatabaseMissing('firewall_rules', [
|
||||
'id' => $rule->id,
|
||||
|
@ -6,7 +6,6 @@
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Foundation\Testing\WithFaker;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use JsonException;
|
||||
use Tests\TestCase;
|
||||
|
||||
class NotificationChannelsTest extends TestCase
|
||||
@ -14,9 +13,6 @@ class NotificationChannelsTest extends TestCase
|
||||
use RefreshDatabase;
|
||||
use WithFaker;
|
||||
|
||||
/**
|
||||
* @throws JsonException
|
||||
*/
|
||||
public function test_add_email_channel(): void
|
||||
{
|
||||
$this->actingAs($this->user);
|
||||
@ -25,7 +21,7 @@ public function test_add_email_channel(): void
|
||||
'provider' => NotificationChannel::EMAIL,
|
||||
'email' => 'email@example.com',
|
||||
'label' => 'Email',
|
||||
])->assertSessionHasNoErrors();
|
||||
])->assertSessionDoesntHaveErrors();
|
||||
|
||||
/** @var \App\Models\NotificationChannel $channel */
|
||||
$channel = \App\Models\NotificationChannel::query()
|
||||
@ -36,9 +32,6 @@ public function test_add_email_channel(): void
|
||||
$this->assertTrue($channel->connected);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws JsonException
|
||||
*/
|
||||
public function test_add_slack_channel(): void
|
||||
{
|
||||
$this->actingAs($this->user);
|
||||
@ -49,7 +42,7 @@ public function test_add_slack_channel(): void
|
||||
'provider' => NotificationChannel::SLACK,
|
||||
'webhook_url' => 'https://hooks.slack.com/services/123/token',
|
||||
'label' => 'Slack',
|
||||
])->assertSessionHasNoErrors();
|
||||
])->assertSessionDoesntHaveErrors();
|
||||
|
||||
/** @var \App\Models\NotificationChannel $channel */
|
||||
$channel = \App\Models\NotificationChannel::query()
|
||||
@ -60,9 +53,6 @@ public function test_add_slack_channel(): void
|
||||
$this->assertTrue($channel->connected);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws JsonException
|
||||
*/
|
||||
public function test_add_discord_channel(): void
|
||||
{
|
||||
$this->actingAs($this->user);
|
||||
@ -73,7 +63,7 @@ public function test_add_discord_channel(): void
|
||||
'provider' => NotificationChannel::DISCORD,
|
||||
'webhook_url' => 'https://discord.com/api/webhooks/123/token',
|
||||
'label' => 'Discord',
|
||||
])->assertSessionHasNoErrors();
|
||||
])->assertSessionDoesntHaveErrors();
|
||||
|
||||
/** @var \App\Models\NotificationChannel $channel */
|
||||
$channel = \App\Models\NotificationChannel::query()
|
||||
@ -87,9 +77,7 @@ public function test_add_discord_channel(): void
|
||||
/*
|
||||
* @TODO fix json comparison
|
||||
*/
|
||||
/**
|
||||
* @throws JsonException
|
||||
*/
|
||||
|
||||
public function test_add_telegram_channel(): void
|
||||
{
|
||||
$this->actingAs($this->user);
|
||||
@ -101,7 +89,7 @@ public function test_add_telegram_channel(): void
|
||||
'bot_token' => 'token',
|
||||
'chat_id' => '123',
|
||||
'label' => 'Telegram',
|
||||
])->assertSessionHasNoErrors();
|
||||
])->assertSessionDoesntHaveErrors();
|
||||
|
||||
/** @var \App\Models\NotificationChannel $channel */
|
||||
$channel = \App\Models\NotificationChannel::query()
|
||||
@ -123,9 +111,6 @@ public function test_see_channels_list(): void
|
||||
->assertSee($channel->provider);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws JsonException
|
||||
*/
|
||||
public function test_delete_channel(): void
|
||||
{
|
||||
$this->actingAs($this->user);
|
||||
@ -133,7 +118,7 @@ public function test_delete_channel(): void
|
||||
$channel = \App\Models\NotificationChannel::factory()->create();
|
||||
|
||||
$this->delete(route('notification-channels.delete', $channel->id))
|
||||
->assertSessionHasNoErrors();
|
||||
->assertSessionDoesntHaveErrors();
|
||||
|
||||
$this->assertDatabaseMissing('notification_channels', [
|
||||
'id' => $channel->id,
|
||||
|
@ -3,12 +3,9 @@
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Enums\ServiceStatus;
|
||||
use App\Jobs\Installation\InstallPHP;
|
||||
use App\Jobs\Installation\UninstallPHP;
|
||||
use App\Jobs\PHP\InstallPHPExtension;
|
||||
use App\Facades\SSH;
|
||||
use App\Models\Service;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Bus;
|
||||
use Tests\TestCase;
|
||||
|
||||
class PHPTest extends TestCase
|
||||
@ -17,21 +14,26 @@ class PHPTest extends TestCase
|
||||
|
||||
public function test_install_new_php(): void
|
||||
{
|
||||
Bus::fake();
|
||||
SSH::fake();
|
||||
|
||||
$this->actingAs($this->user);
|
||||
|
||||
$this->post(route('servers.php.install', [
|
||||
'server' => $this->server,
|
||||
'version' => '8.1',
|
||||
]))->assertSessionHasNoErrors();
|
||||
]))->assertSessionDoesntHaveErrors();
|
||||
|
||||
Bus::assertDispatched(InstallPHP::class);
|
||||
$this->assertDatabaseHas('services', [
|
||||
'server_id' => $this->server->id,
|
||||
'type' => 'php',
|
||||
'version' => '8.1',
|
||||
'status' => ServiceStatus::READY,
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_uninstall_php(): void
|
||||
{
|
||||
Bus::fake();
|
||||
SSH::fake();
|
||||
|
||||
$this->actingAs($this->user);
|
||||
|
||||
@ -52,9 +54,11 @@ public function test_uninstall_php(): void
|
||||
$this->delete(route('servers.php.uninstall', [
|
||||
'server' => $this->server,
|
||||
'version' => '8.1',
|
||||
]))->assertSessionHasNoErrors();
|
||||
]))->assertSessionDoesntHaveErrors();
|
||||
|
||||
Bus::assertDispatched(UninstallPHP::class);
|
||||
$this->assertDatabaseMissing('services', [
|
||||
'id' => $php->id,
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_cannot_uninstall_php(): void
|
||||
@ -69,6 +73,8 @@ public function test_cannot_uninstall_php(): void
|
||||
|
||||
public function test_change_default_php_cli(): void
|
||||
{
|
||||
SSH::fake();
|
||||
|
||||
$this->actingAs($this->user);
|
||||
|
||||
$php = Service::factory()->create([
|
||||
@ -85,7 +91,7 @@ public function test_change_default_php_cli(): void
|
||||
$this->post(route('servers.php.default-cli', [
|
||||
'server' => $this->server,
|
||||
'version' => '8.1',
|
||||
]))->assertSessionHasNoErrors();
|
||||
]))->assertSessionDoesntHaveErrors();
|
||||
|
||||
$php->refresh();
|
||||
|
||||
@ -94,7 +100,7 @@ public function test_change_default_php_cli(): void
|
||||
|
||||
public function test_install_extension(): void
|
||||
{
|
||||
Bus::fake();
|
||||
SSH::fake('output... [PHP Modules] gmp');
|
||||
|
||||
$this->actingAs($this->user);
|
||||
|
||||
@ -102,14 +108,16 @@ public function test_install_extension(): void
|
||||
'server' => $this->server,
|
||||
'version' => '8.2',
|
||||
'extension' => 'gmp',
|
||||
]))->assertSessionHasNoErrors();
|
||||
]))->assertSessionDoesntHaveErrors();
|
||||
|
||||
Bus::assertDispatched(InstallPHPExtension::class);
|
||||
$php = $this->server->php('8.2');
|
||||
|
||||
$this->assertContains('gmp', $php->type_data['extensions']);
|
||||
}
|
||||
|
||||
public function test_extension_already_installed(): void
|
||||
{
|
||||
Bus::fake();
|
||||
SSH::fake();
|
||||
|
||||
$this->actingAs($this->user);
|
||||
|
||||
@ -126,7 +134,5 @@ public function test_extension_already_installed(): void
|
||||
'version' => '8.2',
|
||||
'extension' => 'gmp',
|
||||
]))->assertSessionHasErrors();
|
||||
|
||||
Bus::assertNotDispatched(InstallPHPExtension::class);
|
||||
}
|
||||
}
|
||||
|
@ -4,23 +4,19 @@
|
||||
|
||||
use App\Models\Project;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use JsonException;
|
||||
use Tests\TestCase;
|
||||
|
||||
class ProjectsTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
/**
|
||||
* @throws JsonException
|
||||
*/
|
||||
public function test_create_project(): void
|
||||
{
|
||||
$this->actingAs($this->user);
|
||||
|
||||
$this->post(route('projects.create'), [
|
||||
'name' => 'test',
|
||||
])->assertSessionHasNoErrors();
|
||||
])->assertSessionDoesntHaveErrors();
|
||||
|
||||
$this->assertDatabaseHas('projects', [
|
||||
'name' => 'test',
|
||||
@ -39,9 +35,6 @@ public function test_see_projects_list(): void
|
||||
->assertSee($project->name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws JsonException
|
||||
*/
|
||||
public function test_delete_project(): void
|
||||
{
|
||||
$this->actingAs($this->user);
|
||||
@ -51,16 +44,13 @@ public function test_delete_project(): void
|
||||
]);
|
||||
|
||||
$this->delete(route('projects.delete', $project))
|
||||
->assertSessionHasNoErrors();
|
||||
->assertSessionDoesntHaveErrors();
|
||||
|
||||
$this->assertDatabaseMissing('projects', [
|
||||
'id' => $project->id,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws JsonException
|
||||
*/
|
||||
public function test_edit_project(): void
|
||||
{
|
||||
$this->actingAs($this->user);
|
||||
@ -71,7 +61,7 @@ public function test_edit_project(): void
|
||||
|
||||
$this->post(route('projects.update', $project), [
|
||||
'name' => 'new-name',
|
||||
])->assertSessionHasNoErrors();
|
||||
])->assertSessionDoesntHaveErrors();
|
||||
|
||||
$this->assertDatabaseHas('projects', [
|
||||
'id' => $project->id,
|
||||
|
@ -3,6 +3,7 @@
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Enums\QueueStatus;
|
||||
use App\Facades\SSH;
|
||||
use App\Models\Queue;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
@ -32,6 +33,8 @@ public function test_see_queues()
|
||||
|
||||
public function test_delete_queue()
|
||||
{
|
||||
SSH::fake();
|
||||
|
||||
$this->actingAs($this->user);
|
||||
|
||||
$queue = Queue::factory()->create([
|
||||
@ -47,14 +50,15 @@ public function test_delete_queue()
|
||||
])
|
||||
)->assertRedirect();
|
||||
|
||||
$this->assertDatabaseHas('queues', [
|
||||
$this->assertDatabaseMissing('queues', [
|
||||
'id' => $queue->id,
|
||||
'status' => QueueStatus::DELETING,
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_create_queue()
|
||||
{
|
||||
SSH::fake();
|
||||
|
||||
$this->actingAs($this->user);
|
||||
|
||||
$this->post(
|
||||
@ -79,7 +83,7 @@ public function test_create_queue()
|
||||
'auto_start' => 1,
|
||||
'auto_restart' => 1,
|
||||
'numprocs' => 1,
|
||||
'status' => QueueStatus::CREATING,
|
||||
'status' => QueueStatus::RUNNING,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -3,11 +3,9 @@
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Enums\SshKeyStatus;
|
||||
use App\Jobs\SshKey\DeleteSshKeyFromServer;
|
||||
use App\Jobs\SshKey\DeploySshKeyToServer;
|
||||
use App\Facades\SSH;
|
||||
use App\Models\SshKey;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Bus;
|
||||
use Tests\TestCase;
|
||||
|
||||
class ServerKeysTest extends TestCase
|
||||
@ -34,7 +32,7 @@ public function test_see_server_keys()
|
||||
|
||||
public function test_delete_ssh_key()
|
||||
{
|
||||
Bus::fake();
|
||||
SSH::fake();
|
||||
|
||||
$this->actingAs($this->user);
|
||||
|
||||
@ -50,18 +48,15 @@ public function test_delete_ssh_key()
|
||||
|
||||
$this->delete(route('servers.ssh-keys.destroy', [$this->server, $sshKey]));
|
||||
|
||||
$this->assertDatabaseHas('server_ssh_keys', [
|
||||
$this->assertDatabaseMissing('server_ssh_keys', [
|
||||
'server_id' => $this->server->id,
|
||||
'ssh_key_id' => $sshKey->id,
|
||||
'status' => SshKeyStatus::DELETING,
|
||||
]);
|
||||
|
||||
Bus::assertDispatched(DeleteSshKeyFromServer::class);
|
||||
}
|
||||
|
||||
public function test_add_new_ssh_key()
|
||||
{
|
||||
Bus::fake();
|
||||
SSH::fake();
|
||||
|
||||
$this->actingAs($this->user);
|
||||
|
||||
@ -72,15 +67,13 @@ public function test_add_new_ssh_key()
|
||||
|
||||
$this->assertDatabaseHas('server_ssh_keys', [
|
||||
'server_id' => $this->server->id,
|
||||
'status' => SshKeyStatus::ADDING,
|
||||
'status' => SshKeyStatus::ADDED,
|
||||
]);
|
||||
|
||||
Bus::assertDispatched(DeploySshKeyToServer::class);
|
||||
}
|
||||
|
||||
public function test_add_existing_key()
|
||||
{
|
||||
Bus::fake();
|
||||
SSH::fake();
|
||||
|
||||
$this->actingAs($this->user);
|
||||
|
||||
@ -96,9 +89,7 @@ public function test_add_existing_key()
|
||||
|
||||
$this->assertDatabaseHas('server_ssh_keys', [
|
||||
'server_id' => $this->server->id,
|
||||
'status' => SshKeyStatus::ADDING,
|
||||
'status' => SshKeyStatus::ADDED,
|
||||
]);
|
||||
|
||||
Bus::assertDispatched(DeploySshKeyToServer::class);
|
||||
}
|
||||
}
|
||||
|
@ -5,16 +5,12 @@
|
||||
use App\Enums\ServerProvider;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use JsonException;
|
||||
use Tests\TestCase;
|
||||
|
||||
class ServerProvidersTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
/**
|
||||
* @throws JsonException
|
||||
*/
|
||||
public function test_connect_hetzner(): void
|
||||
{
|
||||
$this->actingAs($this->user);
|
||||
@ -25,7 +21,7 @@ public function test_connect_hetzner(): void
|
||||
'provider' => ServerProvider::HETZNER,
|
||||
'name' => 'profile',
|
||||
'token' => 'token',
|
||||
])->assertSessionHasNoErrors();
|
||||
])->assertSessionDoesntHaveErrors();
|
||||
|
||||
$this->assertDatabaseHas('server_providers', [
|
||||
'provider' => ServerProvider::HETZNER,
|
||||
@ -45,9 +41,6 @@ public function test_see_providers_list(): void
|
||||
->assertSee($provider->profile);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws JsonException
|
||||
*/
|
||||
public function test_delete_provider(): void
|
||||
{
|
||||
$this->actingAs($this->user);
|
||||
@ -57,7 +50,7 @@ public function test_delete_provider(): void
|
||||
]);
|
||||
|
||||
$this->delete(route('server-providers.delete', $provider->id))
|
||||
->assertSessionHasNoErrors();
|
||||
->assertSessionDoesntHaveErrors();
|
||||
|
||||
$this->assertDatabaseMissing('server_providers', [
|
||||
'id' => $provider->id,
|
||||
|
@ -7,11 +7,10 @@
|
||||
use App\Enums\ServerProvider;
|
||||
use App\Enums\ServerStatus;
|
||||
use App\Enums\ServerType;
|
||||
use App\Enums\ServiceStatus;
|
||||
use App\Enums\Webserver;
|
||||
use App\Jobs\Installation\Initialize;
|
||||
use App\Facades\SSH;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Bus;
|
||||
use JsonException;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
@ -21,14 +20,11 @@ class ServerTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
/**
|
||||
* @throws JsonException
|
||||
*/
|
||||
public function test_create_custom_server(): void
|
||||
{
|
||||
$this->actingAs($this->user);
|
||||
|
||||
Bus::fake();
|
||||
SSH::fake('Active: active'); // fake output for service installations
|
||||
|
||||
$this->post(route('servers.create'), [
|
||||
'type' => ServerType::REGULAR,
|
||||
@ -40,14 +36,57 @@ public function test_create_custom_server(): void
|
||||
'webserver' => Webserver::NGINX,
|
||||
'database' => Database::MYSQL80,
|
||||
'php' => '8.2',
|
||||
])->assertSessionHasNoErrors();
|
||||
])->assertSessionDoesntHaveErrors();
|
||||
|
||||
$this->assertDatabaseHas('servers', [
|
||||
'name' => 'test',
|
||||
'ip' => '1.1.1.1',
|
||||
'status' => ServerStatus::INSTALLING,
|
||||
'status' => ServerStatus::READY,
|
||||
]);
|
||||
|
||||
Bus::assertDispatched(Initialize::class);
|
||||
$this->assertDatabaseHas('services', [
|
||||
'server_id' => 1,
|
||||
'type' => 'php',
|
||||
'version' => '8.2',
|
||||
'status' => ServiceStatus::READY,
|
||||
]);
|
||||
|
||||
$this->assertDatabaseHas('services', [
|
||||
'server_id' => 1,
|
||||
'type' => 'webserver',
|
||||
'name' => 'nginx',
|
||||
'version' => 'latest',
|
||||
'status' => ServiceStatus::READY,
|
||||
]);
|
||||
|
||||
$this->assertDatabaseHas('services', [
|
||||
'server_id' => 1,
|
||||
'type' => 'database',
|
||||
'name' => 'mysql',
|
||||
'version' => '8.0',
|
||||
'status' => ServiceStatus::READY,
|
||||
]);
|
||||
|
||||
$this->assertDatabaseHas('services', [
|
||||
'server_id' => 1,
|
||||
'type' => 'firewall',
|
||||
'name' => 'ufw',
|
||||
'version' => 'latest',
|
||||
'status' => ServiceStatus::READY,
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_delete_server(): void
|
||||
{
|
||||
$this->actingAs($this->user);
|
||||
|
||||
SSH::fake();
|
||||
|
||||
$this->delete(route('servers.delete', $this->server))
|
||||
->assertSessionDoesntHaveErrors();
|
||||
|
||||
$this->assertDatabaseMissing('servers', [
|
||||
'id' => $this->server->id,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -3,12 +3,8 @@
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Enums\ServiceStatus;
|
||||
use App\Jobs\Installation\InstallPHPMyAdmin as InstallationInstallPHPMyAdmin;
|
||||
use App\Jobs\Installation\UninstallPHPMyAdmin;
|
||||
use App\Jobs\Service\Manage;
|
||||
use App\Models\Service;
|
||||
use App\Facades\SSH;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Bus;
|
||||
use Tests\TestCase;
|
||||
|
||||
class ServicesTest extends TestCase
|
||||
@ -36,14 +32,16 @@ public function test_restart_service(string $name): void
|
||||
|
||||
$service = $this->server->services()->where('name', $name)->firstOrFail();
|
||||
|
||||
Bus::fake();
|
||||
SSH::fake('Active: active');
|
||||
|
||||
$this->get(route('servers.services.restart', [
|
||||
'server' => $this->server,
|
||||
'service' => $service,
|
||||
]))->assertSessionHasNoErrors();
|
||||
]))->assertSessionDoesntHaveErrors();
|
||||
|
||||
Bus::assertDispatched(Manage::class);
|
||||
$service->refresh();
|
||||
|
||||
$this->assertEquals(ServiceStatus::READY, $service->status);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -53,16 +51,18 @@ public function test_stop_service(string $name): void
|
||||
{
|
||||
$this->actingAs($this->user);
|
||||
|
||||
$service = $this->server->services()->where('name', $name)->first();
|
||||
$service = $this->server->services()->where('name', $name)->firstOrFail();
|
||||
|
||||
Bus::fake();
|
||||
SSH::fake('Active: inactive');
|
||||
|
||||
$this->get(route('servers.services.stop', [
|
||||
'server' => $this->server,
|
||||
'service' => $service,
|
||||
]))->assertSessionHasNoErrors();
|
||||
]))->assertSessionDoesntHaveErrors();
|
||||
|
||||
Bus::assertDispatched(Manage::class);
|
||||
$service->refresh();
|
||||
|
||||
$this->assertEquals(ServiceStatus::STOPPED, $service->status);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -72,52 +72,81 @@ public function test_start_service(string $name): void
|
||||
{
|
||||
$this->actingAs($this->user);
|
||||
|
||||
$service = $this->server->services()->where('name', $name)->first();
|
||||
$service = $this->server->services()->where('name', $name)->firstOrFail();
|
||||
|
||||
$service->status = ServiceStatus::STOPPED;
|
||||
$service->save();
|
||||
|
||||
Bus::fake();
|
||||
SSH::fake('Active: active');
|
||||
|
||||
$this->get(route('servers.services.start', [
|
||||
'server' => $this->server,
|
||||
'service' => $service,
|
||||
]))->assertSessionHasNoErrors();
|
||||
]))->assertSessionDoesntHaveErrors();
|
||||
|
||||
Bus::assertDispatched(Manage::class);
|
||||
$service->refresh();
|
||||
|
||||
$this->assertEquals(ServiceStatus::READY, $service->status);
|
||||
}
|
||||
|
||||
public function test_install_phpmyadmin(): void
|
||||
/**
|
||||
* @dataProvider data
|
||||
*/
|
||||
public function test_failed_to_start_service(string $name): void
|
||||
{
|
||||
$this->markTestSkipped('PHPMyAdmin is depricated');
|
||||
$this->actingAs($this->user);
|
||||
|
||||
Bus::fake();
|
||||
$service = $this->server->services()->where('name', $name)->firstOrFail();
|
||||
|
||||
Bus::assertDispatched(InstallationInstallPHPMyAdmin::class);
|
||||
SSH::fake('Active: inactive');
|
||||
|
||||
$this->get(route('servers.services.start', [
|
||||
'server' => $this->server,
|
||||
'service' => $service,
|
||||
]))->assertSessionDoesntHaveErrors();
|
||||
|
||||
$service->refresh();
|
||||
|
||||
$this->assertEquals(ServiceStatus::FAILED, $service->status);
|
||||
}
|
||||
|
||||
public function test_uninstall_phpmyadmin(): void
|
||||
/**
|
||||
* @dataProvider data
|
||||
*/
|
||||
public function test_failed_to_restart_service(string $name): void
|
||||
{
|
||||
$this->markTestSkipped('PHPMyAdmin is depricated');
|
||||
$this->actingAs($this->user);
|
||||
|
||||
$service = Service::factory()->create([
|
||||
'server_id' => $this->server->id,
|
||||
'type' => 'phpmyadmin',
|
||||
'type_data' => [
|
||||
'allowed_ip' => '0.0.0.0',
|
||||
'port' => '5433',
|
||||
'php' => '8.1',
|
||||
],
|
||||
'name' => 'phpmyadmin',
|
||||
'version' => '5.1.2',
|
||||
'status' => ServiceStatus::READY,
|
||||
'is_default' => 1,
|
||||
$service = $this->server->services()->where('name', $name)->firstOrFail();
|
||||
|
||||
]);
|
||||
SSH::fake('Active: inactive');
|
||||
|
||||
Bus::fake();
|
||||
$this->get(route('servers.services.restart', [
|
||||
'server' => $this->server,
|
||||
'service' => $service,
|
||||
]))->assertSessionDoesntHaveErrors();
|
||||
|
||||
Bus::assertDispatched(UninstallPHPMyAdmin::class);
|
||||
$service->refresh();
|
||||
|
||||
$this->assertEquals(ServiceStatus::FAILED, $service->status);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider data
|
||||
*/
|
||||
public function test_failed_to_stop_service(string $name): void
|
||||
{
|
||||
$this->actingAs($this->user);
|
||||
|
||||
$service = $this->server->services()->where('name', $name)->firstOrFail();
|
||||
|
||||
SSH::fake('Active: active');
|
||||
|
||||
$this->get(route('servers.services.stop', [
|
||||
'server' => $this->server,
|
||||
'service' => $service,
|
||||
]))->assertSessionDoesntHaveErrors();
|
||||
|
||||
$service->refresh();
|
||||
|
||||
$this->assertEquals(ServiceStatus::FAILED, $service->status);
|
||||
}
|
||||
|
||||
public static function data(): array
|
||||
|
@ -6,10 +6,8 @@
|
||||
use App\Enums\SiteType;
|
||||
use App\Enums\SourceControl;
|
||||
use App\Facades\SSH;
|
||||
use App\Jobs\Site\CreateVHost;
|
||||
use App\Models\Site;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Bus;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Tests\TestCase;
|
||||
|
||||
@ -22,9 +20,12 @@ class SitesTest extends TestCase
|
||||
*/
|
||||
public function test_create_site(array $inputs): void
|
||||
{
|
||||
Bus::fake();
|
||||
SSH::fake();
|
||||
|
||||
Http::fake();
|
||||
Http::fake([
|
||||
'https://api.github.com/repos/*' => Http::response([
|
||||
], 201),
|
||||
]);
|
||||
|
||||
$this->actingAs($this->user);
|
||||
|
||||
@ -39,11 +40,9 @@ public function test_create_site(array $inputs): void
|
||||
'server' => $this->server,
|
||||
]), $inputs)->assertSessionDoesntHaveErrors();
|
||||
|
||||
Bus::assertDispatched(CreateVHost::class);
|
||||
|
||||
$this->assertDatabaseHas('sites', [
|
||||
'domain' => 'example.com',
|
||||
'status' => SiteStatus::INSTALLING,
|
||||
'status' => SiteStatus::READY,
|
||||
]);
|
||||
}
|
||||
|
||||
@ -64,7 +63,7 @@ public function test_see_sites_list(): void
|
||||
|
||||
public function test_delete_site(): void
|
||||
{
|
||||
Bus::fake();
|
||||
SSH::fake();
|
||||
|
||||
$this->actingAs($this->user);
|
||||
|
||||
@ -77,15 +76,15 @@ public function test_delete_site(): void
|
||||
'site' => $site,
|
||||
]))->assertRedirect();
|
||||
|
||||
Bus::assertDispatched(\App\Jobs\Site\DeleteSite::class);
|
||||
|
||||
$site->refresh();
|
||||
|
||||
$this->assertEquals(SiteStatus::DELETING, $site->status);
|
||||
$this->assertDatabaseMissing('sites', [
|
||||
'id' => $site->id,
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_change_php_version(): void
|
||||
{
|
||||
SSH::fake();
|
||||
|
||||
$this->actingAs($this->user);
|
||||
|
||||
$site = Site::factory()->create([
|
||||
@ -117,7 +116,7 @@ public function test_update_v_host(): void
|
||||
$this->get(route('servers.sites.settings.vhost', [
|
||||
'server' => $this->server,
|
||||
'site' => $site,
|
||||
]))->assertSessionHasNoErrors();
|
||||
]))->assertSessionDoesntHaveErrors();
|
||||
}
|
||||
|
||||
public static function create_data(): array
|
||||
|
@ -33,7 +33,7 @@ public function test_connect_provider(string $provider, ?string $customUrl): voi
|
||||
$input['url'] = $customUrl;
|
||||
}
|
||||
$this->post(route('source-controls.connect'), $input)
|
||||
->assertSessionHasNoErrors();
|
||||
->assertSessionDoesntHaveErrors();
|
||||
|
||||
$this->assertDatabaseHas('source_controls', [
|
||||
'provider' => $provider,
|
||||
@ -57,7 +57,7 @@ public function test_delete_provider(string $provider): void
|
||||
]);
|
||||
|
||||
$this->delete(route('source-controls.delete', $sourceControl->id))
|
||||
->assertSessionHasNoErrors();
|
||||
->assertSessionDoesntHaveErrors();
|
||||
|
||||
$this->assertDatabaseMissing('source_controls', [
|
||||
'id' => $sourceControl->id,
|
||||
|
@ -4,16 +4,12 @@
|
||||
|
||||
use App\Models\SshKey;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use JsonException;
|
||||
use Tests\TestCase;
|
||||
|
||||
class SshKeysTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
/**
|
||||
* @throws JsonException
|
||||
*/
|
||||
public function test_create_ssh_key(): void
|
||||
{
|
||||
$this->actingAs($this->user);
|
||||
@ -21,7 +17,7 @@ public function test_create_ssh_key(): void
|
||||
$this->post(route('ssh-keys.add'), [
|
||||
'name' => 'test',
|
||||
'public_key' => 'ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAklOUpkDHrfHY17SbrmTIpNLTGK9Tjom/BWDSUGPl+nafzlHDTYW7hdI4yZ5ew18JH4JW9jbhUFrviQzM7xlELEVf4h9lFX5QVkbPppSwg0cda3Pbv7kOdJ/MTyBlWXFCR+HAo3FXRitBqxiX1nKhXpHAZsMciLq8V6RjsNAQwdsdMFvSlVK/7XAt3FaoJoAsncM1Q9x5+3V0Ww68/eIFmb1zuUFljQJKprrX88XypNDvjYNby6vw/Pb0rwert/EnmZ+AW4OZPnTPI89ZPmVMLuayrD2cE86Z/il8b+gw3r3+1nKatmIkjn2so1d01QraTlMqVSsbxNrRFi9wrf+M7Q== test@test.local',
|
||||
])->assertSessionHasNoErrors();
|
||||
])->assertSessionDoesntHaveErrors();
|
||||
}
|
||||
|
||||
public function test_get_public_keys_list(): void
|
||||
@ -36,9 +32,6 @@ public function test_get_public_keys_list(): void
|
||||
->assertSee($key->name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws JsonException
|
||||
*/
|
||||
public function test_delete_key(): void
|
||||
{
|
||||
$this->actingAs($this->user);
|
||||
@ -48,7 +41,7 @@ public function test_delete_key(): void
|
||||
]);
|
||||
|
||||
$this->delete(route('ssh-keys.delete', $key->id))
|
||||
->assertSessionHasNoErrors();
|
||||
->assertSessionDoesntHaveErrors();
|
||||
|
||||
$this->assertDatabaseMissing('ssh_keys', [
|
||||
'id' => $key->id,
|
||||
|
@ -4,11 +4,9 @@
|
||||
|
||||
use App\Enums\SslStatus;
|
||||
use App\Enums\SslType;
|
||||
use App\Jobs\Ssl\Deploy;
|
||||
use App\Jobs\Ssl\Remove;
|
||||
use App\Facades\SSH;
|
||||
use App\Models\Ssl;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Bus;
|
||||
use Tests\TestCase;
|
||||
|
||||
class SslTest extends TestCase
|
||||
@ -45,7 +43,7 @@ public function test_see_ssls_list_with_no_ssls()
|
||||
|
||||
public function test_create_ssl()
|
||||
{
|
||||
Bus::fake();
|
||||
SSH::fake('Successfully received certificate');
|
||||
|
||||
$this->actingAs($this->user);
|
||||
|
||||
@ -59,15 +57,13 @@ public function test_create_ssl()
|
||||
$this->assertDatabaseHas('ssls', [
|
||||
'site_id' => $this->site->id,
|
||||
'type' => SslType::LETSENCRYPT,
|
||||
'status' => SslStatus::CREATING,
|
||||
'status' => SslStatus::CREATED,
|
||||
]);
|
||||
|
||||
Bus::assertDispatched(Deploy::class);
|
||||
}
|
||||
|
||||
public function test_delete_ssl()
|
||||
{
|
||||
Bus::fake();
|
||||
SSH::fake();
|
||||
|
||||
$this->actingAs($this->user);
|
||||
|
||||
@ -81,11 +77,8 @@ public function test_delete_ssl()
|
||||
'ssl' => $ssl,
|
||||
]))->assertRedirect();
|
||||
|
||||
$this->assertDatabaseHas('ssls', [
|
||||
$this->assertDatabaseMissing('ssls', [
|
||||
'id' => $ssl->id,
|
||||
'status' => SslStatus::DELETING,
|
||||
]);
|
||||
|
||||
Bus::assertDispatched(Remove::class);
|
||||
}
|
||||
}
|
||||
|
@ -5,16 +5,12 @@
|
||||
use App\Enums\StorageProvider;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use JsonException;
|
||||
use Tests\TestCase;
|
||||
|
||||
class StorageProvidersTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
/**
|
||||
* @throws JsonException
|
||||
*/
|
||||
public function test_connect_dropbox(): void
|
||||
{
|
||||
$this->actingAs($this->user);
|
||||
@ -25,7 +21,7 @@ public function test_connect_dropbox(): void
|
||||
'provider' => StorageProvider::DROPBOX,
|
||||
'name' => 'profile',
|
||||
'token' => 'token',
|
||||
])->assertSessionHasNoErrors();
|
||||
])->assertSessionDoesntHaveErrors();
|
||||
|
||||
$this->assertDatabaseHas('storage_providers', [
|
||||
'provider' => StorageProvider::DROPBOX,
|
||||
@ -46,9 +42,6 @@ public function test_see_providers_list(): void
|
||||
->assertSee($provider->profile);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws JsonException
|
||||
*/
|
||||
public function test_delete_provider(): void
|
||||
{
|
||||
$this->actingAs($this->user);
|
||||
@ -58,7 +51,7 @@ public function test_delete_provider(): void
|
||||
]);
|
||||
|
||||
$this->delete(route('storage-providers.delete', $provider->id))
|
||||
->assertSessionHasNoErrors();
|
||||
->assertSessionDoesntHaveErrors();
|
||||
|
||||
$this->assertDatabaseMissing('storage_providers', [
|
||||
'id' => $provider->id,
|
||||
|
Reference in New Issue
Block a user