TestSMTPAPI_Raw verifies the raw RFC822 endpoint.
(t *testing.T)
| 291 | |
| 292 | // TestSMTPAPI_Raw verifies the raw RFC822 endpoint. |
| 293 | func 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. |
| 330 | func TestSMTPAPI_Links(t *testing.T) { |
nothing calls this directly
no test coverage detected