Skip to content

Commit

Permalink
fix: tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
jcchavezs committed Oct 7, 2024
1 parent 660f381 commit 2398c1a
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions internal/seclang/rule_parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
package seclang

import (
"errors"
"reflect"
"strings"
"testing"
Expand Down Expand Up @@ -111,19 +110,20 @@ func TestSecRuleUpdateTargetVariableNegation(t *testing.T) {
SecRule REQUEST_URI|REQUEST_COOKIES "abc" "id:8,phase:2"
SecRuleUpdateTargetById 8 "!REQUEST_HEADERS:"
`)
expectedErr := errors.New("unknown variable")
if errors.Unwrap(err).Error() != expectedErr.Error() {
t.Fatalf("unexpexted error, want %q, have %q", expectedErr, errors.Unwrap(err).Error())

expectedErrMsg := "unknown variable"
if !strings.Contains(err.Error(), expectedErrMsg) {
t.Fatalf("unexpexted error, want to contain %q, have %q", expectedErrMsg, err)
}

// Try to update undefined rule
err = p.FromString(`
SecRule REQUEST_URI|REQUEST_COOKIES "abc" "id:9,phase:2"
SecRuleUpdateTargetById 99 "!REQUEST_HEADERS:xyz"
`)
expectedErr = errors.New("SecRuleUpdateTargetById: rule \"99\" not found")
if errors.Unwrap(err).Error() != expectedErr.Error() {
t.Fatalf("unexpected error, want %q, have %q", expectedErr, errors.Unwrap(err).Error())
expectedErrMsg = "SecRuleUpdateTargetById: rule \"99\" not found"
if !strings.Contains(err.Error(), expectedErrMsg) {
t.Fatalf("unexpexted error, want to contain %q, have %q", expectedErrMsg, err)
}
}

Expand Down

0 comments on commit 2398c1a

Please sign in to comment.