mirror of
https://github.com/vitodeploy/vito.git
synced 2025-04-20 10:21:37 +00:00
Bug fixes (#155)
This commit is contained in:
parent
2d566b853f
commit
12c500e125
@ -34,8 +34,6 @@ public function create(Site $site, array $input): void
|
|||||||
$ssl->status = SslStatus::CREATED;
|
$ssl->status = SslStatus::CREATED;
|
||||||
$ssl->save();
|
$ssl->save();
|
||||||
$site->type()->edit();
|
$site->type()->edit();
|
||||||
})->catch(function () use ($ssl) {
|
|
||||||
$ssl->delete();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
namespace App\Actions\Site;
|
namespace App\Actions\Site;
|
||||||
|
|
||||||
use App\Enums\SiteStatus;
|
use App\Enums\SiteStatus;
|
||||||
|
use App\Exceptions\RepositoryNotFound;
|
||||||
|
use App\Exceptions\RepositoryPermissionDenied;
|
||||||
use App\Exceptions\SourceControlIsNotConnected;
|
use App\Exceptions\SourceControlIsNotConnected;
|
||||||
use App\Facades\Notifier;
|
use App\Facades\Notifier;
|
||||||
use App\Models\Server;
|
use App\Models\Server;
|
||||||
@ -19,7 +21,6 @@
|
|||||||
class CreateSite
|
class CreateSite
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @throws SourceControlIsNotConnected
|
|
||||||
* @throws ValidationException
|
* @throws ValidationException
|
||||||
*/
|
*/
|
||||||
public function create(Server $server, array $input): Site
|
public function create(Server $server, array $input): Site
|
||||||
@ -47,7 +48,15 @@ public function create(Server $server, array $input): Site
|
|||||||
}
|
}
|
||||||
} catch (SourceControlIsNotConnected) {
|
} catch (SourceControlIsNotConnected) {
|
||||||
throw ValidationException::withMessages([
|
throw ValidationException::withMessages([
|
||||||
'source_control' => __('Source control is not connected'),
|
'source_control' => 'Source control is not connected',
|
||||||
|
]);
|
||||||
|
} catch (RepositoryPermissionDenied) {
|
||||||
|
throw ValidationException::withMessages([
|
||||||
|
'repository' => 'You do not have permission to access this repository',
|
||||||
|
]);
|
||||||
|
} catch (RepositoryNotFound) {
|
||||||
|
throw ValidationException::withMessages([
|
||||||
|
'repository' => 'Repository not found',
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
49
app/Actions/Site/UpdateSourceControl.php
Normal file
49
app/Actions/Site/UpdateSourceControl.php
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Actions\Site;
|
||||||
|
|
||||||
|
use App\Exceptions\RepositoryNotFound;
|
||||||
|
use App\Exceptions\RepositoryPermissionDenied;
|
||||||
|
use App\Exceptions\SourceControlIsNotConnected;
|
||||||
|
use App\Models\Site;
|
||||||
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
use Illuminate\Validation\Rule;
|
||||||
|
use Illuminate\Validation\ValidationException;
|
||||||
|
|
||||||
|
class UpdateSourceControl
|
||||||
|
{
|
||||||
|
public function update(Site $site, array $input): void
|
||||||
|
{
|
||||||
|
$this->validate($input);
|
||||||
|
|
||||||
|
$site->source_control_id = $input['source_control'];
|
||||||
|
try {
|
||||||
|
if ($site->sourceControl()) {
|
||||||
|
$site->sourceControl()->getRepo($site->repository);
|
||||||
|
}
|
||||||
|
} catch (SourceControlIsNotConnected) {
|
||||||
|
throw ValidationException::withMessages([
|
||||||
|
'source_control' => 'Source control is not connected',
|
||||||
|
]);
|
||||||
|
} catch (RepositoryPermissionDenied) {
|
||||||
|
throw ValidationException::withMessages([
|
||||||
|
'repository' => 'You do not have permission to access this repository',
|
||||||
|
]);
|
||||||
|
} catch (RepositoryNotFound) {
|
||||||
|
throw ValidationException::withMessages([
|
||||||
|
'repository' => 'Repository not found',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
$site->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function validate(array $input): void
|
||||||
|
{
|
||||||
|
Validator::make($input, [
|
||||||
|
'source_control' => [
|
||||||
|
'required',
|
||||||
|
Rule::exists('source_controls', 'id'),
|
||||||
|
],
|
||||||
|
])->validate();
|
||||||
|
}
|
||||||
|
}
|
@ -2,9 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Exceptions;
|
namespace App\Exceptions;
|
||||||
|
|
||||||
use Exception;
|
class SSHAuthenticationError extends SSHError
|
||||||
|
|
||||||
class SSHAuthenticationError extends Exception
|
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
@ -2,9 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Exceptions;
|
namespace App\Exceptions;
|
||||||
|
|
||||||
use Exception;
|
class SSLCreationException extends SSHError
|
||||||
|
|
||||||
class SSLCreationException extends Exception
|
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
@ -133,7 +133,7 @@ public function exec(string $command, string $log = '', ?int $siteId = null, ?bo
|
|||||||
$this->log?->write($output);
|
$this->log?->write($output);
|
||||||
|
|
||||||
if (Str::contains($output, 'VITO_SSH_ERROR')) {
|
if (Str::contains($output, 'VITO_SSH_ERROR')) {
|
||||||
throw new Exception('SSH command failed with an error');
|
throw new SSHCommandError('SSH command failed with an error');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $output;
|
return $output;
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
use App\Actions\Site\UpdateDeploymentScript;
|
use App\Actions\Site\UpdateDeploymentScript;
|
||||||
use App\Actions\Site\UpdateEnv;
|
use App\Actions\Site\UpdateEnv;
|
||||||
use App\Exceptions\DeploymentScriptIsEmptyException;
|
use App\Exceptions\DeploymentScriptIsEmptyException;
|
||||||
|
use App\Exceptions\RepositoryNotFound;
|
||||||
|
use App\Exceptions\RepositoryPermissionDenied;
|
||||||
use App\Exceptions\SourceControlIsNotConnected;
|
use App\Exceptions\SourceControlIsNotConnected;
|
||||||
use App\Facades\Toast;
|
use App\Facades\Toast;
|
||||||
use App\Helpers\HtmxResponse;
|
use App\Helpers\HtmxResponse;
|
||||||
@ -24,12 +26,14 @@ public function deploy(Server $server, Site $site): HtmxResponse
|
|||||||
app(Deploy::class)->run($site);
|
app(Deploy::class)->run($site);
|
||||||
|
|
||||||
Toast::success('Deployment started!');
|
Toast::success('Deployment started!');
|
||||||
} catch (SourceControlIsNotConnected $e) {
|
} catch (SourceControlIsNotConnected) {
|
||||||
Toast::error($e->getMessage());
|
Toast::error('Source control is not connected. Check site\'s settings.');
|
||||||
|
|
||||||
return htmx()->redirect(route('source-controls'));
|
|
||||||
} catch (DeploymentScriptIsEmptyException) {
|
} catch (DeploymentScriptIsEmptyException) {
|
||||||
Toast::error('Deployment script is empty!');
|
Toast::error('Deployment script is empty!');
|
||||||
|
} catch (RepositoryPermissionDenied) {
|
||||||
|
Toast::error('You do not have permission to access this repository!');
|
||||||
|
} catch (RepositoryNotFound) {
|
||||||
|
Toast::error('Repository not found!');
|
||||||
}
|
}
|
||||||
|
|
||||||
return htmx()->back();
|
return htmx()->back();
|
||||||
@ -83,6 +87,12 @@ public function enableAutoDeployment(Server $server, Site $site): HtmxResponse
|
|||||||
Toast::success('Auto deployment has been enabled.');
|
Toast::success('Auto deployment has been enabled.');
|
||||||
} catch (SourceControlIsNotConnected) {
|
} catch (SourceControlIsNotConnected) {
|
||||||
Toast::error('Source control is not connected. Check site\'s settings.');
|
Toast::error('Source control is not connected. Check site\'s settings.');
|
||||||
|
} catch (DeploymentScriptIsEmptyException) {
|
||||||
|
Toast::error('Deployment script is empty!');
|
||||||
|
} catch (RepositoryPermissionDenied) {
|
||||||
|
Toast::error('You do not have permission to access this repository!');
|
||||||
|
} catch (RepositoryNotFound) {
|
||||||
|
Toast::error('Repository not found!');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
use App\Actions\Site\CreateSite;
|
use App\Actions\Site\CreateSite;
|
||||||
use App\Actions\Site\DeleteSite;
|
use App\Actions\Site\DeleteSite;
|
||||||
|
use App\Enums\SiteStatus;
|
||||||
use App\Enums\SiteType;
|
use App\Enums\SiteType;
|
||||||
use App\Facades\Toast;
|
use App\Facades\Toast;
|
||||||
use App\Helpers\HtmxResponse;
|
use App\Helpers\HtmxResponse;
|
||||||
@ -42,14 +43,38 @@ public function create(Server $server): View
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function show(Server $server, Site $site): View
|
public function show(Server $server, Site $site, Request $request): View|RedirectResponse|HtmxResponse
|
||||||
{
|
{
|
||||||
|
if (in_array($site->status, [SiteStatus::INSTALLING, SiteStatus::INSTALLATION_FAILED])) {
|
||||||
|
if ($request->hasHeader('HX-Request')) {
|
||||||
|
return htmx()->redirect(route('servers.sites.installing', [$server, $site]));
|
||||||
|
}
|
||||||
|
|
||||||
|
return redirect()->route('servers.sites.installing', [$server, $site]);
|
||||||
|
}
|
||||||
|
|
||||||
return view('sites.show', [
|
return view('sites.show', [
|
||||||
'server' => $server,
|
'server' => $server,
|
||||||
'site' => $site,
|
'site' => $site,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function installing(Server $server, Site $site, Request $request): View|RedirectResponse|HtmxResponse
|
||||||
|
{
|
||||||
|
if (! in_array($site->status, [SiteStatus::INSTALLING, SiteStatus::INSTALLATION_FAILED])) {
|
||||||
|
if ($request->hasHeader('HX-Request')) {
|
||||||
|
return htmx()->redirect(route('servers.sites.show', [$server, $site]));
|
||||||
|
}
|
||||||
|
|
||||||
|
return redirect()->route('servers.sites.show', [$server, $site]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('sites.installing', [
|
||||||
|
'server' => $server,
|
||||||
|
'site' => $site,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
public function destroy(Server $server, Site $site): RedirectResponse
|
public function destroy(Server $server, Site $site): RedirectResponse
|
||||||
{
|
{
|
||||||
app(DeleteSite::class)->delete($site);
|
app(DeleteSite::class)->delete($site);
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Actions\Site\UpdateSourceControl;
|
||||||
use App\Facades\Toast;
|
use App\Facades\Toast;
|
||||||
use App\Helpers\HtmxResponse;
|
use App\Helpers\HtmxResponse;
|
||||||
use App\Models\Server;
|
use App\Models\Server;
|
||||||
@ -63,4 +64,13 @@ public function updatePHPVersion(Server $server, Site $site, Request $request):
|
|||||||
|
|
||||||
return htmx()->back();
|
return htmx()->back();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function updateSourceControl(Server $server, Site $site, Request $request): HtmxResponse
|
||||||
|
{
|
||||||
|
$site = app(UpdateSourceControl::class)->update($site, $request->input());
|
||||||
|
|
||||||
|
Toast::success('Source control updated successfully!');
|
||||||
|
|
||||||
|
return htmx()->back();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
<x-slot name="trigger">
|
<x-slot name="trigger">
|
||||||
<x-secondary-button>
|
<x-secondary-button>
|
||||||
{{ __("Auto Deployment") }}
|
{{ __("Auto Deployment") }}
|
||||||
|
<x-heroicon name="o-chevron-down" class="ml-1 h-4 w-4" />
|
||||||
</x-secondary-button>
|
</x-secondary-button>
|
||||||
</x-slot>
|
</x-slot>
|
||||||
<x-slot name="content">
|
<x-slot name="content">
|
||||||
|
@ -12,6 +12,8 @@ class="p-6"
|
|||||||
{{ __("Deployment Script") }}
|
{{ __("Deployment Script") }}
|
||||||
</h2>
|
</h2>
|
||||||
|
|
||||||
|
<div class="mt-6">A bash script that will be executed when you run the deployment process.</div>
|
||||||
|
|
||||||
<div class="mt-6">
|
<div class="mt-6">
|
||||||
<x-input-label for="script" :value="__('Script')" />
|
<x-input-label for="script" :value="__('Script')" />
|
||||||
<x-textarea id="script" name="script" class="mt-1 min-h-[400px] w-full">
|
<x-textarea id="script" name="script" class="mt-1 min-h-[400px] w-full">
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
<x-slot name="trigger">
|
<x-slot name="trigger">
|
||||||
<x-secondary-button>
|
<x-secondary-button>
|
||||||
{{ __("Manage") }}
|
{{ __("Manage") }}
|
||||||
|
<x-heroicon name="o-chevron-down" class="ml-1 h-4 w-4" />
|
||||||
</x-secondary-button>
|
</x-secondary-button>
|
||||||
</x-slot>
|
</x-slot>
|
||||||
<x-slot name="content">
|
<x-slot name="content">
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
runUrl: '{{ route("servers.console.run", ["server" => $server]) }}',
|
runUrl: '{{ route("servers.console.run", ["server" => $server]) }}',
|
||||||
async run() {
|
async run() {
|
||||||
this.running = true
|
this.running = true
|
||||||
this.output = 'Running...\n'
|
this.output = this.command + '\n'
|
||||||
const fetchOptions = {
|
const fetchOptions = {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
@ -23,6 +23,7 @@
|
|||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.command = ''
|
||||||
const response = await fetch(this.runUrl, fetchOptions)
|
const response = await fetch(this.runUrl, fetchOptions)
|
||||||
const reader = response.body.getReader()
|
const reader = response.body.getReader()
|
||||||
const decoder = new TextDecoder('utf-8')
|
const decoder = new TextDecoder('utf-8')
|
||||||
|
@ -38,6 +38,17 @@ class="p-6"
|
|||||||
@endif
|
@endif
|
||||||
@endforeach
|
@endforeach
|
||||||
</x-select-input>
|
</x-select-input>
|
||||||
|
<x-input-help>
|
||||||
|
Check
|
||||||
|
<a
|
||||||
|
href="https://vitodeploy.com/settings/source-controls.html"
|
||||||
|
class="text-primary-500"
|
||||||
|
target="_blank"
|
||||||
|
>
|
||||||
|
here
|
||||||
|
</a>
|
||||||
|
to see what permissions you need
|
||||||
|
</x-input-help>
|
||||||
@error("provider")
|
@error("provider")
|
||||||
<x-input-error class="mt-2" :messages="$message" />
|
<x-input-error class="mt-2" :messages="$message" />
|
||||||
@enderror
|
@enderror
|
||||||
|
@ -3,6 +3,10 @@
|
|||||||
|
|
||||||
@include("site-settings.partials.change-php-version")
|
@include("site-settings.partials.change-php-version")
|
||||||
|
|
||||||
|
@if ($site->source_control_id)
|
||||||
|
@include("site-settings.partials.update-source-control")
|
||||||
|
@endif
|
||||||
|
|
||||||
@include("site-settings.partials.update-v-host")
|
@include("site-settings.partials.update-v-host")
|
||||||
|
|
||||||
<x-card>
|
<x-card>
|
||||||
|
@ -0,0 +1,32 @@
|
|||||||
|
<x-card>
|
||||||
|
<x-slot name="title">{{ __("Update Source Control") }}</x-slot>
|
||||||
|
|
||||||
|
<x-slot name="description">
|
||||||
|
{{ __("You can switch the source control profile (token) in case of token expiration. Keep in mind that it must be the same account and provider") }}
|
||||||
|
</x-slot>
|
||||||
|
|
||||||
|
<form
|
||||||
|
id="update-source-control"
|
||||||
|
hx-post="{{ route("servers.sites.settings.source-control", ["server" => $server, "site" => $site]) }}"
|
||||||
|
hx-swap="outerHTML"
|
||||||
|
hx-select="#update-source-control"
|
||||||
|
hx-ext="disable-element"
|
||||||
|
hx-disable-element="#btn-update-source-control"
|
||||||
|
class="space-y-6"
|
||||||
|
>
|
||||||
|
@include(
|
||||||
|
"sites.partials.create.fields.source-control",
|
||||||
|
[
|
||||||
|
"sourceControls" => \App\Models\SourceControl::query()
|
||||||
|
->where("provider", $site->sourceControl()?->provider)
|
||||||
|
->get(),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<x-slot name="actions">
|
||||||
|
<x-primary-button id="btn-update-source-control" form="update-source-control" hx-disable>
|
||||||
|
{{ __("Save") }}
|
||||||
|
</x-primary-button>
|
||||||
|
</x-slot>
|
||||||
|
</x-card>
|
15
resources/views/sites/installing.blade.php
Normal file
15
resources/views/sites/installing.blade.php
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<x-site-layout :site="$site">
|
||||||
|
<x-slot name="pageTitle">{{ $site->domain }}</x-slot>
|
||||||
|
|
||||||
|
<x-live id="site">
|
||||||
|
@if ($site->status === \App\Enums\SiteStatus::INSTALLING)
|
||||||
|
@include("sites.partials.installing", ["site" => $site])
|
||||||
|
@endif
|
||||||
|
|
||||||
|
@if ($site->status === \App\Enums\SiteStatus::INSTALLATION_FAILED)
|
||||||
|
@include("sites.partials.installation-failed", ["site" => $site])
|
||||||
|
@endif
|
||||||
|
</x-live>
|
||||||
|
|
||||||
|
@include("server-logs.partials.logs-list", ["server" => $site->server, "site" => $site])
|
||||||
|
</x-site-layout>
|
@ -6,7 +6,7 @@
|
|||||||
@foreach ($sourceControls as $sourceControl)
|
@foreach ($sourceControls as $sourceControl)
|
||||||
<option
|
<option
|
||||||
value="{{ $sourceControl->id }}"
|
value="{{ $sourceControl->id }}"
|
||||||
@if($sourceControl->id === old('source_control')) selected @endif
|
@if($sourceControl->id == old('source_control', isset($site) ? $site->source_control_id : null)) selected @endif
|
||||||
>
|
>
|
||||||
{{ $sourceControl->profile }}
|
{{ $sourceControl->profile }}
|
||||||
({{ $sourceControl->provider }})
|
({{ $sourceControl->provider }})
|
||||||
|
@ -1,17 +0,0 @@
|
|||||||
<div>
|
|
||||||
@if ($site->status === \App\Enums\SiteStatus::INSTALLING)
|
|
||||||
@include("sites.partials.installing", ["site" => $site])
|
|
||||||
|
|
||||||
@include("server-logs.partials.logs-list", ["server" => $site->server, "site" => $site])
|
|
||||||
@endif
|
|
||||||
|
|
||||||
@if ($site->status === \App\Enums\SiteStatus::INSTALLATION_FAILED)
|
|
||||||
@include("sites.partials.installation-failed", ["site" => $site])
|
|
||||||
|
|
||||||
@include("server-logs.partials.logs-list", ["server" => $site->server, "site" => $site])
|
|
||||||
@endif
|
|
||||||
|
|
||||||
@if ($site->status === \App\Enums\SiteStatus::READY)
|
|
||||||
@include("application." . $site->type . "-app", ["site" => $site])
|
|
||||||
@endif
|
|
||||||
</div>
|
|
@ -1,5 +1,5 @@
|
|||||||
<x-site-layout :site="$site">
|
<x-site-layout :site="$site">
|
||||||
<x-slot name="pageTitle">{{ $site->domain }}</x-slot>
|
<x-slot name="pageTitle">{{ $site->domain }}</x-slot>
|
||||||
|
|
||||||
@include("sites.partials.show-site")
|
@include("application." . $site->type . "-app", ["site" => $site])
|
||||||
</x-site-layout>
|
</x-site-layout>
|
||||||
|
@ -36,6 +36,7 @@
|
|||||||
Route::post('/create', [SiteController::class, 'store']);
|
Route::post('/create', [SiteController::class, 'store']);
|
||||||
Route::get('/{site}', [SiteController::class, 'show'])->name('servers.sites.show');
|
Route::get('/{site}', [SiteController::class, 'show'])->name('servers.sites.show');
|
||||||
Route::delete('/{site}', [SiteController::class, 'destroy'])->name('servers.sites.destroy');
|
Route::delete('/{site}', [SiteController::class, 'destroy'])->name('servers.sites.destroy');
|
||||||
|
Route::get('/{site}/installing', [SiteController::class, 'installing'])->name('servers.sites.installing');
|
||||||
|
|
||||||
// site application
|
// site application
|
||||||
Route::post('/{site}/application/deploy', [ApplicationController::class, 'deploy'])->name('servers.sites.application.deploy');
|
Route::post('/{site}/application/deploy', [ApplicationController::class, 'deploy'])->name('servers.sites.application.deploy');
|
||||||
@ -64,6 +65,7 @@
|
|||||||
Route::get('/{site}/settings/vhost', [SiteSettingController::class, 'getVhost'])->name('servers.sites.settings.vhost');
|
Route::get('/{site}/settings/vhost', [SiteSettingController::class, 'getVhost'])->name('servers.sites.settings.vhost');
|
||||||
Route::post('/{site}/settings/vhost', [SiteSettingController::class, 'updateVhost']);
|
Route::post('/{site}/settings/vhost', [SiteSettingController::class, 'updateVhost']);
|
||||||
Route::post('/{site}/settings/php', [SiteSettingController::class, 'updatePHPVersion'])->name('servers.sites.settings.php');
|
Route::post('/{site}/settings/php', [SiteSettingController::class, 'updatePHPVersion'])->name('servers.sites.settings.php');
|
||||||
|
Route::post('/{site}/settings/source-control', [SiteSettingController::class, 'updateSourceControl'])->name('servers.sites.settings.source-control');
|
||||||
|
|
||||||
// site logs
|
// site logs
|
||||||
Route::get('/{site}/logs', [SiteLogController::class, 'index'])->name('servers.sites.logs');
|
Route::get('/{site}/logs', [SiteLogController::class, 'index'])->name('servers.sites.logs');
|
||||||
|
@ -46,6 +46,48 @@ public function test_create_site(array $inputs): void
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider create_failure_data
|
||||||
|
*/
|
||||||
|
public function test_create_site_failed_due_to_source_control(int $status): void
|
||||||
|
{
|
||||||
|
$inputs = [
|
||||||
|
'type' => SiteType::LARAVEL,
|
||||||
|
'domain' => 'example.com',
|
||||||
|
'alias' => 'www.example.com',
|
||||||
|
'php_version' => '8.2',
|
||||||
|
'web_directory' => 'public',
|
||||||
|
'repository' => 'test/test',
|
||||||
|
'branch' => 'main',
|
||||||
|
'composer' => true,
|
||||||
|
];
|
||||||
|
|
||||||
|
SSH::fake();
|
||||||
|
|
||||||
|
Http::fake([
|
||||||
|
'https://api.github.com/repos/*' => Http::response([
|
||||||
|
], $status),
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->actingAs($this->user);
|
||||||
|
|
||||||
|
/** @var \App\Models\SourceControl $sourceControl */
|
||||||
|
$sourceControl = \App\Models\SourceControl::factory()->create([
|
||||||
|
'provider' => SourceControl::GITHUB,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$inputs['source_control'] = $sourceControl->id;
|
||||||
|
|
||||||
|
$this->post(route('servers.sites.create', [
|
||||||
|
'server' => $this->server,
|
||||||
|
]), $inputs)->assertSessionHasErrors();
|
||||||
|
|
||||||
|
$this->assertDatabaseMissing('sites', [
|
||||||
|
'domain' => 'example.com',
|
||||||
|
'status' => SiteStatus::READY,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
public function test_see_sites_list(): void
|
public function test_see_sites_list(): void
|
||||||
{
|
{
|
||||||
$this->actingAs($this->user);
|
$this->actingAs($this->user);
|
||||||
@ -103,6 +145,58 @@ public function test_change_php_version(): void
|
|||||||
$this->assertEquals('8.2', $site->php_version);
|
$this->assertEquals('8.2', $site->php_version);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function test_update_source_control(): void
|
||||||
|
{
|
||||||
|
SSH::fake();
|
||||||
|
|
||||||
|
$this->actingAs($this->user);
|
||||||
|
|
||||||
|
Http::fake([
|
||||||
|
'https://api.github.com/repos/*' => Http::response([
|
||||||
|
], 201),
|
||||||
|
]);
|
||||||
|
|
||||||
|
/** @var \App\Models\SourceControl $sourceControl */
|
||||||
|
$sourceControl = \App\Models\SourceControl::factory()->create([
|
||||||
|
'provider' => SourceControl::GITHUB,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->post(route('servers.sites.settings.source-control', [
|
||||||
|
'server' => $this->server,
|
||||||
|
'site' => $this->site,
|
||||||
|
]), [
|
||||||
|
'source_control' => $sourceControl->id,
|
||||||
|
])->assertSessionDoesntHaveErrors();
|
||||||
|
|
||||||
|
$this->site->refresh();
|
||||||
|
|
||||||
|
$this->assertEquals($sourceControl->id, $this->site->source_control_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_failed_to_update_source_control(): void
|
||||||
|
{
|
||||||
|
SSH::fake();
|
||||||
|
|
||||||
|
$this->actingAs($this->user);
|
||||||
|
|
||||||
|
Http::fake([
|
||||||
|
'https://api.github.com/repos/*' => Http::response([
|
||||||
|
], 404),
|
||||||
|
]);
|
||||||
|
|
||||||
|
/** @var \App\Models\SourceControl $sourceControl */
|
||||||
|
$sourceControl = \App\Models\SourceControl::factory()->create([
|
||||||
|
'provider' => SourceControl::GITHUB,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->post(route('servers.sites.settings.source-control', [
|
||||||
|
'server' => $this->server,
|
||||||
|
'site' => $this->site,
|
||||||
|
]), [
|
||||||
|
'source_control' => $sourceControl->id,
|
||||||
|
])->assertSessionHasErrors();
|
||||||
|
}
|
||||||
|
|
||||||
public function test_update_v_host(): void
|
public function test_update_v_host(): void
|
||||||
{
|
{
|
||||||
SSH::fake();
|
SSH::fake();
|
||||||
@ -170,6 +264,15 @@ public static function create_data(): array
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function create_failure_data(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[401],
|
||||||
|
[403],
|
||||||
|
[404],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
public function test_see_logs(): void
|
public function test_see_logs(): void
|
||||||
{
|
{
|
||||||
$this->actingAs($this->user);
|
$this->actingAs($this->user);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user