Files
robinhood-agentic-mcp/auth/login_test.go
T
s1d3sw1ped_bot 9e711957c0 docs: Remove sibling product and lab path leaks
Outsiders reading this module should not see private sibling
names (tradey), unfinished rewire notes, or /fast/projects
lab paths. Keep the library self-contained in README, design,
plan, and test fixtures/identity strings.
2026-09-01 19:43:35 +00:00

41 lines
1023 B
Go

package auth_test
import (
"path/filepath"
"testing"
"s1d3sw1ped/robinhood-agentic-mcp/auth"
)
func TestLoginFromEnv(t *testing.T) {
t.Setenv("ROBINHOOD_ACCESS_TOKEN", "tok-live")
t.Setenv("ROBINHOOD_REFRESH_TOKEN", "ref")
path := filepath.Join(t.TempDir(), "tokens.json")
id, err := auth.Login(t.Context(), auth.Config{TokenFile: path, Name: "example-app", Version: "9"})
if err != nil {
t.Fatal(err)
}
if id != "" {
t.Fatalf("id %q", id)
}
tok, err := auth.ReadTokens(path)
if err != nil {
t.Fatal(err)
}
if tok.AccessToken != "tok-live" || tok.RefreshToken != "ref" {
t.Fatalf("%+v", tok)
}
}
func TestWithDefaults(t *testing.T) {
t.Parallel()
c := auth.Config{}.WithDefaults()
if c.URL != auth.DefaultURL || c.Name != auth.DefaultName || c.Version != auth.DefaultVersion {
t.Fatalf("%+v", c)
}
c = auth.Config{Name: "example-app", Version: "1.2.3", URL: "http://x"}.WithDefaults()
if c.Name != "example-app" || c.Version != "1.2.3" || c.URL != "http://x" {
t.Fatalf("%+v", c)
}
}