Files
GuwandykA 41ae56240a
Some checks failed
CI/CD / Vet, test, build (push) Has been cancelled
CI/CD / Docker image (push) Has been cancelled
CI/CD / Deploy binary to server (push) Has been cancelled
visamasteractions: register /:id/actions as its own rbac prefix
The server panicked at startup: the actions group declared
require-staff:cards for /visa-master-payment-orders, which
cards/visamaster already registers with require:cards, and rbac allows
one policy per prefix. The group is now /visa-master-payment-orders/:id/actions,
the same way /callback has its own prefix; the routes are unchanged.

manager.New's handler registration moves into registerRoutes, and
TestRegisterRoutes runs it without a database, so a conflicting policy
fails the tests instead of the server.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-25 22:46:43 +05:00

30 lines
767 B
Go

package handlermanager
import (
"testing"
"online-back/internal/config"
"online-back/internal/identity/rbac"
"online-back/pkg/logging"
"github.com/gin-gonic/gin"
)
// TestRegisterRoutes registers every handler the way New does (no database:
// handlers only touch it per request), so a startup panic such as two
// groups declaring different policies for one prefix fails here instead
// of on the server.
func TestRegisterRoutes(t *testing.T) {
gin.SetMode(gin.TestMode)
debug := true
cfg := &config.Config{IsDebug: &debug}
router := gin.New()
adminGroup := router.Group(adminAPIPrefix)
registerRoutes(router, adminGroup, cfg, nil, logging.GetLogger())
if err := rbac.VerifyRoutes(router.Routes(), adminAPIPrefix); err != nil {
t.Fatal(err)
}
}