fix: complete platform admin audit remediation
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user