package discovery import ( "strings" "testing" ) func TestExtractSignature_StripsQuotedReply(t *testing.T) { body := `Merci pour votre retour. Cordialement, Alice Martin Directrice — Acme SAS alice@acme.com +33 1 23 45 67 89 Le lun. 3 juin 2024 à 10:15, Bob Dupont a écrit : > Bonjour Alice, > Pouvez-vous me rappeler ? > > Cordialement, > Bob Dupont > bob@client.com > +33 6 11 22 33 44` text, conf := extractSignature(body, "", "alice@acme.com", "Alice Martin") if text == "" || conf < 0.35 { t.Fatalf("expected Alice signature, got %q conf=%v", text, conf) } if strings.Contains(text, "bob@client.com") || strings.Contains(text, "Bob Dupont") { t.Fatalf("quoted reply signature leaked: %q", text) } } func TestExtractSignature_RejectsOtherEmailInBlock(t *testing.T) { body := `Bonjour, Cordialement, Bob Dupont bob@client.com` _, conf := extractSignature(body, "", "alice@acme.com", "Alice Martin") if conf >= 0.35 { t.Fatalf("expected rejection when signature email != sender, got conf=%v", conf) } } func TestExtractSignature_AcceptsDelimiterBlock(t *testing.T) { body := `Hello, see attached. -- Jane Doe Engineer jane@corp.io` text, conf := extractSignature(body, "", "jane@corp.io", "Jane Doe") if text == "" || conf < 0.5 { t.Fatalf("expected signature after --, got %q conf=%v", text, conf) } }