Home

go-spectre @4ecbdcf5a4a6e38621fdab234c61a9947d5a51c0 - 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
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,
				"--template", tc.ResultType,
				"--counter", tc.KeyCounter,
				"--scope", tc.KeyPurpose,
				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()
			}
		})
	}
}