diff --git a/provider/lib.go b/provider/lib.go index 818e2d7..ddcc17b 100644 --- a/provider/lib.go +++ b/provider/lib.go @@ -505,10 +505,17 @@ var siteImporter = schema.ResourceImporter{ } func validateConditionField(val interface{}, key string) ([]string, []error) { - if existsInString(val.(string), "scheme", "method", "path", "useragent", "domain", "ip", "responseCode", "agentname", "paramname", "paramvalue", "country", "name", "valueString", "valueIp", "signalType", "signal", "requestHeader", "queryParameter", "postParameter") { + knownFields := []string{ + "scheme", "method", "path", "useragent", "domain", "ip", "responseCode", "agentname", + "paramname", "paramvalue", "country", "name", "valueString", "valueIp", "signalType", + "signal", "requestHeader", "queryParameter", "postParameter", "requestCookie", "value", + } + + if existsInString(val.(string), knownFields...) { return nil, nil } - return []string{fmt.Sprintf("received '%s' for conditions.field. This is not necessairly an error, but we only know about the following values. If this is a new value, please open a PR to get it added.\n(scheme, method, path, useragent, domain, ip, responseCode, agentname, paramname, paramvalue, country, name, valueString, valueIp, signalType, signal, requestHeader, queryParameter, postParameter)", val.(string))}, nil + + return []string{fmt.Sprintf("received %q for conditions.field. This is not necessarily an error, but we only know about the following values. If this is a new value, please open a PR to get it added.\n(%s)", val.(string), strings.Join(knownFields, ", "))}, nil } func validateActionResponseCode(val interface{}, key string) ([]string, []error) { diff --git a/provider/lib_test.go b/provider/lib_test.go index 17c7151..9a4971b 100644 --- a/provider/lib_test.go +++ b/provider/lib_test.go @@ -124,3 +124,31 @@ func testInspect() resource.TestCheckFunc { } } */ + +func TestValidateConditionField(t *testing.T) { + cases := []struct { + in string + wantErr bool + }{ + {in: "scheme"}, + {in: "queryParameter"}, + {in: "value"}, + + {in: "unknownconditionfield", wantErr: true}, + } + + for _, tt := range cases { + got, err := validateConditionField(tt.in, "key") + if err != nil { + t.Fatal(err) + } + + if got != nil && !tt.wantErr { + t.Errorf("validateConditionField(%q) returned invalid, want valid", tt.in) + } + + if got == nil && tt.wantErr { + t.Errorf("validateConditionField(%q) returned valid, want invalid", tt.in) + } + } +}