fix: complete platform admin audit remediation

This commit is contained in:
2026-07-27 11:00:21 +08:00
parent a545559fa8
commit 48fc80b003
6 changed files with 268 additions and 90 deletions

View File

@@ -4,9 +4,36 @@ import (
"net/http"
"testing"
"git.apinb.com/heqiapp/platforms/backend/api/internal/logic/platform"
"github.com/gin-gonic/gin"
)
func TestEveryContractHasRegisteredRoute(t *testing.T) {
engine := gin.New()
RegisterPlatform("heqi", engine)
routes := make(map[string]map[string]bool)
for _, route := range engine.Routes() {
if routes[route.Path] == nil {
routes[route.Path] = make(map[string]bool)
}
routes[route.Path][route.Method] = true
}
for _, contract := range platform.ExpectedResources() {
path := "/heqi/platform/v1" + contract.Path
switch contract.Mode {
case platform.ReadOnly:
assertRouteMethods(t, routes, path, http.MethodGet)
assertRouteMethods(t, routes, path+"/:identity", http.MethodGet)
case platform.AppendOnly:
assertRouteMethods(t, routes, path, http.MethodPost)
default:
assertRouteMethods(t, routes, path, http.MethodGet, http.MethodPost)
assertRouteMethods(t, routes, path+"/:identity", http.MethodGet, http.MethodPut, http.MethodDelete)
assertRouteMethods(t, routes, path+"/:identity/status", http.MethodPatch)
}
}
}
func TestPlatformGasRouteUsesGasBasic(t *testing.T) {
engine := gin.New()
RegisterPlatform("heqi", engine)