feat(tenant): 隔离邀请返利与推广追踪数据
This commit is contained in:
@@ -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")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user