remove dead dashboard admin routes
This commit is contained in:
@@ -61,7 +61,6 @@ func (r *dashboardUsageRepoCacheProbe) GetUserUsageTrend(
|
||||
func resetDashboardReadCachesForTest() {
|
||||
dashboardTrendCache = newSnapshotCache(30 * time.Second)
|
||||
dashboardUsersTrendCache = newSnapshotCache(30 * time.Second)
|
||||
dashboardAPIKeysTrendCache = newSnapshotCache(30 * time.Second)
|
||||
dashboardModelStatsCache = newSnapshotCache(30 * time.Second)
|
||||
dashboardGroupStatsCache = newSnapshotCache(30 * time.Second)
|
||||
dashboardSnapshotV2Cache = newSnapshotCache(30 * time.Second)
|
||||
@@ -76,15 +75,15 @@ func TestDashboardHandler_GetUsageTrend_UsesCache(t *testing.T) {
|
||||
dashboardSvc := service.NewDashboardService(repo, nil, nil, nil)
|
||||
handler := NewDashboardHandler(dashboardSvc, nil)
|
||||
router := gin.New()
|
||||
router.GET("/admin/dashboard/trend", handler.GetUsageTrend)
|
||||
router.GET("/admin/dashboard/snapshot-v2", handler.GetSnapshotV2)
|
||||
|
||||
req1 := httptest.NewRequest(http.MethodGet, "/admin/dashboard/trend?start_date=2026-03-01&end_date=2026-03-07&granularity=day", nil)
|
||||
req1 := httptest.NewRequest(http.MethodGet, "/admin/dashboard/snapshot-v2?start_date=2026-03-01&end_date=2026-03-07&granularity=day&include_stats=false&include_trend=true&include_model_stats=false&include_group_stats=false&include_users_trend=false", nil)
|
||||
rec1 := httptest.NewRecorder()
|
||||
router.ServeHTTP(rec1, req1)
|
||||
require.Equal(t, http.StatusOK, rec1.Code)
|
||||
require.Equal(t, "miss", rec1.Header().Get("X-Snapshot-Cache"))
|
||||
|
||||
req2 := httptest.NewRequest(http.MethodGet, "/admin/dashboard/trend?start_date=2026-03-01&end_date=2026-03-07&granularity=day", nil)
|
||||
req2 := httptest.NewRequest(http.MethodGet, "/admin/dashboard/snapshot-v2?start_date=2026-03-01&end_date=2026-03-07&granularity=day&include_stats=false&include_trend=true&include_model_stats=false&include_group_stats=false&include_users_trend=false", nil)
|
||||
rec2 := httptest.NewRecorder()
|
||||
router.ServeHTTP(rec2, req2)
|
||||
require.Equal(t, http.StatusOK, rec2.Code)
|
||||
|
||||
@@ -71,7 +71,7 @@ func newDashboardRequestTypeTestRouter(repo *dashboardUsageRepoCapture) *gin.Eng
|
||||
dashboardSvc := service.NewDashboardService(repo, nil, nil, nil)
|
||||
handler := NewDashboardHandler(dashboardSvc, nil)
|
||||
router := gin.New()
|
||||
router.GET("/admin/dashboard/trend", handler.GetUsageTrend)
|
||||
router.GET("/admin/dashboard/snapshot-v2", handler.GetSnapshotV2)
|
||||
router.GET("/admin/dashboard/models", handler.GetModelStats)
|
||||
router.GET("/admin/dashboard/users-ranking", handler.GetUserSpendingRanking)
|
||||
return router
|
||||
@@ -81,7 +81,7 @@ func TestDashboardTrendRequestTypePriority(t *testing.T) {
|
||||
repo := &dashboardUsageRepoCapture{}
|
||||
router := newDashboardRequestTypeTestRouter(repo)
|
||||
|
||||
req := httptest.NewRequest(http.MethodGet, "/admin/dashboard/trend?request_type=ws_v2&stream=bad", nil)
|
||||
req := httptest.NewRequest(http.MethodGet, "/admin/dashboard/snapshot-v2?request_type=ws_v2&stream=bad&include_stats=false&include_trend=true&include_model_stats=false&include_group_stats=false&include_users_trend=false", nil)
|
||||
rec := httptest.NewRecorder()
|
||||
router.ServeHTTP(rec, req)
|
||||
|
||||
@@ -95,7 +95,7 @@ func TestDashboardTrendInvalidRequestType(t *testing.T) {
|
||||
repo := &dashboardUsageRepoCapture{}
|
||||
router := newDashboardRequestTypeTestRouter(repo)
|
||||
|
||||
req := httptest.NewRequest(http.MethodGet, "/admin/dashboard/trend?request_type=bad", nil)
|
||||
req := httptest.NewRequest(http.MethodGet, "/admin/dashboard/snapshot-v2?request_type=bad&include_stats=false&include_trend=true&include_model_stats=false&include_group_stats=false&include_users_trend=false", nil)
|
||||
rec := httptest.NewRecorder()
|
||||
router.ServeHTTP(rec, req)
|
||||
|
||||
@@ -106,7 +106,7 @@ func TestDashboardTrendInvalidStream(t *testing.T) {
|
||||
repo := &dashboardUsageRepoCapture{}
|
||||
router := newDashboardRequestTypeTestRouter(repo)
|
||||
|
||||
req := httptest.NewRequest(http.MethodGet, "/admin/dashboard/trend?stream=bad", nil)
|
||||
req := httptest.NewRequest(http.MethodGet, "/admin/dashboard/snapshot-v2?stream=bad&include_stats=false&include_trend=true&include_model_stats=false&include_group_stats=false&include_users_trend=false", nil)
|
||||
rec := httptest.NewRecorder()
|
||||
router.ServeHTTP(rec, req)
|
||||
|
||||
|
||||
@@ -210,17 +210,11 @@ func registerDashboardRoutes(admin *gin.RouterGroup, h *handler.Handlers) {
|
||||
dashboard := admin.Group("/dashboard")
|
||||
{
|
||||
dashboard.GET("/snapshot-v2", h.Admin.Dashboard.GetSnapshotV2)
|
||||
dashboard.GET("/stats", h.Admin.Dashboard.GetStats)
|
||||
dashboard.GET("/trend", h.Admin.Dashboard.GetUsageTrend)
|
||||
dashboard.GET("/models", h.Admin.Dashboard.GetModelStats)
|
||||
dashboard.GET("/groups", h.Admin.Dashboard.GetGroupStats)
|
||||
dashboard.GET("/api-keys-trend", h.Admin.Dashboard.GetAPIKeyUsageTrend)
|
||||
dashboard.GET("/users-trend", h.Admin.Dashboard.GetUserUsageTrend)
|
||||
dashboard.GET("/users-ranking", h.Admin.Dashboard.GetUserSpendingRanking)
|
||||
dashboard.POST("/users-usage", h.Admin.Dashboard.GetBatchUsersUsage)
|
||||
dashboard.POST("/api-keys-usage", h.Admin.Dashboard.GetBatchAPIKeysUsage)
|
||||
dashboard.GET("/user-breakdown", h.Admin.Dashboard.GetUserBreakdown)
|
||||
dashboard.POST("/aggregation/backfill", h.Admin.Dashboard.BackfillAggregation)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -29,6 +29,12 @@ func TestRegisterAdminRoutes_OmitsDeprecatedMockEndpoints(t *testing.T) {
|
||||
|
||||
deprecatedRoutes := []string{
|
||||
"GET /api/v1/admin/dashboard/realtime",
|
||||
"GET /api/v1/admin/dashboard/stats",
|
||||
"GET /api/v1/admin/dashboard/trend",
|
||||
"GET /api/v1/admin/dashboard/groups",
|
||||
"GET /api/v1/admin/dashboard/api-keys-trend",
|
||||
"POST /api/v1/admin/dashboard/api-keys-usage",
|
||||
"POST /api/v1/admin/dashboard/aggregation/backfill",
|
||||
"GET /api/v1/admin/groups/:id/stats",
|
||||
"GET /api/v1/admin/users/:id/usage",
|
||||
"GET /api/v1/admin/proxies/:id/stats",
|
||||
|
||||
@@ -25,9 +25,11 @@ describe('deprecated admin features', () => {
|
||||
})
|
||||
|
||||
it('does not expose dead dashboard admin wrappers', () => {
|
||||
expect(adminDashboardApiSource).not.toContain('getStats,')
|
||||
expect(adminDashboardApiSource).not.toContain('getUsageTrend,')
|
||||
expect(adminDashboardApiSource).not.toContain('getGroupStats,')
|
||||
expect(adminDashboardApiSource).not.toContain('getApiKeyUsageTrend,')
|
||||
expect(adminDashboardApiSource).not.toContain('getBatchApiKeysUsage')
|
||||
expect(adminDashboardApiSource).not.toContain('backfillAggregation')
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user