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)
| 26 | // approvaltoken.Signer onto the API. Returns the server, store, signer |
| 27 | // (for issuing tokens in tests), and the fake-SMTP accessor. |
| 28 | func 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. |
no test coverage detected