MCPcopy Create free account
hub / github.com/Mnexa-AI/e2a / setupUserAuthWithFakeOAuth

Function setupUserAuthWithFakeOAuth

internal/auth/cli_login_test.go:240–255  ·  view source on GitHub ↗

setupUserAuthWithFakeOAuth creates a UserAuth backed by a fake Google OAuth server so we can test HandleCallback without hitting real Google.

(t *testing.T)

Source from the content-addressed store, hash-verified

238// setupUserAuthWithFakeOAuth creates a UserAuth backed by a fake Google OAuth
239// server so we can test HandleCallback without hitting real Google.
240func 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
257func TestHandleCallback_CLILogin_HandsOffToCLI(t *testing.T) {
258 ua, _, srv := setupUserAuthWithFakeOAuth(t)

Calls 4

TestDBFunction · 0.92
NewStoreFunction · 0.92
fakeGoogleOAuthFunction · 0.85

Tested by

no test coverage detected