refactor: drop tautological tls tests, password.ErrMsg, and go-cmp
This commit is contained in:
parent
d6415666de
commit
129ded84c0
6 changed files with 7 additions and 54 deletions
1
go.mod
1
go.mod
|
|
@ -19,7 +19,6 @@ require (
|
|||
github.com/bogdanfinn/fhttp v0.6.9
|
||||
github.com/bogdanfinn/tls-client v1.16.0
|
||||
github.com/gdamore/tcell/v3 v3.5.0
|
||||
github.com/google/go-cmp v0.7.0
|
||||
github.com/gorilla/websocket v1.5.3
|
||||
github.com/klauspost/compress v1.20.1
|
||||
github.com/mattn/go-shellwords v1.0.15
|
||||
|
|
|
|||
2
go.sum
2
go.sum
|
|
@ -52,8 +52,6 @@ github.com/gdamore/tcell/v3 v3.5.0 h1:SCp9czLv2K2aPORgD6+4fjV0xNAzKIkiezCkp6bHLe
|
|||
github.com/gdamore/tcell/v3 v3.5.0/go.mod h1:Oe5U3S3jm3NzypswDNUhe+LUnF5CoFq2b4sepD++QHo=
|
||||
github.com/godbus/dbus/v5 v5.2.2 h1:TUR3TgtSVDmjiXOgAAyaZbYmIeP3DPkld3jgKGV8mXQ=
|
||||
github.com/godbus/dbus/v5 v5.2.2/go.mod h1:3AAv2+hPq5rdnr5txxxRwiGjPXamgoIHgz9FPBfOp3c=
|
||||
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
|
||||
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
|
||||
github.com/gorilla/schema v1.4.1 h1:jUg5hUjCSDZpNGLuXQOgIWGdlgrIdYvgQ0wZtdK1M3E=
|
||||
github.com/gorilla/schema v1.4.1/go.mod h1:Dg5SSm5PV60mhF2NFaTV1xuYYj8tV8NOPRo4FggUMnM=
|
||||
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
|
||||
|
|
|
|||
|
|
@ -8,10 +8,6 @@ import (
|
|||
|
||||
"github.com/BurntSushi/toml"
|
||||
"github.com/ayn2op/discordo/internal/consts"
|
||||
tviewkeybind "github.com/ayn2op/tview/keybind"
|
||||
"github.com/gdamore/tcell/v3"
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"github.com/google/go-cmp/cmp/cmpopts"
|
||||
)
|
||||
|
||||
func TestDefaultPath(t *testing.T) {
|
||||
|
|
@ -129,19 +125,14 @@ func TestLoad(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
|
||||
var defCfg Config
|
||||
defCfg := Config{Keybinds: defaultKeybinds()}
|
||||
if err := toml.Unmarshal(defaultCfg, &defCfg); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defCfg.applyDefaults()
|
||||
|
||||
if diff := cmp.Diff(
|
||||
defCfg,
|
||||
*cfg,
|
||||
cmpopts.EquateComparable(tcell.Style{}),
|
||||
cmpopts.IgnoreUnexported(tviewkeybind.Keybind{}),
|
||||
); diff != "" {
|
||||
t.Fatalf("got = -, want = +, diff=%s", diff)
|
||||
if !reflect.DeepEqual(defCfg, *cfg) {
|
||||
t.Fatalf("got = %+v, want = %+v", *cfg, defCfg)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,15 +0,0 @@
|
|||
//go:build !no_spoof_tls_fingerprint
|
||||
|
||||
package tls
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestNewClient(t *testing.T) {
|
||||
client := NewClient()
|
||||
if client == nil {
|
||||
t.Fatal("client is nil")
|
||||
}
|
||||
if client.GetTLSDialer() == nil {
|
||||
t.Fatal("TLS dialer is nil")
|
||||
}
|
||||
}
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
package tls
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestBrowserName(t *testing.T) {
|
||||
want := clientProfile.GetClientHelloId().Client
|
||||
if got := BrowserName(); got != want {
|
||||
t.Fatalf("BrowserName() = %q, want %q", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBrowserVersion(t *testing.T) {
|
||||
want := clientProfile.GetClientHelloId().Version + ".0.0.0"
|
||||
if got := BrowserVersion(); got != want {
|
||||
t.Fatalf("BrowserVersion() = %q, want %q", got, want)
|
||||
}
|
||||
}
|
||||
|
|
@ -8,10 +8,7 @@ import (
|
|||
"github.com/ayn2op/tview"
|
||||
)
|
||||
|
||||
type (
|
||||
TokenMsg string
|
||||
ErrMsg error
|
||||
)
|
||||
type TokenMsg string
|
||||
|
||||
func submitLogin(login, password string) tview.Cmd {
|
||||
return func() tview.Msg {
|
||||
|
|
@ -23,13 +20,13 @@ func submitLogin(login, password string) tview.Cmd {
|
|||
|
||||
loginResp, err := client.Login(login, password)
|
||||
if err != nil {
|
||||
return ErrMsg(err)
|
||||
return err
|
||||
}
|
||||
if loginResp.Token == "" {
|
||||
if loginResp.MFA {
|
||||
return ErrMsg(errors.New("multi-factor authentication is required; use token or QR login"))
|
||||
return errors.New("multi-factor authentication is required; use token or QR login")
|
||||
}
|
||||
return ErrMsg(errors.New("login response did not include a token"))
|
||||
return errors.New("login response did not include a token")
|
||||
}
|
||||
return TokenMsg(loginResp.Token)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue