Files
ladill-hosting/tests/Feature/HardenHostingAccountIsolationCommandTest.php
T
isaaccladandCursor e251a4cf60
Deploy Ladill Hosting / deploy (push) Failing after 17s
Initial Ladill Hosting app with Gitea deploy pipeline.
Shared web hosting extracted from the platform monolith, with CI deploy
to /var/www/ladill-hosting matching Bird/Domains/Email.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-06 16:24:20 +00:00

86 lines
2.9 KiB
PHP

<?php
namespace Tests\Feature;
use App\Models\HostingAccount;
use App\Models\HostingProduct;
use App\Models\User;
use App\Services\Hosting\Providers\SharedNodeProvider;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class HardenHostingAccountIsolationCommandTest extends TestCase
{
use RefreshDatabase;
public function test_it_hardens_a_single_shared_account(): void
{
$user = User::factory()->create();
$product = HostingProduct::create([
'name' => 'Isolation Test Product',
'slug' => 'isolation-test-' . str()->random(6),
'category' => HostingProduct::CATEGORY_SHARED,
'type' => HostingProduct::TYPE_SINGLE_DOMAIN,
'price_monthly' => 10,
'currency' => 'GHS',
'disk_gb' => 10,
'max_domains' => 1,
'is_active' => true,
'is_visible' => true,
]);
$account = HostingAccount::create([
'user_id' => $user->id,
'hosting_product_id' => $product->id,
'username' => 'isolateacct',
'primary_domain' => 'example.test',
'type' => HostingAccount::TYPE_SHARED,
'status' => HostingAccount::STATUS_ACTIVE,
]);
$provider = \Mockery::mock(SharedNodeProvider::class);
$provider->shouldReceive('hardenAccountFilesystem')->once()->withArgs(
fn (HostingAccount $candidate): bool => $candidate->id === $account->id
);
$this->app->instance(SharedNodeProvider::class, $provider);
$this->artisan('hosting:harden-account-isolation', [
'--account' => $account->id,
])->assertExitCode(0);
}
public function test_it_supports_dry_run_without_touching_accounts(): void
{
$user = User::factory()->create();
$product = HostingProduct::create([
'name' => 'Isolation Test Product',
'slug' => 'isolation-dry-run-' . str()->random(6),
'category' => HostingProduct::CATEGORY_SHARED,
'type' => HostingProduct::TYPE_SINGLE_DOMAIN,
'price_monthly' => 10,
'currency' => 'GHS',
'disk_gb' => 10,
'max_domains' => 1,
'is_active' => true,
'is_visible' => true,
]);
HostingAccount::create([
'user_id' => $user->id,
'hosting_product_id' => $product->id,
'username' => 'dryrunacct',
'primary_domain' => 'dry-run.test',
'type' => HostingAccount::TYPE_SHARED,
'status' => HostingAccount::STATUS_ACTIVE,
]);
$provider = \Mockery::mock(SharedNodeProvider::class);
$provider->shouldNotReceive('hardenAccountFilesystem');
$this->app->instance(SharedNodeProvider::class, $provider);
$this->artisan('hosting:harden-account-isolation', [
'--dry-run' => true,
])->assertExitCode(0);
}
}