diff options
| author | Joe Richey joerichey@google.com <joerichey@google.com> | 2017-06-08 10:51:04 -0700 |
|---|---|---|
| committer | Joe Richey joerichey@google.com <joerichey@google.com> | 2017-06-15 22:32:35 -0700 |
| commit | ea3e258610340de0dd585c221f4e18a199f16bca (patch) | |
| tree | 6619b0564b988803346d09e211ea400d02b3161d /crypto/crypto_test.go | |
| parent | d5f89f8fcc5172be183fb02b802fa23ed3e9f8fa (diff) | |
crypto: add in additional keyring functionality
This commit adds in the FindPolicyKey and RemovePolicyKey functions to
complement the InsertPolicyKey function. The existing functions were
also refactored slightly.
Change-Id: Iabd275f2186a9e3023d5efd44c772966123e3657
Diffstat (limited to 'crypto/crypto_test.go')
| -rw-r--r-- | crypto/crypto_test.go | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/crypto/crypto_test.go b/crypto/crypto_test.go index 674baeb..2141fb8 100644 --- a/crypto/crypto_test.go +++ b/crypto/crypto_test.go @@ -234,24 +234,30 @@ func TestKeyLargeResize(t *testing.T) { } } -// Adds a key with and without legacy (check keyctl to see the key identifiers). -func TestAddKeys(t *testing.T) { +// Adds and removes a key with various services. +func TestAddRemoveKeys(t *testing.T) { for _, service := range []string{ServiceDefault, ServiceExt4, ServiceF2FS} { if err := InsertPolicyKey(fakeValidPolicyKey, fakeValidDescriptor, service); err != nil { t.Error(err) } + if err := RemovePolicyKey(fakeValidDescriptor, service); err != nil { + t.Error(err) + } } } // Makes sure a key fails with bad descriptor, policy, or service func TestBadAddKeys(t *testing.T) { if InsertPolicyKey(fakeInvalidPolicyKey, fakeValidDescriptor, ServiceDefault) == nil { + RemovePolicyKey(fakeValidDescriptor, ServiceDefault) t.Error("InsertPolicyKey should fail with bad policy key") } if InsertPolicyKey(fakeValidPolicyKey, fakeInvalidDescriptor, ServiceDefault) == nil { + RemovePolicyKey(fakeInvalidDescriptor, ServiceDefault) t.Error("InsertPolicyKey should fail with bad descriptor") } if InsertPolicyKey(fakeValidPolicyKey, fakeValidDescriptor, "ext4") == nil { + RemovePolicyKey(fakeValidDescriptor, "ext4") t.Error("InsertPolicyKey should fail with bad service") } } |