libgocryptfs/gocryptfs-xray/xray_tests/xray_test.go
Jakob Unterwurzacher 28584d0d2c xray: recreate test filesytems with -scrypt 10
Speeds up the dumpmasterkey test *a lot*:

Before:
  ok  	github.com/rfjakob/gocryptfs/gocryptfs-xray/xray_tests	0.398s

After:
  ok  	github.com/rfjakob/gocryptfs/gocryptfs-xray/xray_tests	0.023s
2019-01-04 19:31:08 +01:00

61 lines
1.4 KiB
Go

package xray_tests
import (
"bytes"
"fmt"
"io/ioutil"
"os/exec"
"testing"
)
func TestAesgcmXray(t *testing.T) {
expected, err := ioutil.ReadFile("aesgcm_fs.xray.txt")
if err != nil {
t.Fatal(err)
}
cmd := exec.Command("../gocryptfs-xray", "aesgcm_fs/VnvoeSetPaOFjZDaZAh0lA")
out, err := cmd.CombinedOutput()
if err != nil {
t.Fatal(err)
}
if bytes.Compare(out, expected) != 0 {
t.Errorf("Unexpected output")
fmt.Printf("expected:\n%s", string(expected))
fmt.Printf("have:\n%s", string(out))
}
}
func TestAessivXray(t *testing.T) {
expected, err := ioutil.ReadFile("aessiv_fs.xray.txt")
if err != nil {
t.Fatal(err)
}
cmd := exec.Command("../gocryptfs-xray", "-aessiv", "aessiv_fs/klepPXQJIaEDaIx-yurAqQ")
out, err := cmd.CombinedOutput()
if err != nil {
t.Fatal(err)
}
if bytes.Compare(out, expected) != 0 {
t.Errorf("Unexpected output")
fmt.Printf("expected:\n%s", string(expected))
fmt.Printf("have:\n%s", string(out))
}
}
func TestDumpmasterkey(t *testing.T) {
expected := "b4d8b25c324dd6eaa328c9906e8a2a3c6038552a042ced4326cfff210c62957a\n"
cmd := exec.Command("../gocryptfs-xray", "-dumpmasterkey", "aesgcm_fs/gocryptfs.conf")
// Password = "test"
cmd.Stdin = bytes.NewBuffer([]byte("test"))
out1, err := cmd.CombinedOutput()
if err != nil {
t.Fatal(err)
}
out := string(out1)
if out != expected {
t.Errorf("Wrong output")
fmt.Printf("expected: %s\n", expected)
fmt.Printf("have: %s\n", out)
}
}