mirror of
https://github.com/vitodeploy/vito.git
synced 2025-04-20 02:11:36 +00:00
fix custom ssl creation (#122)
This commit is contained in:
parent
3dc38bf56b
commit
7949165648
@ -24,7 +24,7 @@ public function create(Site $site, array $input): void
|
||||
'type' => $input['type'],
|
||||
'certificate' => $input['certificate'] ?? null,
|
||||
'pk' => $input['private'] ?? null,
|
||||
'expires_at' => $input['type'] === SslType::LETSENCRYPT ? now()->addMonths(3) : null,
|
||||
'expires_at' => $input['type'] === SslType::LETSENCRYPT ? now()->addMonths(3) : $input['expires_at'],
|
||||
'status' => SslStatus::CREATING,
|
||||
]);
|
||||
$ssl->save();
|
||||
@ -53,6 +53,7 @@ protected function validate(array $input): void
|
||||
if (isset($input['type']) && $input['type'] == SslType::CUSTOM) {
|
||||
$rules['certificate'] = 'required';
|
||||
$rules['private'] = 'required';
|
||||
$rules['expires_at'] = 'required|date_format:Y-m-d|after_or_equal:'.now();
|
||||
}
|
||||
|
||||
Validator::make($input, $rules)->validate();
|
||||
|
@ -1,12 +1,12 @@
|
||||
if ! sudo mkdir __path__; then
|
||||
if ! sudo mkdir -p __path__; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
||||
|
||||
if ! echo __certificate__ | sudo tee __certificate_path__; then
|
||||
if ! echo "__certificate__" | sudo tee __certificate_path__; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
||||
|
||||
if ! echo __pk__ | sudo tee __pk_path__; then
|
||||
if ! echo "__pk__" | sudo tee __pk_path__; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
||||
|
||||
|
@ -42,7 +42,9 @@ class="p-6"
|
||||
type="text"
|
||||
class="mt-1 w-full"
|
||||
rows="5"
|
||||
/>
|
||||
>
|
||||
{{ old("certificate") }}
|
||||
</x-textarea>
|
||||
@error("certificate")
|
||||
<x-input-error class="mt-2" :messages="$message" />
|
||||
@enderror
|
||||
@ -57,11 +59,27 @@ class="mt-1 w-full"
|
||||
type="text"
|
||||
class="mt-1 w-full"
|
||||
rows="5"
|
||||
/>
|
||||
>
|
||||
{{ old("private") }}
|
||||
</x-textarea>
|
||||
@error("private")
|
||||
<x-input-error class="mt-2" :messages="$message" />
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
<div class="mt-6">
|
||||
<x-input-label for="expires_at" :value="__('Expires At')" />
|
||||
<x-text-input
|
||||
value="{{ old('expires_at') }}"
|
||||
id="expires_at"
|
||||
name="expires_at"
|
||||
type="text"
|
||||
class="mt-1 w-full"
|
||||
/>
|
||||
@error("expires_at")
|
||||
<x-input-error class="mt-2" :messages="$message" />
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-6 flex justify-end">
|
||||
|
@ -41,7 +41,7 @@ public function test_see_ssls_list_with_no_ssls()
|
||||
->assertSeeText(__("You don't have any SSL certificates yet!"));
|
||||
}
|
||||
|
||||
public function test_create_ssl()
|
||||
public function test_letsencrypt_ssl()
|
||||
{
|
||||
SSH::fake('Successfully received certificate');
|
||||
|
||||
@ -61,6 +61,29 @@ public function test_create_ssl()
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_custom_ssl()
|
||||
{
|
||||
SSH::fake('Successfully received certificate');
|
||||
|
||||
$this->actingAs($this->user);
|
||||
|
||||
$this->post(route('servers.sites.ssl.store', [
|
||||
'server' => $this->server,
|
||||
'site' => $this->site,
|
||||
]), [
|
||||
'type' => SslType::CUSTOM,
|
||||
'certificate' => 'certificate',
|
||||
'private' => 'private',
|
||||
'expires_at' => now()->addYear()->format('Y-m-d'),
|
||||
])->assertSessionDoesntHaveErrors();
|
||||
|
||||
$this->assertDatabaseHas('ssls', [
|
||||
'site_id' => $this->site->id,
|
||||
'type' => SslType::CUSTOM,
|
||||
'status' => SslStatus::CREATED,
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_delete_ssl()
|
||||
{
|
||||
SSH::fake();
|
||||
|
Loading…
x
Reference in New Issue
Block a user