2015-11-15 15:05:15 +01:00
|
|
|
package integration_tests
|
|
|
|
|
|
|
|
// Mount example filesystems and check that the file "status.txt" is there
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io/ioutil"
|
|
|
|
"os"
|
2015-11-29 21:55:20 +01:00
|
|
|
"path/filepath"
|
2015-11-15 15:05:15 +01:00
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
const statusTxtContent = "It works!\n"
|
|
|
|
|
|
|
|
// checkStatusTxt - read file "filename" and verify that it contains
|
|
|
|
// "It works!\n"
|
2015-12-10 20:02:18 +01:00
|
|
|
func checkExampleFS(t *testing.T, dir string) {
|
|
|
|
// Read regular file
|
2015-11-28 20:21:06 +01:00
|
|
|
statusFile := filepath.Join(dir, "status.txt")
|
|
|
|
contentBytes, err := ioutil.ReadFile(statusFile)
|
2015-11-15 15:05:15 +01:00
|
|
|
if err != nil {
|
2015-11-27 21:50:11 +01:00
|
|
|
t.Fatal(err)
|
2015-11-15 15:05:15 +01:00
|
|
|
}
|
|
|
|
content := string(contentBytes)
|
|
|
|
if content != statusTxtContent {
|
|
|
|
t.Errorf("Unexpected content: %s\n", content)
|
|
|
|
}
|
2015-12-10 20:02:18 +01:00
|
|
|
// Read relative symlink
|
2015-11-28 20:21:06 +01:00
|
|
|
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)
|
|
|
|
}
|
2015-12-10 20:02:18 +01:00
|
|
|
// Read absolute symlink
|
2015-11-28 20:21:06 +01:00
|
|
|
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)
|
|
|
|
}
|
2015-12-10 20:02:18 +01:00
|
|
|
// Test directory operations
|
|
|
|
testRename(t, dir)
|
|
|
|
testMkdirRmdir(t, dir)
|
2015-11-15 15:05:15 +01:00
|
|
|
}
|
|
|
|
|
2015-11-28 20:31:01 +01:00
|
|
|
// Test example_filesystems/v0.4
|
2015-11-15 15:05:15 +01:00
|
|
|
// with password mount and -masterkey mount
|
2015-12-10 20:02:18 +01:00
|
|
|
func TestExampleFSv04(t *testing.T) {
|
2015-11-28 20:31:01 +01:00
|
|
|
pDir := tmpDir + "TestExampleFsV04/"
|
|
|
|
cDir := "example_filesystems/v0.4"
|
2015-11-15 15:05:15 +01:00
|
|
|
err := os.Mkdir(pDir, 0777)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
mount(cDir, pDir, "-extpass", "echo test")
|
2015-12-10 20:02:18 +01:00
|
|
|
checkExampleFS(t, pDir)
|
2015-11-15 15:05:15 +01:00
|
|
|
unmount(pDir)
|
|
|
|
mount(cDir, pDir, "-masterkey", "74676e34-0b47c145-00dac61a-17a92316-"+
|
2015-12-08 16:13:29 +01:00
|
|
|
"bb57044c-e205b71f-65f4fdca-7cabd4b3", "-diriv=false", "-emenames=false")
|
2015-12-10 20:02:18 +01:00
|
|
|
checkExampleFS(t, pDir)
|
2015-11-15 15:05:15 +01:00
|
|
|
unmount(pDir)
|
|
|
|
err = os.Remove(pDir)
|
|
|
|
if err != nil {
|
|
|
|
t.Error(err)
|
|
|
|
}
|
|
|
|
}
|
2015-11-28 20:31:01 +01:00
|
|
|
|
|
|
|
// Test example_filesystems/v0.5
|
|
|
|
// with password mount and -masterkey mount
|
2015-12-10 20:02:18 +01:00
|
|
|
func TestExampleFSv05(t *testing.T) {
|
2015-11-28 20:31:01 +01:00
|
|
|
pDir := tmpDir + "TestExampleFsV05/"
|
|
|
|
cDir := "example_filesystems/v0.5"
|
|
|
|
err := os.Mkdir(pDir, 0777)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
mount(cDir, pDir, "-extpass", "echo test")
|
2015-12-10 20:02:18 +01:00
|
|
|
checkExampleFS(t, pDir)
|
2015-11-28 20:31:01 +01:00
|
|
|
unmount(pDir)
|
2015-12-06 14:27:27 +01:00
|
|
|
mount(cDir, pDir, "-masterkey", "199eae55-36bff4af-83b9a3a2-4fa16f65-"+
|
2015-12-08 16:13:29 +01:00
|
|
|
"1549ccdb-2d08d1f0-b1b26965-1b61f896", "-emenames=false")
|
2015-12-10 20:02:18 +01:00
|
|
|
checkExampleFS(t, pDir)
|
2015-11-28 20:31:01 +01:00
|
|
|
unmount(pDir)
|
|
|
|
err = os.Remove(pDir)
|
|
|
|
if err != nil {
|
|
|
|
t.Error(err)
|
|
|
|
}
|
|
|
|
}
|
2015-12-08 16:17:19 +01:00
|
|
|
|
|
|
|
// Test example_filesystems/v0.6
|
|
|
|
// with password mount and -masterkey mount
|
2015-12-10 20:02:18 +01:00
|
|
|
func TestExampleFSv06(t *testing.T) {
|
2015-12-08 16:17:19 +01:00
|
|
|
pDir := tmpDir + "TestExampleFsV06/"
|
|
|
|
cDir := "example_filesystems/v0.6"
|
|
|
|
err := os.Mkdir(pDir, 0777)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
mount(cDir, pDir, "-extpass", "echo test")
|
2015-12-10 20:02:18 +01:00
|
|
|
checkExampleFS(t, pDir)
|
2015-12-08 16:17:19 +01:00
|
|
|
unmount(pDir)
|
|
|
|
mount(cDir, pDir, "-masterkey", "7bc8deb0-5fc894ef-a093da43-61561a81-"+
|
|
|
|
"0e8dee83-fdc056a4-937c37dd-9df5c520")
|
2015-12-10 20:02:18 +01:00
|
|
|
checkExampleFS(t, pDir)
|
2015-12-08 16:17:19 +01:00
|
|
|
unmount(pDir)
|
|
|
|
err = os.Remove(pDir)
|
|
|
|
if err != nil {
|
|
|
|
t.Error(err)
|
|
|
|
}
|
|
|
|
}
|
2015-12-10 19:50:45 +01:00
|
|
|
|
|
|
|
// Test example_filesystems/v0.6
|
|
|
|
// with password mount and -masterkey mount
|
2015-12-10 20:02:18 +01:00
|
|
|
func TestExampleFSv06PlaintextNames(t *testing.T) {
|
2015-12-10 19:50:45 +01:00
|
|
|
pDir := tmpDir + "TestExampleFsV06PlaintextNames/"
|
|
|
|
cDir := "example_filesystems/v0.6-plaintextnames"
|
|
|
|
err := os.Mkdir(pDir, 0777)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
mount(cDir, pDir, "-extpass", "echo test")
|
2015-12-10 20:02:18 +01:00
|
|
|
checkExampleFS(t, pDir)
|
2015-12-10 19:50:45 +01:00
|
|
|
unmount(pDir)
|
|
|
|
mount(cDir, pDir, "-masterkey", "f4690202-595e4593-64c4f7e0-4dddd7d1-"+
|
|
|
|
"303147f9-0ca8aea2-966341a7-52ea8ae9", "-plaintextnames")
|
2015-12-10 20:02:18 +01:00
|
|
|
checkExampleFS(t, pDir)
|
2015-12-10 19:50:45 +01:00
|
|
|
unmount(pDir)
|
|
|
|
err = os.Remove(pDir)
|
|
|
|
if err != nil {
|
|
|
|
t.Error(err)
|
|
|
|
}
|
|
|
|
}
|