Files
MeBox/internal/handler/routes_authenticated_test.go
T

47 lines
1.0 KiB
Go

package handler
import (
"testing"
"github.com/gin-gonic/gin"
"go.uber.org/zap"
"github.com/ShukeBta/MediaStationGo/internal/config"
"github.com/ShukeBta/MediaStationGo/internal/service"
)
func TestAuthenticatedRouteSurfacesAreRegistered(t *testing.T) {
gin.SetMode(gin.TestMode)
router := gin.New()
Register(router, &config.Config{
Secrets: config.SecretsConfig{JWTSecret: "test-secret"},
}, zap.NewNop(), &service.Container{Log: zap.NewNop()})
routes := map[string]bool{}
for _, route := range router.Routes() {
routes[route.Method+" "+route.Path] = true
}
for _, want := range []string{
"GET /api/me",
"GET /api/auth/permissions",
"GET /api/libraries",
"GET /api/media",
"GET /api/stream/:id",
"GET /api/storage",
"GET /api/downloads",
"GET /api/subscriptions",
"GET /api/sites/search",
"GET /api/watch-history",
"GET /api/discover/feed",
"GET /api/playback/:id/info",
"GET /api/download/tasks",
"GET /api/admin/assistant/history",
} {
if !routes[want] {
t.Fatalf("%s route is not registered", want)
}
}
}