Files
3x-ui-agent/internal/sub/format_endpoints_gone_test.go
T
Muse 1bd63e6625 settings trim: remove dead settings, upstream remnants, JSON/Clash subscriptions
Per SETTINGS-AUDIT (all three tiers approved 2026-10-23):

Dead settings:
- panelOutbound, ipLimitAllowlist (+ orphan parser job), outboundDownThreshold
- tg fake events outbound.down/outbound.up/xray.crash (no publisher in lite)
- phantom routing sub-tabs (Happ/Clash/Incy) and subJsonRules direct-rules tab
  (no backend keys); subHideSettings moved to the subscription info tab first

Upstream remnants:
- ldap* / smtp* model+schema keys, EmailNotifications orphan component
- twoFactorEnable/twoFactorToken + login-page probe (no backend handler)
- externalTrafficInform*

Newly approved removals:
- JSON subscription family (producer, routes, UA auto-detect, mux/finalmask/
  observatory) and Clash subscription family (producer, routes, UA detect)
- SubBalancer (table, service, controller, settings tab)
- subThemeDir (subscription page falls back to the built-in template)
- datepicker jalalian option (gregorian only; Persian picker removed)

JSON/Clash endpoints now 404; link-format output pinned by regression tests.
Guarded keys untouched: webListen/webPort/webBasePath/certs, tg* chain,
expireDiff/trafficDiff/tgBotProxy, subHideSettings, pageSize/tgLang.
2026-10-22 19:21:07 +00:00

45 lines
1.3 KiB
Go

package sub
import (
"encoding/base64"
"net/http"
"net/http/httptest"
"strings"
"testing"
"github.com/gin-gonic/gin"
)
// The JSON and Clash subscription formats were removed: their endpoints must
// answer 404, while the link-format endpoint keeps serving the exact raw
// base64 link list.
func TestRemovedFormatEndpointsReturn404(t *testing.T) {
seedSubDB(t)
seedSubInbound(t, "s1", "gone", 4499, 1, `{"network":"tcp","security":"none"}`)
gin.SetMode(gin.TestMode)
router := newSubscriptionTestRouter()
for _, path := range []string{"/json/s1", "/clash/s1"} {
req := httptest.NewRequest(http.MethodGet, "http://sub.example.com"+path, nil)
resp := httptest.NewRecorder()
router.ServeHTTP(resp, req)
if resp.Code != http.StatusNotFound {
t.Fatalf("GET %s status = %d, want 404", path, resp.Code)
}
}
req := httptest.NewRequest(http.MethodGet, "http://sub.example.com/sub/s1", nil)
resp := httptest.NewRecorder()
router.ServeHTTP(resp, req)
if resp.Code != http.StatusOK {
t.Fatalf("GET /sub/s1 status = %d, want 200; body=%s", resp.Code, resp.Body.String())
}
decoded, err := base64.StdEncoding.DecodeString(resp.Body.String())
if err != nil {
t.Fatalf("link response is not base64: %v", err)
}
if !strings.Contains(string(decoded), "vless://") {
t.Fatalf("link output changed, decoded body lacks a VLESS link: %s", decoded)
}
}