diff --git a/internal/corazawaf/transaction_test.go b/internal/corazawaf/transaction_test.go index 64d548546..07881c092 100644 --- a/internal/corazawaf/transaction_test.go +++ b/internal/corazawaf/transaction_test.go @@ -19,6 +19,7 @@ import ( "github.com/corazawaf/coraza/v3/experimental/plugins/plugintypes" "github.com/corazawaf/coraza/v3/internal/collections" "github.com/corazawaf/coraza/v3/internal/corazarules" + "github.com/corazawaf/coraza/v3/internal/environment" utils "github.com/corazawaf/coraza/v3/internal/strings" "github.com/corazawaf/coraza/v3/types" "github.com/corazawaf/coraza/v3/types/variables" @@ -1731,6 +1732,9 @@ func TestForceRequestBodyOverride(t *testing.T) { } func TestCloseFails(t *testing.T) { + if !environment.HasAccessToFS { + t.Skip("skipping test as it requires access to filesystem") + } waf := NewWAF() tx := waf.NewTransaction() col := tx.Variables().FilesTmpNames().(*collections.Map) diff --git a/internal/seclang/directives_test.go b/internal/seclang/directives_test.go index b5b47b777..373f100be 100644 --- a/internal/seclang/directives_test.go +++ b/internal/seclang/directives_test.go @@ -10,6 +10,7 @@ import ( "testing" "github.com/corazawaf/coraza/v3/internal/corazawaf" + "github.com/corazawaf/coraza/v3/internal/environment" "github.com/corazawaf/coraza/v3/types" ) @@ -165,11 +166,6 @@ func TestDirectives(t *testing.T) { {"", expectErrorOnDirective}, {"1000", func(w *corazawaf.WAF) bool { return w.UploadFileLimit == 1000 }}, }, - "SecUploadDir": { - {"", expectErrorOnDirective}, - {"/tmp-non-existing", expectErrorOnDirective}, - {os.TempDir(), func(w *corazawaf.WAF) bool { return w.UploadDir == os.TempDir() }}, - }, "SecSensorId": { {"", expectErrorOnDirective}, {"test", func(w *corazawaf.WAF) bool { return w.SensorID == "test" }}, @@ -315,6 +311,13 @@ func TestDirectives(t *testing.T) { {"1000", func(waf *corazawaf.WAF) bool { return waf.ArgumentLimit == 1000 }}, }, } + if environment.HasAccessToFS { + directiveCases["SecUploadDir"] = []directiveCase{ + {"", expectErrorOnDirective}, + {"/tmp-non-existing", expectErrorOnDirective}, + {os.TempDir(), func(w *corazawaf.WAF) bool { return w.UploadDir == os.TempDir() }}, + } + } for name, dCases := range directiveCases { t.Run(name, func(t *testing.T) {