diff options
Diffstat (limited to 'metadata')
| -rw-r--r-- | metadata/policy.go | 3 | ||||
| -rw-r--r-- | metadata/policy_test.go | 4 |
2 files changed, 4 insertions, 3 deletions
diff --git a/metadata/policy.go b/metadata/policy.go index ae8b869..8c67f52 100644 --- a/metadata/policy.go +++ b/metadata/policy.go @@ -120,12 +120,13 @@ func GetPolicy(path string) (*PolicyData, error) { // policy. Returns an error if we cannot set the policy for any reason (not a // directory, invalid options or KeyDescriptor, etc). func SetPolicy(path string, data *PolicyData) error { - // Convert the padding value to a flag and the policyID to a byte array + // Convert the padding value to a flag paddingFlag, ok := util.Lookup(data.Options.Padding, paddingArray, flagsArray) if !ok { return util.InvalidInputF("padding of %d", data.Options.Padding) } + // Convert the policyDescriptor to a byte array if len(data.KeyDescriptor) != DescriptorLen { return util.InvalidLengthError("policy descriptor", DescriptorLen, len(data.KeyDescriptor)) } diff --git a/metadata/policy_test.go b/metadata/policy_test.go index 7f8a48b..593f3da 100644 --- a/metadata/policy_test.go +++ b/metadata/policy_test.go @@ -110,7 +110,7 @@ func TestSetPolicyFile(t *testing.T) { } // Tests that we fail when using bad policies -func TestSetPolicyBadIDs(t *testing.T) { +func TestSetPolicyBadDescriptors(t *testing.T) { // Policies that are too short, have invalid chars, or are too long badDescriptors := []string{"123456789abcde", "xxxxxxxxxxxxxxxx", "0123456789abcdef00"} for _, badDescriptor := range badDescriptors { @@ -121,7 +121,7 @@ func TestSetPolicyBadIDs(t *testing.T) { } if err = SetPolicy(directory, badPolicy); err == nil { - t.Errorf("id %q should have made SetPolicy fail", badDescriptor) + t.Errorf("descriptor %q should have made SetPolicy fail", badDescriptor) } os.RemoveAll(directory) } |