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>
This commit is contained in:
1 parent
11e1fa4972
commit
41ae56240a
3 files changed
+48
-11
No files matched your search
@@ -0,0 +1,29 @@
|
||||
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)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user