MCPcopy Create free account
hub / github.com/dropbox/dbxcli / TestReadTokensReadsTokenMap

Function TestReadTokensReadsTokenMap

cmd/auth_test.go:54–74  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

52}
53
54func TestReadTokensReadsTokenMap(t *testing.T) {
55 authFile := filepath.Join(t.TempDir(), "auth.json")
56 if err := os.WriteFile(authFile, []byte(`{"":{"personal":"personal-token"},"api.example.com":{"teamManage":"team-token"}}`), 0600); err != nil {
57 t.Fatal(err)
58 }
59
60 tokens, err := readTokens(authFile)
61 if err != nil {
62 t.Fatal(err)
63 }
64
65 if tokens[""][tokenPersonal].AccessToken != "personal-token" {
66 t.Fatalf("expected personal token, got %q", tokens[""][tokenPersonal].AccessToken)
67 }
68 if tokens["api.example.com"][tokenTeamManage].AccessToken != "team-token" {
69 t.Fatalf("expected team token, got %q", tokens["api.example.com"][tokenTeamManage].AccessToken)
70 }
71 if tokens[""][tokenPersonal].RefreshToken != "" {
72 t.Fatalf("expected legacy personal token to have no refresh token, got %q", tokens[""][tokenPersonal].RefreshToken)
73 }
74}
75
76func TestReadTokensReadsRefreshableCredentials(t *testing.T) {
77 authFile := filepath.Join(t.TempDir(), "auth.json")

Callers

nothing calls this directly

Calls 1

readTokensFunction · 0.85

Tested by

no test coverage detected