@@ -3,6 +3,7 @@ package service
33import (
44 "bytes"
55 "context"
6+ "os"
67 "path/filepath"
78 "testing"
89
@@ -35,6 +36,9 @@ func TestResolveInstallPlanDefaults(t *testing.T) {
3536 if plan .HTTPPort != 80 || plan .HTTPSPort != 443 {
3637 t .Fatalf ("expected default ports 80/443, got %d/%d" , plan .HTTPPort , plan .HTTPSPort )
3738 }
39+ if plan .OWASPCRSVersion != defaultOWASPCRSVersion {
40+ t .Fatalf ("expected default owasp crs version %s, got %s" , defaultOWASPCRSVersion , plan .OWASPCRSVersion )
41+ }
3842}
3943
4044func TestResolveInstallPlanOverrides (t * testing.T ) {
@@ -74,6 +78,31 @@ func TestResolveInstallPlanOverrides(t *testing.T) {
7478 }
7579}
7680
81+ func TestLoadRuntimeInstallConfigIncludesOWASPCRSVersion (t * testing.T ) {
82+ configPath := filepath .Join (t .TempDir (), "install.json" )
83+ content := `{
84+ "php_version": "85",
85+ "database": "mariadb",
86+ "configure_listeners": true,
87+ "http_port": 80,
88+ "https_port": 443,
89+ "ssl_cert_file": "/usr/local/lsws/admin/conf/webadmin.crt",
90+ "ssl_key_file": "/usr/local/lsws/admin/conf/webadmin.key",
91+ "owasp_crs_version": "4.22.0"
92+ }`
93+ if err := os .WriteFile (configPath , []byte (content ), 0o644 ); err != nil {
94+ t .Fatalf ("write config: %v" , err )
95+ }
96+
97+ cfg , _ , err := loadRuntimeInstallConfig (configPath , "/usr/local/lsws" )
98+ if err != nil {
99+ t .Fatalf ("unexpected load error: %v" , err )
100+ }
101+ if cfg .OWASPCRSVersion != "4.22.0" {
102+ t .Fatalf ("expected owasp_crs_version 4.22.0, got %s" , cfg .OWASPCRSVersion )
103+ }
104+ }
105+
77106func TestResolveInstallPlanDatabaseNone (t * testing.T ) {
78107 plan , err := resolveInstallPlan (
79108 InstallOptions {ConfigPath : filepath .Join (t .TempDir (), "install.json" ), DatabaseEngine : "none" },
@@ -102,12 +131,12 @@ func TestResolveInstallPlanInvalidDatabase(t *testing.T) {
102131func TestResolveInstallPlanRejectsUnsafeSSLPaths (t * testing.T ) {
103132 _ , err := resolveInstallPlan (
104133 InstallOptions {
105- ConfigPath : filepath .Join (t .TempDir (), "install.json" ),
106- SSLCertFile : "/etc/ssl/certs/server.crt\n malicious 1" ,
107- SSLKeyFile : "/etc/ssl/private/server.key" ,
108- HTTPPort : 80 ,
109- HTTPSPort : 443 ,
110- PHPVersion : "85" ,
134+ ConfigPath : filepath .Join (t .TempDir (), "install.json" ),
135+ SSLCertFile : "/etc/ssl/certs/server.crt\n malicious 1" ,
136+ SSLKeyFile : "/etc/ssl/private/server.key" ,
137+ HTTPPort : 80 ,
138+ HTTPSPort : 443 ,
139+ PHPVersion : "85" ,
111140 DatabaseEngine : "mariadb" ,
112141 },
113142 platform.Info {PackageManager : platform .PackageManagerAPT },
@@ -134,4 +163,3 @@ func TestInstallRuntimeDryRunIncludesResolvedPlan(t *testing.T) {
134163 t .Fatalf ("expected no runner calls in dry-run, got %d" , len (r .calls ))
135164 }
136165}
137-
0 commit comments