mirror of
https://github.com/vitodeploy/vito.git
synced 2025-04-19 01:41:36 +00:00
commit
df96b860c1
@ -1,4 +1,4 @@
|
||||
name: tests
|
||||
name: checks
|
||||
|
||||
on:
|
||||
push:
|
||||
@ -54,3 +54,34 @@ jobs:
|
||||
DB_DATABASE: test_db
|
||||
DB_USERNAME: user
|
||||
DB_PASSWORD: password
|
||||
|
||||
code-style:
|
||||
runs-on: ubuntu-20.04
|
||||
|
||||
strategy:
|
||||
fail-fast: true
|
||||
matrix:
|
||||
php: [ 8.1 ]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Setup PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: ${{ matrix.php }}
|
||||
|
||||
- name: Cache Composer packages
|
||||
id: composer-cache
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: vendor
|
||||
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-php-
|
||||
- name: Install dependencies
|
||||
if: steps.composer-cache.outputs.cache-hit != 'true'
|
||||
run: composer install --prefer-dist --no-progress --no-suggest
|
||||
|
||||
- name: Run pint
|
||||
run: ./vendor/bin/pint --test
|
@ -59,7 +59,7 @@ private function validate($type, Server $server, array $input): void
|
||||
'0 0 * * *',
|
||||
'0 0 * * 0',
|
||||
'0 0 1 * *',
|
||||
'custom'
|
||||
'custom',
|
||||
]),
|
||||
],
|
||||
];
|
||||
|
@ -6,7 +6,6 @@
|
||||
use App\Models\FirewallRule;
|
||||
use App\Models\Server;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
||||
class CreateRule
|
||||
|
@ -15,7 +15,7 @@ public function connect(array $input): void
|
||||
$sourceControl = new SourceControl([
|
||||
'provider' => $input['provider'],
|
||||
'profile' => $input['name'],
|
||||
'access_token' => $input['token']
|
||||
'access_token' => $input['token'],
|
||||
]);
|
||||
|
||||
if (! $sourceControl->provider()->connect()) {
|
||||
@ -24,7 +24,7 @@ public function connect(array $input): void
|
||||
),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
$sourceControl->save();
|
||||
}
|
||||
|
||||
@ -36,14 +36,14 @@ private function validate(array $input): void
|
||||
$rules = [
|
||||
'provider' => [
|
||||
'required',
|
||||
Rule::in(\App\Enums\SourceControl::getValues())
|
||||
Rule::in(\App\Enums\SourceControl::getValues()),
|
||||
],
|
||||
'name' => [
|
||||
'required',
|
||||
],
|
||||
'token' => [
|
||||
'required'
|
||||
]
|
||||
'required',
|
||||
],
|
||||
];
|
||||
Validator::make($input, $rules)->validate();
|
||||
}
|
||||
|
@ -22,15 +22,15 @@ public function create(User $user, array $input): void
|
||||
'provider' => $input['provider'],
|
||||
'profile' => $input['name'],
|
||||
'credentials' => [
|
||||
'token' => $input['token']
|
||||
]
|
||||
'token' => $input['token'],
|
||||
],
|
||||
]);
|
||||
if (! $storageProvider->provider()->connect()) {
|
||||
throw ValidationException::withMessages([
|
||||
'token' => __("Couldn't connect to the provider")
|
||||
'token' => __("Couldn't connect to the provider"),
|
||||
]);
|
||||
}
|
||||
$storageProvider->save();;
|
||||
$storageProvider->save();
|
||||
}
|
||||
|
||||
private function validate(User $user, array $input): void
|
||||
@ -45,8 +45,8 @@ private function validate(User $user, array $input): void
|
||||
Rule::unique('storage_providers', 'profile')->where('user_id', $user->id),
|
||||
],
|
||||
'token' => [
|
||||
'required'
|
||||
]
|
||||
'required',
|
||||
],
|
||||
])->validate();
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,6 @@
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class CreateUserCommand extends Command
|
||||
{
|
||||
@ -20,6 +19,6 @@ public function handle(): void
|
||||
'password' => bcrypt($this->argument('password')),
|
||||
]);
|
||||
|
||||
$this->info("User created with password");
|
||||
$this->info('User created with password');
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,6 @@
|
||||
namespace App\Contracts;
|
||||
|
||||
use App\Models\Server;
|
||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||
|
||||
interface StorageProvider
|
||||
{
|
||||
|
@ -7,5 +7,6 @@
|
||||
final class ServerType extends Enum
|
||||
{
|
||||
const REGULAR = 'regular';
|
||||
|
||||
const DATABASE = 'database';
|
||||
}
|
||||
|
@ -74,11 +74,11 @@ public function connect(bool $sftp = false): void
|
||||
$login = $this->connection->login($this->user, $this->privateKey);
|
||||
|
||||
if (! $login) {
|
||||
throw new SSHAuthenticationError("Error authenticating");
|
||||
throw new SSHAuthenticationError('Error authenticating');
|
||||
}
|
||||
} catch (Throwable $e) {
|
||||
Log::error("Error connecting", [
|
||||
"msg" => $e->getMessage()
|
||||
Log::error('Error connecting', [
|
||||
'msg' => $e->getMessage(),
|
||||
]);
|
||||
throw $e;
|
||||
}
|
||||
|
@ -64,6 +64,6 @@ class Kernel extends HttpKernel
|
||||
'signed' => \App\Http\Middleware\ValidateSignature::class,
|
||||
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
|
||||
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
|
||||
'server-is-ready' => ServerIsReadyMiddleware::class
|
||||
'server-is-ready' => ServerIsReadyMiddleware::class,
|
||||
];
|
||||
}
|
||||
|
@ -20,9 +20,9 @@ class DatabaseBackupFiles extends Component
|
||||
|
||||
public Backup $backup;
|
||||
|
||||
public string $restoreId = "";
|
||||
public string $restoreId = '';
|
||||
|
||||
public string $restoreDatabaseId = "";
|
||||
public string $restoreDatabaseId = '';
|
||||
|
||||
public int $deleteId;
|
||||
|
||||
@ -61,7 +61,7 @@ public function delete(): void
|
||||
public function render(): View
|
||||
{
|
||||
return view('livewire.databases.database-backup-files', [
|
||||
'files' => $this->backup->files()->orderByDesc('id')->simplePaginate(10)
|
||||
'files' => $this->backup->files()->orderByDesc('id')->simplePaginate(10),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ public function render(): View
|
||||
return view('livewire.databases.database-backups', [
|
||||
'backups' => $this->server->backups,
|
||||
'databases' => $this->server->databases,
|
||||
'files' => $this->files
|
||||
'files' => $this->files,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ public function handle(): void
|
||||
{
|
||||
if ($this->server->provider()->isRunning()) {
|
||||
$this->server->install();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -33,6 +34,7 @@ public function handle(): void
|
||||
'server' => $this->server,
|
||||
])
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
use App\Jobs\Job;
|
||||
use App\Models\FirewallRule;
|
||||
use App\Models\Service;
|
||||
use App\SSHCommands\PHPMyAdmin\DeleteNginxPHPMyAdminVHost;
|
||||
use App\SSHCommands\PHPMyAdmin\DeleteNginxPHPMyAdminVHostCommand;
|
||||
use Exception;
|
||||
use Throwable;
|
||||
|
||||
@ -48,7 +48,7 @@ private function removeFirewallRule(): void
|
||||
private function deleteVHost(): void
|
||||
{
|
||||
$this->service->server->ssh()->exec(
|
||||
new DeleteNginxPHPMyAdminVHost('/home/vito/phpmyadmin'),
|
||||
new DeleteNginxPHPMyAdminVHostCommand('/home/vito/phpmyadmin'),
|
||||
'delete-phpmyadmin-vhost'
|
||||
);
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
use App\Helpers\SSH;
|
||||
use App\Jobs\Job;
|
||||
use App\Models\Deployment;
|
||||
use App\SSHCommands\System\RunScript;
|
||||
use App\SSHCommands\System\RunScriptCommand;
|
||||
use Throwable;
|
||||
|
||||
class Deploy extends Job
|
||||
@ -34,7 +34,7 @@ public function handle(): void
|
||||
{
|
||||
$this->ssh = $this->deployment->site->server->ssh();
|
||||
$this->ssh->exec(
|
||||
new RunScript($this->path, $this->script),
|
||||
new RunScriptCommand($this->path, $this->script),
|
||||
'deploy',
|
||||
$this->deployment->site_id
|
||||
);
|
||||
|
@ -34,7 +34,7 @@ public function handle(): void
|
||||
);
|
||||
$this->site->save();
|
||||
$this->site->sourceControl()->provider()->deployKey(
|
||||
$this->site->domain.'-key-' . $this->site->id,
|
||||
$this->site->domain.'-key-'.$this->site->id,
|
||||
$this->site->repository,
|
||||
$this->site->ssh_key
|
||||
);
|
||||
|
@ -15,7 +15,7 @@ public function handle(Broadcast $event): void
|
||||
{
|
||||
Cache::set('broadcast', [
|
||||
'type' => $event->type,
|
||||
'data' => $event->data
|
||||
'data' => $event->data,
|
||||
], now()->addMinutes(5));
|
||||
}
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ public static function boot(): void
|
||||
static::created(function (Site $site) {
|
||||
$site->deploymentScript()->create([
|
||||
'name' => 'default',
|
||||
'content' => ''
|
||||
'content' => '',
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
@ -7,7 +7,6 @@
|
||||
use Illuminate\Auth\Events\Registered;
|
||||
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
|
||||
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
|
||||
class EventServiceProvider extends ServiceProvider
|
||||
{
|
||||
|
@ -13,7 +13,7 @@ public function __construct(protected string $provider, protected string $databa
|
||||
|
||||
public function file(): string
|
||||
{
|
||||
return File::get(resource_path(sprintf("commands/database/%s/backup.sh", $this->provider)));
|
||||
return File::get(resource_path(sprintf('commands/database/%s/backup.sh', $this->provider)));
|
||||
}
|
||||
|
||||
public function content(): string
|
||||
|
@ -13,7 +13,7 @@ public function __construct(protected string $provider, protected string $name)
|
||||
|
||||
public function file(): string
|
||||
{
|
||||
return File::get(resource_path(sprintf("commands/database/%s/create.sh", $this->provider)));
|
||||
return File::get(resource_path(sprintf('commands/database/%s/create.sh', $this->provider)));
|
||||
}
|
||||
|
||||
public function content(): string
|
||||
|
@ -17,7 +17,7 @@ public function __construct(
|
||||
|
||||
public function file(): string
|
||||
{
|
||||
return File::get(resource_path(sprintf("commands/database/%s/create-user.sh", $this->provider)));
|
||||
return File::get(resource_path(sprintf('commands/database/%s/create-user.sh', $this->provider)));
|
||||
}
|
||||
|
||||
public function content(): string
|
||||
|
@ -13,7 +13,7 @@ public function __construct(protected string $provider, protected string $name)
|
||||
|
||||
public function file(): string
|
||||
{
|
||||
return File::get(resource_path(sprintf("commands/database/%s/delete.sh", $this->provider)));
|
||||
return File::get(resource_path(sprintf('commands/database/%s/delete.sh', $this->provider)));
|
||||
}
|
||||
|
||||
public function content(): string
|
||||
|
@ -13,7 +13,7 @@ public function __construct(protected string $provider, protected string $userna
|
||||
|
||||
public function file(): string
|
||||
{
|
||||
return File::get(resource_path(sprintf("commands/database/%s/delete-user.sh", $this->provider)));
|
||||
return File::get(resource_path(sprintf('commands/database/%s/delete-user.sh', $this->provider)));
|
||||
}
|
||||
|
||||
public function content(): string
|
||||
|
@ -17,7 +17,7 @@ public function __construct(
|
||||
|
||||
public function file(): string
|
||||
{
|
||||
return File::get(resource_path(sprintf("commands/database/%s/link.sh", $this->provider)));
|
||||
return File::get(resource_path(sprintf('commands/database/%s/link.sh', $this->provider)));
|
||||
}
|
||||
|
||||
public function content(): string
|
||||
|
@ -13,7 +13,7 @@ public function __construct(protected string $provider, protected string $databa
|
||||
|
||||
public function file(): string
|
||||
{
|
||||
return File::get(resource_path(sprintf("commands/database/%s/restore.sh", $this->provider)));
|
||||
return File::get(resource_path(sprintf('commands/database/%s/restore.sh', $this->provider)));
|
||||
}
|
||||
|
||||
public function content(): string
|
||||
|
@ -16,7 +16,7 @@ public function __construct(
|
||||
|
||||
public function file(): string
|
||||
{
|
||||
return File::get(resource_path(sprintf("commands/database/%s/unlink.sh", $this->provider)));
|
||||
return File::get(resource_path(sprintf('commands/database/%s/unlink.sh', $this->provider)));
|
||||
}
|
||||
|
||||
public function content(): string
|
||||
|
@ -21,6 +21,6 @@ public function __construct(
|
||||
|
||||
public function file(): string
|
||||
{
|
||||
return File::get(resource_path(sprintf("commands/firewall/%s/add-rule.sh", $this->provider)));
|
||||
return File::get(resource_path(sprintf('commands/firewall/%s/add-rule.sh', $this->provider)));
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,6 @@ public function __construct(
|
||||
|
||||
public function file(): string
|
||||
{
|
||||
return File::get(resource_path(sprintf("commands/firewall/%s/remove-rule.sh", $this->provider)));
|
||||
return File::get(resource_path(sprintf('commands/firewall/%s/remove-rule.sh', $this->provider)));
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,6 @@
|
||||
|
||||
use App\SSHCommands\Command;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class InstallNginxCommand extends Command
|
||||
{
|
||||
|
@ -4,7 +4,6 @@
|
||||
|
||||
use App\SSHCommands\Command;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class InstallPHPCommand extends Command
|
||||
{
|
||||
|
@ -4,7 +4,6 @@
|
||||
|
||||
use App\SSHCommands\Command;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class UninstallPHPCommand extends Command
|
||||
{
|
||||
|
@ -5,7 +5,7 @@
|
||||
use App\SSHCommands\Command;
|
||||
use Illuminate\Support\Facades\File;
|
||||
|
||||
class DeleteNginxPHPMyAdminVHost extends Command
|
||||
class DeleteNginxPHPMyAdminVHostCommand extends Command
|
||||
{
|
||||
public function __construct(protected string $path)
|
||||
{
|
@ -17,6 +17,6 @@ public function file(): string
|
||||
|
||||
public function content(): string
|
||||
{
|
||||
return 'sudo rm -rf '.$this->path.'*'."\n";
|
||||
return 'sudo rm -rf '.$this->path.'*';
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
use App\SSHCommands\Command;
|
||||
use Illuminate\Support\Facades\File;
|
||||
|
||||
class RunScript extends Command
|
||||
class RunScriptCommand extends Command
|
||||
{
|
||||
public function __construct(protected string $path, protected string $script)
|
||||
{
|
||||
@ -20,7 +20,7 @@ public function content(): string
|
||||
{
|
||||
return str($this->file())
|
||||
->replace('__path__', $this->path)
|
||||
->replace('__script__', make_bash_script($this->script))
|
||||
->replace('__script__', $this->script)
|
||||
->toString();
|
||||
}
|
||||
}
|
@ -4,7 +4,6 @@
|
||||
|
||||
use App\Enums\OperatingSystem;
|
||||
use App\Exceptions\CouldNotConnectToProvider;
|
||||
use App\Notifications\FailedToDeleteServerFromProvider;
|
||||
use Aws\Ec2\Ec2Client;
|
||||
use Aws\EC2InstanceConnect\EC2InstanceConnectClient;
|
||||
use Exception;
|
||||
|
@ -4,7 +4,6 @@
|
||||
|
||||
use App\Exceptions\CouldNotConnectToProvider;
|
||||
use App\Exceptions\ServerProviderError;
|
||||
use App\Notifications\FailedToDeleteServerFromProvider;
|
||||
use Exception;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
@ -4,7 +4,6 @@
|
||||
|
||||
use App\Exceptions\CouldNotConnectToProvider;
|
||||
use App\Exceptions\ServerProviderError;
|
||||
use App\Notifications\FailedToDeleteServerFromProvider;
|
||||
use Illuminate\Http\Client\Response;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
|
@ -4,7 +4,6 @@
|
||||
|
||||
use App\Exceptions\CouldNotConnectToProvider;
|
||||
use App\Exceptions\ServerProviderError;
|
||||
use App\Notifications\FailedToDeleteServerFromProvider;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
@ -104,7 +103,7 @@ public function create(): void
|
||||
if (count($errors) > 0) {
|
||||
$msg = $errors[0]['reason'];
|
||||
}
|
||||
Log::error("Linode error", $errors);
|
||||
Log::error('Linode error', $errors);
|
||||
throw new ServerProviderError($msg);
|
||||
}
|
||||
$this->server->ip = $create->json()['ipv4'][0];
|
||||
|
@ -4,7 +4,6 @@
|
||||
|
||||
use App\Exceptions\CouldNotConnectToProvider;
|
||||
use App\Exceptions\ServerProviderError;
|
||||
use App\Notifications\FailedToDeleteServerFromProvider;
|
||||
use Exception;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
@ -4,9 +4,6 @@
|
||||
|
||||
use App\Events\Broadcast;
|
||||
use App\Jobs\Installation\Initialize;
|
||||
use App\Jobs\Installation\InstallCertbot;
|
||||
use App\Jobs\Installation\InstallComposer;
|
||||
use App\Jobs\Installation\InstallNodejs;
|
||||
use App\Jobs\Installation\InstallRequirements;
|
||||
use App\Jobs\Installation\Upgrade;
|
||||
use Illuminate\Support\Facades\Bus;
|
||||
|
@ -5,9 +5,6 @@
|
||||
use App\Exceptions\FailedToDeployGitHook;
|
||||
use App\Exceptions\FailedToDeployGitKey;
|
||||
use App\Exceptions\FailedToDestroyGitHook;
|
||||
use App\Exceptions\RepositoryNotFound;
|
||||
use App\Exceptions\RepositoryPermissionDenied;
|
||||
use App\Exceptions\SourceControlIsNotConnected;
|
||||
use Exception;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Str;
|
||||
@ -39,7 +36,7 @@ public function getRepo(string $repo = null): mixed
|
||||
|
||||
public function fullRepoUrl(string $repo, string $key): string
|
||||
{
|
||||
return sprintf("git@bitbucket.org-%s:%s.git", $key, $repo);
|
||||
return sprintf('git@bitbucket.org-%s:%s.git', $key, $repo);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2,8 +2,8 @@
|
||||
|
||||
namespace App\SourceControlProviders;
|
||||
|
||||
use App\Exceptions\FailedToDeployGitKey;
|
||||
use App\Exceptions\FailedToDeployGitHook;
|
||||
use App\Exceptions\FailedToDeployGitKey;
|
||||
use App\Exceptions\FailedToDestroyGitHook;
|
||||
use Exception;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
@ -44,7 +44,7 @@ public function getRepo(string $repo = null): mixed
|
||||
|
||||
public function fullRepoUrl(string $repo, string $key): string
|
||||
{
|
||||
return sprintf("git@github.com-%s:%s.git", $key, $repo);
|
||||
return sprintf('git@github.com-%s:%s.git', $key, $repo);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2,8 +2,8 @@
|
||||
|
||||
namespace App\SourceControlProviders;
|
||||
|
||||
use App\Exceptions\FailedToDeployGitKey;
|
||||
use App\Exceptions\FailedToDeployGitHook;
|
||||
use App\Exceptions\FailedToDeployGitKey;
|
||||
use App\Exceptions\FailedToDestroyGitHook;
|
||||
use Exception;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
@ -36,7 +36,7 @@ public function getRepo(string $repo = null): mixed
|
||||
|
||||
public function fullRepoUrl(string $repo, string $key): string
|
||||
{
|
||||
return sprintf("git@gitlab.com-%s:%s.git", $key, $repo);
|
||||
return sprintf('git@gitlab.com-%s:%s.git', $key, $repo);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -17,7 +17,7 @@ public function connect(): bool
|
||||
{
|
||||
$res = Http::withToken($this->storageProvider->credentials['token'])
|
||||
->post($this->apiUrl.'/check/user', [
|
||||
'query' => ''
|
||||
'query' => '',
|
||||
]);
|
||||
|
||||
return $res->successful();
|
||||
@ -40,7 +40,7 @@ public function upload(Server $server, string $src, string $dest): array
|
||||
$data = json_decode($upload, true);
|
||||
|
||||
if (isset($data['error'])) {
|
||||
throw new BackupFileException("Failed to upload to Dropbox ".$data['error_summary'] ?? '');
|
||||
throw new BackupFileException('Failed to upload to Dropbox '.$data['error_summary'] ?? '');
|
||||
}
|
||||
|
||||
return [
|
||||
|
@ -193,7 +193,7 @@
|
||||
App\Providers\AuthServiceProvider::class,
|
||||
App\Providers\BroadcastServiceProvider::class,
|
||||
App\Providers\EventServiceProvider::class,
|
||||
App\Providers\RouteServiceProvider::class
|
||||
App\Providers\RouteServiceProvider::class,
|
||||
],
|
||||
|
||||
/*
|
||||
|
@ -25,7 +25,6 @@
|
||||
use App\ServiceHandlers\Webserver\Nginx;
|
||||
use App\SiteTypes\Laravel;
|
||||
use App\SiteTypes\PHPSite;
|
||||
use App\SiteTypes\Wordpress;
|
||||
use App\SourceControlProviders\Bitbucket;
|
||||
use App\SourceControlProviders\Custom;
|
||||
use App\SourceControlProviders\Github;
|
||||
@ -48,7 +47,7 @@
|
||||
'operating_systems' => [
|
||||
// 'ubuntu_18',
|
||||
'ubuntu_20',
|
||||
'ubuntu_22'
|
||||
'ubuntu_22',
|
||||
],
|
||||
'webservers' => ['none', 'nginx'],
|
||||
'php_versions' => [
|
||||
|
@ -13,7 +13,7 @@ public function definition(): array
|
||||
'type' => 'database',
|
||||
'interval' => '0 * * * *',
|
||||
'keep_backups' => 10,
|
||||
'status' => BackupStatus::RUNNING
|
||||
'status' => BackupStatus::RUNNING,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Enums\LogType;
|
||||
use App\Models\ServerLog;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
|
@ -2,10 +2,8 @@
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Server;
|
||||
use App\Models\Service;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
class ServiceFactory extends Factory
|
||||
{
|
||||
|
@ -20,7 +20,7 @@ public function definition(): array
|
||||
'status' => 'ready',
|
||||
'progress' => '100',
|
||||
'php_version' => '8.2',
|
||||
'branch' => 'main'
|
||||
'branch' => 'main',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,6 @@
|
||||
|
||||
use App\Models\SshKey;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
class SshKeyFactory extends Factory
|
||||
{
|
||||
|
@ -3,7 +3,8 @@
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
return new class extends Migration {
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
DB::statement('ALTER TABLE firewall_rules MODIFY mask varchar(10) null');
|
||||
|
@ -4,7 +4,8 @@
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration {
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('sites', function (Blueprint $table) {
|
||||
|
@ -4,7 +4,8 @@
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration {
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('source_controls', function (Blueprint $table) {
|
||||
|
@ -4,7 +4,8 @@
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration {
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('source_controls', function (Blueprint $table) {
|
||||
|
@ -4,7 +4,8 @@
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration {
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('sites', function (Blueprint $table) {
|
||||
|
@ -4,7 +4,8 @@
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration {
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('storage_providers', function (Blueprint $table) {
|
||||
|
@ -4,7 +4,8 @@
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration {
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('backups', function (Blueprint $table) {
|
||||
|
@ -4,7 +4,8 @@
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration {
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('backup_files', function (Blueprint $table) {
|
||||
|
@ -21,13 +21,13 @@ public function run(): void
|
||||
'email' => 'user@example.com',
|
||||
]);
|
||||
$server = Server::factory()->create([
|
||||
'user_id' => $user->id
|
||||
'user_id' => $user->id,
|
||||
]);
|
||||
$server->services()->create([
|
||||
'type' => 'database',
|
||||
'name' => config('core.databases_name.mysql80'),
|
||||
'version' => config('core.databases_version.mysql80'),
|
||||
'status' => ServiceStatus::READY
|
||||
'status' => ServiceStatus::READY,
|
||||
]);
|
||||
$server->services()->create([
|
||||
'type' => 'php',
|
||||
@ -36,17 +36,17 @@ public function run(): void
|
||||
],
|
||||
'name' => 'php',
|
||||
'version' => '8.1',
|
||||
'status' => ServiceStatus::READY
|
||||
'status' => ServiceStatus::READY,
|
||||
]);
|
||||
$server->services()->create([
|
||||
'type' => 'webserver',
|
||||
'name' => 'nginx',
|
||||
'version' => 'latest',
|
||||
'status' => ServiceStatus::READY
|
||||
'status' => ServiceStatus::READY,
|
||||
]);
|
||||
Site::factory()->create([
|
||||
'server_id' => $server->id,
|
||||
'type' => SiteType::LARAVEL
|
||||
'type' => SiteType::LARAVEL,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,6 @@ if ! sudo ln -s /usr/bin/php__version__ /usr/bin/php; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
||||
|
||||
echo "Default php is: \n"
|
||||
echo "Default php is: "
|
||||
|
||||
php -v
|
||||
|
@ -2,4 +2,6 @@ if ! cd __path__; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
||||
|
||||
__script__
|
||||
if ! __script__; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
||||
|
@ -23,7 +23,7 @@ public function test_visit_application()
|
||||
$this->get(
|
||||
route('servers.sites.show', [
|
||||
'server' => $this->server,
|
||||
'site' => $this->site
|
||||
'site' => $this->site,
|
||||
])
|
||||
)
|
||||
->assertOk()
|
||||
@ -44,7 +44,7 @@ public function test_update_deployment_script()
|
||||
|
||||
$this->assertDatabaseHas('deployment_scripts', [
|
||||
'site_id' => $this->site->id,
|
||||
'content' => 'some script'
|
||||
'content' => 'some script',
|
||||
]);
|
||||
|
||||
$this->site->refresh();
|
||||
|
@ -58,7 +58,7 @@ public function test_create_cronjob()
|
||||
'command' => 'ls -la',
|
||||
'user' => 'vito',
|
||||
'frequency' => '* * * * *',
|
||||
'status' => CronjobStatus::CREATING
|
||||
'status' => CronjobStatus::CREATING,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ public function test_create_backup(): void
|
||||
|
||||
$storage = StorageProvider::factory()->create([
|
||||
'user_id' => $this->user->id,
|
||||
'provider' => \App\Enums\StorageProvider::DROPBOX
|
||||
'provider' => \App\Enums\StorageProvider::DROPBOX,
|
||||
]);
|
||||
|
||||
Livewire::test(DatabaseBackups::class, ['server' => $this->server])
|
||||
@ -60,7 +60,7 @@ public function test_see_backups_list(): void
|
||||
|
||||
$storage = StorageProvider::factory()->create([
|
||||
'user_id' => $this->user->id,
|
||||
'provider' => \App\Enums\StorageProvider::DROPBOX
|
||||
'provider' => \App\Enums\StorageProvider::DROPBOX,
|
||||
]);
|
||||
|
||||
$backup = Backup::factory()->create([
|
||||
@ -85,7 +85,7 @@ public function test_delete_database(): void
|
||||
|
||||
$storage = StorageProvider::factory()->create([
|
||||
'user_id' => $this->user->id,
|
||||
'provider' => \App\Enums\StorageProvider::DROPBOX
|
||||
'provider' => \App\Enums\StorageProvider::DROPBOX,
|
||||
]);
|
||||
|
||||
$backup = Backup::factory()->create([
|
||||
|
@ -35,7 +35,7 @@ public function test_create_firewall_rule(): void
|
||||
Bus::assertDispatched(AddToServer::class);
|
||||
|
||||
$this->assertDatabaseHas('firewall_rules', [
|
||||
'port' => '1234'
|
||||
'port' => '1234',
|
||||
]);
|
||||
}
|
||||
|
||||
@ -44,7 +44,7 @@ public function test_see_firewall_rules(): void
|
||||
$this->actingAs($this->user);
|
||||
|
||||
$rule = FirewallRule::factory()->create([
|
||||
'server_id' => $this->server->id
|
||||
'server_id' => $this->server->id,
|
||||
]);
|
||||
|
||||
Livewire::test(FirewallRulesList::class, ['server' => $this->server])
|
||||
@ -61,7 +61,7 @@ public function test_delete_firewall_rule(): void
|
||||
$this->actingAs($this->user);
|
||||
|
||||
$rule = FirewallRule::factory()->create([
|
||||
'server_id' => $this->server->id
|
||||
'server_id' => $this->server->id,
|
||||
]);
|
||||
|
||||
Livewire::test(FirewallRulesList::class, ['server' => $this->server])
|
||||
@ -73,7 +73,7 @@ public function test_delete_firewall_rule(): void
|
||||
|
||||
$this->assertDatabaseHas('firewall_rules', [
|
||||
'id' => $rule->id,
|
||||
'status' => FirewallRuleStatus::DELETING
|
||||
'status' => FirewallRuleStatus::DELETING,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ public function test_change_default_php_cli(): void
|
||||
],
|
||||
'name' => 'php',
|
||||
'version' => '8.1',
|
||||
'status' => ServiceStatus::READY
|
||||
'status' => ServiceStatus::READY,
|
||||
]);
|
||||
|
||||
Livewire::test(DefaultCli::class, ['server' => $this->server])
|
||||
|
@ -63,7 +63,7 @@ public function test_create_queue()
|
||||
'auto_start' => 1,
|
||||
'auto_restart' => 1,
|
||||
'numprocs' => 1,
|
||||
'status' => QueueStatus::CREATING
|
||||
'status' => QueueStatus::CREATING,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ public function test_delete_ssh_key()
|
||||
$this->assertDatabaseHas('server_ssh_keys', [
|
||||
'server_id' => $this->server->id,
|
||||
'ssh_key_id' => $sshKey->id,
|
||||
'status' => SshKeyStatus::DELETING
|
||||
'status' => SshKeyStatus::DELETING,
|
||||
]);
|
||||
|
||||
Bus::assertDispatched(DeleteSshKeyFromServer::class);
|
||||
@ -77,7 +77,7 @@ public function test_add_new_ssh_key()
|
||||
|
||||
$this->assertDatabaseHas('server_ssh_keys', [
|
||||
'server_id' => $this->server->id,
|
||||
'status' => SshKeyStatus::ADDING
|
||||
'status' => SshKeyStatus::ADDING,
|
||||
]);
|
||||
|
||||
Bus::assertDispatched(DeploySshKeyToServer::class);
|
||||
@ -103,7 +103,7 @@ public function test_add_existing_key()
|
||||
|
||||
$this->assertDatabaseHas('server_ssh_keys', [
|
||||
'server_id' => $this->server->id,
|
||||
'status' => SshKeyStatus::ADDING
|
||||
'status' => SshKeyStatus::ADDING,
|
||||
]);
|
||||
|
||||
Bus::assertDispatched(DeploySshKeyToServer::class);
|
||||
|
@ -25,7 +25,7 @@ public function test_see_services_list(): void
|
||||
'supervisor',
|
||||
'redis',
|
||||
'ufw',
|
||||
'php'
|
||||
'php',
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -2,10 +2,7 @@
|
||||
|
||||
namespace Tests\Feature\Http;
|
||||
|
||||
use App\Http\Livewire\SourceControls\Bitbucket;
|
||||
use App\Http\Livewire\SourceControls\Connect;
|
||||
use App\Http\Livewire\SourceControls\Github;
|
||||
use App\Http\Livewire\SourceControls\Gitlab;
|
||||
use App\Http\Livewire\SourceControls\SourceControlsList;
|
||||
use App\Models\SourceControl;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
@ -48,7 +45,7 @@ public function test_delete_provider(string $provider): void
|
||||
/** @var SourceControl $sourceControl */
|
||||
$sourceControl = SourceControl::factory()->create([
|
||||
'provider' => $provider,
|
||||
'profile' => 'test'
|
||||
'profile' => 'test',
|
||||
]);
|
||||
|
||||
Livewire::test(SourceControlsList::class)
|
||||
|
@ -3,8 +3,8 @@
|
||||
namespace Tests\Feature\Http;
|
||||
|
||||
use App\Enums\StorageProvider;
|
||||
use App\Http\Livewire\StorageProviders\ProvidersList;
|
||||
use App\Http\Livewire\StorageProviders\ConnectProvider;
|
||||
use App\Http\Livewire\StorageProviders\ProvidersList;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Livewire\Livewire;
|
||||
@ -39,7 +39,7 @@ public function test_see_providers_list(): void
|
||||
|
||||
$provider = \App\Models\StorageProvider::factory()->create([
|
||||
'user_id' => $this->user->id,
|
||||
'provider' => StorageProvider::DROPBOX
|
||||
'provider' => StorageProvider::DROPBOX,
|
||||
]);
|
||||
|
||||
Livewire::test(ProvidersList::class)
|
||||
|
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\SSHCommands\CronJob;
|
||||
|
||||
use App\SSHCommands\CronJob\UpdateCronJobsCommand;
|
||||
use Tests\TestCase;
|
||||
|
||||
class UpdateCronJobsCommandTest extends TestCase
|
||||
{
|
||||
public function test_generate_command()
|
||||
{
|
||||
$command = new UpdateCronJobsCommand('vito', 'ls -la');
|
||||
|
||||
$this->assertStringContainsString("echo 'ls -la' | sudo -u vito crontab -;", $command->content());
|
||||
|
||||
$this->assertStringContainsString('sudo -u vito crontab -l;', $command->content());
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\SSHCommands\Database;
|
||||
|
||||
use App\SSHCommands\Database\BackupDatabaseCommand;
|
||||
use Tests\TestCase;
|
||||
|
||||
class BackupDatabaseCommandTest extends TestCase
|
||||
{
|
||||
public function test_generate_command()
|
||||
{
|
||||
$command = new BackupDatabaseCommand('mysql', 'test', 'test');
|
||||
|
||||
$this->assertStringContainsString('sudo DEBIAN_FRONTEND=noninteractive mysqldump -u root test > test.sql;', $command->content());
|
||||
|
||||
$this->assertStringContainsString('DEBIAN_FRONTEND=noninteractive zip test.zip test.sql;', $command->content());
|
||||
|
||||
$this->assertStringContainsString('rm test.sql;', $command->content());
|
||||
}
|
||||
}
|
18
tests/Feature/SSHCommands/Database/CreateCommandTest.php
Normal file
18
tests/Feature/SSHCommands/Database/CreateCommandTest.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\SSHCommands\Database;
|
||||
|
||||
use App\SSHCommands\Database\CreateCommand;
|
||||
use Tests\TestCase;
|
||||
|
||||
class CreateCommandTest extends TestCase
|
||||
{
|
||||
public function test_generate_command()
|
||||
{
|
||||
$command = new CreateCommand('mysql', 'test');
|
||||
|
||||
$this->assertStringContainsString('sudo mysql -e "CREATE DATABASE IF NOT EXISTS test CHARACTER SET utf8 COLLATE utf8_general_ci";', $command->content());
|
||||
|
||||
$this->assertStringContainsString('echo "Command executed"', $command->content());
|
||||
}
|
||||
}
|
18
tests/Feature/SSHCommands/Database/CreateUserCommandTest.php
Normal file
18
tests/Feature/SSHCommands/Database/CreateUserCommandTest.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\SSHCommands\Database;
|
||||
|
||||
use App\SSHCommands\Database\CreateUserCommand;
|
||||
use Tests\TestCase;
|
||||
|
||||
class CreateUserCommandTest extends TestCase
|
||||
{
|
||||
public function test_generate_command()
|
||||
{
|
||||
$command = new CreateUserCommand('mysql', 'user', 'password', '%');
|
||||
|
||||
$this->assertStringContainsString('sudo mysql -e "CREATE USER IF NOT EXISTS \'user\'@\'%\' IDENTIFIED BY \'password\'";', $command->content());
|
||||
|
||||
$this->assertStringContainsString('sudo mysql -e "FLUSH PRIVILEGES";', $command->content());
|
||||
}
|
||||
}
|
16
tests/Feature/SSHCommands/Database/DeleteCommandTest.php
Normal file
16
tests/Feature/SSHCommands/Database/DeleteCommandTest.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\SSHCommands\Database;
|
||||
|
||||
use App\SSHCommands\Database\DeleteCommand;
|
||||
use Tests\TestCase;
|
||||
|
||||
class DeleteCommandTest extends TestCase
|
||||
{
|
||||
public function test_generate_command()
|
||||
{
|
||||
$command = new DeleteCommand('mysql', 'test');
|
||||
|
||||
$this->assertStringContainsString('sudo mysql -e "DROP DATABASE IF EXISTS test";', $command->content());
|
||||
}
|
||||
}
|
18
tests/Feature/SSHCommands/Database/DeleteUserCommandTest.php
Normal file
18
tests/Feature/SSHCommands/Database/DeleteUserCommandTest.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\SSHCommands\Database;
|
||||
|
||||
use App\SSHCommands\Database\DeleteUserCommand;
|
||||
use Tests\TestCase;
|
||||
|
||||
class DeleteUserCommandTest extends TestCase
|
||||
{
|
||||
public function test_generate_command()
|
||||
{
|
||||
$command = new DeleteUserCommand('mysql', 'user', '%');
|
||||
|
||||
$this->assertStringContainsString('sudo mysql -e "DROP USER IF EXISTS \'user\'@\'%\'";', $command->content());
|
||||
|
||||
$this->assertStringContainsString('sudo mysql -e "FLUSH PRIVILEGES";', $command->content());
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\SSHCommands\Database;
|
||||
|
||||
use App\SSHCommands\Database\InstallMariadbCommand;
|
||||
use Tests\TestCase;
|
||||
|
||||
class InstallMariadbCommandTest extends TestCase
|
||||
{
|
||||
public function test_generate_command()
|
||||
{
|
||||
$command = new InstallMariadbCommand();
|
||||
|
||||
$expected = <<<EOD
|
||||
wget https://downloads.mariadb.com/MariaDB/mariadb_repo_setup
|
||||
|
||||
chmod +x mariadb_repo_setup
|
||||
|
||||
sudo DEBIAN_FRONTEND=noninteractive ./mariadb_repo_setup \
|
||||
--mariadb-server-version="mariadb-10.3"
|
||||
|
||||
sudo DEBIAN_FRONTEND=noninteractive apt update
|
||||
|
||||
sudo DEBIAN_FRONTEND=noninteractive apt install mariadb-server mariadb-backup -y
|
||||
|
||||
sudo service mysql start
|
||||
EOD;
|
||||
|
||||
$this->assertStringContainsString($expected, $command->content());
|
||||
}
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\SSHCommands\Database;
|
||||
|
||||
use App\SSHCommands\Database\InstallMysqlCommand;
|
||||
use Tests\TestCase;
|
||||
|
||||
class InstallMysqlCommandTest extends TestCase
|
||||
{
|
||||
public function test_generate_command_mysql8()
|
||||
{
|
||||
$command = new InstallMysqlCommand('8.0');
|
||||
|
||||
$expected = <<<'EOD'
|
||||
wget -c https://dev.mysql.com/get/mysql-apt-config_0.8.22-1_all.deb
|
||||
|
||||
sudo DEBIAN_FRONTEND=noninteractive dpkg -i mysql-apt-config_0.8.22-1_all.deb
|
||||
|
||||
sudo DEBIAN_FRONTEND=noninteractive apt update
|
||||
|
||||
sudo DEBIAN_FRONTEND=noninteractive apt install mysql-server -y
|
||||
|
||||
sudo service mysql enable
|
||||
|
||||
sudo service mysql start
|
||||
|
||||
if ! sudo mysql -e "ALTER USER 'root'@'localhost' IDENTIFIED WITH auth_socket;"; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
||||
|
||||
if ! sudo mysql -e "FLUSH PRIVILEGES"; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
||||
EOD;
|
||||
|
||||
$this->assertStringContainsString($expected, $command->content());
|
||||
}
|
||||
|
||||
public function test_generate_command_mysql5()
|
||||
{
|
||||
$command = new InstallMysqlCommand('5.7');
|
||||
|
||||
$expected = <<<'EOD'
|
||||
sudo DEBIAN_FRONTEND=noninteractive apt install mysql-server -y
|
||||
|
||||
sudo service mysql enable
|
||||
|
||||
sudo service mysql start
|
||||
|
||||
if ! sudo mysql -e "ALTER USER 'root'@'localhost' IDENTIFIED WITH auth_socket;"; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
||||
|
||||
if ! sudo mysql -e "FLUSH PRIVILEGES"; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
||||
EOD;
|
||||
|
||||
$this->assertStringContainsString($expected, $command->content());
|
||||
}
|
||||
}
|
28
tests/Feature/SSHCommands/Database/LinkCommandTest.php
Normal file
28
tests/Feature/SSHCommands/Database/LinkCommandTest.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\SSHCommands\Database;
|
||||
|
||||
use App\SSHCommands\Database\LinkCommand;
|
||||
use Tests\TestCase;
|
||||
|
||||
class LinkCommandTest extends TestCase
|
||||
{
|
||||
public function test_generate_command()
|
||||
{
|
||||
$command = new LinkCommand('mysql', 'user', '%', 'test');
|
||||
|
||||
$expected = <<<'EOD'
|
||||
if ! sudo mysql -e "GRANT ALL PRIVILEGES ON test.* TO 'user'@'%'"; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
||||
|
||||
if ! sudo mysql -e "FLUSH PRIVILEGES"; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
||||
|
||||
echo "Linking to test finished"
|
||||
EOD;
|
||||
|
||||
$this->assertStringContainsString($expected, $command->content());
|
||||
}
|
||||
}
|
24
tests/Feature/SSHCommands/Database/UnlinkCommandTest.php
Normal file
24
tests/Feature/SSHCommands/Database/UnlinkCommandTest.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\SSHCommands\Database;
|
||||
|
||||
use App\SSHCommands\Database\UnlinkCommand;
|
||||
use Tests\TestCase;
|
||||
|
||||
class UnlinkCommandTest extends TestCase
|
||||
{
|
||||
public function test_generate_command()
|
||||
{
|
||||
$command = new UnlinkCommand('mysql', 'user', '%');
|
||||
|
||||
$expected = <<<'EOD'
|
||||
if ! sudo mysql -e "REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'user'@'%'"; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
||||
|
||||
echo "Command executed"
|
||||
EOD;
|
||||
|
||||
$this->assertStringContainsString($expected, $command->content());
|
||||
}
|
||||
}
|
30
tests/Feature/SSHCommands/Firewall/AddRuleCommandTest.php
Normal file
30
tests/Feature/SSHCommands/Firewall/AddRuleCommandTest.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\SSHCommands\Firewall;
|
||||
|
||||
use App\SSHCommands\Firewall\AddRuleCommand;
|
||||
use Tests\TestCase;
|
||||
|
||||
class AddRuleCommandTest extends TestCase
|
||||
{
|
||||
public function test_generate_command()
|
||||
{
|
||||
$command = new AddRuleCommand('ufw', 'allow', 'tcp', '1080', '0.0.0.0', '0');
|
||||
|
||||
$expected = <<<'EOD'
|
||||
if ! sudo ufw allow from 0.0.0.0/0 to any proto tcp port 1080; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
||||
|
||||
if ! sudo ufw reload; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
||||
|
||||
if ! sudo service ufw restart; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
||||
EOD;
|
||||
|
||||
$this->assertStringContainsString($expected, $command->content());
|
||||
}
|
||||
}
|
46
tests/Feature/SSHCommands/Firewall/InstallUfwCommandTest.php
Normal file
46
tests/Feature/SSHCommands/Firewall/InstallUfwCommandTest.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\SSHCommands\Firewall;
|
||||
|
||||
use App\SSHCommands\Firewall\InstallUfwCommand;
|
||||
use Tests\TestCase;
|
||||
|
||||
class InstallUfwCommandTest extends TestCase
|
||||
{
|
||||
public function test_generate_command()
|
||||
{
|
||||
$command = new InstallUfwCommand();
|
||||
|
||||
$expected = <<<'EOD'
|
||||
if ! sudo ufw default deny incoming; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
||||
|
||||
if ! sudo ufw default allow outgoing; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
||||
|
||||
if ! sudo ufw allow from 0.0.0.0/0 to any proto tcp port 22; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
||||
|
||||
if ! sudo ufw allow from 0.0.0.0/0 to any proto tcp port 80; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
||||
|
||||
if ! sudo ufw allow from 0.0.0.0/0 to any proto tcp port 443; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
||||
|
||||
if ! sudo ufw --force enable; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
||||
|
||||
if ! sudo ufw reload; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
||||
EOD;
|
||||
|
||||
$this->assertStringContainsString($expected, $command->content());
|
||||
}
|
||||
}
|
31
tests/Feature/SSHCommands/Firewall/RemoveRuleCommandTest.php
Normal file
31
tests/Feature/SSHCommands/Firewall/RemoveRuleCommandTest.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\SSHCommands\Firewall;
|
||||
|
||||
use App\SSHCommands\Firewall\RemoveRuleCommand;
|
||||
use Tests\TestCase;
|
||||
|
||||
class RemoveRuleCommandTest extends TestCase
|
||||
{
|
||||
public function test_generate_command()
|
||||
{
|
||||
$command = new RemoveRuleCommand('ufw', 'allow', 'tcp', '1080', '0.0.0.0', '0');
|
||||
|
||||
$expected = <<<'EOD'
|
||||
if ! sudo ufw delete allow from 0.0.0.0/0 to any proto tcp port 1080; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
||||
|
||||
if ! sudo ufw reload; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
||||
|
||||
if ! sudo service ufw restart; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
||||
|
||||
EOD;
|
||||
|
||||
$this->assertStringContainsString($expected, $command->content());
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\SSHCommands\Installation;
|
||||
|
||||
use App\SSHCommands\Installation\InstallNodejsCommand;
|
||||
use Tests\TestCase;
|
||||
|
||||
class InstallNodejsCommandTest extends TestCase
|
||||
{
|
||||
public function test_generate_command()
|
||||
{
|
||||
$command = new InstallNodejsCommand();
|
||||
|
||||
$expected = <<<'EOD'
|
||||
curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -;
|
||||
|
||||
sudo DEBIAN_FRONTEND=noninteractive apt update
|
||||
|
||||
sudo DEBIAN_FRONTEND=noninteractive apt install nodejs -y
|
||||
EOD;
|
||||
|
||||
$this->assertStringContainsString($expected, $command->content());
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\SSHCommands\Installation;
|
||||
|
||||
use App\SSHCommands\Installation\InstallRedisCommand;
|
||||
use Tests\TestCase;
|
||||
|
||||
class InstallRedisCommandTest extends TestCase
|
||||
{
|
||||
public function test_generate_command()
|
||||
{
|
||||
$command = new InstallRedisCommand();
|
||||
|
||||
$expected = <<<'EOD'
|
||||
sudo DEBIAN_FRONTEND=noninteractive apt install redis-server -y
|
||||
|
||||
sudo sed -i 's/bind 127.0.0.1 ::1/bind 0.0.0.0/g' /etc/redis/redis.conf
|
||||
|
||||
sudo service redis enable
|
||||
|
||||
sudo service redis start
|
||||
EOD;
|
||||
|
||||
$this->assertStringContainsString($expected, $command->content());
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\SSHCommands\Installation;
|
||||
|
||||
use App\SSHCommands\Installation\InstallRequirementsCommand;
|
||||
use Tests\TestCase;
|
||||
|
||||
class InstallRequirementsCommandTest extends TestCase
|
||||
{
|
||||
public function test_generate_command()
|
||||
{
|
||||
$command = new InstallRequirementsCommand('user@example.com', 'user');
|
||||
|
||||
$expected = <<<'EOD'
|
||||
sudo DEBIAN_FRONTEND=noninteractive apt install -y software-properties-common curl zip unzip git gcc
|
||||
git config --global user.email "user@example.com"
|
||||
git config --global user.name "user"
|
||||
EOD;
|
||||
|
||||
$this->assertStringContainsString($expected, $command->content());
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\SSHCommands\Nginx;
|
||||
|
||||
use App\SSHCommands\Nginx\ChangeNginxPHPVersionCommand;
|
||||
use Tests\TestCase;
|
||||
|
||||
class ChangeNginxPHPVersionCommandTest extends TestCase
|
||||
{
|
||||
public function test_generate_command()
|
||||
{
|
||||
$command = new ChangeNginxPHPVersionCommand('example.com', '7.1', '8.2');
|
||||
|
||||
$expected = <<<'EOD'
|
||||
if ! sudo sed -i 's/php7.1/php8.2/g' /etc/nginx/sites-available/example.com; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
||||
|
||||
if ! sudo service nginx restart; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
||||
|
||||
echo "PHP Version Changed to 8.2"
|
||||
EOD;
|
||||
|
||||
$this->assertStringContainsString($expected, $command->content());
|
||||
}
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\SSHCommands\Nginx;
|
||||
|
||||
use App\SSHCommands\Nginx\CreateNginxVHostCommand;
|
||||
use Tests\TestCase;
|
||||
|
||||
class CreateNginxVHostCommandTest extends TestCase
|
||||
{
|
||||
public function test_generate_command()
|
||||
{
|
||||
$command = new CreateNginxVHostCommand('example.com', '/home/vito/example.com', '__the__vhost__');
|
||||
|
||||
$expected = <<<'EOD'
|
||||
if ! rm -rf /home/vito/example.com; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
||||
|
||||
if ! mkdir /home/vito/example.com; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
||||
|
||||
if ! sudo chown -R 755 /home/vito/example.com; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
||||
|
||||
if ! echo '' | sudo tee /etc/nginx/conf.d/example.com_redirects; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
||||
|
||||
if ! echo '__the__vhost__' | sudo tee /etc/nginx/sites-available/example.com; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
||||
|
||||
if ! sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
||||
|
||||
if ! sudo service nginx restart; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
||||
EOD;
|
||||
|
||||
$this->assertStringContainsString($expected, $command->content());
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\SSHCommands\Nginx;
|
||||
|
||||
use App\SSHCommands\Nginx\DeleteNginxSiteCommand;
|
||||
use Tests\TestCase;
|
||||
|
||||
class DeleteNginxSiteCommandTest extends TestCase
|
||||
{
|
||||
public function test_generate_command()
|
||||
{
|
||||
$command = new DeleteNginxSiteCommand('example.com', '/home/vito/example.com');
|
||||
|
||||
$expected = <<<'EOD'
|
||||
rm -rf /home/vito/example.com
|
||||
|
||||
sudo rm /etc/nginx/sites-available/example.com
|
||||
|
||||
sudo rm /etc/nginx/sites-enabled/example.com
|
||||
|
||||
echo "Site deleted"
|
||||
EOD;
|
||||
|
||||
$this->assertStringContainsString($expected, $command->content());
|
||||
}
|
||||
}
|
115
tests/Feature/SSHCommands/Nginx/InstallNginxCommandTest.php
Normal file
115
tests/Feature/SSHCommands/Nginx/InstallNginxCommandTest.php
Normal file
@ -0,0 +1,115 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\SSHCommands\Nginx;
|
||||
|
||||
use App\SSHCommands\Nginx\InstallNginxCommand;
|
||||
use Tests\TestCase;
|
||||
|
||||
class InstallNginxCommandTest extends TestCase
|
||||
{
|
||||
public function test_generate_command()
|
||||
{
|
||||
$command = new InstallNginxCommand();
|
||||
|
||||
$nginxConfig = <<<'EOD'
|
||||
user vito;
|
||||
worker_processes auto;
|
||||
pid /run/nginx.pid;
|
||||
include /etc/nginx/modules-enabled/*.conf;
|
||||
|
||||
events {
|
||||
worker_connections 768;
|
||||
# multi_accept on;
|
||||
}
|
||||
|
||||
http {
|
||||
|
||||
##
|
||||
# Basic Settings
|
||||
##
|
||||
|
||||
sendfile on;
|
||||
tcp_nopush on;
|
||||
tcp_nodelay on;
|
||||
keepalive_timeout 65;
|
||||
types_hash_max_size 2048;
|
||||
# server_tokens off;
|
||||
|
||||
# server_names_hash_bucket_size 64;
|
||||
# server_name_in_redirect off;
|
||||
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
##
|
||||
# SSL Settings
|
||||
##
|
||||
|
||||
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
|
||||
ssl_prefer_server_ciphers on;
|
||||
|
||||
##
|
||||
# Logging Settings
|
||||
##
|
||||
|
||||
access_log /var/log/nginx/access.log;
|
||||
error_log /var/log/nginx/error.log;
|
||||
|
||||
##
|
||||
# Gzip Settings
|
||||
##
|
||||
|
||||
gzip on;
|
||||
|
||||
# gzip_vary on;
|
||||
# gzip_proxied any;
|
||||
# gzip_comp_level 6;
|
||||
# gzip_buffers 16 8k;
|
||||
# gzip_http_version 1.1;
|
||||
# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
|
||||
|
||||
##
|
||||
# Virtual Host Configs
|
||||
##
|
||||
|
||||
include /etc/nginx/conf.d/*.conf;
|
||||
include /etc/nginx/sites-enabled/*;
|
||||
}
|
||||
|
||||
|
||||
#mail {
|
||||
# # See sample authentication script at:
|
||||
# # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
|
||||
#
|
||||
# # auth_http localhost/auth.php;
|
||||
# # pop3_capabilities "TOP" "USER";
|
||||
# # imap_capabilities "IMAP4rev1" "UIDPLUS";
|
||||
#
|
||||
# server {
|
||||
# listen localhost:110;
|
||||
# protocol pop3;
|
||||
# proxy on;
|
||||
# }
|
||||
#
|
||||
# server {
|
||||
# listen localhost:143;
|
||||
# protocol imap;
|
||||
# proxy on;
|
||||
# }
|
||||
#}
|
||||
|
||||
EOD;
|
||||
|
||||
$expected = <<<EOD
|
||||
sudo DEBIAN_FRONTEND=noninteractive apt install nginx -y
|
||||
|
||||
if ! echo '$nginxConfig' | sudo tee /etc/nginx/nginx.conf; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
||||
|
||||
sudo service nginx start
|
||||
EOD;
|
||||
|
||||
$this->assertStringContainsString($expected, $command->content());
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\SSHCommands\Nginx;
|
||||
|
||||
use App\SSHCommands\Nginx\UpdateNginxRedirectsCommand;
|
||||
use Tests\TestCase;
|
||||
|
||||
class UpdateNginxRedirectsCommandTest extends TestCase
|
||||
{
|
||||
public function test_generate_command()
|
||||
{
|
||||
$command = new UpdateNginxRedirectsCommand('example.com', '__redirects__');
|
||||
|
||||
$expected = <<<'EOD'
|
||||
if ! echo '__redirects__' | sudo tee /etc/nginx/conf.d/example.com_redirects; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
||||
|
||||
if ! sudo service nginx restart; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
||||
EOD;
|
||||
|
||||
$this->assertStringContainsString($expected, $command->content());
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\SSHCommands\Nginx;
|
||||
|
||||
use App\SSHCommands\Nginx\UpdateNginxVHostCommand;
|
||||
use Tests\TestCase;
|
||||
|
||||
class UpdateNginxVHostCommandTest extends TestCase
|
||||
{
|
||||
public function test_generate_command()
|
||||
{
|
||||
$command = new UpdateNginxVHostCommand('example.com', '/home/vito/example.com', '__vhost__');
|
||||
|
||||
$expected = <<<'EOD'
|
||||
if ! echo '__vhost__' | sudo tee /etc/nginx/sites-available/example.com; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
||||
|
||||
if ! sudo service nginx restart; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
||||
EOD;
|
||||
|
||||
$this->assertStringContainsString($expected, $command->content());
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\SSHCommands\PHP;
|
||||
|
||||
use App\SSHCommands\PHP\ChangeDefaultPHPCommand;
|
||||
use Tests\TestCase;
|
||||
|
||||
class ChangeDefaultPHPCommandTest extends TestCase
|
||||
{
|
||||
public function test_generate_command()
|
||||
{
|
||||
$command = new ChangeDefaultPHPCommand('8.2');
|
||||
|
||||
$expected = <<<'EOD'
|
||||
if ! sudo rm /usr/bin/php; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
||||
|
||||
if ! sudo ln -s /usr/bin/php8.2 /usr/bin/php; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
||||
|
||||
echo "Default php is: "
|
||||
|
||||
php -v
|
||||
EOD;
|
||||
|
||||
$this->assertStringContainsString($expected, $command->content());
|
||||
}
|
||||
}
|
20
tests/Feature/SSHCommands/PHP/GetPHPIniCommandTest.php
Normal file
20
tests/Feature/SSHCommands/PHP/GetPHPIniCommandTest.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\SSHCommands\PHP;
|
||||
|
||||
use App\SSHCommands\PHP\GetPHPIniCommand;
|
||||
use Tests\TestCase;
|
||||
|
||||
class GetPHPIniCommandTest extends TestCase
|
||||
{
|
||||
public function test_generate_command()
|
||||
{
|
||||
$command = new GetPHPIniCommand('8.2');
|
||||
|
||||
$expected = <<<'EOD'
|
||||
cat /etc/php/8.2/cli/php.ini
|
||||
EOD;
|
||||
|
||||
$this->assertStringContainsString($expected, $command->content());
|
||||
}
|
||||
}
|
26
tests/Feature/SSHCommands/PHP/InstallComposerCommandTest.php
Normal file
26
tests/Feature/SSHCommands/PHP/InstallComposerCommandTest.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\SSHCommands\PHP;
|
||||
|
||||
use App\SSHCommands\PHP\InstallComposerCommand;
|
||||
use Tests\TestCase;
|
||||
|
||||
class InstallComposerCommandTest extends TestCase
|
||||
{
|
||||
public function test_generate_command()
|
||||
{
|
||||
$command = new InstallComposerCommand();
|
||||
|
||||
$expected = <<<'EOD'
|
||||
cd ~
|
||||
|
||||
curl -sS https://getcomposer.org/installer -o composer-setup.php
|
||||
|
||||
sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer
|
||||
|
||||
composer
|
||||
EOD;
|
||||
|
||||
$this->assertStringContainsString($expected, $command->content());
|
||||
}
|
||||
}
|
32
tests/Feature/SSHCommands/PHP/InstallPHPCommandTest.php
Normal file
32
tests/Feature/SSHCommands/PHP/InstallPHPCommandTest.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\SSHCommands\PHP;
|
||||
|
||||
use App\SSHCommands\PHP\InstallPHPCommand;
|
||||
use Tests\TestCase;
|
||||
|
||||
class InstallPHPCommandTest extends TestCase
|
||||
{
|
||||
public function test_generate_command()
|
||||
{
|
||||
$command = new InstallPHPCommand('8.1');
|
||||
|
||||
$expected = <<<'EOD'
|
||||
sudo add-apt-repository ppa:ondrej/php -y
|
||||
|
||||
sudo DEBIAN_FRONTEND=noninteractive apt update
|
||||
|
||||
sudo DEBIAN_FRONTEND=noninteractive apt install -y php8.1 php8.1-fpm php8.1-mbstring php8.1-mysql php8.1-mcrypt php8.1-gd php8.1-xml php8.1-curl php8.1-gettext php8.1-zip php8.1-bcmath php8.1-soap php8.1-redis
|
||||
|
||||
if ! sudo sed -i 's/www-data/vito/g' /etc/php/8.1/fpm/pool.d/www.conf; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
||||
|
||||
sudo service php8.1-fpm enable
|
||||
|
||||
sudo service php8.1-fpm start
|
||||
EOD;
|
||||
|
||||
$this->assertStringContainsString($expected, $command->content());
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\SSHCommands\PHP;
|
||||
|
||||
use App\SSHCommands\PHP\InstallPHPExtensionCommand;
|
||||
use Tests\TestCase;
|
||||
|
||||
class InstallPHPExtensionCommandTest extends TestCase
|
||||
{
|
||||
public function test_generate_command()
|
||||
{
|
||||
$command = new InstallPHPExtensionCommand('8.1', 'imagick');
|
||||
|
||||
$expected = <<<'EOD'
|
||||
sudo apt install -y php8.1-imagick
|
||||
|
||||
sudo service php8.1-fpm restart
|
||||
|
||||
php8.1 -m
|
||||
EOD;
|
||||
|
||||
$this->assertStringContainsString($expected, $command->content());
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user