优化结构

This commit is contained in:
Yvan
2026-08-22 17:43:14 +08:00
parent 491ed21d48
commit 44ab14448a
14 changed files with 413 additions and 430 deletions
+5 -2
View File
@@ -12,6 +12,7 @@ func TestSwaggerMarksOnlyPublicRoutesWithoutAuth(t *testing.T) {
{Method: "GET", Path: "/api/freshCasbin"},
{Method: "GET", Path: "/info/getInfoDataSource"},
{Method: "GET", Path: "/info/getInfoPublic"},
{Method: "POST", Path: "/payment/callback/:provider"},
}, "", "test")
var payload struct {
Paths map[string]map[string]map[string]any `json:"paths"`
@@ -24,7 +25,9 @@ func TestSwaggerMarksOnlyPublicRoutesWithoutAuth(t *testing.T) {
t.Fatalf("private route %s was marked public", path)
}
}
if _, ok := payload.Paths["/info/getInfoPublic"]["get"]["security"]; ok {
t.Fatal("public route /info/getInfoPublic requires authentication")
for path, method := range map[string]string{"/info/getInfoPublic": "get", "/payment/callback/{provider}": "post"} {
if _, ok := payload.Paths[path][method]["security"]; ok {
t.Fatalf("public route %s requires authentication", path)
}
}
}