aboutsummaryrefslogtreecommitdiff
path: root/crypto/crypto_test.go
diff options
context:
space:
mode:
authorJoe Richey joerichey@google.com <joerichey@google.com>2017-08-15 18:11:29 -0700
committerJoe Richey joerichey@google.com <joerichey@google.com>2017-08-17 22:49:44 -0700
commit151e8965fa3a9c8f65e316430f9df0fa763fb02d (patch)
tree5be6cb1e1d617e60ba7624abc3c940c65715ba5e /crypto/crypto_test.go
parentb4d51e0f4d34dbfd78e23662f3dfd90e86ae5e48 (diff)
cmd/fscrypt: purge command now clears cache
Diffstat (limited to 'crypto/crypto_test.go')
-rw-r--r--crypto/crypto_test.go18
1 files changed, 11 insertions, 7 deletions
diff --git a/crypto/crypto_test.go b/crypto/crypto_test.go
index 58aca9e..a069b1b 100644
--- a/crypto/crypto_test.go
+++ b/crypto/crypto_test.go
@@ -30,7 +30,10 @@ import (
"os"
"testing"
+ "golang.org/x/sys/unix"
+
"github.com/google/fscrypt/metadata"
+ "github.com/google/fscrypt/security"
)
// Reader that always returns the same byte
@@ -52,6 +55,7 @@ var (
fakeValidDescriptor = "0123456789abcdef"
fakeSalt = bytes.Repeat([]byte{'a'}, metadata.SaltLen)
fakePassword = []byte("password")
+ defaultService = unix.FS_KEY_DESC_PREFIX
fakeValidPolicyKey, _ = makeKey(42, metadata.PolicyKeyLen)
fakeInvalidPolicyKey, _ = makeKey(42, metadata.PolicyKeyLen-1)
@@ -237,12 +241,12 @@ func TestKeyLargeResize(t *testing.T) {
// Adds and removes a key with various services.
func TestAddRemoveKeys(t *testing.T) {
- for _, service := range []string{DefaultService, "ext4:", "f2fs:"} {
+ for _, service := range []string{defaultService, "ext4:", "f2fs:"} {
validDescription := service + fakeValidDescriptor
if err := InsertPolicyKey(fakeValidPolicyKey, validDescription); err != nil {
t.Error(err)
}
- if err := RemovePolicyKey(validDescription); err != nil {
+ if err := security.RemoveKey(validDescription); err != nil {
t.Error(err)
}
}
@@ -250,24 +254,24 @@ func TestAddRemoveKeys(t *testing.T) {
// Adds a key twice (both should succeed)
func TestAddTwice(t *testing.T) {
- validDescription := DefaultService + fakeValidDescriptor
+ validDescription := defaultService + fakeValidDescriptor
InsertPolicyKey(fakeValidPolicyKey, validDescription)
if InsertPolicyKey(fakeValidPolicyKey, validDescription) != nil {
t.Error("InsertPolicyKey should not fail if key already exists")
}
- RemovePolicyKey(validDescription)
+ security.RemoveKey(validDescription)
}
// Makes sure a key fails with bad policy or service
func TestBadAddKeys(t *testing.T) {
- validDescription := DefaultService + fakeValidDescriptor
+ validDescription := defaultService + fakeValidDescriptor
if InsertPolicyKey(fakeInvalidPolicyKey, validDescription) == nil {
- RemovePolicyKey(validDescription)
+ security.RemoveKey(validDescription)
t.Error("InsertPolicyKey should fail with bad policy key")
}
invalidDescription := "ext4" + fakeValidDescriptor
if InsertPolicyKey(fakeValidPolicyKey, invalidDescription) == nil {
- RemovePolicyKey(invalidDescription)
+ security.RemoveKey(invalidDescription)
t.Error("InsertPolicyKey should fail with bad service")
}
}