fix(canary-phase12): address audit findings before phase rollup
- Rename admin.Handler.Register → RegisterRoutes for parity with health.Handler.RegisterRoutes and token.Handler.RegisterAPIRoutes / RegisterManageRoutes / RegisterTriggerRoutes. Spec §6.3 line 558 also illustrates the canonical wire-up as `adminH.RegisterRoutes(api)`. - Drop the local strItoa helper in handler_test.go; use strconv.Itoa. The helper was a code-reviewer nit — equivalent stdlib already exists; fewer lines, less surface to drift. Both findings are non-blocking but covered by the fix-in-phase rule (no backlog rot). Phase 12 audits otherwise PASS on first dispatch: - superpowers:code-reviewer: PASS - general-purpose spec-adherence: PASS
This commit is contained in:
parent
9adb3d2eb8
commit
3cf198657b
|
|
@ -333,7 +333,7 @@ func mountAdminRoutes(
|
|||
}
|
||||
api.Route("/admin", func(adm chi.Router) {
|
||||
adm.Use(middleware.OperatorBearer(cfg.Operator.Token))
|
||||
adminH.Register(adm)
|
||||
adminH.RegisterRoutes(adm)
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ func NewHandler(
|
|||
}
|
||||
}
|
||||
|
||||
func (h *Handler) Register(r chi.Router) {
|
||||
func (h *Handler) RegisterRoutes(r chi.Router) {
|
||||
r.Get("/stats", h.GetStats)
|
||||
r.Get("/tokens", h.ListTokens)
|
||||
r.Post("/tokens/{"+urlParamID+"}/disable", h.DisableToken)
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import (
|
|||
"log/slog"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"strconv"
|
||||
"sync"
|
||||
"testing"
|
||||
|
||||
|
|
@ -158,7 +159,7 @@ func quietLogger() *slog.Logger {
|
|||
|
||||
func newRouter(h *admin.Handler) chi.Router {
|
||||
r := chi.NewRouter()
|
||||
h.Register(r)
|
||||
h.RegisterRoutes(r)
|
||||
return r
|
||||
}
|
||||
|
||||
|
|
@ -370,7 +371,7 @@ func TestAdmin_ListTokens_LimitCappedAt100(t *testing.T) {
|
|||
repo := newFakeTokenRepo()
|
||||
for i := range 150 {
|
||||
repo.tokens = append(repo.tokens, seedToken(
|
||||
"lim"+strItoa(i),
|
||||
"lim"+strconv.Itoa(i),
|
||||
token.TypeWebbug,
|
||||
token.ChannelWebhook,
|
||||
))
|
||||
|
|
@ -503,16 +504,3 @@ func TestAdmin_DisableToken_GetIsNotRouted(t *testing.T) {
|
|||
))
|
||||
require.Equal(t, http.StatusMethodNotAllowed, w.Code)
|
||||
}
|
||||
|
||||
func strItoa(i int) string {
|
||||
const digits = "0123456789"
|
||||
if i == 0 {
|
||||
return "0"
|
||||
}
|
||||
var out []byte
|
||||
for i > 0 {
|
||||
out = append([]byte{digits[i%10]}, out...)
|
||||
i /= 10
|
||||
}
|
||||
return string(out)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ func setupIntgStack(t *testing.T) *intgStack {
|
|||
r.Route("/api", func(api chi.Router) {
|
||||
api.Route("/admin", func(adm chi.Router) {
|
||||
adm.Use(middleware.OperatorBearer(intgOperatorToken))
|
||||
adminH.Register(adm)
|
||||
adminH.RegisterRoutes(adm)
|
||||
})
|
||||
})
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue