fix(caddy): prevent exact label generation argument error (#11397)
This commit is contained in:
parent
541d743907
commit
38aaf8cb2a
4 changed files with 47 additions and 2 deletions
|
|
@ -12,6 +12,7 @@
|
|||
use App\Traits\HasMetrics;
|
||||
use App\Traits\HasNoindexDomains;
|
||||
use App\Traits\HasSafeStringAttribute;
|
||||
use Database\Factories\ApplicationFactory;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
|
@ -120,7 +121,10 @@
|
|||
|
||||
class Application extends BaseModel
|
||||
{
|
||||
use ClearsGlobalSearchCache, HasConfiguration, HasFactory, HasMetrics, HasNoindexDomains, HasSafeStringAttribute, SoftDeletes;
|
||||
use ClearsGlobalSearchCache, HasConfiguration, HasMetrics, HasNoindexDomains, HasSafeStringAttribute, SoftDeletes;
|
||||
|
||||
/** @use HasFactory<ApplicationFactory> */
|
||||
use HasFactory;
|
||||
|
||||
public const MAX_DOCKER_COMPOSE_SIZE_BYTES = 5 * 1024 * 1024;
|
||||
|
||||
|
|
|
|||
|
|
@ -891,7 +891,6 @@ function generateLabelsApplication(Application $application, ?ApplicationPreview
|
|||
http_basic_auth_username: $application->http_basic_auth_username,
|
||||
http_basic_auth_password: $application->http_basic_auth_password,
|
||||
noindex_domains: $noindexDomains,
|
||||
escape_redirect_replacement_for_compose: false,
|
||||
));
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,8 +2,12 @@
|
|||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Application;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends Factory<Application>
|
||||
*/
|
||||
class ApplicationFactory extends Factory
|
||||
{
|
||||
public function definition(): array
|
||||
|
|
|
|||
38
tests/Feature/CaddyApplicationLabelGenerationTest.php
Normal file
38
tests/Feature/CaddyApplicationLabelGenerationTest.php
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
use App\Enums\ProxyTypes;
|
||||
use App\Models\Application;
|
||||
use App\Models\Environment;
|
||||
use App\Models\Project;
|
||||
use App\Models\Server;
|
||||
use App\Models\StandaloneDocker;
|
||||
use App\Models\Team;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
|
||||
uses(RefreshDatabase::class);
|
||||
|
||||
test('generates exact Caddy labels for an application with a domain', function () {
|
||||
$team = Team::factory()->create();
|
||||
$project = Project::factory()->create(['team_id' => $team->id]);
|
||||
$environment = Environment::factory()->create(['project_id' => $project->id]);
|
||||
$server = Server::factory()->create([
|
||||
'team_id' => $team->id,
|
||||
'proxy' => ['type' => ProxyTypes::CADDY->value],
|
||||
]);
|
||||
$server->settings->update(['generate_exact_labels' => true]);
|
||||
$destination = StandaloneDocker::query()->where('server_id', $server->id)->firstOrFail();
|
||||
$application = Application::factory()->createOne([
|
||||
'environment_id' => $environment->id,
|
||||
'destination_id' => $destination->id,
|
||||
'destination_type' => $destination->getMorphClass(),
|
||||
'fqdn' => 'https://example.com',
|
||||
'redirect' => 'both',
|
||||
'is_http_basic_auth_enabled' => false,
|
||||
]);
|
||||
|
||||
$labels = generateLabelsApplication($application);
|
||||
|
||||
expect($labels)
|
||||
->toContain('caddy_ingress_network=coolify')
|
||||
->not->toContain('traefik.enable=true');
|
||||
});
|
||||
Loading…
Reference in a new issue