(t *testing.T)
| 481 | } |
| 482 | |
| 483 | func TestLoginSucceedsWhenKeyringUnavailable(t *testing.T) { |
| 484 | // The refreshable-record purge is best effort against capability loss: an unavailable keyring must not fail an |
| 485 | // otherwise valid insecure login. refreshableFromKeyring collapses an unavailable keyring to "not found", so the |
| 486 | // purge's post-condition check resolves no surviving record and login stays silent. Without that, surfacing the |
| 487 | // keyring delete error would break login wherever the keyring is absent. |
| 488 | authCfg := newTestAuthConfig(t) |
| 489 | keyring.MockInitWithError(errors.New("keyring is unavailable")) |
| 490 | |
| 491 | insecureStorageUsed, err := authCfg.Login("github.com", "test-user", "gho_token", "https", false) |
| 492 | require.NoError(t, err) |
| 493 | require.True(t, insecureStorageUsed) |
| 494 | |
| 495 | token, err := authCfg.cfg.Get([]string{hostsKey, "github.com", usersKey, "test-user", oauthTokenKey}) |
| 496 | require.NoError(t, err) |
| 497 | require.Equal(t, "gho_token", token) |
| 498 | } |
| 499 | |
| 500 | func TestSwitchUserActivatesRefreshableCredential(t *testing.T) { |
| 501 | authCfg := newTestAuthConfig(t) |
nothing calls this directly
no test coverage detected