(t *testing.T)
| 493 | } |
| 494 | |
| 495 | func TestInitDbxAccessTokenEnvTakesPrecedenceOverAuthFile(t *testing.T) { |
| 496 | origConfig := config |
| 497 | defer func() { config = origConfig }() |
| 498 | stubUsersClient(t, &mockUsersClient{ |
| 499 | getCurrentAccountFn: func() (*users.FullAccount, error) { |
| 500 | return testRootFullAccount(common.NewUserRootInfo("env-root", "env-home")), nil |
| 501 | }, |
| 502 | }) |
| 503 | |
| 504 | authFile := filepath.Join(t.TempDir(), "auth.json") |
| 505 | if err := os.WriteFile(authFile, []byte(`{"":{"personal":"file-token"}}`), 0600); err != nil { |
| 506 | t.Fatal(err) |
| 507 | } |
| 508 | |
| 509 | t.Setenv(envAccessToken, "env-token") |
| 510 | t.Setenv(envAuthFile, authFile) |
| 511 | |
| 512 | cmd := newAuthTestCommand() |
| 513 | if err := initDbx(cmd, nil); err != nil { |
| 514 | t.Fatal(err) |
| 515 | } |
| 516 | |
| 517 | if config.Token != "env-token" { |
| 518 | t.Fatalf("expected %s to take precedence, got %q", envAccessToken, config.Token) |
| 519 | } |
| 520 | if config.PathRoot != `{".tag": "root", "root": "env-root"}` { |
| 521 | t.Fatalf("expected path root from env token account, got %q", config.PathRoot) |
| 522 | } |
| 523 | assertCurrentAuthContext(t, authSourceEnv, false, authFileNone) |
| 524 | } |
| 525 | |
| 526 | func TestInitDbxAccessTokenEnvBypassesRefresh(t *testing.T) { |
| 527 | origConfig := config |
nothing calls this directly
no test coverage detected