diff --git a/src/validation.go b/src/validation.go index a4dba91..47357b1 100644 --- a/src/validation.go +++ b/src/validation.go @@ -123,6 +123,8 @@ func validateConditionPattern(condType, pattern string) error { case "keyword": // Keywords can be any non-empty string return nil + default: + return fmt.Errorf("Invalid condition type: %s", condType) } return nil diff --git a/src/validation_test.go b/src/validation_test.go index 95464df..8e667d7 100644 --- a/src/validation_test.go +++ b/src/validation_test.go @@ -303,6 +303,12 @@ func TestValidateConditionPattern(t *testing.T) { pattern: "", wantErr: true, }, + { + name: "invalid condition type", + condType: "invalid_type", + pattern: "example.com", + wantErr: true, + }, } for _, tt := range tests { @@ -381,6 +387,14 @@ func TestIsConditionValid(t *testing.T) { }, want: false, }, + { + name: "invalid condition type", + condition: Condition{ + Type: "invalid_type", + Pattern: "example.com", + }, + want: false, + }, } for _, tt := range tests { @@ -449,6 +463,14 @@ func TestAreAllConditionsValid(t *testing.T) { }, want: false, }, + { + name: "invalid condition type in list", + conditions: []Condition{ + {Type: "domain", Pattern: "example.com"}, + {Type: "invalid_type", Pattern: "example.com"}, + }, + want: false, + }, } for _, tt := range tests {