Drop one-shot tmp/axe scripts and agent i18n scratch so the Gitea tree is deployable.
53 lines
1.5 KiB
Go
53 lines
1.5 KiB
Go
package support
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/descrybe/descrybe-v2/apps/api/internal/security"
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
func TestRedactSecretsForMatch_delegates(t *testing.T) {
|
|
t.Parallel()
|
|
in := "Bearer tokensecretvalue api_key=hunter2"
|
|
got := RedactSecretsForMatch(in)
|
|
want := security.RedactSecrets(in)
|
|
if got != want {
|
|
t.Fatalf("match redact diverged from security: %q vs %q", got, want)
|
|
}
|
|
if strings.Contains(got, "hunter2") || strings.Contains(got, "tokensecretvalue") {
|
|
t.Fatalf("secret remained: %q", got)
|
|
}
|
|
}
|
|
|
|
func TestBuildAutoReplyMessages_dropsForeignCompanySnippets(t *testing.T) {
|
|
t.Parallel()
|
|
mine := uuid.MustParse("11111111-1111-1111-1111-111111111111")
|
|
other := uuid.MustParse("22222222-2222-2222-2222-222222222222")
|
|
_, user := BuildAutoReplyMessages(AutoPromptInput{
|
|
Subject: "Billing",
|
|
Body: "Need invoice",
|
|
CompanyID: mine,
|
|
KBSnippets: []KBSnippet{
|
|
{Slug: "ok", Title: "OK", BodyMD: "Public help", Company: uuid.Nil},
|
|
{Slug: "leak", Title: "Leak", BodyMD: "OTHER_TENANT_SECRET", Company: other},
|
|
},
|
|
})
|
|
if strings.Contains(user, "OTHER_TENANT_SECRET") || strings.Contains(user, "kb:leak") {
|
|
t.Fatalf("cross-tenant KB leaked: %q", user)
|
|
}
|
|
if !strings.Contains(user, "Public help") {
|
|
t.Fatalf("platform KB missing: %q", user)
|
|
}
|
|
}
|
|
|
|
func TestSanitizeAutoBody_capsLength(t *testing.T) {
|
|
t.Parallel()
|
|
long := strings.Repeat("x", maxBodyLen+50)
|
|
got := sanitizeAutoBody(long)
|
|
if len([]rune(got)) != maxBodyLen {
|
|
t.Fatalf("len=%d", len([]rune(got)))
|
|
}
|
|
}
|