summaryrefslogtreecommitdiff
path: root/tests/hkdf_sanity/sanity_test.go
diff options
context:
space:
mode:
authorJakob Unterwurzacher2017-03-18 16:48:58 +0100
committerJakob Unterwurzacher2017-03-18 16:48:58 +0100
commitf1dbd19fe9f277430f4edc1501f4fb5dd8f745b1 (patch)
tree66006704ed99b2fc53b62c6684c0f41d4177c030 /tests/hkdf_sanity/sanity_test.go
parentcb47f65212801fbdd999674e549921d8cf23f2f2 (diff)
tests: add hkdf_sanity tests with broken example filesystemv1.3-beta1
These are deliberately corrupt.
Diffstat (limited to 'tests/hkdf_sanity/sanity_test.go')
-rw-r--r--tests/hkdf_sanity/sanity_test.go34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/hkdf_sanity/sanity_test.go b/tests/hkdf_sanity/sanity_test.go
new file mode 100644
index 0000000..b382861
--- /dev/null
+++ b/tests/hkdf_sanity/sanity_test.go
@@ -0,0 +1,34 @@
+// We test two filesystems that have the "HKDF" feature flag in their config file
+// set, but the actual file contents and names are encrypted with HKDF disabled.
+// This test verifies that the "HKDF" feature flag in the config file takes effect.
+package hkdf_sanity
+
+import (
+ "io/ioutil"
+ "os"
+ "testing"
+
+ "github.com/rfjakob/gocryptfs/tests/test_helpers"
+)
+
+func TestBrokenContent(t *testing.T) {
+ cDir := "broken_content"
+ pDir := test_helpers.TmpDir + "/" + cDir
+ test_helpers.MountOrFatal(t, cDir, pDir, "-extpass", "echo test", "-wpanic=false")
+ _, err := ioutil.ReadFile(pDir + "/status.txt")
+ if err == nil {
+ t.Error("this should fail")
+ }
+ test_helpers.UnmountPanic(pDir)
+}
+
+func TestBrokenNames(t *testing.T) {
+ cDir := "broken_names"
+ pDir := test_helpers.TmpDir + "/" + cDir
+ test_helpers.MountOrFatal(t, cDir, pDir, "-extpass", "echo test", "-wpanic=false")
+ _, err := os.Stat(pDir + "/status.txt")
+ if err == nil {
+ t.Error("this should fail")
+ }
+ test_helpers.UnmountPanic(pDir)
+}