From defd27f75df3a6eef84ac33adf89b1ce255e738c Mon Sep 17 00:00:00 2001 From: "Joe Richey joerichey@google.com" Date: Wed, 31 May 2017 17:54:35 -0700 Subject: actions: Simplify the callback mechanism This commit makes the callbacks for getting keys easier to understand. Functions which need keys now take a KeyFunc callback. This callback contains a ProtectorInfo parameter (basically a read-only version of metadata.ProtectorData) and a boolean which indicates if the call is being retried. The documentation is also updated to say which functions will retry the KeyFunc. For selecting a protector, there is now an OptionFunc callback which takes a slice of ProtectorOptions. A ProtectorOption is a ProtectorInfo along with additional information about a linked filesystem (if applicable). This commit also adds in methods for getting the protector options for a specific filesystem or policy. It also adds a function for getting the policy descriptor for a specific path. Change-Id: I41e0d94ffd44e7166b0c5cf1b5d18437960bdf90 --- crypto/crypto_test.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'crypto/crypto_test.go') diff --git a/crypto/crypto_test.go b/crypto/crypto_test.go index 2141fb8..a3a2880 100644 --- a/crypto/crypto_test.go +++ b/crypto/crypto_test.go @@ -236,7 +236,7 @@ func TestKeyLargeResize(t *testing.T) { // Adds and removes a key with various services. func TestAddRemoveKeys(t *testing.T) { - for _, service := range []string{ServiceDefault, ServiceExt4, ServiceF2FS} { + for _, service := range []string{DefaultService, "ext4:", "f2fs:"} { if err := InsertPolicyKey(fakeValidPolicyKey, fakeValidDescriptor, service); err != nil { t.Error(err) } @@ -248,12 +248,12 @@ func TestAddRemoveKeys(t *testing.T) { // 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) + if InsertPolicyKey(fakeInvalidPolicyKey, fakeValidDescriptor, DefaultService) == nil { + RemovePolicyKey(fakeValidDescriptor, DefaultService) t.Error("InsertPolicyKey should fail with bad policy key") } - if InsertPolicyKey(fakeValidPolicyKey, fakeInvalidDescriptor, ServiceDefault) == nil { - RemovePolicyKey(fakeInvalidDescriptor, ServiceDefault) + if InsertPolicyKey(fakeValidPolicyKey, fakeInvalidDescriptor, DefaultService) == nil { + RemovePolicyKey(fakeInvalidDescriptor, DefaultService) t.Error("InsertPolicyKey should fail with bad descriptor") } if InsertPolicyKey(fakeValidPolicyKey, fakeValidDescriptor, "ext4") == nil { -- cgit v1.2.3