feat(tenant): 隔离邀请返利与推广追踪数据

This commit is contained in:
yml
2026-11-15 20:18:47 +08:00
parent db7dbc7596
commit 1eb2fa749b
10 changed files with 344 additions and 30 deletions
@@ -1,7 +1,10 @@
package adtracking
import (
"context"
"testing"
"hfb_sys/backend/internal/tenancy"
)
func TestAppendTrackCode(t *testing.T) {
@@ -129,3 +132,21 @@ func TestValidateTargetURL(t *testing.T) {
}
}
}
func TestValidateTargetURLAllowsCurrentTenantDomain(t *testing.T) {
ctx := tenancy.WithScope(context.Background(), tenancy.Scope{
TenantID: 2,
TenantCode: "jieyou",
Host: "zuhaox.com",
})
got, err := validateTargetURLForTenant(ctx, "https://h5.zuhaox.com/listings", false)
if err != nil {
t.Fatalf("tenant domain should be allowed: %v", err)
}
if got != "https://h5.zuhaox.com/listings" {
t.Fatalf("target URL = %q", got)
}
if _, err := validateTargetURLForTenant(ctx, "https://evil.example.com", false); err == nil {
t.Fatal("external tenant URL should be rejected")
}
}