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

Function setupMagicLinkAPI

internal/agent/hitl_magic_api_test.go:28–49  ·  view source on GitHub ↗

setupMagicLinkAPI mirrors setupAPIWithSMTP but also wires an approvaltoken.Signer onto the API. Returns the server, store, signer (for issuing tokens in tests), and the fake-SMTP accessor.

(t *testing.T)

Source from the content-addressed store, hash-verified

26// approvaltoken.Signer onto the API. Returns the server, store, signer
27// (for issuing tokens in tests), and the fake-SMTP accessor.
28func setupMagicLinkAPI(t *testing.T) (
29 *httptest.Server,
30 *identity.Store,
31 *approvaltoken.Signer,
32 func() []testutil.SMTPMessage,
33) {
34 t.Helper()
35 smtpAddr, smtpDone := testutil.FakeSMTPServer(t)
36 pool := testutil.TestDB(t)
37 store := identity.NewStore(pool)
38 smtpRelay := outbound.NewSMTPRelay(&config.OutboundSMTPConfig{Host: smtpAddr.Host, Port: smtpAddr.Port})
39 sender := outbound.NewSender(smtpRelay, "test.e2a.dev")
40 noopUsage := usage.NewNoopUsageTracker()
41 api := agent.NewAPI(store, sender, smtpRelay, nil, noopUsage, "e2a.dev", "test.e2a.dev", "agents.e2a.dev", "", false)
42 signer := approvaltoken.NewSigner(magicLinkSecret)
43 api.SetApprovalSigner(signer)
44 router := mux.NewRouter()
45 api.RegisterRoutes(router)
46 server := httptest.NewServer(router)
47 t.Cleanup(server.Close)
48 return server, store, signer, smtpDone
49}
50
51// prepareHITLAgent creates a verified agent with HITL enabled. Returns
52// agent + userID.

Calls 11

SetApprovalSignerMethod · 0.95
RegisterRoutesMethod · 0.95
FakeSMTPServerFunction · 0.92
TestDBFunction · 0.92
NewStoreFunction · 0.92
NewSMTPRelayFunction · 0.92
NewSenderFunction · 0.92
NewNoopUsageTrackerFunction · 0.92
NewAPIFunction · 0.92
NewSignerFunction · 0.92
CleanupMethod · 0.80

Tested by

no test coverage detected