32 lines
777 B
Go
32 lines
777 B
Go
package service
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"browser.local/platform/domain"
|
|
)
|
|
|
|
func TestSanitizeLogNetworkFieldsIsGameAgnostic(t *testing.T) {
|
|
batch := domain.LogBatchIngest{Entries: []domain.LogEntry{
|
|
{Fields: map[string]string{
|
|
"eventType": "game.session.opened",
|
|
"networkFingerprint": "fingerprint",
|
|
"ip": "192.0.2.1",
|
|
"ipAddress": "2001:db8::1",
|
|
"playerId": "player-1",
|
|
}},
|
|
}}
|
|
|
|
sanitizeLogNetworkFields(&batch)
|
|
|
|
fields := batch.Entries[0].Fields
|
|
for _, key := range []string{"networkFingerprint", "ip", "ipAddress"} {
|
|
if _, exists := fields[key]; exists {
|
|
t.Fatalf("expected %s to be removed", key)
|
|
}
|
|
}
|
|
if fields["playerId"] != "player-1" {
|
|
t.Fatal("expected unrelated fields to be preserved")
|
|
}
|
|
}
|