setupUserAuthWithFakeOAuth creates a UserAuth backed by a fake Google OAuth server so we can test HandleCallback without hitting real Google.
(t *testing.T)
| 238 | // setupUserAuthWithFakeOAuth creates a UserAuth backed by a fake Google OAuth |
| 239 | // server so we can test HandleCallback without hitting real Google. |
| 240 | func setupUserAuthWithFakeOAuth(t *testing.T) (*auth.UserAuth, *identity.Store, *httptest.Server) { |
| 241 | t.Helper() |
| 242 | pool := testutil.TestDB(t) |
| 243 | store := identity.NewStore(pool) |
| 244 | |
| 245 | srv, oauthCfg := fakeGoogleOAuth(t) |
| 246 | |
| 247 | cfg := &config.OAuthConfig{ |
| 248 | GoogleClientID: oauthCfg.ClientID, |
| 249 | GoogleClientSecret: oauthCfg.ClientSecret, |
| 250 | RedirectURL: oauthCfg.RedirectURL, |
| 251 | } |
| 252 | ua := auth.NewUserAuthWithOAuthConfig(cfg, oauthCfg, store, false, srv.URL+"/userinfo") |
| 253 | |
| 254 | return ua, store, srv |
| 255 | } |
| 256 | |
| 257 | func TestHandleCallback_CLILogin_HandsOffToCLI(t *testing.T) { |
| 258 | ua, _, srv := setupUserAuthWithFakeOAuth(t) |
no test coverage detected