27 lines
673 B
Go
27 lines
673 B
Go
package chat
|
|
|
|
import (
|
|
"encoding/json"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestBuildLangfuseMessagesRedactsMultiContentImage(t *testing.T) {
|
|
secret := "TOPSECRETBASE64"
|
|
msgs := buildLangfuseMessages([]Message{{
|
|
Role: "user",
|
|
MultiContent: []MessageContentPart{
|
|
{Type: "image_url", ImageURL: &ImageURL{URL: "data:image/png;base64," + secret}},
|
|
{Type: "text", Text: "describe"},
|
|
},
|
|
}})
|
|
encoded, err := json.Marshal(msgs)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
serialized := string(encoded)
|
|
if strings.Contains(serialized, secret) || strings.Contains(strings.ToLower(serialized), "data:image") {
|
|
t.Fatalf("Langfuse input leaked image payload: %s", serialized)
|
|
}
|
|
}
|