diff options
| author | Joe Richey <joerichey@google.com> | 2017-08-30 17:57:38 -0700 |
|---|---|---|
| committer | Joe Richey <joerichey@google.com> | 2017-08-30 17:57:38 -0700 |
| commit | d685f6b232485a0dc0cc8b915561b9be37d32722 (patch) | |
| tree | 2b10098a5d26c4aa9cae6a074bdf62dea75ce198 /crypto/crypto_test.go | |
| parent | 70efc397db81f3ad170e54114f3ad0a97f2ed7d0 (diff) | |
crypto: Updated to include user parameter
Diffstat (limited to 'crypto/crypto_test.go')
| -rw-r--r-- | crypto/crypto_test.go | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/crypto/crypto_test.go b/crypto/crypto_test.go index 719db00..444f847 100644 --- a/crypto/crypto_test.go +++ b/crypto/crypto_test.go @@ -34,6 +34,7 @@ import ( "github.com/google/fscrypt/metadata" "github.com/google/fscrypt/security" + "github.com/google/fscrypt/util" ) // Reader that always returns the same byte @@ -60,6 +61,8 @@ var ( fakeValidPolicyKey, _ = makeKey(42, metadata.PolicyKeyLen) fakeInvalidPolicyKey, _ = makeKey(42, metadata.PolicyKeyLen-1) fakeWrappingKey, _ = makeKey(17, metadata.InternalKeyLen) + + testUser, _ = util.EffectiveUser() ) // As the passpharase hashing function clears the passphrase, we need to make @@ -243,10 +246,10 @@ func TestKeyLargeResize(t *testing.T) { func TestAddRemoveKeys(t *testing.T) { for _, service := range []string{defaultService, "ext4:", "f2fs:"} { validDescription := service + fakeValidDescriptor - if err := InsertPolicyKey(fakeValidPolicyKey, validDescription); err != nil { + if err := InsertPolicyKey(fakeValidPolicyKey, validDescription, testUser); err != nil { t.Error(err) } - if err := security.RemoveKey(validDescription); err != nil { + if err := security.RemoveKey(validDescription, testUser); err != nil { t.Error(err) } } @@ -255,23 +258,23 @@ func TestAddRemoveKeys(t *testing.T) { // Adds a key twice (both should succeed) func TestAddTwice(t *testing.T) { validDescription := defaultService + fakeValidDescriptor - InsertPolicyKey(fakeValidPolicyKey, validDescription) - if InsertPolicyKey(fakeValidPolicyKey, validDescription) != nil { + InsertPolicyKey(fakeValidPolicyKey, validDescription, testUser) + if InsertPolicyKey(fakeValidPolicyKey, validDescription, testUser) != nil { t.Error("InsertPolicyKey should not fail if key already exists") } - security.RemoveKey(validDescription) + security.RemoveKey(validDescription, testUser) } // Makes sure a key fails with bad policy or service func TestBadAddKeys(t *testing.T) { validDescription := defaultService + fakeValidDescriptor - if InsertPolicyKey(fakeInvalidPolicyKey, validDescription) == nil { - security.RemoveKey(validDescription) + if InsertPolicyKey(fakeInvalidPolicyKey, validDescription, testUser) == nil { + security.RemoveKey(validDescription, testUser) t.Error("InsertPolicyKey should fail with bad policy key") } invalidDescription := "ext4" + fakeValidDescriptor - if InsertPolicyKey(fakeValidPolicyKey, invalidDescription) == nil { - security.RemoveKey(invalidDescription) + if InsertPolicyKey(fakeValidPolicyKey, invalidDescription, testUser) == nil { + security.RemoveKey(invalidDescription, testUser) t.Error("InsertPolicyKey should fail with bad service") } } |