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) } }