Home

go-spectre @4112f3e9e656dbf98a909d2d3adebef69ba63ed7 - refs - log -
-
https://git.jolheiser.com/go-spectre.git
Go implementation for spectre/masterpassword
go-spectre / cmd / spectre / main_test.go
- raw
 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
package main

import (
	_ "embed"
	"testing"

	"go.jolheiser.com/go-spectre/testdata"
)

// These are the exact same tests as spectre_test.go
// These are here just to make sure the CLI is giving the same outputs
func TestCLI(t *testing.T) {
	cases, err := testdata.Cases()
	if err != nil {
		t.Log(err)
		t.FailNow()
	}

	for _, tc := range cases {
		t.Run(tc.ID, func(t *testing.T) {
			args := []string{
				"--username", tc.UserName,
				"--secret", tc.UserSecret,
				"--secret-file", "",
				"--template", tc.ResultType,
				"--counter", tc.KeyCounter,
				"--scope", tc.KeyPurpose,
				"--print",
				tc.SiteName,
			}

			pw, err := maine(args)
			if err != nil {
				t.Log(err)
				t.FailNow()
			}

			if pw != tc.Result {
				t.Log("passwords did not match")
				t.Fail()
			}
		})
	}
}