v2api: fix TestOpenBackingDir
This commit is contained in:
parent
7de3330d70
commit
b0342fae5d
@ -7,6 +7,8 @@ import (
|
|||||||
|
|
||||||
"golang.org/x/sys/unix"
|
"golang.org/x/sys/unix"
|
||||||
|
|
||||||
|
"github.com/hanwen/go-fuse/v2/fuse"
|
||||||
|
|
||||||
"github.com/rfjakob/gocryptfs/internal/syscallcompat"
|
"github.com/rfjakob/gocryptfs/internal/syscallcompat"
|
||||||
"github.com/rfjakob/gocryptfs/tests/test_helpers"
|
"github.com/rfjakob/gocryptfs/tests/test_helpers"
|
||||||
)
|
)
|
||||||
@ -17,14 +19,15 @@ func TestOpenBackingDir(t *testing.T) {
|
|||||||
Cipherdir: cipherdir,
|
Cipherdir: cipherdir,
|
||||||
}
|
}
|
||||||
fs := newTestFS(args)
|
fs := newTestFS(args)
|
||||||
|
out := &fuse.EntryOut{}
|
||||||
|
|
||||||
code := fs.Mkdir("dir1", 0700, nil)
|
_, errno := fs.Mkdir(nil, "dir1", 0700, out)
|
||||||
if !code.Ok() {
|
if errno != 0 {
|
||||||
t.Fatal(code)
|
t.Fatal(errno)
|
||||||
}
|
}
|
||||||
code = fs.Mkdir("dir1/dir2", 0700, nil)
|
_, errno = fs.Mkdir(nil, "dir1/dir2", 0700, out)
|
||||||
if !code.Ok() {
|
if errno != 0 {
|
||||||
t.Fatal(code)
|
t.Fatal(errno)
|
||||||
}
|
}
|
||||||
|
|
||||||
dirfd, cName, err := fs.openBackingDir("")
|
dirfd, cName, err := fs.openBackingDir("")
|
||||||
@ -37,7 +40,7 @@ func TestOpenBackingDir(t *testing.T) {
|
|||||||
syscall.Close(dirfd)
|
syscall.Close(dirfd)
|
||||||
|
|
||||||
// Again, but populate the cache for "" by looking up a non-existing file
|
// Again, but populate the cache for "" by looking up a non-existing file
|
||||||
fs.GetAttr("xyz1234", nil)
|
fs.Getattr(nil, "xyz1234", &fuse.AttrOut{})
|
||||||
dirfd, cName, err = fs.openBackingDir("")
|
dirfd, cName, err = fs.openBackingDir("")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
@ -84,7 +87,7 @@ func TestOpenBackingDir(t *testing.T) {
|
|||||||
|
|
||||||
n255 := strings.Repeat("n", 255)
|
n255 := strings.Repeat("n", 255)
|
||||||
path := "dir1/" + n255
|
path := "dir1/" + n255
|
||||||
fs.Mkdir(path, 0700, nil)
|
fs.Mkdir(nil, path, 0700, out)
|
||||||
dirfd, cName, err = fs.openBackingDir(path)
|
dirfd, cName, err = fs.openBackingDir(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
@ -109,14 +112,15 @@ func TestOpenBackingDirPlaintextNames(t *testing.T) {
|
|||||||
PlaintextNames: true,
|
PlaintextNames: true,
|
||||||
}
|
}
|
||||||
fs := newTestFS(args)
|
fs := newTestFS(args)
|
||||||
|
out := &fuse.EntryOut{}
|
||||||
|
|
||||||
code := fs.Mkdir("dir1", 0700, nil)
|
_, errno := fs.Mkdir(nil, "dir1", 0700, out)
|
||||||
if !code.Ok() {
|
if errno != 0 {
|
||||||
t.Fatal(code)
|
t.Fatal(errno)
|
||||||
}
|
}
|
||||||
code = fs.Mkdir("dir1/dir2", 0700, nil)
|
_, errno = fs.Mkdir(nil, "dir1/dir2", 0700, out)
|
||||||
if !code.Ok() {
|
if errno != 0 {
|
||||||
t.Fatal(code)
|
t.Fatal(errno)
|
||||||
}
|
}
|
||||||
|
|
||||||
dirfd, cName, err := fs.openBackingDir("")
|
dirfd, cName, err := fs.openBackingDir("")
|
||||||
|
@ -5,28 +5,41 @@ package fusefrontend
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/hanwen/go-fuse/v2/fs"
|
||||||
|
|
||||||
"github.com/rfjakob/gocryptfs/internal/contentenc"
|
"github.com/rfjakob/gocryptfs/internal/contentenc"
|
||||||
"github.com/rfjakob/gocryptfs/internal/cryptocore"
|
"github.com/rfjakob/gocryptfs/internal/cryptocore"
|
||||||
"github.com/rfjakob/gocryptfs/internal/nametransform"
|
"github.com/rfjakob/gocryptfs/internal/nametransform"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newTestFS(args Args) *FS {
|
func newTestFS(args Args) *RootNode {
|
||||||
// Init crypto backend
|
// Init crypto backend
|
||||||
key := make([]byte, cryptocore.KeyLen)
|
key := make([]byte, cryptocore.KeyLen)
|
||||||
cCore := cryptocore.New(key, cryptocore.BackendGoGCM, contentenc.DefaultIVBits, true, false)
|
cCore := cryptocore.New(key, cryptocore.BackendGoGCM, contentenc.DefaultIVBits, true, false)
|
||||||
cEnc := contentenc.New(cCore, contentenc.DefaultBS, false)
|
cEnc := contentenc.New(cCore, contentenc.DefaultBS, false)
|
||||||
nameTransform := nametransform.New(cCore.EMECipher, true, true)
|
n := nametransform.New(cCore.EMECipher, true, true)
|
||||||
return NewFS(args, cEnc, nameTransform)
|
rn := NewRootNode(args, cEnc, n)
|
||||||
|
oneSec := time.Second
|
||||||
|
options := &fs.Options{
|
||||||
|
EntryTimeout: &oneSec,
|
||||||
|
AttrTimeout: &oneSec,
|
||||||
|
}
|
||||||
|
fs.NewNodeFS(rn, options)
|
||||||
|
return rn
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestEncryptDecryptXattrName(t *testing.T) {
|
func TestEncryptDecryptXattrName(t *testing.T) {
|
||||||
fs := newTestFS(Args{})
|
t.Fatal("not yet implemented")
|
||||||
attr1 := "user.foo123456789"
|
/*
|
||||||
cAttr := fs.encryptXattrName(attr1)
|
fs := newTestFS(Args{})
|
||||||
t.Logf("cAttr=%v", cAttr)
|
attr1 := "user.foo123456789"
|
||||||
attr2, err := fs.decryptXattrName(cAttr)
|
cAttr := fs.encryptXattrName(attr1)
|
||||||
if attr1 != attr2 || err != nil {
|
t.Logf("cAttr=%v", cAttr)
|
||||||
t.Fatalf("Decrypt mismatch: %v != %v", attr1, attr2)
|
attr2, err := fs.decryptXattrName(cAttr)
|
||||||
}
|
if attr1 != attr2 || err != nil {
|
||||||
|
t.Fatalf("Decrypt mismatch: %v != %v", attr1, attr2)
|
||||||
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user