aboutsummaryrefslogtreecommitdiff
path: root/tests/trezor/trezor_test.go
diff options
context:
space:
mode:
authorJakob Unterwurzacher2018-06-24 19:53:08 +0200
committerJakob Unterwurzacher2018-07-01 20:56:09 +0200
commit4bf02f476034f6a30a378769cda323e0ce5ae59f (patch)
treeb1c17031d076cfa90dc943d8bada9d90a068a7cd /tests/trezor/trezor_test.go
parentc6f6e8ec4d71475a24ebbb0e64f19ad94249efd9 (diff)
trezor: add basic "-init -trezor" test
Verify that the Trezor feature flag is set after "-init -trezor".
Diffstat (limited to 'tests/trezor/trezor_test.go')
-rw-r--r--tests/trezor/trezor_test.go44
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/trezor/trezor_test.go b/tests/trezor/trezor_test.go
new file mode 100644
index 0000000..ba468d9
--- /dev/null
+++ b/tests/trezor/trezor_test.go
@@ -0,0 +1,44 @@
+package trezor
+
+// Test operations with "-trezor".
+// See also the "cli" package - the tests there are very similar.
+
+import (
+ "os/exec"
+ "runtime"
+ "testing"
+
+ "github.com/rfjakob/gocryptfs/internal/configfile"
+
+ "github.com/rfjakob/gocryptfs/tests/test_helpers"
+)
+
+func isTrezorConnected() bool {
+ if runtime.GOOS != "linux" {
+ return false
+ }
+ c := exec.Command("lsusb", "-d", "534c:0001")
+ err := c.Run()
+ if err != nil {
+ return false
+ }
+ return true
+}
+
+// Test -init with -trezor
+func TestInitTrezor(t *testing.T) {
+ if !isTrezorConnected() {
+ t.Skip("No Trezor device connected")
+ }
+ t.Log("Trying gocryptfs -init -trezor ...")
+ // vvvvvvvvvvvvv disable -extpass
+ dir := test_helpers.InitFS(t, "-trezor", "-extpass", "")
+ // The freshly created config file should have the Trezor feature flag set.
+ _, c, err := configfile.LoadConfFile(dir+"/"+configfile.ConfDefaultName, nil)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if !c.IsFeatureFlagSet(configfile.FlagTrezor) {
+ t.Error("Trezor flag should be set but is not")
+ }
+}