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

Function TestInitDbxRecordsSavedRefreshableAuthContext

cmd/root_test.go:610–648  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

608}
609
610func TestInitDbxRecordsSavedRefreshableAuthContext(t *testing.T) {
611 origConfig := config
612 defer func() { config = origConfig }()
613 stubUsersClient(t, &mockUsersClient{
614 getCurrentAccountFn: func() (*users.FullAccount, error) {
615 return testRootFullAccount(common.NewUserRootInfo("root-ns", "home-ns")), nil
616 },
617 })
618
619 home := t.TempDir()
620 t.Setenv("HOME", home)
621 t.Setenv(envAccessToken, "")
622 t.Setenv(envAuthFile, "")
623
624 expiry := time.Now().Add(time.Hour)
625 authFile := filepath.Join(home, ".config", "dbxcli", "auth.json")
626 if err := writeTokens(authFile, TokenMap{
627 "": {
628 tokenPersonal: {
629 AccessToken: "file-token",
630 RefreshToken: "refresh-token",
631 Expiry: &expiry,
632 AppKey: "app-key",
633 },
634 },
635 }); err != nil {
636 t.Fatal(err)
637 }
638
639 cmd := newAuthTestCommand()
640 if err := initDbx(cmd, nil); err != nil {
641 t.Fatal(err)
642 }
643
644 if config.Token != "file-token" {
645 t.Fatalf("expected saved token, got %q", config.Token)
646 }
647 assertCurrentAuthContext(t, authSourceSaved, true, authFileDefault)
648}
649
650func TestWithRootNamespaceSkipsTeamManage(t *testing.T) {
651 cfg := makeDropboxConfig("team-token", false, "", "")

Callers

nothing calls this directly

Calls 6

stubUsersClientFunction · 0.85
testRootFullAccountFunction · 0.85
writeTokensFunction · 0.85
newAuthTestCommandFunction · 0.85
initDbxFunction · 0.85
assertCurrentAuthContextFunction · 0.85

Tested by

no test coverage detected