acl: more keyring tests

This commit is contained in:
Ryan Uber 2015-07-07 11:21:27 -06:00
parent 7e50a457d9
commit 02b49058a2
1 changed files with 28 additions and 0 deletions

View File

@ -245,6 +245,7 @@ func TestPolicyACL(t *testing.T) {
}
}
// Test the events
type eventcase struct {
inp string
read bool
@ -369,3 +370,30 @@ func TestPolicyACL_Parent(t *testing.T) {
}
}
}
func TestPolicyACL_Keyring(t *testing.T) {
// Test keyring ACLs
type keyringcase struct {
inp string
read bool
write bool
}
keyringcases := []keyringcase{
{"", false, false},
{KeyringPolicyRead, true, false},
{KeyringPolicyWrite, true, true},
{KeyringPolicyDeny, false, false},
}
for _, c := range keyringcases {
acl, err := New(DenyAll(), &Policy{Keyring: c.inp})
if err != nil {
t.Fatalf("bad: %s", err)
}
if acl.KeyringRead() != c.read {
t.Fatalf("bad: %#v", c)
}
if acl.KeyringWrite() != c.write {
t.Fatalf("bad: %#v", c)
}
}
}