aboutsummaryrefslogtreecommitdiff
path: root/integration_tests
diff options
context:
space:
mode:
authorJakob Unterwurzacher2016-06-06 23:57:42 +0200
committerJakob Unterwurzacher2016-06-07 00:08:56 +0200
commitc2a5303eebc84d616072163f74eef8483c9f5386 (patch)
tree181ffdbb956eb76351d137a4fa9f52ed98b8f242 /integration_tests
parent0f4d3501369e13c8ba6ee4c9fc7df02a3cc698b1 (diff)
tests: split example_filesystems into its own package
Running these tests from integration_tests' TestMain() was awkward because they were run twice with unchanged settings. integration_tests tests everything with OpenSSL and with native Go crypto, but this does not take affect for the example filesystems. To make this work, test_helpers is also split into its own package.
Diffstat (limited to 'integration_tests')
-rw-r--r--integration_tests/cli_test.go118
l---------integration_tests/example_filesystems/abs1
l---------integration_tests/example_filesystems/rel1
-rw-r--r--integration_tests/example_filesystems/status.txt1
-rw-r--r--integration_tests/example_filesystems/v0.4/3-HZSwv99agoWgTErV0YFQ==bin56 -> 0 bytes
l---------integration_tests/example_filesystems/v0.4/6hL2fPVB2aMSh4-UoDn5Kw==1
l---------integration_tests/example_filesystems/v0.4/TBIgdfhDKwkXVTnWLVzFSg==1
-rw-r--r--integration_tests/example_filesystems/v0.4/gocryptfs.conf12
l---------integration_tests/example_filesystems/v0.5/AOtl_i4xQWDyG0_zUqntOw==1
l---------integration_tests/example_filesystems/v0.5/Pf35wlWlf43N68EbhIgTcQ==1
-rw-r--r--integration_tests/example_filesystems/v0.5/gocryptfs.conf14
-rw-r--r--integration_tests/example_filesystems/v0.5/gocryptfs.diriv1
-rw-r--r--integration_tests/example_filesystems/v0.5/j2BpGUT5kOtia20PWQ2rEA==bin56 -> 0 bytes
l---------integration_tests/example_filesystems/v0.6-plaintextnames/abs1
-rw-r--r--integration_tests/example_filesystems/v0.6-plaintextnames/gocryptfs.conf14
l---------integration_tests/example_filesystems/v0.6-plaintextnames/rel1
-rw-r--r--integration_tests/example_filesystems/v0.6-plaintextnames/status.txtbin56 -> 0 bytes
l---------integration_tests/example_filesystems/v0.6/9pOs0yjJI5A67pv5CnqomQ==1
l---------integration_tests/example_filesystems/v0.6/G79Zdu41H3bgwdaQlrz-dg==1
-rw-r--r--integration_tests/example_filesystems/v0.6/RuYvQG_raW_-H_LcyJC4LQ==bin56 -> 0 bytes
-rw-r--r--integration_tests/example_filesystems/v0.6/gocryptfs.conf15
-rw-r--r--integration_tests/example_filesystems/v0.6/gocryptfs.diriv1
l---------integration_tests/example_filesystems/v0.7/4tRF1LdULRFLiXwfze671Q==1
-rw-r--r--integration_tests/example_filesystems/v0.7/RWPXmXkRFrWw1aOpq7C-NQ==bin60 -> 0 bytes
l---------integration_tests/example_filesystems/v0.7/dwPcZNei4HN4qPA6FxoG_A==1
-rw-r--r--integration_tests/example_filesystems/v0.7/gocryptfs.conf16
-rw-r--r--integration_tests/example_filesystems/v0.7/gocryptfs.diriv1
l---------integration_tests/example_filesystems/v0.9/00msNUi5h5aKMX_f-4pBhA==1
-rw-r--r--integration_tests/example_filesystems/v0.9/R83PhW-BBA_q4rPYD7dEMg==bin60 -> 0 bytes
-rw-r--r--integration_tests/example_filesystems/v0.9/gocryptfs.conf17
-rw-r--r--integration_tests/example_filesystems/v0.9/gocryptfs.diriv1
-rw-r--r--integration_tests/example_filesystems/v0.9/gocryptfs.longname.y4J-w3LBX165Mn_pGdDRY7Gb6EgHcTrdWjME3WGu-CQ=bin60 -> 0 bytes
-rw-r--r--integration_tests/example_filesystems/v0.9/gocryptfs.longname.y4J-w3LBX165Mn_pGdDRY7Gb6EgHcTrdWjME3WGu-CQ=.name1
l---------integration_tests/example_filesystems/v0.9/hwE1RKIXtF8hmQMvEXSTtg==1
-rw-r--r--integration_tests/example_filesystems_test.go203
-rw-r--r--integration_tests/helpers.go237
-rw-r--r--integration_tests/main_test.go437
-rw-r--r--integration_tests/performance_test.go129
38 files changed, 0 insertions, 1232 deletions
diff --git a/integration_tests/cli_test.go b/integration_tests/cli_test.go
deleted file mode 100644
index 062a90d..0000000
--- a/integration_tests/cli_test.go
+++ /dev/null
@@ -1,118 +0,0 @@
-package integration_tests
-
-// Test CLI operations like "-init", "-password" etc
-
-import (
- "os"
- "os/exec"
- "testing"
-
- "github.com/rfjakob/gocryptfs/internal/configfile"
- "github.com/rfjakob/gocryptfs/internal/nametransform"
-)
-
-// Test -init flag
-func TestInit(t *testing.T) {
- dir := tmpDir + "TestInit/"
- err := os.Mkdir(dir, 0777)
- if err != nil {
- t.Fatal(err)
- }
- cmd := exec.Command(gocryptfsBinary, "-init", "-extpass", "echo test", "-scryptn=10", dir)
- if testing.Verbose() {
- cmd.Stdout = os.Stdout
- cmd.Stderr = os.Stderr
- }
- err = cmd.Run()
- if err != nil {
- t.Fatal(err)
- }
- _, err = os.Stat(dir + configfile.ConfDefaultName)
- if err != nil {
- t.Fatal(err)
- }
-
- // Test -passwd
- cmd2 := exec.Command(gocryptfsBinary, "-passwd", "-extpass", "echo test", dir)
- if testing.Verbose() {
- cmd2.Stdout = os.Stdout
- cmd2.Stderr = os.Stderr
- }
- err = cmd2.Run()
- if err != nil {
- t.Error(err)
- }
-}
-
-// Test -init & -config flag
-func TestInitConfig(t *testing.T) {
- dir := tmpDir + "TestInitConfig/"
- config := tmpDir + "TestInitConfig.conf"
- err := os.Mkdir(dir, 0777)
- if err != nil {
- t.Fatal(err)
- }
- cmd := exec.Command(gocryptfsBinary, "-init", "-extpass", "echo test",
- "-config", config, "-scryptn=10", dir)
- if testing.Verbose() {
- cmd.Stdout = os.Stdout
- cmd.Stderr = os.Stderr
- }
- err = cmd.Run()
- if err != nil {
- t.Fatal(err)
- }
- _, err = os.Stat(config)
- if err != nil {
- t.Fatal(err)
- }
-
- // Test -passwd & -config
- cmd2 := exec.Command(gocryptfsBinary, "-passwd", "-extpass", "echo test",
- "-config", config, dir)
- if testing.Verbose() {
- cmd2.Stdout = os.Stdout
- cmd2.Stderr = os.Stderr
- }
- err = cmd2.Run()
- if err != nil {
- t.Error(err)
- }
-}
-
-// Test -init -plaintextnames
-func TestInitPlaintextNames(t *testing.T) {
- dir := tmpDir + "TestInitPlaintextNames/"
- err := os.Mkdir(dir, 0777)
- if err != nil {
- t.Fatal(err)
- }
- cmd := exec.Command(gocryptfsBinary, "-init", "-extpass", "echo test",
- "-scryptn=10", "-plaintextnames", dir)
- if testing.Verbose() {
- cmd.Stdout = os.Stdout
- cmd.Stderr = os.Stderr
- }
- err = cmd.Run()
- if err != nil {
- t.Fatal(err)
- }
- _, err = os.Stat(dir + configfile.ConfDefaultName)
- if err != nil {
- t.Fatal(err)
- }
- _, err = os.Stat(dir + nametransform.DirIVFilename)
- if err == nil {
- t.Errorf("gocryptfs.diriv should not have been created with -plaintextnames")
- }
- _, cf, err := configfile.LoadConfFile(dir+configfile.ConfDefaultName, "test")
- if err != nil {
- t.Fatal(err)
- }
- if !cf.IsFeatureFlagSet(configfile.FlagPlaintextNames) {
- t.Error("PlaintextNames flag should be set but isnt")
- }
- if cf.IsFeatureFlagSet(configfile.FlagEMENames) || cf.IsFeatureFlagSet(configfile.FlagDirIV) {
- t.Error("FlagEMENames and FlagDirIV should be not set")
- }
-}
diff --git a/integration_tests/example_filesystems/abs b/integration_tests/example_filesystems/abs
deleted file mode 120000
index e1740fa..0000000
--- a/integration_tests/example_filesystems/abs
+++ /dev/null
@@ -1 +0,0 @@
-/a/b/c/d \ No newline at end of file
diff --git a/integration_tests/example_filesystems/rel b/integration_tests/example_filesystems/rel
deleted file mode 120000
index 8279c75..0000000
--- a/integration_tests/example_filesystems/rel
+++ /dev/null
@@ -1 +0,0 @@
-status.txt \ No newline at end of file
diff --git a/integration_tests/example_filesystems/status.txt b/integration_tests/example_filesystems/status.txt
deleted file mode 100644
index 68300b8..0000000
--- a/integration_tests/example_filesystems/status.txt
+++ /dev/null
@@ -1 +0,0 @@
-It works!
diff --git a/integration_tests/example_filesystems/v0.4/3-HZSwv99agoWgTErV0YFQ== b/integration_tests/example_filesystems/v0.4/3-HZSwv99agoWgTErV0YFQ==
deleted file mode 100644
index 5d0af82..0000000
--- a/integration_tests/example_filesystems/v0.4/3-HZSwv99agoWgTErV0YFQ==
+++ /dev/null
Binary files differ
diff --git a/integration_tests/example_filesystems/v0.4/6hL2fPVB2aMSh4-UoDn5Kw== b/integration_tests/example_filesystems/v0.4/6hL2fPVB2aMSh4-UoDn5Kw==
deleted file mode 120000
index 31b9013..0000000
--- a/integration_tests/example_filesystems/v0.4/6hL2fPVB2aMSh4-UoDn5Kw==
+++ /dev/null
@@ -1 +0,0 @@
-3-HZSwv99agoWgTErV0YFQ== \ No newline at end of file
diff --git a/integration_tests/example_filesystems/v0.4/TBIgdfhDKwkXVTnWLVzFSg== b/integration_tests/example_filesystems/v0.4/TBIgdfhDKwkXVTnWLVzFSg==
deleted file mode 120000
index 7a15694..0000000
--- a/integration_tests/example_filesystems/v0.4/TBIgdfhDKwkXVTnWLVzFSg==
+++ /dev/null
@@ -1 +0,0 @@
-/tTXhw8tmmz4PK9YG21Whug==/Qe8z0HUArb5bZJjUqEo2Nw==/wv68UB9DLF9OfAcxgRKKtQ==/9No5n3deBUGa-BsvPRi3DQ== \ No newline at end of file
diff --git a/integration_tests/example_filesystems/v0.4/gocryptfs.conf b/integration_tests/example_filesystems/v0.4/gocryptfs.conf
deleted file mode 100644
index 354b4bb..0000000
--- a/integration_tests/example_filesystems/v0.4/gocryptfs.conf
+++ /dev/null
@@ -1,12 +0,0 @@
-{
- "EncryptedKey": "He757VFOKOWbMJqJ7HBs67SMSi3Vu8/2vgWNI6j1tVo4JBlNvrQSw6KkCh0lGrHrh6ICbPv4MyoyFdGa",
- "ScryptObject": {
- "Salt": "MeHSsxsnJwngAwptNzuXQlj7JtF1b0uzZuWvVV3cH3w=",
- "N": 65536,
- "R": 8,
- "P": 1,
- "KeyLen": 32
- },
- "Version": 2,
- "FeatureFlags": null
-} \ No newline at end of file
diff --git a/integration_tests/example_filesystems/v0.5/AOtl_i4xQWDyG0_zUqntOw== b/integration_tests/example_filesystems/v0.5/AOtl_i4xQWDyG0_zUqntOw==
deleted file mode 120000
index 7c52a28..0000000
--- a/integration_tests/example_filesystems/v0.5/AOtl_i4xQWDyG0_zUqntOw==
+++ /dev/null
@@ -1 +0,0 @@
-LFInXW9Djd1p8VfnwbhBaQy7MowhfNUDhsPPXXEiAfrfaVar6Ec= \ No newline at end of file
diff --git a/integration_tests/example_filesystems/v0.5/Pf35wlWlf43N68EbhIgTcQ== b/integration_tests/example_filesystems/v0.5/Pf35wlWlf43N68EbhIgTcQ==
deleted file mode 120000
index 596cc3d..0000000
--- a/integration_tests/example_filesystems/v0.5/Pf35wlWlf43N68EbhIgTcQ==
+++ /dev/null
@@ -1 +0,0 @@
-OrWiZIVoBo4qbbJdsPy1MCwlvGTE4t_ackP4lbcLdKiTA-Zf \ No newline at end of file
diff --git a/integration_tests/example_filesystems/v0.5/gocryptfs.conf b/integration_tests/example_filesystems/v0.5/gocryptfs.conf
deleted file mode 100644
index f839664..0000000
--- a/integration_tests/example_filesystems/v0.5/gocryptfs.conf
+++ /dev/null
@@ -1,14 +0,0 @@
-{
- "EncryptedKey": "zIY8foMncKrAG8USA1/AQ+R8z+xRge3QZqDpGRIDAeNOkMeQQsnMsJzFJbZHcGlRbUye0CwRghR/UX4R",
- "ScryptObject": {
- "Salt": "BFQklFzt3j9ZDa8zcR9pwHfa8nDdLqyCzNp5kA+V6Y0=",
- "N": 1024,
- "R": 8,
- "P": 1,
- "KeyLen": 32
- },
- "Version": 2,
- "FeatureFlags": [
- "DirIV"
- ]
-} \ No newline at end of file
diff --git a/integration_tests/example_filesystems/v0.5/gocryptfs.diriv b/integration_tests/example_filesystems/v0.5/gocryptfs.diriv
deleted file mode 100644
index 3670294..0000000
--- a/integration_tests/example_filesystems/v0.5/gocryptfs.diriv
+++ /dev/null
@@ -1 +0,0 @@
-VLlgk# \ No newline at end of file
diff --git a/integration_tests/example_filesystems/v0.5/j2BpGUT5kOtia20PWQ2rEA== b/integration_tests/example_filesystems/v0.5/j2BpGUT5kOtia20PWQ2rEA==
deleted file mode 100644
index 1ad2358..0000000
--- a/integration_tests/example_filesystems/v0.5/j2BpGUT5kOtia20PWQ2rEA==
+++ /dev/null
Binary files differ
diff --git a/integration_tests/example_filesystems/v0.6-plaintextnames/abs b/integration_tests/example_filesystems/v0.6-plaintextnames/abs
deleted file mode 120000
index e1740fa..0000000
--- a/integration_tests/example_filesystems/v0.6-plaintextnames/abs
+++ /dev/null
@@ -1 +0,0 @@
-/a/b/c/d \ No newline at end of file
diff --git a/integration_tests/example_filesystems/v0.6-plaintextnames/gocryptfs.conf b/integration_tests/example_filesystems/v0.6-plaintextnames/gocryptfs.conf
deleted file mode 100644
index 257b7ee..0000000
--- a/integration_tests/example_filesystems/v0.6-plaintextnames/gocryptfs.conf
+++ /dev/null
@@ -1,14 +0,0 @@
-{
- "EncryptedKey": "SoTMt+DMqVDia42c7cx8YW6KrnzF9EQVYIq5DGR1yFqNKxtOCBIuXEIKJHYSw1Z8VluKRQmkugTOvyTU",
- "ScryptObject": {
- "Salt": "83wR2p5eDPtozsP48vizN1rAbYeXOtksvwoAZ9Y0vn4=",
- "N": 1024,
- "R": 8,
- "P": 1,
- "KeyLen": 32
- },
- "Version": 2,
- "FeatureFlags": [
- "PlaintextNames"
- ]
-} \ No newline at end of file
diff --git a/integration_tests/example_filesystems/v0.6-plaintextnames/rel b/integration_tests/example_filesystems/v0.6-plaintextnames/rel
deleted file mode 120000
index 8279c75..0000000
--- a/integration_tests/example_filesystems/v0.6-plaintextnames/rel
+++ /dev/null
@@ -1 +0,0 @@
-status.txt \ No newline at end of file
diff --git a/integration_tests/example_filesystems/v0.6-plaintextnames/status.txt b/integration_tests/example_filesystems/v0.6-plaintextnames/status.txt
deleted file mode 100644
index e5b62fb..0000000
--- a/integration_tests/example_filesystems/v0.6-plaintextnames/status.txt
+++ /dev/null
Binary files differ
diff --git a/integration_tests/example_filesystems/v0.6/9pOs0yjJI5A67pv5CnqomQ== b/integration_tests/example_filesystems/v0.6/9pOs0yjJI5A67pv5CnqomQ==
deleted file mode 120000
index 11b0234..0000000
--- a/integration_tests/example_filesystems/v0.6/9pOs0yjJI5A67pv5CnqomQ==
+++ /dev/null
@@ -1 +0,0 @@
-OoEsnmmWQzBSl3E471yZkI2t2vB4SteL_l1J60HYXZ7g0W3CkTM= \ No newline at end of file
diff --git a/integration_tests/example_filesystems/v0.6/G79Zdu41H3bgwdaQlrz-dg== b/integration_tests/example_filesystems/v0.6/G79Zdu41H3bgwdaQlrz-dg==
deleted file mode 120000
index b72a393..0000000
--- a/integration_tests/example_filesystems/v0.6/G79Zdu41H3bgwdaQlrz-dg==
+++ /dev/null
@@ -1 +0,0 @@
-4IGGj21t4IYWI76F46v3gG-JwTcw_QxGDFMSk_19bJav2WNw \ No newline at end of file
diff --git a/integration_tests/example_filesystems/v0.6/RuYvQG_raW_-H_LcyJC4LQ== b/integration_tests/example_filesystems/v0.6/RuYvQG_raW_-H_LcyJC4LQ==
deleted file mode 100644
index 5821d87..0000000
--- a/integration_tests/example_filesystems/v0.6/RuYvQG_raW_-H_LcyJC4LQ==
+++ /dev/null
Binary files differ
diff --git a/integration_tests/example_filesystems/v0.6/gocryptfs.conf b/integration_tests/example_filesystems/v0.6/gocryptfs.conf
deleted file mode 100644
index 1c72781..0000000
--- a/integration_tests/example_filesystems/v0.6/gocryptfs.conf
+++ /dev/null
@@ -1,15 +0,0 @@
-{
- "EncryptedKey": "/PhLwDblkFRGfoIA0egXikG0ZSZTWrOOoFZJPPX0R8JgU5+XnT2M2rxUzHIKKeuGoqZN55phgJjhTu0J",
- "ScryptObject": {
- "Salt": "YSHRXpcWYp95npMxAy9cf27LoaPR3gvrFpk3Xhg2tM8=",
- "N": 1024,
- "R": 8,
- "P": 1,
- "KeyLen": 32
- },
- "Version": 2,
- "FeatureFlags": [
- "DirIV",
- "EMENames"
- ]
-} \ No newline at end of file
diff --git a/integration_tests/example_filesystems/v0.6/gocryptfs.diriv b/integration_tests/example_filesystems/v0.6/gocryptfs.diriv
deleted file mode 100644
index ec9f503..0000000
--- a/integration_tests/example_filesystems/v0.6/gocryptfs.diriv
+++ /dev/null
@@ -1 +0,0 @@
-('<7Q \ No newline at end of file
diff --git a/integration_tests/example_filesystems/v0.7/4tRF1LdULRFLiXwfze671Q== b/integration_tests/example_filesystems/v0.7/4tRF1LdULRFLiXwfze671Q==
deleted file mode 120000
index f06d136..0000000
--- a/integration_tests/example_filesystems/v0.7/4tRF1LdULRFLiXwfze671Q==
+++ /dev/null
@@ -1 +0,0 @@
-_IdSjAmPQOJW6QkskuyQJS9bFTjntqx9kdg4Z3y8EzKBnIb_Ihqz4w== \ No newline at end of file
diff --git a/integration_tests/example_filesystems/v0.7/RWPXmXkRFrWw1aOpq7C-NQ== b/integration_tests/example_filesystems/v0.7/RWPXmXkRFrWw1aOpq7C-NQ==
deleted file mode 100644
index 6ddcd1e..0000000
--- a/integration_tests/example_filesystems/v0.7/RWPXmXkRFrWw1aOpq7C-NQ==
+++ /dev/null
Binary files differ
diff --git a/integration_tests/example_filesystems/v0.7/dwPcZNei4HN4qPA6FxoG_A== b/integration_tests/example_filesystems/v0.7/dwPcZNei4HN4qPA6FxoG_A==
deleted file mode 120000
index c0c731f..0000000
--- a/integration_tests/example_filesystems/v0.7/dwPcZNei4HN4qPA6FxoG_A==
+++ /dev/null
@@ -1 +0,0 @@
-Ygqk_pYyxE_ac_ufVgxKCPxWHMGqQ8xUohIaHcmgeLU4uQB3_UmicPKB \ No newline at end of file
diff --git a/integration_tests/example_filesystems/v0.7/gocryptfs.conf b/integration_tests/example_filesystems/v0.7/gocryptfs.conf
deleted file mode 100644
index 80c2673..0000000
--- a/integration_tests/example_filesystems/v0.7/gocryptfs.conf
+++ /dev/null
@@ -1,16 +0,0 @@
-{
- "EncryptedKey": "0crm+qEf00XPxQrc8NIMp/0rgfaLb8wzTj+3G1slSytjsLHctj/fOKkGJIFyBk7xzvnWdkhyxxvHgfMS",
- "ScryptObject": {
- "Salt": "yZn+QMjR2ENZ6MoiURpqEqr8mgnCX8WN87KJafgiXhU=",
- "N": 1024,
- "R": 8,
- "P": 1,
- "KeyLen": 32
- },
- "Version": 2,
- "FeatureFlags": [
- "GCMIV128",
- "DirIV",
- "EMENames"
- ]
-} \ No newline at end of file
diff --git a/integration_tests/example_filesystems/v0.7/gocryptfs.diriv b/integration_tests/example_filesystems/v0.7/gocryptfs.diriv
deleted file mode 100644
index 3adef3c..0000000
--- a/integration_tests/example_filesystems/v0.7/gocryptfs.diriv
+++ /dev/null
@@ -1 +0,0 @@
-iȤ\?=Mc \ No newline at end of file
diff --git a/integration_tests/example_filesystems/v0.9/00msNUi5h5aKMX_f-4pBhA== b/integration_tests/example_filesystems/v0.9/00msNUi5h5aKMX_f-4pBhA==
deleted file mode 120000
index c717734..0000000
--- a/integration_tests/example_filesystems/v0.9/00msNUi5h5aKMX_f-4pBhA==
+++ /dev/null
@@ -1 +0,0 @@
-5nI119EbCRtgT8AwTDPmxCuORvbGV4xdtmqnur7KK9ufir-ALyneV7Iy \ No newline at end of file
diff --git a/integration_tests/example_filesystems/v0.9/R83PhW-BBA_q4rPYD7dEMg== b/integration_tests/example_filesystems/v0.9/R83PhW-BBA_q4rPYD7dEMg==
deleted file mode 100644
index 1bc4a81..0000000
--- a/integration_tests/example_filesystems/v0.9/R83PhW-BBA_q4rPYD7dEMg==
+++ /dev/null
Binary files differ
diff --git a/integration_tests/example_filesystems/v0.9/gocryptfs.conf b/integration_tests/example_filesystems/v0.9/gocryptfs.conf
deleted file mode 100644
index 4d9b089..0000000
--- a/integration_tests/example_filesystems/v0.9/gocryptfs.conf
+++ /dev/null
@@ -1,17 +0,0 @@
-{
- "EncryptedKey": "sAB/dsiDbFBbMr7ppsB3Fu81hVr6BBxlcfY1wZYRHlRvRV2uwRdYAACNM39CDxLBHZuNjk9UyWh87McP",
- "ScryptObject": {
- "Salt": "3mphl9Hmhzd6exmc8Um0jOOCgR8hAYvbzbEpTnIEMPg=",
- "N": 1024,
- "R": 8,
- "P": 1,
- "KeyLen": 32
- },
- "Version": 2,
- "FeatureFlags": [
- "GCMIV128",
- "DirIV",
- "EMENames",
- "LongNames"
- ]
-} \ No newline at end of file
diff --git a/integration_tests/example_filesystems/v0.9/gocryptfs.diriv b/integration_tests/example_filesystems/v0.9/gocryptfs.diriv
deleted file mode 100644
index 47d97ee..0000000
--- a/integration_tests/example_filesystems/v0.9/gocryptfs.diriv
+++ /dev/null
@@ -1 +0,0 @@
-~HA|ԁ \ No newline at end of file
diff --git a/integration_tests/example_filesystems/v0.9/gocryptfs.longname.y4J-w3LBX165Mn_pGdDRY7Gb6EgHcTrdWjME3WGu-CQ= b/integration_tests/example_filesystems/v0.9/gocryptfs.longname.y4J-w3LBX165Mn_pGdDRY7Gb6EgHcTrdWjME3WGu-CQ=
deleted file mode 100644
index 78eb3ff..0000000
--- a/integration_tests/example_filesystems/v0.9/gocryptfs.longname.y4J-w3LBX165Mn_pGdDRY7Gb6EgHcTrdWjME3WGu-CQ=
+++ /dev/null
Binary files differ
diff --git a/integration_tests/example_filesystems/v0.9/gocryptfs.longname.y4J-w3LBX165Mn_pGdDRY7Gb6EgHcTrdWjME3WGu-CQ=.name b/integration_tests/example_filesystems/v0.9/gocryptfs.longname.y4J-w3LBX165Mn_pGdDRY7Gb6EgHcTrdWjME3WGu-CQ=.name
deleted file mode 100644
index 535cee7..0000000
--- a/integration_tests/example_filesystems/v0.9/gocryptfs.longname.y4J-w3LBX165Mn_pGdDRY7Gb6EgHcTrdWjME3WGu-CQ=.name
+++ /dev/null
@@ -1 +0,0 @@
-Py7wkyXYf1YXvFvHuizOqva6WWWYEQ-JYv1rOAvWWaARLyGdQdxuW-iBf1Vwd8orZjqkcIGgnxOfuRsarXKmn4-3L2MRIZKPhhx2QRqpPRtFylEABH1KwZ_2ZZnx5cpcO8TIoeVdL6NXnRw-WrT06zTUzVRioNPRLPa0J6c8_eb5QFb4EG5wPpn-XlJSedjAw31MUNvFxKYQku_UwJF0CvvXLCozVnNM_dDNWsgBevzB8VBySbfW7XgYMRPJRlJe3Pjeues9tyGJvAxGJVjfo4nZyWusMF2G4f9w06m3Bxjc7ladgJR6F6pyI4Z65DCIL7G6G2y__agmNcKtFwCS_Q== \ No newline at end of file
diff --git a/integration_tests/example_filesystems/v0.9/hwE1RKIXtF8hmQMvEXSTtg== b/integration_tests/example_filesystems/v0.9/hwE1RKIXtF8hmQMvEXSTtg==
deleted file mode 120000
index 4190a7e..0000000
--- a/integration_tests/example_filesystems/v0.9/hwE1RKIXtF8hmQMvEXSTtg==
+++ /dev/null
@@ -1 +0,0 @@
-XRx7Nqxt_zuPNo7h8_j1LLVzqzIZg9qAYGRN9Iuq3XBc11Y7_RoQsg== \ No newline at end of file
diff --git a/integration_tests/example_filesystems_test.go b/integration_tests/example_filesystems_test.go
deleted file mode 100644
index 68191f8..0000000
--- a/integration_tests/example_filesystems_test.go
+++ /dev/null
@@ -1,203 +0,0 @@
-package integration_tests
-
-// Mount example filesystems and check that the file "status.txt" is there
-
-import (
- "io/ioutil"
- "os"
- "path/filepath"
- "testing"
-)
-
-const statusTxtContent = "It works!\n"
-
-// checkExampleFS - verify that "dir" contains the expected test files
-func checkExampleFS(t *testing.T, dir string) {
- // Read regular file
- statusFile := filepath.Join(dir, "status.txt")
- contentBytes, err := ioutil.ReadFile(statusFile)
- if err != nil {
- t.Fatal(err)
- }
- content := string(contentBytes)
- if content != statusTxtContent {
- t.Errorf("Unexpected content: %s\n", content)
- }
- // Read relative symlink
- symlink := filepath.Join(dir, "rel")
- target, err := os.Readlink(symlink)
- if err != nil {
- t.Fatal(err)
- }
- if target != "status.txt" {
- t.Errorf("Unexpected link target: %s\n", target)
- }
- // Read absolute symlink
- symlink = filepath.Join(dir, "abs")
- target, err = os.Readlink(symlink)
- if err != nil {
- t.Fatal(err)
- }
- if target != "/a/b/c/d" {
- t.Errorf("Unexpected link target: %s\n", target)
- }
- // Test directory operations
- testRename(t, dir)
- testMkdirRmdir(t, dir)
-}
-
-// checkExampleFSLongnames - verify that "dir" contains the expected test files
-// plus the long file name test file
-func checkExampleFSLongnames(t *testing.T, dir string) {
- // regular tests
- checkExampleFS(t, dir)
- // long name test file
- longname := "longname_255_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" +
- "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" +
- "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" +
- "xxxxxxxxxxxxxxxxxxxxxxxx"
- contentBytes, err := ioutil.ReadFile(filepath.Join(dir, longname))
- if err != nil {
- t.Fatal(err)
- }
- content := string(contentBytes)
- if content != statusTxtContent {
- t.Errorf("longname_255: unexpected content: %s\n", content)
- }
-
-}
-
-// Test example_filesystems/v0.4
-// with password mount and -masterkey mount
-func TestExampleFSv04(t *testing.T) {
- pDir := tmpDir + "TestExampleFsV04/"
- cDir := "example_filesystems/v0.4"
- err := os.Mkdir(pDir, 0777)
- if err != nil {
- t.Fatal(err)
- }
- mountOrFatal(t, cDir, pDir, "-extpass", "echo test")
- checkExampleFS(t, pDir)
- unmount(pDir)
- mountOrFatal(t, cDir, pDir, "-masterkey", "74676e34-0b47c145-00dac61a-17a92316-"+
- "bb57044c-e205b71f-65f4fdca-7cabd4b3", "-diriv=false", "-emenames=false", "-gcmiv128=false")
- checkExampleFS(t, pDir)
- unmount(pDir)
- err = os.Remove(pDir)
- if err != nil {
- t.Error(err)
- }
-}
-
-// Test example_filesystems/v0.5
-// with password mount and -masterkey mount
-func TestExampleFSv05(t *testing.T) {
- pDir := tmpDir + "TestExampleFsV05/"
- cDir := "example_filesystems/v0.5"
- err := os.Mkdir(pDir, 0777)
- if err != nil {
- t.Fatal(err)
- }
- mountOrFatal(t, cDir, pDir, "-extpass", "echo test")
- checkExampleFS(t, pDir)
- unmount(pDir)
- mountOrFatal(t, cDir, pDir, "-masterkey", "199eae55-36bff4af-83b9a3a2-4fa16f65-"+
- "1549ccdb-2d08d1f0-b1b26965-1b61f896", "-emenames=false", "-gcmiv128=false")
- checkExampleFS(t, pDir)
- unmount(pDir)
- err = os.Remove(pDir)
- if err != nil {
- t.Error(err)
- }
-}
-
-// Test example_filesystems/v0.6
-// with password mount and -masterkey mount
-func TestExampleFSv06(t *testing.T) {
- pDir := tmpDir + "TestExampleFsV06/"
- cDir := "example_filesystems/v0.6"
- err := os.Mkdir(pDir, 0777)
- if err != nil {
- t.Fatal(err)
- }
- mountOrFatal(t, cDir, pDir, "-extpass", "echo test")
- checkExampleFS(t, pDir)
- unmount(pDir)
- mountOrFatal(t, cDir, pDir, "-masterkey", "7bc8deb0-5fc894ef-a093da43-61561a81-"+
- "0e8dee83-fdc056a4-937c37dd-9df5c520", "-gcmiv128=false")
- checkExampleFS(t, pDir)
- unmount(pDir)
- err = os.Remove(pDir)
- if err != nil {
- t.Error(err)
- }
-}
-
-// Test example_filesystems/v0.6-plaintextnames
-// with password mount and -masterkey mount
-// v0.6 changed the file name handling a lot, hence the explicit test case for
-// plaintextnames.
-func TestExampleFSv06PlaintextNames(t *testing.T) {
- pDir := tmpDir + "TestExampleFsV06PlaintextNames/"
- cDir := "example_filesystems/v0.6-plaintextnames"
- err := os.Mkdir(pDir, 0777)
- if err != nil {
- t.Fatal(err)
- }
- mountOrFatal(t, cDir, pDir, "-extpass", "echo test")
- checkExampleFS(t, pDir)
- unmount(pDir)
- mountOrFatal(t, cDir, pDir, "-masterkey", "f4690202-595e4593-64c4f7e0-4dddd7d1-"+
- "303147f9-0ca8aea2-966341a7-52ea8ae9", "-plaintextnames", "-gcmiv128=false")
- checkExampleFS(t, pDir)
- unmount(pDir)
- err = os.Remove(pDir)
- if err != nil {
- t.Error(err)
- }
-}
-
-// Test example_filesystems/v0.7
-// with password mount and -masterkey mount
-// v0.7 adds 128 bit GCM IVs
-func TestExampleFSv07(t *testing.T) {
- pDir := tmpDir + "TestExampleFsV07/"
- cDir := "example_filesystems/v0.7"
- err := os.Mkdir(pDir, 0777)
- if err != nil {
- t.Fatal(err)
- }
- mountOrFatal(t, cDir, pDir, "-extpass", "echo test")
- checkExampleFS(t, pDir)
- unmount(pDir)
- mountOrFatal(t, cDir, pDir, "-masterkey", "ed7f6d83-40cce86c-0e7d79c2-a9438710-"+
- "575221bf-30a0eb60-2821fa8f-7f3123bf")
- checkExampleFS(t, pDir)
- unmount(pDir)
- err = os.Remove(pDir)
- if err != nil {
- t.Error(err)
- }
-}
-
-// Test example_filesystems/v0.9
-// (gocryptfs v0.9 introduced long file name support)
-func TestExampleFSv09(t *testing.T) {
- cDir := "example_filesystems/v0.9"
- pDir := tmpDir + "TestExampleFsV09/"
- err := os.Mkdir(pDir, 0777)
- if err != nil {
- t.Fatal(err)
- }
- mountOrFatal(t, cDir, pDir, "-extpass", "echo test")
- checkExampleFSLongnames(t, pDir)
- unmount(pDir)
- mountOrFatal(t, cDir, pDir, "-masterkey", "1cafe3f4-bc316466-2214c47c-ecd89bf3-"+
- "4e078fe4-f5faeea7-8b7cab02-884f5e1c")
- checkExampleFSLongnames(t, pDir)
- unmount(pDir)
- err = os.Remove(pDir)
- if err != nil {
- t.Error(err)
- }
-}
diff --git a/integration_tests/helpers.go b/integration_tests/helpers.go
deleted file mode 100644
index 4881a4b..0000000
--- a/integration_tests/helpers.go
+++ /dev/null
@@ -1,237 +0,0 @@
-package integration_tests
-
-import (
- "crypto/md5"
- "encoding/hex"
- "fmt"
- "io/ioutil"
- "os"
- "os/exec"
- "path/filepath"
- "syscall"
- "testing"
-
- "github.com/rfjakob/gocryptfs/internal/nametransform"
-)
-
-// Note: the code assumes that all have a trailing slash
-const tmpDir = "/tmp/gocryptfs_main_test/"
-const defaultPlainDir = tmpDir + "plain/"
-const defaultCipherDir = tmpDir + "cipher/"
-
-const gocryptfsBinary = "../gocryptfs"
-
-// resetTmpDir - delete old tmp dir, create new one, write gocryptfs.diriv
-func resetTmpDir(plaintextNames bool) {
-
- // Try to unmount everything
- entries, err := ioutil.ReadDir(tmpDir)
- if err == nil {
- for _, e := range entries {
- fu := exec.Command("fusermount", "-z", "-u", filepath.Join(tmpDir, e.Name()))
- fu.Run()
- }
- }
-
- err = os.RemoveAll(tmpDir)
- if err != nil {
- fmt.Println("resetTmpDir: RemoveAll:" + err.Error())
- os.Exit(1)
- }
-
- err = os.MkdirAll(defaultPlainDir, 0777)
- if err != nil {
- fmt.Println(err)
- os.Exit(1)
- }
-
- err = os.MkdirAll(defaultCipherDir, 0777)
- if err != nil {
- fmt.Println(err)
- os.Exit(1)
- }
- if !plaintextNames {
- err = nametransform.WriteDirIV(defaultCipherDir)
- if err != nil {
- fmt.Println(err)
- os.Exit(1)
- }
- }
-}
-
-// mount CIPHERDIR "c" on PLAINDIR "p"
-func mount(c string, p string, extraArgs ...string) error {
- var args []string
- args = append(args, extraArgs...)
- args = append(args, "-nosyslog", "-q", "-wpanic")
- //args = append(args, "-fusedebug")
- //args = append(args, "-d")
- args = append(args, c)
- args = append(args, p)
- cmd := exec.Command(gocryptfsBinary, args...)
- cmd.Stderr = os.Stderr
- cmd.Stdout = os.Stdout
- return cmd.Run()
-}
-
-// mountOrExit calls mount() and exits on failure.
-func mountOrExit(c string, p string, extraArgs ...string) {
- err := mount(c, p, extraArgs...)
- if err != nil {
- fmt.Printf("mount failed: %v", err)
- os.Exit(1)
- }
-}
-
-// mountOrFatal calls mount() and calls t.Fatal() on failure.
-func mountOrFatal(t *testing.T, c string, p string, extraArgs ...string) {
- err := mount(c, p, extraArgs...)
- if err != nil {
- t.Fatal(fmt.Errorf("mount failed: %v", err))
- }
-}
-
-// unmount PLAINDIR "p"
-func unmount(p string) error {
- fu := exec.Command("fusermount", "-u", "-z", p)
- fu.Stdout = os.Stdout
- fu.Stderr = os.Stderr
- err := fu.Run()
- if err != nil {
- fmt.Println(err)
- }
- return err
-}
-
-// Return md5 string for file "filename"
-func md5fn(filename string) string {
- buf, err := ioutil.ReadFile(filename)
- if err != nil {
- fmt.Printf("ReadFile: %v\n", err)
- return ""
- }
- return md5hex(buf)
-}
-
-// Return md5 string for "buf"
-func md5hex(buf []byte) string {
- rawHash := md5.Sum(buf)
- hash := hex.EncodeToString(rawHash[:])
- return hash
-}
-
-// Verify that the file size equals "want". This checks:
-// 1) Size reported by Stat()
-// 2) Number of bytes returned when reading the whole file
-func verifySize(t *testing.T, path string, want int) {
- buf, err := ioutil.ReadFile(path)
- if err != nil {
- t.Errorf("ReadFile failed: %v", err)
- } else if len(buf) != want {
- t.Errorf("wrong read size: got=%d want=%d", len(buf), want)
- }
-
- fi, err := os.Stat(path)
- if err != nil {
- t.Errorf("Stat failed: %v", err)
- } else if fi.Size() != int64(want) {
- t.Errorf("wrong stat file size, got=%d want=%d", fi.Size(), want)
- }
-}
-
-// Create and delete a directory
-func testMkdirRmdir(t *testing.T, plainDir string) {
- dir := plainDir + "dir1"
- err := os.Mkdir(dir, 0777)
- if err != nil {
- t.Fatal(err)
- }
- err = syscall.Rmdir(dir)
- if err != nil {
- t.Fatal(err)
- }
-
- // Removing a non-empty dir should fail with ENOTEMPTY
- if os.Mkdir(dir, 0777) != nil {
- t.Fatal(err)
- }
- f, err := os.Create(dir + "/file")
- if err != nil {
- t.Fatal(err)
- }
- f.Close()
- err = syscall.Rmdir(dir)
- errno := err.(syscall.Errno)
- if errno != syscall.ENOTEMPTY {
- t.Errorf("Should have gotten ENOTEMPTY, go %v", errno)
- }
- if syscall.Unlink(dir+"/file") != nil {
- t.Fatal(err)
- }
- if syscall.Rmdir(dir) != nil {
- t.Fatal(err)
- }
-
- // We should also be able to remove a directory we do not have permissions to
- // read or write
- err = os.Mkdir(dir, 0000)
- if err != nil {
- t.Fatal(err)
- }
- err = syscall.Rmdir(dir)
- if err != nil {
- // Make sure the directory can cleaned up by the next test run
- os.Chmod(dir, 0700)
- t.Fatal(err)
- }
-}
-
-// Create and rename a file
-func testRename(t *testing.T, plainDir string) {
- file1 := plainDir + "rename1"
- file2 := plainDir + "rename2"
- err := ioutil.WriteFile(file1, []byte("content"), 0777)
- if err != nil {
- t.Fatal(err)
- }
- err = syscall.Rename(file1, file2)
- if err != nil {
- t.Fatal(err)
- }
- syscall.Unlink(file2)
-}
-
-// verifyExistence - check in 3 ways that "path" exists:
-// stat, open, readdir
-func verifyExistence(path string) bool {
-
- // Check that file can be stated
- _, err := os.Stat(path)
- if err != nil {
- //t.Log(err)
- return false
- }
-
- // Check that file can be opened
- fd, err := os.Open(path)
- if err != nil {
- //t.Log(err)
- return false
- }
- fd.Close()
-
- // Check that file shows up in directory listing
- dir := filepath.Dir(path)
- name := filepath.Base(path)
- fi, err := ioutil.ReadDir(dir)
- if err != nil {
- //t.Log(err)
- return false
- }
- for _, i := range fi {
- if i.Name() == name {
- return true
- }
- }
- return false
-}
diff --git a/integration_tests/main_test.go b/integration_tests/main_test.go
deleted file mode 100644
index c7607ce..0000000
--- a/integration_tests/main_test.go
+++ /dev/null
@@ -1,437 +0,0 @@
-package integration_tests
-
-// File reading, writing, modification, truncate
-
-import (
- "bytes"
- "crypto/md5"
- "encoding/hex"
- "flag"
- "fmt"
- "io/ioutil"
- "os"
- "runtime"
- "sync"
- "syscall"
- "testing"
-)
-
-var plaintextNames bool
-
-// This is the entry point for the tests
-func TestMain(m *testing.M) {
- var defaultonly bool
- flag.BoolVar(&defaultonly, "defaultonly", false, "Only test default configuration (openssl=true, plaintextnames=false)")
- flag.Parse()
-
- if testing.Verbose() {
- fmt.Println("***** Testing with OpenSSL")
- }
- resetTmpDir(false) // <- this also create gocryptfs.diriv
- mountOrExit(defaultCipherDir, defaultPlainDir, "--zerokey")
- r := m.Run()
- unmount(defaultPlainDir)
-
- if r != 0 {
- os.Exit(r)
- }
-
- if defaultonly {
- os.Exit(r)
- }
-
- if testing.Verbose() {
- fmt.Println("***** Testing with native Go crypto")
- }
- resetTmpDir(false)
- mountOrExit(defaultCipherDir, defaultPlainDir, "--zerokey", "--openssl=false")
- r = m.Run()
- unmount(defaultPlainDir)
-
- if r != 0 {
- os.Exit(r)
- }
-
- if testing.Verbose() {
- fmt.Println("***** Testing \"--plaintextnames\"")
- }
- resetTmpDir(true) // do not create gocryptfs.diriv
- mountOrExit(defaultCipherDir, defaultPlainDir, "--zerokey", "--plaintextnames")
- plaintextNames = true
- r = m.Run()
- unmount(defaultPlainDir)
-
- if r != 0 {
- os.Exit(r)
- }
-
- os.Exit(r)
-}
-
-// Write "n" zero bytes to filename "fn", read again, compare hash
-func testWriteN(t *testing.T, fn string, n int) string {
- file, err := os.Create(defaultPlainDir + fn)
- if err != nil {
- t.Fatal(err)
- }
-
- d := make([]byte, n)
- written, err := file.Write(d)
- if err != nil || written != len(d) {
- t.Errorf("err=\"%s\", written=%d", err, written)
- }
- err = file.Close()
- if err != nil {
- t.Error(err)
- }
-
- verifySize(t, defaultPlainDir+fn, n)
-
- bin := md5.Sum(d)
- hashWant := hex.EncodeToString(bin[:])
-
- hashActual := md5fn(defaultPlainDir + fn)
-
- if hashActual != hashWant {
- t.Errorf("Wrong content, hashWant=%s hashActual=%s", hashWant, hashActual)
- }
-
- return hashActual
-}
-
-func TestWrite10(t *testing.T) {
- testWriteN(t, "10", 10)
-}
-
-func TestWrite100(t *testing.T) {
- testWriteN(t, "100", 100)
-}
-
-func TestWrite1M(t *testing.T) {
- testWriteN(t, "1M", 1024*1024)
-}
-
-func TestWrite1Mx100(t *testing.T) {
- hashWant := testWriteN(t, "1Mx100", 1024*1024)
- // Read and check 100 times to catch race conditions
- var i int
- for i = 0; i < 100; i++ {
- hashActual := md5fn(defaultPlainDir + "1M")
- if hashActual != hashWant {
- fmt.Printf("Read corruption in loop # %d\n", i)
- t.FailNow()
- } else {
- //fmt.Print(".")
- }
- }
-}
-
-func TestTruncate(t *testing.T) {
- fn := defaultPlainDir + "truncate"
- file, err := os.Create(fn)
- if err != nil {
- t.FailNow()
- }
- // Grow to two blocks
- file.Truncate(7000)
- verifySize(t, fn, 7000)
- if md5fn(fn) != "95d4ec7038e3e4fdbd5f15c34c3f0b34" {
- t.Errorf("wrong content")
- }
- // Shrink - needs RMW
- file.Truncate(6999)
- verifySize(t, fn, 6999)
- if md5fn(fn) != "35fd15873ec6c35380064a41b9b9683b" {
- t.Errorf("wrong content")
- }
- // Shrink to one partial block
- file.Truncate(465)
- verifySize(t, fn, 465)
- if md5fn(fn) != "a1534d6e98a6b21386456a8f66c55260" {
- t.Errorf("wrong content")
- }
- // Grow to exactly one block
- file.Truncate(4096)
- verifySize(t, fn, 4096)
- if md5fn(fn) != "620f0b67a91f7f74151bc5be745b7110" {
- t.Errorf("wrong content")
- }
-}
-
-func TestAppend(t *testing.T) {
- fn := defaultPlainDir + "append"
- file, err := os.Create(fn)
- if err != nil {
- t.FailNow()
- }
- data := []byte("testdata123456789") // length 17
- var buf bytes.Buffer
- var hashWant string
- for i := 0; i <= 500; i++ {
- file.Write(data)
- buf.Write(data)
- bin := md5.Sum(buf.Bytes())
- hashWant = hex.EncodeToString(bin[:])
- hashActual := md5fn(fn)
- if hashWant != hashActual {
- t.FailNow()
- }
- }
-
- // Overwrite with the same data
- // Hash must stay the same
- file.Seek(0, 0)
- for i := 0; i <= 500; i++ {
- file.Write(data)
- hashActual := md5fn(fn)
- if hashWant != hashActual {
- t.FailNow()
- }
- }
-}
-
-// Create a file with holes by writing to offset 0 (block #0) and
-// offset 4096 (block #1).
-func TestFileHoles(t *testing.T) {
- fn := defaultPlainDir + "fileholes"
- file, err := os.Create(fn)
- if err != nil {
- t.Errorf("file create failed")
- }
- foo := []byte("foo")
- file.Write(foo)
- file.WriteAt(foo, 4096)
- _, err = ioutil.ReadFile(fn)
- if err != nil {
- t.Error(err)
- }
-}
-
-// sContains - does the slice of strings "haystack" contain "needle"?
-func sContains(haystack []string, needle string) bool {
- for _, element := range haystack {
- if element == needle {
- return true
- }
- }
- return false
-}
-
-func TestRmwRace(t *testing.T) {
-
- runtime.GOMAXPROCS(10)
-
- fn := defaultPlainDir + "rmwrace"
- f1, err := os.Create(fn)
- if err != nil {
- t.Fatalf("file create failed")
- }
- f2, err := os.Create(fn)
- if err != nil {
- t.Fatalf("file create failed")
- }
-
- oldBlock := bytes.Repeat([]byte("o"), 4096)
-
- newBlock := bytes.Repeat([]byte("n"), 4096)
-
- shortBlock := bytes.Repeat([]byte("s"), 16)
-
- mergedBlock := make([]byte, 4096)
- copy(mergedBlock, newBlock)
- copy(mergedBlock[4080:], shortBlock)
-
- goodMd5 := make(map[string]int)
-
- for i := 0; i < 1000; i++ {
- // Reset to [ooooooooo]
- _, err = f1.WriteAt(oldBlock, 0)
- if err != nil {
- t.Fatalf("Write failed")
- }
-
- var wg sync.WaitGroup
- wg.Add(2)
-
- // Write to the end of the file, [....ssss]
- go func() {
- f1.WriteAt(shortBlock, 4080)
- wg.Done()
- }()
-
- // Overwrite to [nnnnnnn]
- go func() {
- f2.WriteAt(newBlock, 0)
- wg.Done()
- }()
-
- wg.Wait()
-
- // The file should be either:
- // [nnnnnnnnnn] (md5: 6c1660fdabccd448d1359f27b3db3c99) or
- // [nnnnnnssss] (md5: da885006a6a284530a427c73ce1e5c32)
- // but it must not be
- // [oooooossss]
-
- buf, _ := ioutil.ReadFile(fn)
- m := md5hex(buf)
- goodMd5[m] = goodMd5[m] + 1
-
- /*
- if m == "6c1660fdabccd448d1359f27b3db3c99" {
- fmt.Println(hex.Dump(buf))
- t.FailNow()
- }
- */
- }
- if testing.Verbose() {
- fmt.Println(goodMd5)
- }
-}
-
-// With "--plaintextnames", the name "/gocryptfs.conf" is reserved.
-// Otherwise there should be no restrictions.
-func TestFiltered(t *testing.T) {
- filteredFile := defaultPlainDir + "gocryptfs.conf"
- file, err := os.Create(filteredFile)
- if plaintextNames == true && err == nil {
- t.Errorf("should have failed but didn't")
- } else if plaintextNames == false && err != nil {
- t.Error(err)
- }
- file.Close()
-
- err = os.Remove(filteredFile)
- if plaintextNames == true && err == nil {
- t.Errorf("should have failed but didn't")
- } else if plaintextNames == false && err != nil {
- t.Error(err)
- }
-}
-
-func TestFilenameEncryption(t *testing.T) {
- file, err := os.Create(defaultPlainDir + "TestFilenameEncryption.txt")
- file.Close()
- if err != nil {
- t.Fatal(err)
- }
-
- _, err = os.Stat(defaultCipherDir + "TestFilenameEncryption.txt")
- if plaintextNames == true && err != nil {
- t.Errorf("plaintextnames not working: %v", err)
- } else if plaintextNames == false && err == nil {
- t.Errorf("file name encryption not working")
- }
-}
-
-// Test Mkdir and Rmdir
-func TestMkdirRmdir(t *testing.T) {
- testMkdirRmdir(t, defaultPlainDir)
-}
-
-// Test Rename
-func TestRename(t *testing.T) {
- testRename(t, defaultPlainDir)
-}
-
-// Overwrite an empty directory with another directory
-func TestDirOverwrite(t *testing.T) {
- dir1 := defaultPlainDir + "DirOverwrite1"
- dir2 := defaultPlainDir + "DirOverwrite2"
- err := os.Mkdir(dir1, 0777)
- if err != nil {
- t.Fatal(err)
- }
- err = os.Mkdir(dir2, 0777)
- if err != nil {
- t.Fatal(err)
- }
- err = os.Rename(dir1, dir2)
- if err != nil {
- t.Fatal(err)
- }
-}
-
-func TestLongNames(t *testing.T) {
- fi, err := ioutil.ReadDir(defaultCipherDir)
- if err != nil {
- t.Fatal(err)
- }
- cnt1 := len(fi)
- wd := defaultPlainDir
- // Create file with long name
- n255x := string(bytes.Repeat([]byte("x"), 255))
- f, err := os.Create(wd + n255x)
- if err != nil {
- t.Fatalf("Could not create n255x: %v", err)
- }
- f.Close()
- if !verifyExistence(wd + n255x) {
- t.Errorf("n255x is not in directory listing")
- }
- // Rename long to long
- n255y := string(bytes.Repeat([]byte("y"), 255))
- err = os.Rename(wd+n255x, wd+n255y)
- if err != nil {
- t.Fatalf("Could not rename n255x to n255y: %v", err)
- }
- if !verifyExistence(wd + n255y) {
- t.Errorf("n255y is not in directory listing")
- }
- // Rename long to short
- err = os.Rename(wd+n255y, wd+"short")
- if err != nil {
- t.Fatalf("Could not rename n255y to short: %v", err)
- }
- if !verifyExistence(wd + "short") {
- t.Errorf("short is not in directory listing")
- }
- // Rename short to long
- err = os.Rename(wd+"short", wd+n255x)
- if err != nil {
- t.Fatalf("Could not rename short to n255x: %v", err)
- }
- if !verifyExistence(wd + n255x) {
- t.Errorf("255x is not in directory listing II")
- }
- // Unlink
- err = syscall.Unlink(wd + n255x)
- if err != nil {
- t.Fatalf("Could not unlink n255x: %v", err)
- }
- if verifyExistence(wd + n255x) {
- t.Errorf("n255x still there after unlink")
- }
- // Long symlink
- n255s := string(bytes.Repeat([]byte("s"), 255))
- err = os.Symlink("/etc/motd", wd+n255s)
- if err != nil {
- t.Fatal(err)
- }
- if !verifyExistence(wd + n255s) {
- t.Errorf("n255s is not in directory listing")
- }
- err = syscall.Unlink(wd + n255s)
- if err != nil {
- t.Error(err)
- }
- // Long dir
- n255d := string(bytes.Repeat([]byte("d"), 255))
- err = os.Mkdir(wd+n255d, 0777)
- if err != nil {
- t.Fatal(err)
- }
- err = syscall.Rmdir(wd + n255d)
- if err != nil {
- t.Error(err)
- }
- // Check for orphaned files
- fi, err = ioutil.ReadDir(defaultCipherDir)
- if err != nil {
- t.Fatal(err)
- }
- cnt2 := len(fi)
- if cnt1 != cnt2 {
- t.Errorf("Leftover files, cnt1=%d cnt2=%d", cnt1, cnt2)
- }
-}
diff --git a/integration_tests/performance_test.go b/integration_tests/performance_test.go
deleted file mode 100644
index 9a0399a..0000000
--- a/integration_tests/performance_test.go
+++ /dev/null
@@ -1,129 +0,0 @@
-package integration_tests
-
-// Benchmarks
-
-import (
- "fmt"
- "io"
- "io/ioutil"
- "os"
- "testing"
-)
-
-func BenchmarkStreamWrite(t *testing.B) {
- buf := make([]byte, 1024*1024)
- t.SetBytes(int64(len(buf)))
-
- file, err := os.Create(defaultPlainDir + "BenchmarkWrite")
- if err != nil {
- t.FailNow()
- }
-
- t.ResetTimer()
- var i int
- for i = 0; i < t.N; i++ {
- written, err := file.Write(buf)
- if err != nil {
- fmt.Printf("err=\"%s\", written=%d\n", err.Error(), written)
- t.FailNow()
- }
- }
- file.Close()
-}
-
-func BenchmarkStreamRead(t *testing.B) {
- buf := make([]byte, 1024*1024)
- t.SetBytes(int64(len(buf)))
-
- fn := defaultPlainDir + "BenchmarkWrite"
- fi, err := os.Stat(fn)
- if err != nil {
- t.Fatal(err)
- }
- mb := int(fi.Size() / 1024 / 1024)
-
- if t.N > mb {
- // Grow file so we can satisfy the test
- //fmt.Printf("Growing file to %d MB... ", t.N)
- var f2 *os.File
- f2, err = os.OpenFile(fn, os.O_WRONLY|os.O_APPEND, 0666)
- if err != nil {
- fmt.Println(err)
- t.FailNow()
- }
- for h := 0; h < t.N-mb; h++ {
- _, err = f2.Write(buf)
- if err != nil {
- fmt.Println(err)
- t.FailNow()
- }
- }
- f2.Close()
- }
-
- file, err := os.Open(fn)
- if err != nil {
- t.FailNow()
- }
- t.ResetTimer()
- var i int
- for i = 0; i < t.N; i++ {
- _, err := file.Read(buf)
- if err == io.EOF {
- fmt.Println("Test file too small")
- t.SkipNow()
- } else if err != nil {
- fmt.Println(err)
- t.FailNow()
- }
- }
- file.Close()
-}
-
-// createFiles - create "count" files of size "size" bytes each
-func createFiles(t *testing.B, count int, size int) {
- dir := fmt.Sprintf("%s/createFiles_%d_%d", defaultPlainDir, count, size)
- err := os.Mkdir(dir, 0777)
- if err != nil {
- t.Fatal(err)
- }
- buf := make([]byte, size)
- t.SetBytes(int64(len(buf)))
- t.ResetTimer()
- var i int
- for i = 0; i < count; i++ {
- file := fmt.Sprintf("%s/%d", dir, i)
- if size > 0 {
- err = ioutil.WriteFile(file, buf, 0666)
- } else {
- var fh *os.File
- fh, err = os.Create(file)
- fh.Close()
- }
- if err != nil {
- t.Fatal(err)
- }
- }
- t.StopTimer()
- os.RemoveAll(dir)
-}
-
-func BenchmarkCreate0B(t *testing.B) {
- createFiles(t, t.N, 0)
-}
-
-func BenchmarkCreate1B(t *testing.B) {
- createFiles(t, t.N, 1)
-}
-
-func BenchmarkCreate100B(t *testing.B) {
- createFiles(t, t.N, 100)
-}
-
-func BenchmarkCreate4kB(t *testing.B) {
- createFiles(t, t.N, 4*1024)
-}
-
-func BenchmarkCreate10kB(t *testing.B) {
- createFiles(t, t.N, 10*1024)
-}