CI / go-test (push) Canceled after 0s
CI / postgres-durable-first (push) Canceled after 0s
CI / codegen (push) Canceled after 0s
CI / govulncheck (push) Canceled after 0s
CI / race (push) Canceled after 0s
CI / fuzz-smoke (push) Canceled after 0s
CI / golangci (push) Canceled after 0s
CI / frontend (push) Canceled after 0s
CodeQL Advanced / Analyze (go) (push) Canceled after 0s
CodeQL Advanced / Analyze (actions) (push) Canceled after 0s
CodeQL Advanced / Analyze (javascript-typescript) (push) Canceled after 0s
Docs CI / build (push) Canceled after 0s
Docs Deploy (GitHub Pages) / build (push) Canceled after 0s
Release 3X-UI / build (386) (push) Canceled after 0s
Release 3X-UI / build (amd64) (push) Canceled after 0s
Release 3X-UI / build (arm64) (push) Canceled after 0s
Release 3X-UI / build (armv5) (push) Canceled after 0s
Release 3X-UI / build (armv6) (push) Canceled after 0s
Release 3X-UI / build (armv7) (push) Canceled after 0s
Release 3X-UI / build (s390x) (push) Canceled after 0s
Release 3X-UI / Build for Windows (amd64) (push) Canceled after 0s
Deploy Smoke Tests / noninteractive-install (ubuntu-24.04-arm) (push) Canceled after 0s
Deploy Smoke Tests / noninteractive-install (ubuntu-latest) (push) Canceled after 0s
Deploy Smoke Tests / release-tag-install (ubuntu-24.04-arm) (push) Canceled after 0s
Deploy Smoke Tests / release-tag-install (ubuntu-latest) (push) Canceled after 0s
Docs Deploy (GitHub Pages) / deploy (push) Canceled after 0s
Release 3X-UI / Publish rolling dev release (push) Canceled after 0s
44 lines
1.6 KiB
Go
44 lines
1.6 KiB
Go
package sub
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/mhsanaei/3x-ui/v3/internal/database"
|
|
"github.com/mhsanaei/3x-ui/v3/internal/database/model"
|
|
)
|
|
|
|
// inboundLinks (the "Export all inbound links" path) must render the remark
|
|
// template's whole Client token group per client, name-only — the same engine
|
|
// the client/QR pages use.
|
|
func TestInboundLinks_RemarkTemplateClientTokens(t *testing.T) {
|
|
seedSubDB(t)
|
|
db := database.GetDB()
|
|
settings := `{"clients":[{"id":"11111111-2222-4333-8444-000000000001","email":"john@e","subId":"subABC","comment":"vip","tgId":777,"enable":true}],"decryption":"none"}`
|
|
ib := &model.Inbound{
|
|
UserId: 1, Tag: "t", Enable: true, Listen: "203.0.113.5", Port: 4431,
|
|
Protocol: model.VLESS, Remark: "Germany", Settings: settings,
|
|
StreamSettings: `{"network":"ws","security":"tls","wsSettings":{"path":"/","host":""},"tlsSettings":{"serverName":"sni"}}`,
|
|
}
|
|
if err := db.Create(ib).Error; err != nil {
|
|
t.Fatalf("seed inbound: %v", err)
|
|
}
|
|
|
|
svc := NewSubService("{{INBOUND}}-{{EMAIL}}-{{COMMENT}}-{{SUB_ID}}-{{TELEGRAM_ID}}-{{SHORT_ID}}|📊{{TRAFFIC_LEFT}}|⏳{{DAYS_LEFT}}D")
|
|
svc.PrepareForRequest("req.example.com")
|
|
links := svc.inboundLinks(ib)
|
|
|
|
if len(links) != 1 {
|
|
t.Fatalf("links = %d, want 1: %v", len(links), links)
|
|
}
|
|
frag := links[0]
|
|
for _, want := range []string{"Germany-john", "vip", "subABC", "777", "11111111"} {
|
|
if !strings.Contains(frag, want) {
|
|
t.Fatalf("remark missing client token %q: %s", want, frag)
|
|
}
|
|
}
|
|
if strings.Contains(frag, "GB") || strings.ContainsRune(frag, '⏳') {
|
|
t.Fatalf("display mode must drop the traffic/expiry segments: %s", frag)
|
|
}
|
|
}
|