tests: do not create gocryptfs.diriv if plaintextnames==true
This commit is contained in:
parent
6b5d977cce
commit
2a11906963
@ -1,13 +1,13 @@
|
|||||||
package integration_tests
|
package integration_tests
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"path/filepath"
|
|
||||||
"crypto/md5"
|
"crypto/md5"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"path/filepath"
|
||||||
"syscall"
|
"syscall"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@ -22,7 +22,7 @@ const defaultCipherDir = tmpDir + "cipher/"
|
|||||||
const gocryptfsBinary = "../gocryptfs"
|
const gocryptfsBinary = "../gocryptfs"
|
||||||
|
|
||||||
// resetTmpDir - delete old tmp dir, create new one, write gocryptfs.diriv
|
// resetTmpDir - delete old tmp dir, create new one, write gocryptfs.diriv
|
||||||
func resetTmpDir() {
|
func resetTmpDir(plaintextNames bool) {
|
||||||
fu := exec.Command("fusermount", "-z", "-u", defaultPlainDir)
|
fu := exec.Command("fusermount", "-z", "-u", defaultPlainDir)
|
||||||
fu.Run()
|
fu.Run()
|
||||||
|
|
||||||
@ -43,10 +43,12 @@ func resetTmpDir() {
|
|||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
err = nametransform.WriteDirIV(defaultCipherDir)
|
if !plaintextNames {
|
||||||
if err != nil {
|
err = nametransform.WriteDirIV(defaultCipherDir)
|
||||||
fmt.Println(err)
|
if err != nil {
|
||||||
os.Exit(1)
|
fmt.Println(err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,8 +56,9 @@ func resetTmpDir() {
|
|||||||
func mount(c string, p string, extraArgs ...string) {
|
func mount(c string, p string, extraArgs ...string) {
|
||||||
var args []string
|
var args []string
|
||||||
args = append(args, extraArgs...)
|
args = append(args, extraArgs...)
|
||||||
args = append(args, "-q", "-wpanic")
|
args = append(args, "-nosyslog", "-q", "-wpanic")
|
||||||
//args = append(args, "--fusedebug")
|
//args = append(args, "-fusedebug")
|
||||||
|
//args = append(args, "-d")
|
||||||
args = append(args, c)
|
args = append(args, c)
|
||||||
args = append(args, p)
|
args = append(args, p)
|
||||||
cmd := exec.Command(gocryptfsBinary, args...)
|
cmd := exec.Command(gocryptfsBinary, args...)
|
||||||
@ -205,7 +208,7 @@ func verifyExistence(path string) bool {
|
|||||||
//t.Log(err)
|
//t.Log(err)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
for _, i := range(fi) {
|
for _, i := range fi {
|
||||||
if i.Name() == name {
|
if i.Name() == name {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ package integration_tests
|
|||||||
// File reading, writing, modification, truncate
|
// File reading, writing, modification, truncate
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"syscall"
|
|
||||||
"bytes"
|
"bytes"
|
||||||
"crypto/md5"
|
"crypto/md5"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
@ -13,6 +12,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"runtime"
|
"runtime"
|
||||||
"sync"
|
"sync"
|
||||||
|
"syscall"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -27,7 +27,7 @@ func TestMain(m *testing.M) {
|
|||||||
if testing.Verbose() {
|
if testing.Verbose() {
|
||||||
fmt.Println("***** Testing with OpenSSL")
|
fmt.Println("***** Testing with OpenSSL")
|
||||||
}
|
}
|
||||||
resetTmpDir() // <- this also create gocryptfs.diriv
|
resetTmpDir(false) // <- this also create gocryptfs.diriv
|
||||||
mount(defaultCipherDir, defaultPlainDir, "--zerokey")
|
mount(defaultCipherDir, defaultPlainDir, "--zerokey")
|
||||||
r := m.Run()
|
r := m.Run()
|
||||||
unmount(defaultPlainDir)
|
unmount(defaultPlainDir)
|
||||||
@ -43,7 +43,7 @@ func TestMain(m *testing.M) {
|
|||||||
if testing.Verbose() {
|
if testing.Verbose() {
|
||||||
fmt.Println("***** Testing with native Go crypto")
|
fmt.Println("***** Testing with native Go crypto")
|
||||||
}
|
}
|
||||||
resetTmpDir()
|
resetTmpDir(false)
|
||||||
mount(defaultCipherDir, defaultPlainDir, "--zerokey", "--openssl=false")
|
mount(defaultCipherDir, defaultPlainDir, "--zerokey", "--openssl=false")
|
||||||
r = m.Run()
|
r = m.Run()
|
||||||
unmount(defaultPlainDir)
|
unmount(defaultPlainDir)
|
||||||
@ -55,7 +55,7 @@ func TestMain(m *testing.M) {
|
|||||||
if testing.Verbose() {
|
if testing.Verbose() {
|
||||||
fmt.Println("***** Testing \"--plaintextnames\"")
|
fmt.Println("***** Testing \"--plaintextnames\"")
|
||||||
}
|
}
|
||||||
resetTmpDir()
|
resetTmpDir(true) // do not create gocryptfs.diriv
|
||||||
mount(defaultCipherDir, defaultPlainDir, "--zerokey", "--plaintextnames")
|
mount(defaultCipherDir, defaultPlainDir, "--zerokey", "--plaintextnames")
|
||||||
plaintextNames = true
|
plaintextNames = true
|
||||||
r = m.Run()
|
r = m.Run()
|
||||||
@ -356,12 +356,12 @@ func TestLongNames(t *testing.T) {
|
|||||||
// Create
|
// Create
|
||||||
wd := defaultPlainDir
|
wd := defaultPlainDir
|
||||||
n255x := string(bytes.Repeat([]byte("x"), 255))
|
n255x := string(bytes.Repeat([]byte("x"), 255))
|
||||||
f, err := os.Create(wd+n255x)
|
f, err := os.Create(wd + n255x)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Could not create n255x")
|
t.Fatalf("Could not create n255x")
|
||||||
}
|
}
|
||||||
f.Close()
|
f.Close()
|
||||||
if !verifyExistence(wd+n255x) {
|
if !verifyExistence(wd + n255x) {
|
||||||
t.Errorf("n255x is not in directory listing")
|
t.Errorf("n255x is not in directory listing")
|
||||||
}
|
}
|
||||||
// Rename long to long
|
// Rename long to long
|
||||||
@ -370,7 +370,7 @@ func TestLongNames(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Could not rename n255x to n255y")
|
t.Fatalf("Could not rename n255x to n255y")
|
||||||
}
|
}
|
||||||
if !verifyExistence(wd+n255y) {
|
if !verifyExistence(wd + n255y) {
|
||||||
t.Errorf("n255y is not in directory listing")
|
t.Errorf("n255y is not in directory listing")
|
||||||
}
|
}
|
||||||
// Rename long to short
|
// Rename long to short
|
||||||
@ -378,7 +378,7 @@ func TestLongNames(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Could not rename n255y to short")
|
t.Fatalf("Could not rename n255y to short")
|
||||||
}
|
}
|
||||||
if !verifyExistence(wd+"short") {
|
if !verifyExistence(wd + "short") {
|
||||||
t.Errorf("short is not in directory listing")
|
t.Errorf("short is not in directory listing")
|
||||||
}
|
}
|
||||||
// Rename short to long
|
// Rename short to long
|
||||||
@ -386,15 +386,15 @@ func TestLongNames(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Could not rename short to n255x")
|
t.Fatalf("Could not rename short to n255x")
|
||||||
}
|
}
|
||||||
if !verifyExistence(wd+n255x) {
|
if !verifyExistence(wd + n255x) {
|
||||||
t.Errorf("255x is not in directory listing II")
|
t.Errorf("255x is not in directory listing II")
|
||||||
}
|
}
|
||||||
// Unlink
|
// Unlink
|
||||||
err = syscall.Unlink(wd+n255x)
|
err = syscall.Unlink(wd + n255x)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Could not unlink n255x")
|
t.Fatalf("Could not unlink n255x")
|
||||||
}
|
}
|
||||||
if verifyExistence(wd+n255x) {
|
if verifyExistence(wd + n255x) {
|
||||||
t.Errorf("n255x still there after unlink")
|
t.Errorf("n255x still there after unlink")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user