(t *testing.T)
| 608 | } |
| 609 | |
| 610 | func 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 | |
| 650 | func TestWithRootNamespaceSkipsTeamManage(t *testing.T) { |
| 651 | cfg := makeDropboxConfig("team-token", false, "", "") |
nothing calls this directly
no test coverage detected