Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jptosso committed Nov 13, 2024
1 parent d16a3e4 commit 6e05b5a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
4 changes: 4 additions & 0 deletions internal/corazawaf/transaction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down
13 changes: 8 additions & 5 deletions internal/seclang/directives_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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" }},
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 6e05b5a

Please sign in to comment.