(t *testing.T)
| 642 | } |
| 643 | |
| 644 | func TestLoginSucceedsWhenKeyringUnavailable(t *testing.T) { |
| 645 | // The refreshable-record purge is best effort against capability loss: an unavailable keyring must not fail an |
| 646 | // otherwise valid insecure login. refreshableFromKeyring collapses an unavailable keyring to "not found", so the |
| 647 | // purge's post-condition check resolves no surviving record and login stays silent. Without that, surfacing the |
| 648 | // keyring delete error would break login wherever the keyring is absent. |
| 649 | authCfg := newTestAuthConfig(t) |
| 650 | keyring.MockInitWithError(errors.New("keyring is unavailable")) |
| 651 | |
| 652 | insecureStorageUsed, err := authCfg.Login("github.com", "test-user", "gho_token", "https", false) |
| 653 | require.NoError(t, err) |
| 654 | require.True(t, insecureStorageUsed) |
| 655 | |
| 656 | token, err := authCfg.cfg.Get([]string{hostsKey, "github.com", usersKey, "test-user", oauthTokenKey}) |
| 657 | require.NoError(t, err) |
| 658 | require.Equal(t, "gho_token", token) |
| 659 | } |
| 660 | |
| 661 | func TestSwitchUserActivatesRefreshableCredential(t *testing.T) { |
| 662 | authCfg := newTestAuthConfig(t) |
nothing calls this directly
no test coverage detected