ultisuite-backend/internal/contacts/discovery/signature_test.go
R3D347HR4Y 556d5f416d Enhance API and configuration for contact discovery and public sharing
- Introduced new endpoints for contact discovery, including scanning, listing, and managing discovered contacts.
- Implemented retry logic for handling missing DAV credentials during contact operations.
- Added public share functionality for drive API, allowing users to manage public shares, including upload, delete, and rename operations.
- Updated Nextcloud configuration to support public share links and improved error handling for public share permissions.
- Enhanced logging and validation across contact and drive APIs for better error tracking and user feedback.
- Added tests for new contact matching and ranking functionalities to ensure accuracy and reliability.
2026-06-06 20:27:02 +02:00

61 lines
1.3 KiB
Go

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 <bob@client.com> 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)
}
}