aboutsummaryrefslogtreecommitdiff
path: root/actions/policy_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/policy_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/policy_test.go')
-rw-r--r--actions/policy_test.go18
1 files changed, 9 insertions, 9 deletions
diff --git a/actions/policy_test.go b/actions/policy_test.go
index 3a64e01..07a7f87 100644
--- a/actions/policy_test.go
+++ b/actions/policy_test.go
@@ -27,11 +27,11 @@ func makeAll() (ctx *Context, protector *Protector, policy *Policy, err error) {
if err != nil {
return
}
- protector, err = ctx.NewProtector(testProtectorName, goodCallback)
+ protector, err = CreateProtector(ctx, testProtectorName, goodCallback)
if err != nil {
return
}
- policy, err = ctx.NewPolicy(protector)
+ policy, err = CreatePolicy(ctx, protector)
return
}
@@ -47,7 +47,7 @@ func cleanupAll(protector *Protector, policy *Policy) {
}
// Tests that we can make a policy/protector pair
-func TestNewPolicy(t *testing.T) {
+func TestCreatePolicy(t *testing.T) {
_, pro, pol, err := makeAll()
defer cleanupAll(pro, pol)
if err != nil {
@@ -63,7 +63,7 @@ func TestPolicyGoodAddProtector(t *testing.T) {
t.Fatal(err)
}
- pro2, err := ctx.NewProtector(testProtectorName2, goodCallback)
+ pro2, err := CreateProtector(ctx, testProtectorName2, goodCallback)
if err != nil {
t.Fatal(err)
}
@@ -96,7 +96,7 @@ func TestPolicyGoodRemoveProtector(t *testing.T) {
t.Fatal(err)
}
- pro2, err := ctx.NewProtector(testProtectorName2, goodCallback)
+ pro2, err := CreateProtector(ctx, testProtectorName2, goodCallback)
if err != nil {
t.Fatal(err)
}
@@ -107,7 +107,7 @@ func TestPolicyGoodRemoveProtector(t *testing.T) {
t.Fatal(err)
}
- err = pol.RemoveProtector(pro1)
+ err = pol.RemoveProtector(pro1.data.ProtectorDescriptor)
if err != nil {
t.Error(err)
}
@@ -121,17 +121,17 @@ func TestPolicyBadRemoveProtector(t *testing.T) {
t.Fatal(err)
}
- pro2, err := ctx.NewProtector(testProtectorName2, goodCallback)
+ pro2, err := CreateProtector(ctx, testProtectorName2, goodCallback)
if err != nil {
t.Fatal(err)
}
defer pro2.Wipe()
- if pol.RemoveProtector(pro2) == nil {
+ if pol.RemoveProtector(pro2.data.ProtectorDescriptor) == nil {
t.Error("we should not be able to remove a protector we did not add")
}
- if pol.RemoveProtector(pro1) == nil {
+ if pol.RemoveProtector(pro1.data.ProtectorDescriptor) == nil {
t.Error("we should not be able to remove all the protectors from a policy")
}
}