summaryrefslogtreecommitdiff
path: root/gocryptfs-xray/xray_tests/xray_test.go
blob: 57fec71a848cc2983834e5003c9efb5c61b46403 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
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/fRtDWUFQK9vDAtAJrTbbWg")
	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/Ldq-c4ADpM5iGSSrPjUAqQ")
	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 := "f342380e238f708ff4eb94d1fcf79cca7e1e9d9ab91222865e4eaae8a292ee43\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)
	}
}