mirror of https://github.com/status-im/consul.git
acl: adding negative tests for bad policy
This commit is contained in:
parent
38175f450b
commit
58c26497a9
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue