From 02b49058a2e904610b809235072e1ce0435084f4 Mon Sep 17 00:00:00 2001 From: Ryan Uber Date: Tue, 7 Jul 2015 11:21:27 -0600 Subject: [PATCH] acl: more keyring tests --- acl/acl_test.go | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/acl/acl_test.go b/acl/acl_test.go index 6872b04f13..1b83c81dec 100644 --- a/acl/acl_test.go +++ b/acl/acl_test.go @@ -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) + } + } +}