aboutsummaryrefslogtreecommitdiff
path: root/actions/protector_test.go
diff options
context:
space:
mode:
authorJoe Richey joerichey@google.com <joerichey@google.com>2017-05-31 17:54:35 -0700
committerJoe Richey joerichey@google.com <joerichey@google.com>2017-06-26 15:40:08 -0700
commitdefd27f75df3a6eef84ac33adf89b1ce255e738c (patch)
tree851a587fb4a12381e7a29e32759636021ecaf42c /actions/protector_test.go
parentd71b7f248e21f5254c32ecbf752a1dbe940a1177 (diff)
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
Diffstat (limited to 'actions/protector_test.go')
-rw-r--r--actions/protector_test.go10
1 files changed, 5 insertions, 5 deletions
diff --git a/actions/protector_test.go b/actions/protector_test.go
index bb59dba..08d9aed 100644
--- a/actions/protector_test.go
+++ b/actions/protector_test.go
@@ -32,23 +32,23 @@ const testProtectorName2 = testProtectorName + "2"
var errCallback = errors.New("bad callback")
-func goodCallback(data ProtectorData) (*Key, error) {
+func goodCallback(info ProtectorInfo, retry bool) (*Key, error) {
return NewFixedLengthKeyFromReader(bytes.NewReader(timingPassphrase), len(timingPassphrase))
}
-func badCallback(data ProtectorData) (*Key, error) {
+func badCallback(info ProtectorInfo, retry bool) (*Key, error) {
return nil, errCallback
}
// Tests that we can create a valid protector.
-func TestNewProtector(t *testing.T) {
+func TestCreateProtector(t *testing.T) {
ctx, err := makeContext()
defer cleaupContext()
if err != nil {
t.Fatal(err)
}
- p, err := ctx.NewProtector(testProtectorName, goodCallback)
+ p, err := CreateProtector(ctx, testProtectorName, goodCallback)
if err != nil {
t.Error(err)
} else {
@@ -64,7 +64,7 @@ func TestBadCallback(t *testing.T) {
t.Fatal(err)
}
- p, err := ctx.NewProtector(testProtectorName, badCallback)
+ p, err := CreateProtector(ctx, testProtectorName, badCallback)
if err == nil {
p.Wipe()
}