2021-11-24 04:08:40 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
_ "embed"
|
2021-11-24 04:46:37 +00:00
|
|
|
"go.jolheiser.com/go-spectre/testdata"
|
2021-11-24 04:08:40 +00:00
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
// 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) {
|
2021-11-24 04:46:37 +00:00
|
|
|
cases, err := testdata.Cases()
|
|
|
|
if err != nil {
|
|
|
|
t.Log(err)
|
2021-11-24 04:08:40 +00:00
|
|
|
t.FailNow()
|
|
|
|
}
|
|
|
|
|
2021-11-24 04:46:37 +00:00
|
|
|
for _, tc := range cases {
|
2021-11-24 04:08:40 +00:00
|
|
|
t.Run(tc.ID, func(t *testing.T) {
|
|
|
|
args := []string{
|
2021-11-24 04:46:37 +00:00
|
|
|
"--username", tc.UserName,
|
|
|
|
"--secret", tc.UserSecret,
|
|
|
|
"--template", tc.ResultType,
|
|
|
|
"--counter", tc.KeyCounter,
|
|
|
|
"--scope", tc.KeyPurpose,
|
|
|
|
tc.SiteName,
|
2021-11-24 04:08:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pw, err := doMain(args)
|
|
|
|
if err != nil {
|
|
|
|
t.Log(err)
|
|
|
|
t.FailNow()
|
|
|
|
}
|
|
|
|
|
|
|
|
if pw != tc.Result {
|
|
|
|
t.Log("passwords did not match")
|
|
|
|
t.Fail()
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|