优化结构
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user