Files
Charon/docs/plans/archive/fix_generateconfig_tests.md
akanealw eec8c28fb3
Some checks are pending
Go Benchmark / Performance Regression Check (push) Waiting to run
Cerberus Integration / Cerberus Security Stack Integration (push) Waiting to run
Upload Coverage to Codecov / Backend Codecov Upload (push) Waiting to run
Upload Coverage to Codecov / Frontend Codecov Upload (push) Waiting to run
CodeQL - Analyze / CodeQL analysis (go) (push) Waiting to run
CodeQL - Analyze / CodeQL analysis (javascript-typescript) (push) Waiting to run
CrowdSec Integration / CrowdSec Bouncer Integration (push) Waiting to run
Docker Build, Publish & Test / build-and-push (push) Waiting to run
Docker Build, Publish & Test / Security Scan PR Image (push) Blocked by required conditions
Quality Checks / Auth Route Protection Contract (push) Waiting to run
Quality Checks / Codecov Trigger/Comment Parity Guard (push) Waiting to run
Quality Checks / Backend (Go) (push) Waiting to run
Quality Checks / Frontend (React) (push) Waiting to run
Rate Limit integration / Rate Limiting Integration (push) Waiting to run
Security Scan (PR) / Trivy Binary Scan (push) Waiting to run
Supply Chain Verification (PR) / Verify Supply Chain (push) Waiting to run
WAF integration / Coraza WAF Integration (push) Waiting to run
changed perms
2026-04-22 18:19:14 +00:00

2.9 KiB
Executable File

Fix GenerateConfig Test Compilation Errors

Issue

7 test cases in backend/internal/caddy/config_extra_test.go are calling GenerateConfig without enough arguments. The function signature was recently updated to add a new parameter for DNS provider configurations.

Function Signature Change

Old signature (15 parameters):

GenerateConfig(hosts []models.ProxyHost, storageDir, acmeEmail, frontendDir, sslProvider string, acmeStaging, crowdsecEnabled, wafEnabled, rateLimitEnabled, aclEnabled bool, adminWhitelist string, rulesets []models.SecurityRuleSet, rulesetPaths map[string]string, decisions []models.SecurityDecision, secCfg *models.SecurityConfig)

New signature (16 parameters):

GenerateConfig(hosts []models.ProxyHost, storageDir, acmeEmail, frontendDir, sslProvider string, acmeStaging, crowdsecEnabled, wafEnabled, rateLimitEnabled, aclEnabled bool, adminWhitelist string, rulesets []models.SecurityRuleSet, rulesetPaths map[string]string, decisions []models.SecurityDecision, secCfg *models.SecurityConfig, dnsProviderConfigs []DNSProviderConfig)

New parameter: dnsProviderConfigs []DNSProviderConfig - provides DNS provider configuration for DNS challenge-based certificate issuance.

Failing Test Cases

All 7 test cases need the same fix - append nil as the 16th argument:

Line Test Function Current Context Fix
14 TestGenerateConfig_CatchAllFrontend Testing frontend catch-all routes Pass nil (no DNS providers needed)
36 TestGenerateConfig_AdvancedInvalidJSON Testing invalid JSON in advanced_config Pass nil (no DNS providers needed)
67 TestGenerateConfig_AdvancedArrayHandler Testing array handlers in advanced_config Pass nil (no DNS providers needed)
81 TestGenerateConfig_LowercaseDomains Testing domain name normalization Pass nil (no DNS providers needed)
97 TestGenerateConfig_AdvancedObjectHandler Testing object handler in advanced_config Pass nil (no DNS providers needed)
114 TestGenerateConfig_AdvancedHeadersStringToArray Testing header normalization Pass nil (no DNS providers needed)
175 TestGenerateConfig_ACLWhitelistIncluded Testing ACL handler inclusion Pass nil (no DNS providers needed)

Implementation

For all 7 test cases, append , nil as the last argument to the GenerateConfig call.

Example fix for line 14:

// Before
cfg, err := GenerateConfig([]models.ProxyHost{}, "/tmp/caddy-data", "", "/frontend/dist", "", false, false, false, false, false, "", nil, nil, nil, nil)

// After
cfg, err := GenerateConfig([]models.ProxyHost{}, "/tmp/caddy-data", "", "/frontend/dist", "", false, false, false, false, false, "", nil, nil, nil, nil, nil)

All 7 test cases are unit tests that don't require DNS provider configurations, so passing nil is appropriate.