MCPcopy Create free account
hub / github.com/buggregator/server / TestSMTPAPI_Raw

Function TestSMTPAPI_Raw

modules/smtp/api_test.go:293–327  ·  view source on GitHub ↗

TestSMTPAPI_Raw verifies the raw RFC822 endpoint.

(t *testing.T)

Source from the content-addressed store, hash-verified

291
292// TestSMTPAPI_Raw verifies the raw RFC822 endpoint.
293func TestSMTPAPI_Raw(t *testing.T) {
294 mux, store, _ := setupAPITest(t)
295
296 rawSrc := "From: sender@example.com\r\nTo: user@example.com\r\nSubject: Test\r\n\r\nBody"
297 storeSMTPEvent(t, store, "raw-uuid1", ParsedEmail{
298 Subject: "Test",
299 Raw: rawSrc,
300 }, 1000.0, "default")
301
302 t.Run("found", func(t *testing.T) {
303 r := httptest.NewRequest("GET", "/api/smtp/message/raw-uuid1/raw", nil)
304 w := httptest.NewRecorder()
305 mux.ServeHTTP(w, r)
306
307 if w.Code != 200 {
308 t.Fatalf("status = %d", w.Code)
309 }
310 if ct := w.Header().Get("Content-Type"); ct != "message/rfc822" {
311 t.Errorf("Content-Type = %q, want %q", ct, "message/rfc822")
312 }
313 if w.Body.String() != rawSrc {
314 t.Errorf("body = %q, want %q", w.Body.String(), rawSrc)
315 }
316 })
317
318 t.Run("not found", func(t *testing.T) {
319 r := httptest.NewRequest("GET", "/api/smtp/message/nonexistent/raw", nil)
320 w := httptest.NewRecorder()
321 mux.ServeHTTP(w, r)
322
323 if w.Code != http.StatusNotFound {
324 t.Errorf("status = %d, want 404", w.Code)
325 }
326 })
327}
328
329// TestSMTPAPI_Links verifies link extraction from HTML and plain text.
330func TestSMTPAPI_Links(t *testing.T) {

Callers

nothing calls this directly

Calls 6

setupAPITestFunction · 0.85
storeSMTPEventFunction · 0.85
ServeHTTPMethod · 0.80
RunMethod · 0.45
GetMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected