acl: adding negative tests for bad policy

This commit is contained in:
Ryan Uber 2015-07-07 14:46:41 -06:00
parent 38175f450b
commit 58c26497a9
1 changed files with 16 additions and 0 deletions

View File

@ -2,6 +2,7 @@ package acl
import ( import (
"reflect" "reflect"
"strings"
"testing" "testing"
) )
@ -184,3 +185,18 @@ func TestParse_JSON(t *testing.T) {
t.Fatalf("bad: %#v %#v", out, exp) 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)
}
}
}