diff --git a/acl/policy_test.go b/acl/policy_test.go index 043dc9c946..eb0528ffc9 100644 --- a/acl/policy_test.go +++ b/acl/policy_test.go @@ -2,6 +2,7 @@ package acl import ( "reflect" + "strings" "testing" ) @@ -184,3 +185,18 @@ func TestParse_JSON(t *testing.T) { t.Fatalf("bad: %#v %#v", out, exp) } } + +func TestACLPolicy_badPolicy(t *testing.T) { + cases := []string{ + `key "" { policy = "nope" }`, + `service "" { policy = "nope" }`, + `event "" { policy = "nope" }`, + `keyring = "nope"`, + } + for _, c := range cases { + _, err := Parse(c) + if err == nil || !strings.Contains(err.Error(), "Invalid") { + t.Fatalf("expected policy error, got: %#v", err) + } + } +}