diff --git a/api/waf_allow_ip.go b/api/waf_allow_ip.go index 34ce363..37e371d 100644 --- a/api/waf_allow_ip.go +++ b/api/waf_allow_ip.go @@ -25,7 +25,7 @@ type WafAllowIpApi struct { // @Param data body request.WafAllowIpAddReq true "IP白名单配置" // @Success 200 {object} response.Response "添加成功" // @Security ApiKeyAuth -// @Router /wafhost/allowip/add [post] +// @Router /wafhost/ipwhite/add [post] func (w *WafAllowIpApi) AddApi(c *gin.Context) { var req request.WafAllowIpAddReq err := c.ShouldBindJSON(&req) @@ -60,7 +60,7 @@ func (w *WafAllowIpApi) AddApi(c *gin.Context) { // @Param id query string true "记录ID" // @Success 200 {object} response.Response "获取成功" // @Security ApiKeyAuth -// @Router /wafhost/allowip/detail [get] +// @Router /wafhost/ipwhite/detail [get] func (w *WafAllowIpApi) GetDetailApi(c *gin.Context) { var req request.WafAllowIpDetailReq err := c.ShouldBind(&req) @@ -81,7 +81,7 @@ func (w *WafAllowIpApi) GetDetailApi(c *gin.Context) { // @Param data body request.WafAllowIpSearchReq true "分页查询参数" // @Success 200 {object} response.Response{data=response.PageResult} "获取成功" // @Security ApiKeyAuth -// @Router /wafhost/allowip/list [post] +// @Router /wafhost/ipwhite/list [post] func (w *WafAllowIpApi) GetListApi(c *gin.Context) { var req request.WafAllowIpSearchReq err := c.ShouldBindJSON(&req) @@ -107,7 +107,7 @@ func (w *WafAllowIpApi) GetListApi(c *gin.Context) { // @Param id query string true "记录ID" // @Success 200 {object} response.Response "删除成功" // @Security ApiKeyAuth -// @Router /wafhost/allowip/del [get] +// @Router /wafhost/ipwhite/del [get] func (w *WafAllowIpApi) DelAllowIpApi(c *gin.Context) { var req request.WafAllowIpDelReq err := c.ShouldBind(&req) @@ -137,7 +137,7 @@ func (w *WafAllowIpApi) DelAllowIpApi(c *gin.Context) { // @Param data body request.WafAllowIpEditReq true "IP白名单配置" // @Success 200 {object} response.Response "编辑成功" // @Security ApiKeyAuth -// @Router /wafhost/allowip/edit [post] +// @Router /wafhost/ipwhite/edit [post] func (w *WafAllowIpApi) ModifyAllowIpApi(c *gin.Context) { var req request.WafAllowIpEditReq err := c.ShouldBindJSON(&req) diff --git a/api/waf_allow_url.go b/api/waf_allow_url.go index d24378f..4244542 100644 --- a/api/waf_allow_url.go +++ b/api/waf_allow_url.go @@ -25,7 +25,7 @@ type WafAllowUrlApi struct { // @Param data body request.WafAllowUrlAddReq true "URL白名单配置" // @Success 200 {object} response.Response "添加成功" // @Security ApiKeyAuth -// @Router /wafhost/allowurl/add [post] +// @Router /wafhost/urlwhite/add [post] func (w *WafAllowUrlApi) AddApi(c *gin.Context) { var req request.WafAllowUrlAddReq err := c.ShouldBindJSON(&req) @@ -60,7 +60,7 @@ func (w *WafAllowUrlApi) AddApi(c *gin.Context) { // @Param id query string true "记录ID" // @Success 200 {object} response.Response "获取成功" // @Security ApiKeyAuth -// @Router /wafhost/allowurl/detail [get] +// @Router /wafhost/urlwhite/detail [get] func (w *WafAllowUrlApi) GetDetailApi(c *gin.Context) { var req request.WafAllowUrlDetailReq err := c.ShouldBind(&req) @@ -81,7 +81,7 @@ func (w *WafAllowUrlApi) GetDetailApi(c *gin.Context) { // @Param data body request.WafAllowUrlSearchReq true "分页查询参数" // @Success 200 {object} response.Response{data=response.PageResult} "获取成功" // @Security ApiKeyAuth -// @Router /wafhost/allowurl/list [post] +// @Router /wafhost/urlwhite/list [post] func (w *WafAllowUrlApi) GetListApi(c *gin.Context) { var req request.WafAllowUrlSearchReq err := c.ShouldBindJSON(&req) @@ -107,7 +107,7 @@ func (w *WafAllowUrlApi) GetListApi(c *gin.Context) { // @Param id query string true "记录ID" // @Success 200 {object} response.Response "删除成功" // @Security ApiKeyAuth -// @Router /wafhost/allowurl/del [get] +// @Router /wafhost/urlwhite/del [get] func (w *WafAllowUrlApi) DelAllowUrlApi(c *gin.Context) { var req request.WafAllowUrlDelReq err := c.ShouldBind(&req) @@ -137,7 +137,7 @@ func (w *WafAllowUrlApi) DelAllowUrlApi(c *gin.Context) { // @Param data body request.WafAllowUrlEditReq true "URL白名单配置" // @Success 200 {object} response.Response "编辑成功" // @Security ApiKeyAuth -// @Router /wafhost/allowurl/edit [post] +// @Router /wafhost/urlwhite/edit [post] func (w *WafAllowUrlApi) ModifyAllowUrlApi(c *gin.Context) { var req request.WafAllowUrlEditReq err := c.ShouldBindJSON(&req) diff --git a/api/waf_block_ip.go b/api/waf_block_ip.go index db47750..7223e71 100644 --- a/api/waf_block_ip.go +++ b/api/waf_block_ip.go @@ -25,7 +25,7 @@ type WafBlockIpApi struct { // @Param data body request.WafBlockIpAddReq true "IP黑名单配置" // @Success 200 {object} response.Response "添加成功" // @Security ApiKeyAuth -// @Router /wafhost/blockip/add [post] +// @Router /wafhost/ipblock/add [post] func (w *WafBlockIpApi) AddApi(c *gin.Context) { var req request.WafBlockIpAddReq err := c.ShouldBindJSON(&req) @@ -60,7 +60,7 @@ func (w *WafBlockIpApi) AddApi(c *gin.Context) { // @Param id query string true "记录ID" // @Success 200 {object} response.Response "获取成功" // @Security ApiKeyAuth -// @Router /wafhost/blockip/detail [get] +// @Router /wafhost/ipblock/detail [get] func (w *WafBlockIpApi) GetDetailApi(c *gin.Context) { var req request.WafBlockIpDetailReq err := c.ShouldBind(&req) @@ -81,7 +81,7 @@ func (w *WafBlockIpApi) GetDetailApi(c *gin.Context) { // @Param data body request.WafBlockIpSearchReq true "分页查询参数" // @Success 200 {object} response.Response{data=response.PageResult} "获取成功" // @Security ApiKeyAuth -// @Router /wafhost/blockip/list [post] +// @Router /wafhost/ipblock/list [post] func (w *WafBlockIpApi) GetListApi(c *gin.Context) { var req request.WafBlockIpSearchReq err := c.ShouldBindJSON(&req) @@ -107,7 +107,7 @@ func (w *WafBlockIpApi) GetListApi(c *gin.Context) { // @Param id query string true "记录ID" // @Success 200 {object} response.Response "删除成功" // @Security ApiKeyAuth -// @Router /wafhost/blockip/del [get] +// @Router /wafhost/ipblock/del [get] func (w *WafBlockIpApi) DelBlockIpApi(c *gin.Context) { var req request.WafBlockIpDelReq err := c.ShouldBind(&req) @@ -137,7 +137,7 @@ func (w *WafBlockIpApi) DelBlockIpApi(c *gin.Context) { // @Param data body request.WafBlockIpEditReq true "IP黑名单配置" // @Success 200 {object} response.Response "编辑成功" // @Security ApiKeyAuth -// @Router /wafhost/blockip/edit [post] +// @Router /wafhost/ipblock/edit [post] func (w *WafBlockIpApi) ModifyBlockIpApi(c *gin.Context) { var req request.WafBlockIpEditReq err := c.ShouldBindJSON(&req) diff --git a/api/waf_block_url.go b/api/waf_block_url.go index 4d4cd80..9925c03 100644 --- a/api/waf_block_url.go +++ b/api/waf_block_url.go @@ -25,7 +25,7 @@ type WafBlockUrlApi struct { // @Param data body request.WafBlockUrlAddReq true "URL黑名单配置" // @Success 200 {object} response.Response "添加成功" // @Security ApiKeyAuth -// @Router /wafhost/blockurl/add [post] +// @Router /wafhost/urlblock/add [post] func (w *WafBlockUrlApi) AddApi(c *gin.Context) { var req request.WafBlockUrlAddReq err := c.ShouldBindJSON(&req) @@ -60,7 +60,7 @@ func (w *WafBlockUrlApi) AddApi(c *gin.Context) { // @Param id query string true "记录ID" // @Success 200 {object} response.Response "获取成功" // @Security ApiKeyAuth -// @Router /wafhost/blockurl/detail [get] +// @Router /wafhost/urlblock/detail [get] func (w *WafBlockUrlApi) GetDetailApi(c *gin.Context) { var req request.WafBlockUrlDetailReq err := c.ShouldBind(&req) @@ -81,7 +81,7 @@ func (w *WafBlockUrlApi) GetDetailApi(c *gin.Context) { // @Param data body request.WafBlockUrlSearchReq true "分页查询参数" // @Success 200 {object} response.Response{data=response.PageResult} "获取成功" // @Security ApiKeyAuth -// @Router /wafhost/blockurl/list [post] +// @Router /wafhost/urlblock/list [post] func (w *WafBlockUrlApi) GetListApi(c *gin.Context) { var req request.WafBlockUrlSearchReq err := c.ShouldBindJSON(&req) @@ -107,7 +107,7 @@ func (w *WafBlockUrlApi) GetListApi(c *gin.Context) { // @Param id query string true "记录ID" // @Success 200 {object} response.Response "删除成功" // @Security ApiKeyAuth -// @Router /wafhost/blockurl/del [get] +// @Router /wafhost/urlblock/del [get] func (w *WafBlockUrlApi) DelBlockUrlApi(c *gin.Context) { var req request.WafBlockUrlDelReq err := c.ShouldBind(&req) @@ -137,7 +137,7 @@ func (w *WafBlockUrlApi) DelBlockUrlApi(c *gin.Context) { // @Param data body request.WafBlockUrlEditReq true "URL黑名单配置" // @Success 200 {object} response.Response "编辑成功" // @Security ApiKeyAuth -// @Router /wafhost/blockurl/edit [post] +// @Router /wafhost/urlblock/edit [post] func (w *WafBlockUrlApi) ModifyBlockUrlApi(c *gin.Context) { var req request.WafBlockUrlEditReq err := c.ShouldBindJSON(&req) diff --git a/api/waf_engine.go b/api/waf_engine.go index 8d248fa..a4235c5 100644 --- a/api/waf_engine.go +++ b/api/waf_engine.go @@ -16,7 +16,7 @@ type WafEngineApi struct { // @Produce json // @Success 200 {object} response.Response "重启指令发起成功" // @Security ApiKeyAuth -// @Router /wafhost/engine/restart [post] +// @Router /resetWAF [get] func (w *WafEngineApi) ResetWaf(c *gin.Context) { //重启WAF引擎 global.GWAF_CHAN_ENGINE <- 1 diff --git a/api/waf_firewall_ip_block_api.go b/api/waf_firewall_ip_block_api.go index 35071c8..b67d516 100644 --- a/api/waf_firewall_ip_block_api.go +++ b/api/waf_firewall_ip_block_api.go @@ -22,7 +22,7 @@ type WafFirewallIPBlockApi struct { // @Param data body request.WafFirewallIPBlockAddReq true "IP封禁配置" // @Success 200 {object} response.Response "添加成功" // @Security ApiKeyAuth -// @Router /firewallipblock/add [post] +// @Router /firewall/ipblock/add [post] func (w *WafFirewallIPBlockApi) AddApi(c *gin.Context) { var req request.WafFirewallIPBlockAddReq err := c.ShouldBindJSON(&req) @@ -62,7 +62,7 @@ func (w *WafFirewallIPBlockApi) GetDetailApi(c *gin.Context) { // @Param data body request.WafFirewallIPBlockSearchReq true "分页查询参数" // @Success 200 {object} response.Response{data=response.PageResult} "获取成功" // @Security ApiKeyAuth -// @Router /firewallipblock/list [post] +// @Router /firewall/ipblock/list [post] func (w *WafFirewallIPBlockApi) GetListApi(c *gin.Context) { var req request.WafFirewallIPBlockSearchReq err := c.ShouldBindJSON(&req) @@ -94,7 +94,7 @@ func (w *WafFirewallIPBlockApi) GetListApi(c *gin.Context) { // @Param id query string true "封禁记录ID" // @Success 200 {object} response.Response "删除成功" // @Security ApiKeyAuth -// @Router /firewallipblock/del [get] +// @Router /firewall/ipblock/del [get] func (w *WafFirewallIPBlockApi) DelApi(c *gin.Context) { var req request.WafFirewallIPBlockDelReq err := c.ShouldBind(&req) @@ -122,7 +122,7 @@ func (w *WafFirewallIPBlockApi) DelApi(c *gin.Context) { // @Param data body request.WafFirewallIPBlockEditReq true "IP封禁配置" // @Success 200 {object} response.Response "编辑成功" // @Security ApiKeyAuth -// @Router /firewallipblock/edit [post] +// @Router /firewall/ipblock/edit [post] func (w *WafFirewallIPBlockApi) ModifyApi(c *gin.Context) { var req request.WafFirewallIPBlockEditReq err := c.ShouldBindJSON(&req) diff --git a/api/waf_host.go b/api/waf_host.go index bb58f7e..1aa608f 100644 --- a/api/waf_host.go +++ b/api/waf_host.go @@ -16,10 +16,11 @@ import ( "SamWaf/wafenginecore" "errors" "fmt" - "github.com/gin-gonic/gin" - "gorm.io/gorm" "strconv" "strings" + + "github.com/gin-gonic/gin" + "gorm.io/gorm" ) type WafHostAPi struct { @@ -344,7 +345,7 @@ func (w *WafHostAPi) ModifyHostApi(c *gin.Context) { // @Param data body request.WafHostGuardStatusReq true "防御状态参数" // @Success 200 {object} response.Response "状态更新成功" // @Security ApiKeyAuth -// @Router /wafhost/host/guardstatus [post] +// @Router /wafhost/host/guardstatus [get] func (w *WafHostAPi) ModifyGuardStatusApi(c *gin.Context) { var req request.WafHostGuardStatusReq err := c.ShouldBind(&req) @@ -418,7 +419,7 @@ func (w *WafHostAPi) ModifyAllGuardStatusApi(c *gin.Context) { // @Param data body request.WafHostStartStatusReq true "启动状态参数" // @Success 200 {object} response.Response "状态更新成功" // @Security ApiKeyAuth -// @Router /wafhost/host/startstatus [post] +// @Router /wafhost/host/startstatus [get] func (w *WafHostAPi) ModifyStartStatusApi(c *gin.Context) { var req request.WafHostStartStatusReq err := c.ShouldBind(&req) diff --git a/api/waf_ip_failure.go b/api/waf_ip_failure.go index 43ecf22..56cd247 100644 --- a/api/waf_ip_failure.go +++ b/api/waf_ip_failure.go @@ -50,7 +50,7 @@ func (w *WafIPFailureApi) GetConfigApi(c *gin.Context) { // @Param data body request.WafIPFailureSetConfigReq true "配置参数" // @Success 200 {object} response.Response "设置成功" // @Security ApiKeyAuth -// @Router /wafhost/ipfailure/setconfig [post] +// @Router /wafhost/ipfailure/config [post] func (w *WafIPFailureApi) SetConfigApi(c *gin.Context) { var req request.WafIPFailureSetConfigReq err := c.ShouldBindJSON(&req) diff --git a/api/waf_rule.go b/api/waf_rule.go index 703685d..75e6b13 100644 --- a/api/waf_rule.go +++ b/api/waf_rule.go @@ -388,7 +388,7 @@ func (w *WafRuleAPi) FormatRuleApi(c *gin.Context) { // @Param data body request.WafRuleStatusReq true "状态参数" // @Success 200 {object} response.Response "状态更新成功" // @Security ApiKeyAuth -// @Router /wafhost/rule/status [post] +// @Router /wafhost/rule/rulestatus [get] func (w *WafRuleAPi) ModifyRuleStatusApi(c *gin.Context) { var req request.WafRuleStatusReq err := c.ShouldBind(&req) diff --git a/api/waf_ssl.go b/api/waf_ssl.go index 9d27c2a..44d1399 100644 --- a/api/waf_ssl.go +++ b/api/waf_ssl.go @@ -24,7 +24,7 @@ type WafSslConfigApi struct{} // @Param data body request.SslConfigAddReq true "SSL证书配置" // @Success 200 {object} response.Response "添加成功" // @Security ApiKeyAuth -// @Router /wafhost/sslconfig/add [post] +// @Router /sslconfig/add [post] func (s *WafSslConfigApi) AddSslConfigApi(c *gin.Context) { var req request.SslConfigAddReq err := c.ShouldBindJSON(&req) @@ -50,7 +50,7 @@ func (s *WafSslConfigApi) AddSslConfigApi(c *gin.Context) { // @Param id query string true "证书ID" // @Success 200 {object} response.Response "获取成功" // @Security ApiKeyAuth -// @Router /wafhost/sslconfig/detail [get] +// @Router /sslconfig/detail [get] func (s *WafSslConfigApi) GetSslConfigDetailApi(c *gin.Context) { var req request.SslConfigDetailReq err := c.ShouldBind(&req) @@ -71,7 +71,7 @@ func (s *WafSslConfigApi) GetSslConfigDetailApi(c *gin.Context) { // @Param data body request.SslConfigSearchReq true "分页查询参数" // @Success 200 {object} response.Response{data=response.PageResult} "获取成功" // @Security ApiKeyAuth -// @Router /wafhost/sslconfig/list [post] +// @Router /sslconfig/list [post] func (s *WafSslConfigApi) GetSslConfigListApi(c *gin.Context) { var req request.SslConfigSearchReq err := c.ShouldBindJSON(&req) @@ -97,7 +97,7 @@ func (s *WafSslConfigApi) GetSslConfigListApi(c *gin.Context) { // @Param id query string true "证书ID" // @Success 200 {object} response.Response "删除成功" // @Security ApiKeyAuth -// @Router /wafhost/sslconfig/del [get] +// @Router /sslconfig/del [get] func (s *WafSslConfigApi) DelSslConfigApi(c *gin.Context) { var req request.SslConfigDeleteReq err := c.ShouldBind(&req) @@ -124,7 +124,7 @@ func (s *WafSslConfigApi) DelSslConfigApi(c *gin.Context) { // @Param data body request.SslConfigEditReq true "SSL证书配置" // @Success 200 {object} response.Response "编辑成功" // @Security ApiKeyAuth -// @Router /wafhost/sslconfig/edit [post] +// @Router /sslconfig/edit [post] func (s *WafSslConfigApi) ModifySslConfigApi(c *gin.Context) { var req request.SslConfigEditReq err := c.ShouldBindJSON(&req) diff --git a/api/waf_stat.go b/api/waf_stat.go index 8f38110..5c76075 100644 --- a/api/waf_stat.go +++ b/api/waf_stat.go @@ -17,7 +17,7 @@ type WafStatApi struct { // @Produce json // @Success 200 {object} response.Response "获取成功" // @Security ApiKeyAuth -// @Router /stat/sysinfo [get] +// @Router /statsysinfo [get] func (w *WafStatApi) StatSysinfoApi(c *gin.Context) { response.OkWithDetailed(wafStatService.StatHomeSysinfo(c), "获取成功", c) @@ -30,7 +30,7 @@ func (w *WafStatApi) StatSysinfoApi(c *gin.Context) { // @Produce json // @Success 200 {object} response.Response "获取成功" // @Security ApiKeyAuth -// @Router /stat/runtimesysinfo [get] +// @Router /statrumtimesysinfo [get] func (w *WafStatApi) StatRumtimeSysinfoApi(c *gin.Context) { response.OkWithDetailed(wafStatService.StatHomeRumtimeSysinfo(), "获取成功", c) @@ -43,7 +43,7 @@ func (w *WafStatApi) StatRumtimeSysinfoApi(c *gin.Context) { // @Produce json // @Success 200 {object} response.Response "获取成功" // @Security ApiKeyAuth -// @Router /stat/daytotal [get] +// @Router /wafstatsumday [get] func (w *WafStatApi) StatHomeSumDayApi(c *gin.Context) { wafStat, _ := wafStatService.StatHomeSumDayApi() @@ -59,7 +59,7 @@ func (w *WafStatApi) StatHomeSumDayApi(c *gin.Context) { // @Param data body request.WafStatsDayRangeReq true "日期范围参数" // @Success 200 {object} response.Response "获取成功" // @Security ApiKeyAuth -// @Router /stat/dayrangecount [post] +// @Router /wafstatsumdayrange [get] func (w *WafStatApi) StatHomeSumDayRangeApi(c *gin.Context) { var req request.WafStatsDayRangeReq err := c.ShouldBind(&req) @@ -81,7 +81,7 @@ func (w *WafStatApi) StatHomeSumDayRangeApi(c *gin.Context) { // @Param data body request.WafStatsDayRangeReq true "日期范围参数" // @Success 200 {object} response.Response "获取成功" // @Security ApiKeyAuth -// @Router /stat/ipcount [post] +// @Router /wafstatsumdaytopiprange [get] func (w *WafStatApi) StatHomeSumDayTopIPRangeApi(c *gin.Context) { var req request.WafStatsDayRangeReq err := c.ShouldBind(&req) @@ -103,7 +103,7 @@ func (w *WafStatApi) StatHomeSumDayTopIPRangeApi(c *gin.Context) { // @Param end_day query string false "结束日期 如 20260310" // @Success 200 {object} response.Response "获取成功" // @Security ApiKeyAuth -// @Router /stat/siteoverview [get] +// @Router /wafstatsiteoverview [get] func (w *WafStatApi) StatSiteOverviewApi(c *gin.Context) { var req request.WafStatsSiteOverviewReq err := c.ShouldBind(&req) @@ -124,7 +124,7 @@ func (w *WafStatApi) StatSiteOverviewApi(c *gin.Context) { // @Param time_range query string true "时间范围: 24h | 7d | 30d" // @Success 200 {object} response.Response "获取成功" // @Security ApiKeyAuth -// @Router /stat/sitedetail [get] +// @Router /wafstatsitedetail [get] func (w *WafStatApi) StatSiteDetailApi(c *gin.Context) { var req request.WafStatsSiteDetailReq err := c.ShouldBind(&req) diff --git a/api/waf_sys_log.go b/api/waf_sys_log.go index 9f128a0..f97e725 100644 --- a/api/waf_sys_log.go +++ b/api/waf_sys_log.go @@ -18,7 +18,7 @@ type WafSysLogApi struct { // @Param id query string true "日志ID" // @Success 200 {object} response.Response "获取成功" // @Security ApiKeyAuth -// @Router /syslog/detail [get] +// @Router /sys_log/detail [get] func (w *WafSysLogApi) GetDetailApi(c *gin.Context) { var req request.WafSysLogDetailReq err := c.ShouldBind(&req) @@ -39,7 +39,7 @@ func (w *WafSysLogApi) GetDetailApi(c *gin.Context) { // @Param data body request.WafSysLogSearchReq true "分页查询参数" // @Success 200 {object} response.Response{data=response.PageResult} "获取成功" // @Security ApiKeyAuth -// @Router /syslog/list [post] +// @Router /sys_log/list [get] func (w *WafSysLogApi) GetListApi(c *gin.Context) { var req request.WafSysLogSearchReq err := c.ShouldBind(&req) diff --git a/api/waf_system_config.go b/api/waf_system_config.go index 498a948..a0164c0 100644 --- a/api/waf_system_config.go +++ b/api/waf_system_config.go @@ -125,7 +125,7 @@ func (w *WafSystemConfigApi) ModifyApi(c *gin.Context) { // @Param data body request.WafSystemConfigEditByItemReq true "配置参数" // @Success 200 {object} response.Response "编辑成功" // @Security ApiKeyAuth -// @Router /systemconfig/updateitem [post] +// @Router /systemconfig/editByItem [post] func (w *WafSystemConfigApi) ModifyByItemApi(c *gin.Context) { var req request.WafSystemConfigEditByItemReq err := c.ShouldBindJSON(&req) diff --git a/test/apicheck/api_routes_test.go b/test/apicheck/api_routes_test.go new file mode 100644 index 0000000..2a42e2e --- /dev/null +++ b/test/apicheck/api_routes_test.go @@ -0,0 +1,359 @@ +// 集成测试:验证所有带 @Router 注解的 API 路由路径是否可达(返回非 404) +// 运行前请确保 SamWaf 服务已启动。 +// +// 运行命令: +// +// go test -v -run TestAllRoutes ./test/ +// +// 如需跳过集成测试,加 -short 参数: +// +// go test -short ./test/ +package apicheck + +import ( + "bytes" + "fmt" + "net/http" + "strings" + "testing" + "time" +) + +// ───────────────────────────────────────────────────────────────────────────── +// 配置入口:修改这里即可 +// ───────────────────────────────────────────────────────────────────────────── + +const ( + baseURL = "http://127.0.0.1:26666" // 服务地址 + sk = "1111111" // X-Token 登录令牌,按实际值修改 +) + +// ───────────────────────────────────────────────────────────────────────────── +// 路由清单(与 @Router 注解保持一致) +// ───────────────────────────────────────────────────────────────────────────── + +type route struct { + method string + path string + desc string +} + +var registeredRoutes = []route{ + // ── IP 白名单 ────────────────────────────────────────────────── + {"POST", "/api/v1/wafhost/ipwhite/add", "新增IP白名单"}, + {"GET", "/api/v1/wafhost/ipwhite/detail", "获取IP白名单详情"}, + {"POST", "/api/v1/wafhost/ipwhite/list", "获取IP白名单列表"}, + {"GET", "/api/v1/wafhost/ipwhite/del", "删除IP白名单"}, + {"POST", "/api/v1/wafhost/ipwhite/edit", "编辑IP白名单"}, + + // ── URL 白名单 ───────────────────────────────────────────────── + {"POST", "/api/v1/wafhost/urlwhite/add", "新增URL白名单"}, + {"GET", "/api/v1/wafhost/urlwhite/detail", "获取URL白名单详情"}, + {"POST", "/api/v1/wafhost/urlwhite/list", "获取URL白名单列表"}, + {"GET", "/api/v1/wafhost/urlwhite/del", "删除URL白名单"}, + {"POST", "/api/v1/wafhost/urlwhite/edit", "编辑URL白名单"}, + + // ── IP 黑名单 ────────────────────────────────────────────────── + {"POST", "/api/v1/wafhost/ipblock/add", "新增IP黑名单"}, + {"GET", "/api/v1/wafhost/ipblock/detail", "获取IP黑名单详情"}, + {"POST", "/api/v1/wafhost/ipblock/list", "获取IP黑名单列表"}, + {"GET", "/api/v1/wafhost/ipblock/del", "删除IP黑名单"}, + {"POST", "/api/v1/wafhost/ipblock/edit", "编辑IP黑名单"}, + + // ── URL 黑名单 ───────────────────────────────────────────────── + {"POST", "/api/v1/wafhost/urlblock/add", "新增URL黑名单"}, + {"GET", "/api/v1/wafhost/urlblock/detail", "获取URL黑名单详情"}, + {"POST", "/api/v1/wafhost/urlblock/list", "获取URL黑名单列表"}, + {"GET", "/api/v1/wafhost/urlblock/del", "删除URL黑名单"}, + {"POST", "/api/v1/wafhost/urlblock/edit", "编辑URL黑名单"}, + + // ── Anti-CC ──────────────────────────────────────────────────── + {"POST", "/api/v1/wafhost/anticc/add", "新增Anti-CC规则"}, + {"GET", "/api/v1/wafhost/anticc/detail", "获取Anti-CC规则详情"}, + {"POST", "/api/v1/wafhost/anticc/list", "获取Anti-CC规则列表"}, + {"GET", "/api/v1/wafhost/anticc/del", "删除Anti-CC规则"}, + {"POST", "/api/v1/wafhost/anticc/edit", "编辑Anti-CC规则"}, + + // ── IP 失败封禁 ──────────────────────────────────────────────── + {"GET", "/api/v1/wafhost/ipfailure/config", "获取IP失败封禁配置"}, + {"POST", "/api/v1/wafhost/ipfailure/config", "设置IP失败封禁配置"}, + {"GET", "/api/v1/wafhost/ipfailure/baniplist", "获取IP失败封禁列表"}, + + // ── 防火墙 IP 封禁 ───────────────────────────────────────────── + {"POST", "/api/v1/firewall/ipblock/add", "新增防火墙IP封禁"}, + {"POST", "/api/v1/firewall/ipblock/list", "获取防火墙IP封禁列表"}, + {"GET", "/api/v1/firewall/ipblock/del", "删除防火墙IP封禁"}, + {"POST", "/api/v1/firewall/ipblock/edit", "编辑防火墙IP封禁"}, + + // ── WAF 规则 ─────────────────────────────────────────────────── + {"POST", "/api/v1/wafhost/rule/add", "新增WAF规则"}, + {"GET", "/api/v1/wafhost/rule/detail", "获取WAF规则详情"}, + {"POST", "/api/v1/wafhost/rule/list", "获取WAF规则列表"}, + {"GET", "/api/v1/wafhost/rule/del", "删除WAF规则"}, + {"POST", "/api/v1/wafhost/rule/edit", "编辑WAF规则"}, + {"GET", "/api/v1/wafhost/rule/rulestatus", "修改WAF规则状态"}, + + // ── 敏感词 ───────────────────────────────────────────────────── + {"POST", "/api/v1/wafhost/sensitive/add", "新增敏感词"}, + {"GET", "/api/v1/wafhost/sensitive/detail", "获取敏感词详情"}, + {"POST", "/api/v1/wafhost/sensitive/list", "获取敏感词列表"}, + {"GET", "/api/v1/wafhost/sensitive/del", "删除敏感词"}, + {"POST", "/api/v1/wafhost/sensitive/edit", "编辑敏感词"}, + + // ── 缓存规则 ─────────────────────────────────────────────────── + {"POST", "/api/v1/wafhost/cacherule/add", "新增缓存规则"}, + {"GET", "/api/v1/wafhost/cacherule/detail", "获取缓存规则详情"}, + {"POST", "/api/v1/wafhost/cacherule/list", "获取缓存规则列表"}, + {"GET", "/api/v1/wafhost/cacherule/del", "删除缓存规则"}, + {"POST", "/api/v1/wafhost/cacherule/edit", "编辑缓存规则"}, + + // ── 负载均衡 ─────────────────────────────────────────────────── + {"POST", "/api/v1/wafhost/loadbalance/add", "新增负载均衡"}, + {"GET", "/api/v1/wafhost/loadbalance/detail", "获取负载均衡详情"}, + {"POST", "/api/v1/wafhost/loadbalance/list", "获取负载均衡列表"}, + {"GET", "/api/v1/wafhost/loadbalance/del", "删除负载均衡"}, + {"POST", "/api/v1/wafhost/loadbalance/edit", "编辑负载均衡"}, + + // ── 一键修改 ─────────────────────────────────────────────────── + {"GET", "/api/v1/wafhost/onekeymod/detail", "获取一键修改详情"}, + {"POST", "/api/v1/wafhost/onekeymod/list", "获取一键修改列表"}, + {"GET", "/api/v1/wafhost/onekeymod/del", "删除一键修改"}, + {"POST", "/api/v1/wafhost/onekeymod/doModify", "执行一键修改"}, + {"GET", "/api/v1/wafhost/onekeymod/restore", "还原一键修改"}, + + // ── 任务管理 ─────────────────────────────────────────────────── + {"POST", "/api/v1/wafhost/task/add", "新增任务"}, + {"GET", "/api/v1/wafhost/task/detail", "获取任务详情"}, + {"POST", "/api/v1/wafhost/task/list", "获取任务列表"}, + {"GET", "/api/v1/wafhost/task/del", "删除任务"}, + {"POST", "/api/v1/wafhost/task/edit", "编辑任务"}, + {"GET", "/api/v1/wafhost/task/manual_exec", "手动执行任务"}, + {"GET", "/api/v1/wafhost/task/log", "获取任务日志"}, + {"GET", "/api/v1/wafhost/task/log/clear", "清空任务日志"}, + + // ── 数据保留策略 ─────────────────────────────────────────────── + {"POST", "/api/v1/wafhost/dataretention/list", "获取数据保留策略列表"}, + {"GET", "/api/v1/wafhost/dataretention/detail", "获取数据保留策略详情"}, + {"POST", "/api/v1/wafhost/dataretention/edit", "编辑数据保留策略"}, + + // ── 私有信息 ─────────────────────────────────────────────────── + {"POST", "/api/v1/wafhost/privateinfo/add", "新增私有信息"}, + {"GET", "/api/v1/wafhost/privateinfo/detail", "获取私有信息详情"}, + {"POST", "/api/v1/wafhost/privateinfo/list", "获取私有信息列表"}, + {"GET", "/api/v1/wafhost/privateinfo/del", "删除私有信息"}, + {"POST", "/api/v1/wafhost/privateinfo/edit", "编辑私有信息"}, + + // ── 私有分组 ─────────────────────────────────────────────────── + {"POST", "/api/v1/wafhost/privategroup/add", "新增私有分组"}, + {"GET", "/api/v1/wafhost/privategroup/detail", "获取私有分组详情"}, + {"POST", "/api/v1/wafhost/privategroup/list", "获取私有分组列表"}, + {"POST", "/api/v1/wafhost/privategroup/listbybelongcloud", "按云获取私有分组列表"}, + {"GET", "/api/v1/wafhost/privategroup/del", "删除私有分组"}, + {"POST", "/api/v1/wafhost/privategroup/edit", "编辑私有分组"}, + + // ── 网站管理 ─────────────────────────────────────────────────── + {"POST", "/api/v1/wafhost/host/add", "新增站点"}, + {"GET", "/api/v1/wafhost/host/detail", "获取站点详情"}, + {"POST", "/api/v1/wafhost/host/list", "获取站点列表"}, + {"GET", "/api/v1/wafhost/host/del", "删除站点"}, + {"POST", "/api/v1/wafhost/host/edit", "编辑站点"}, + {"GET", "/api/v1/wafhost/host/guardstatus", "修改防护状态"}, + {"GET", "/api/v1/wafhost/host/startstatus", "修改启动状态"}, + + // ── SSL 证书 ─────────────────────────────────────────────────── + {"POST", "/api/v1/sslconfig/add", "新增SSL证书"}, + {"GET", "/api/v1/sslconfig/detail", "获取SSL证书详情"}, + {"POST", "/api/v1/sslconfig/list", "获取SSL证书列表"}, + {"GET", "/api/v1/sslconfig/del", "删除SSL证书"}, + {"POST", "/api/v1/sslconfig/edit", "编辑SSL证书"}, + + // ── SSL 订单 ─────────────────────────────────────────────────── + {"POST", "/api/v1/wafhost/sslorder/add", "新增SSL订单"}, + {"GET", "/api/v1/wafhost/sslorder/detail", "获取SSL订单详情"}, + {"POST", "/api/v1/wafhost/sslorder/list", "获取SSL订单列表"}, + {"GET", "/api/v1/wafhost/sslorder/del", "删除SSL订单"}, + {"POST", "/api/v1/wafhost/sslorder/edit", "编辑SSL订单"}, + + // ── SSL 到期监控 ─────────────────────────────────────────────── + {"POST", "/api/v1/wafhost/sslexpire/add", "新增SSL到期监控"}, + {"GET", "/api/v1/wafhost/sslexpire/detail", "获取SSL到期监控详情"}, + {"POST", "/api/v1/wafhost/sslexpire/list", "获取SSL到期监控列表"}, + {"GET", "/api/v1/wafhost/sslexpire/del", "删除SSL到期监控"}, + {"POST", "/api/v1/wafhost/sslexpire/edit", "编辑SSL到期监控"}, + {"GET", "/api/v1/wafhost/sslexpire/nowcheck", "立即检测SSL到期"}, + {"GET", "/api/v1/wafhost/sslexpire/sync_host", "从站点同步SSL监控"}, + + // ── 隧道 ─────────────────────────────────────────────────────── + {"POST", "/api/v1/tunnel/tunnel/add", "新增隧道"}, + {"GET", "/api/v1/tunnel/tunnel/detail", "获取隧道详情"}, + {"POST", "/api/v1/tunnel/tunnel/list", "获取隧道列表"}, + {"GET", "/api/v1/tunnel/tunnel/del", "删除隧道"}, + {"POST", "/api/v1/tunnel/tunnel/edit", "编辑隧道"}, + {"GET", "/api/v1/tunnel/tunnel/connections", "获取隧道连接数"}, + + // ── 通知渠道 ─────────────────────────────────────────────────── + {"POST", "/api/v1/notify/channel/add", "新增通知渠道"}, + {"GET", "/api/v1/notify/channel/detail", "获取通知渠道详情"}, + {"POST", "/api/v1/notify/channel/list", "获取通知渠道列表"}, + {"GET", "/api/v1/notify/channel/del", "删除通知渠道"}, + {"POST", "/api/v1/notify/channel/edit", "编辑通知渠道"}, + + // ── 通知订阅 ─────────────────────────────────────────────────── + {"POST", "/api/v1/notify/subscription/add", "新增通知订阅"}, + {"POST", "/api/v1/notify/subscription/list", "获取通知订阅列表"}, + {"GET", "/api/v1/notify/subscription/del", "删除通知订阅"}, + + // ── 通知日志 ─────────────────────────────────────────────────── + {"POST", "/api/v1/notify/log/list", "获取通知日志列表"}, + {"GET", "/api/v1/notify/log/detail", "获取通知日志详情"}, + {"GET", "/api/v1/notify/log/del", "删除通知日志"}, + + // ── VIP 配置 ─────────────────────────────────────────────────── + {"POST", "/api/v1/vipconfig/updateIpWhitelist", "更新管理IP白名单"}, + {"GET", "/api/v1/vipconfig/getIpWhitelist", "获取管理IP白名单"}, + {"POST", "/api/v1/vipconfig/updateSslEnable", "更新SSL启用状态"}, + {"GET", "/api/v1/vipconfig/getSslStatus", "获取SSL启用状态"}, + {"GET", "/api/v1/vipconfig/getSecurityEntry", "获取安全入口"}, + {"POST", "/api/v1/vipconfig/updateSecurityEntry", "更新安全入口"}, + + // ── 系统配置 ─────────────────────────────────────────────────── + {"POST", "/api/v1/systemconfig/list", "获取系统配置列表"}, + {"POST", "/api/v1/systemconfig/edit", "更新系统配置"}, + {"POST", "/api/v1/systemconfig/editByItem", "通过item更新系统配置"}, + + // ── 系统监控 ─────────────────────────────────────────────────── + {"GET", "/api/v1/monitor/system_info", "获取系统监控信息"}, + + // ── 统计数据 ─────────────────────────────────────────────────── + {"GET", "/api/v1/wafstatsumday", "获取今日访问统计"}, + {"GET", "/api/v1/wafstatsumdayrange", "按日期范围统计访问量"}, + {"GET", "/api/v1/wafstatsumdaytopiprange", "统计攻击IP排行"}, + {"GET", "/api/v1/statsysinfo", "获取首页系统基本信息"}, + {"GET", "/api/v1/statrumtimesysinfo", "获取运行时系统基本信息"}, + {"GET", "/api/v1/wafstatsiteoverview", "站点综合概览统计"}, + {"GET", "/api/v1/wafstatsitedetail", "站点详情趋势查询"}, + + // ── 系统信息 ─────────────────────────────────────────────────── + {"GET", "/api/v1/sysinfo/version", "获取版本信息"}, + + // ── 系统日志 ─────────────────────────────────────────────────── + {"GET", "/api/v1/sys_log/list", "获取系统日志列表"}, + {"GET", "/api/v1/sys_log/detail", "获取系统日志详情"}, + + // ── 攻击日志 ─────────────────────────────────────────────────── + {"POST", "/api/v1/waflog/attack/list", "获取攻击日志列表"}, + {"GET", "/api/v1/waflog/attack/detail", "获取攻击日志详情"}, + + // ── 日志文件 ─────────────────────────────────────────────────── + {"GET", "/api/v1/logfilewrite/preview", "预览日志文件"}, + {"GET", "/api/v1/logfilewrite/currentfile", "获取当前日志文件"}, + {"GET", "/api/v1/logfilewrite/backupfiles", "获取备份日志文件列表"}, + {"POST", "/api/v1/logfilewrite/clear", "清空日志文件"}, + {"GET", "/api/v1/logfilewrite/variables", "获取日志变量"}, + + // ── WAF 引擎 ─────────────────────────────────────────────────── + {"GET", "/api/v1/resetWAF", "重启WAF引擎"}, +} + +// ───────────────────────────────────────────────────────────────────────────── + +var httpClient = &http.Client{Timeout: 10 * time.Second} + +// sendRequest 发起请求,GET/POST 均带 X-Token,POST body 为空 JSON +func sendRequest(method, url string) (*http.Response, error) { + var body *bytes.Reader + if method == "POST" { + body = bytes.NewReader([]byte("{}")) + } else { + body = bytes.NewReader(nil) + } + + req, err := http.NewRequest(method, url, body) + if err != nil { + return nil, err + } + req.Header.Set("X-API-Key", sk) + req.Header.Set("Content-Type", "application/json") + return httpClient.Do(req) +} + +// TestAllRoutes 逐条验证 @Router 中的路由是否注册可达(非 404) +func TestAllRoutes(t *testing.T) { + if testing.Short() { + t.Skip("跳过集成测试(-short 模式)") + } + + type result struct { + route + status int + err string + passed bool + } + + results := make([]result, 0, len(registeredRoutes)) + failCount := 0 + + for _, r := range registeredRoutes { + url := baseURL + r.path + resp, err := sendRequest(r.method, url) + + res := result{route: r} + if err != nil { + res.err = err.Error() + res.passed = false + } else { + resp.Body.Close() + res.status = resp.StatusCode + res.passed = resp.StatusCode != http.StatusNotFound + } + results = append(results, res) + + if !res.passed { + failCount++ + } + } + + // ── 打印汇总 ────────────────────────────────────────────────── + t.Log(strings.Repeat("─", 80)) + t.Logf("%-6s %-50s %-6s %s", "方法", "路径", "状态", "描述") + t.Log(strings.Repeat("─", 80)) + for _, res := range results { + statusStr := fmt.Sprintf("%d", res.status) + if res.err != "" { + statusStr = "ERR" + } + mark := "✓" + if !res.passed { + mark = "✗" + } + t.Logf("%s %-6s %-50s %-6s %s", mark, res.method, res.path, statusStr, res.desc) + } + t.Log(strings.Repeat("─", 80)) + t.Logf("合计 %d 条,通过 %d 条,失败 %d 条", len(results), len(results)-failCount, failCount) + + if failCount > 0 { + t.Fail() + } +} + +// TestSingleRoute 调试单条路由时使用(修改下面的 method/path 后运行) +func TestSingleRoute(t *testing.T) { + if testing.Short() { + t.Skip("跳过集成测试(-short 模式)") + } + + method := "GET" + path := "/api/v1/sysinfo/version" + + url := baseURL + path + resp, err := sendRequest(method, url) + if err != nil { + t.Fatalf("请求失败: %v", err) + } + defer resp.Body.Close() + + t.Logf("%s %s → HTTP %d", method, url, resp.StatusCode) + if resp.StatusCode == http.StatusNotFound { + t.Errorf("路由不存在 (404)") + } +} diff --git a/test/apicheck/readme.md b/test/apicheck/readme.md new file mode 100644 index 0000000..8f9f529 --- /dev/null +++ b/test/apicheck/readme.md @@ -0,0 +1,172 @@ +# api 可行性测试 + + +``` +go test -v -run TestAllRoutes ./test/apicheck/ + +``` + +# 测试结果 + +``` + +C:\huawei\goproject\SamWaf>go test -v -run TestAllRoutes ./test/apicheck/ +=== RUN TestAllRoutes + api_routes_test.go:317: ──────────────────────────────────────────────────────────────────────────────── + api_routes_test.go:318: 方法 路径 状态 描述 + api_routes_test.go:319: ──────────────────────────────────────────────────────────────────────────────── + api_routes_test.go:329: ✓ POST /api/v1/wafhost/ipwhite/add 200 新增IP白名单 + api_routes_test.go:329: ✓ GET /api/v1/wafhost/ipwhite/detail 200 获取IP白名单详情 + api_routes_test.go:329: ✓ POST /api/v1/wafhost/ipwhite/list 200 获取IP白名单列表 + api_routes_test.go:329: ✓ GET /api/v1/wafhost/ipwhite/del 200 删除IP白名单 + api_routes_test.go:329: ✓ POST /api/v1/wafhost/ipwhite/edit 200 编辑IP白名单 + api_routes_test.go:329: ✓ POST /api/v1/wafhost/urlwhite/add 200 新增URL白名单 + api_routes_test.go:329: ✓ GET /api/v1/wafhost/urlwhite/detail 200 获取URL白名单详情 + api_routes_test.go:329: ✓ POST /api/v1/wafhost/urlwhite/list 200 获取URL白名单列表 + api_routes_test.go:329: ✓ GET /api/v1/wafhost/urlwhite/del 200 删除URL白名单 + api_routes_test.go:329: ✓ POST /api/v1/wafhost/urlwhite/edit 200 编辑URL白名单 + api_routes_test.go:329: ✓ POST /api/v1/wafhost/ipblock/add 200 新增IP黑名单 + api_routes_test.go:329: ✓ GET /api/v1/wafhost/ipblock/detail 200 获取IP黑名单详情 + api_routes_test.go:329: ✓ POST /api/v1/wafhost/ipblock/list 200 获取IP黑名单列表 + api_routes_test.go:329: ✓ GET /api/v1/wafhost/ipblock/del 200 删除IP黑名单 + api_routes_test.go:329: ✓ POST /api/v1/wafhost/ipblock/edit 200 编辑IP黑名单 + api_routes_test.go:329: ✓ POST /api/v1/wafhost/urlblock/add 200 新增URL黑名单 + api_routes_test.go:329: ✓ GET /api/v1/wafhost/urlblock/detail 200 获取URL黑名单详情 + api_routes_test.go:329: ✓ POST /api/v1/wafhost/urlblock/list 200 获取URL黑名单列表 + api_routes_test.go:329: ✓ GET /api/v1/wafhost/urlblock/del 200 删除URL黑名单 + api_routes_test.go:329: ✓ POST /api/v1/wafhost/urlblock/edit 200 编辑URL黑名单 + api_routes_test.go:329: ✓ POST /api/v1/wafhost/anticc/add 200 新增Anti-CC规则 + api_routes_test.go:329: ✓ GET /api/v1/wafhost/anticc/detail 200 获取Anti-CC规则详情 + api_routes_test.go:329: ✓ POST /api/v1/wafhost/anticc/list 200 获取Anti-CC规则列表 + api_routes_test.go:329: ✓ GET /api/v1/wafhost/anticc/del 200 删除Anti-CC规则 + api_routes_test.go:329: ✓ POST /api/v1/wafhost/anticc/edit 200 编辑Anti-CC规则 + api_routes_test.go:329: ✓ GET /api/v1/wafhost/ipfailure/config 200 获取IP失败封禁配置 + api_routes_test.go:329: ✓ POST /api/v1/wafhost/ipfailure/config 200 设置IP失败封禁配置 + api_routes_test.go:329: ✓ GET /api/v1/wafhost/ipfailure/baniplist 200 获取IP失败封禁列表 + api_routes_test.go:329: ✓ POST /api/v1/firewall/ipblock/add 200 新增防火墙IP封禁 + api_routes_test.go:329: ✓ POST /api/v1/firewall/ipblock/list 200 获取防火墙IP封禁列表 + api_routes_test.go:329: ✓ GET /api/v1/firewall/ipblock/del 200 删除防火墙IP封禁 + api_routes_test.go:329: ✓ POST /api/v1/firewall/ipblock/edit 200 编辑防火墙IP封禁 + api_routes_test.go:329: ✓ POST /api/v1/wafhost/rule/add 200 新增WAF规则 + api_routes_test.go:329: ✓ GET /api/v1/wafhost/rule/detail 200 获取WAF规则详情 + api_routes_test.go:329: ✓ POST /api/v1/wafhost/rule/list 200 获取WAF规则列表 + api_routes_test.go:329: ✓ GET /api/v1/wafhost/rule/del 200 删除WAF规则 + api_routes_test.go:329: ✓ POST /api/v1/wafhost/rule/edit 200 编辑WAF规则 + api_routes_test.go:329: ✓ GET /api/v1/wafhost/rule/rulestatus 200 修改WAF规则状态 + api_routes_test.go:329: ✓ POST /api/v1/wafhost/sensitive/add 200 新增敏感词 + api_routes_test.go:329: ✓ GET /api/v1/wafhost/sensitive/detail 200 获取敏感词详情 + api_routes_test.go:329: ✓ POST /api/v1/wafhost/sensitive/list 200 获取敏感词列表 + api_routes_test.go:329: ✓ GET /api/v1/wafhost/sensitive/del 200 删除敏感词 + api_routes_test.go:329: ✓ POST /api/v1/wafhost/sensitive/edit 200 编辑敏感词 + api_routes_test.go:329: ✓ POST /api/v1/wafhost/cacherule/add 200 新增缓存规则 + api_routes_test.go:329: ✓ GET /api/v1/wafhost/cacherule/detail 200 获取缓存规则详情 + api_routes_test.go:329: ✓ POST /api/v1/wafhost/cacherule/list 200 获取缓存规则列表 + api_routes_test.go:329: ✓ GET /api/v1/wafhost/cacherule/del 200 删除缓存规则 + api_routes_test.go:329: ✓ POST /api/v1/wafhost/cacherule/edit 200 编辑缓存规则 + api_routes_test.go:329: ✓ POST /api/v1/wafhost/loadbalance/add 200 新增负载均衡 + api_routes_test.go:329: ✓ GET /api/v1/wafhost/loadbalance/detail 200 获取负载均衡详情 + api_routes_test.go:329: ✓ POST /api/v1/wafhost/loadbalance/list 200 获取负载均衡列表 + api_routes_test.go:329: ✓ GET /api/v1/wafhost/loadbalance/del 200 删除负载均衡 + api_routes_test.go:329: ✓ POST /api/v1/wafhost/loadbalance/edit 200 编辑负载均衡 + api_routes_test.go:329: ✓ GET /api/v1/wafhost/onekeymod/detail 200 获取一键修改详情 + api_routes_test.go:329: ✓ POST /api/v1/wafhost/onekeymod/list 200 获取一键修改列表 + api_routes_test.go:329: ✓ GET /api/v1/wafhost/onekeymod/del 200 删除一键修改 + api_routes_test.go:329: ✓ POST /api/v1/wafhost/onekeymod/doModify 200 执行一键修改 + api_routes_test.go:329: ✓ GET /api/v1/wafhost/onekeymod/restore 200 还原一键修改 + api_routes_test.go:329: ✓ POST /api/v1/wafhost/task/add 200 新增任务 + api_routes_test.go:329: ✓ GET /api/v1/wafhost/task/detail 200 获取任务详情 + api_routes_test.go:329: ✓ POST /api/v1/wafhost/task/list 200 获取任务列表 + api_routes_test.go:329: ✓ GET /api/v1/wafhost/task/del 200 删除任务 + api_routes_test.go:329: ✓ POST /api/v1/wafhost/task/edit 200 编辑任务 + api_routes_test.go:329: ✓ GET /api/v1/wafhost/task/manual_exec 200 手动执行任务 + api_routes_test.go:329: ✓ GET /api/v1/wafhost/task/log 200 获取任务日志 + api_routes_test.go:329: ✓ GET /api/v1/wafhost/task/log/clear 200 清空任务日志 + api_routes_test.go:329: ✓ POST /api/v1/wafhost/dataretention/list 200 获取数据保留策略列表 + api_routes_test.go:329: ✓ GET /api/v1/wafhost/dataretention/detail 200 获取数据保留策略详情 + api_routes_test.go:329: ✓ POST /api/v1/wafhost/dataretention/edit 200 编辑数据保留策略 + api_routes_test.go:329: ✓ POST /api/v1/wafhost/privateinfo/add 200 新增私有信息 + api_routes_test.go:329: ✓ GET /api/v1/wafhost/privateinfo/detail 200 获取私有信息详情 + api_routes_test.go:329: ✓ POST /api/v1/wafhost/privateinfo/list 200 获取私有信息列表 + api_routes_test.go:329: ✓ GET /api/v1/wafhost/privateinfo/del 200 删除私有信息 + api_routes_test.go:329: ✓ POST /api/v1/wafhost/privateinfo/edit 200 编辑私有信息 + api_routes_test.go:329: ✓ POST /api/v1/wafhost/privategroup/add 200 新增私有分组 + api_routes_test.go:329: ✓ GET /api/v1/wafhost/privategroup/detail 200 获取私有分组详情 + api_routes_test.go:329: ✓ POST /api/v1/wafhost/privategroup/list 200 获取私有分组列表 + api_routes_test.go:329: ✓ POST /api/v1/wafhost/privategroup/listbybelongcloud 200 按云获取私有分组列表 + api_routes_test.go:329: ✓ GET /api/v1/wafhost/privategroup/del 200 删除私有分组 + api_routes_test.go:329: ✓ POST /api/v1/wafhost/privategroup/edit 200 编辑私有分组 + api_routes_test.go:329: ✓ POST /api/v1/wafhost/host/add 200 新增站点 + api_routes_test.go:329: ✓ GET /api/v1/wafhost/host/detail 200 获取站点详情 + api_routes_test.go:329: ✓ POST /api/v1/wafhost/host/list 200 获取站点列表 + api_routes_test.go:329: ✓ GET /api/v1/wafhost/host/del 200 删除站点 + api_routes_test.go:329: ✓ POST /api/v1/wafhost/host/edit 200 编辑站点 + api_routes_test.go:329: ✓ GET /api/v1/wafhost/host/guardstatus 200 修改防护状态 + api_routes_test.go:329: ✓ GET /api/v1/wafhost/host/startstatus 200 修改启动状态 + api_routes_test.go:329: ✓ POST /api/v1/sslconfig/add 200 新增SSL证书 + api_routes_test.go:329: ✓ GET /api/v1/sslconfig/detail 200 获取SSL证书详情 + api_routes_test.go:329: ✓ POST /api/v1/sslconfig/list 200 获取SSL证书列表 + api_routes_test.go:329: ✓ GET /api/v1/sslconfig/del 200 删除SSL证书 + api_routes_test.go:329: ✓ POST /api/v1/sslconfig/edit 200 编辑SSL证书 + api_routes_test.go:329: ✓ POST /api/v1/wafhost/sslorder/add 200 新增SSL订单 + api_routes_test.go:329: ✓ GET /api/v1/wafhost/sslorder/detail 200 获取SSL订单详情 + api_routes_test.go:329: ✓ POST /api/v1/wafhost/sslorder/list 200 获取SSL订单列表 + api_routes_test.go:329: ✓ GET /api/v1/wafhost/sslorder/del 200 删除SSL订单 + api_routes_test.go:329: ✓ POST /api/v1/wafhost/sslorder/edit 200 编辑SSL订单 + api_routes_test.go:329: ✓ POST /api/v1/wafhost/sslexpire/add 200 新增SSL到期监控 + api_routes_test.go:329: ✓ GET /api/v1/wafhost/sslexpire/detail 200 获取SSL到期监控详情 + api_routes_test.go:329: ✓ POST /api/v1/wafhost/sslexpire/list 200 获取SSL到期监控列表 + api_routes_test.go:329: ✓ GET /api/v1/wafhost/sslexpire/del 200 删除SSL到期监控 + api_routes_test.go:329: ✓ POST /api/v1/wafhost/sslexpire/edit 200 编辑SSL到期监控 + api_routes_test.go:329: ✓ GET /api/v1/wafhost/sslexpire/nowcheck 200 立即检测SSL到期 + api_routes_test.go:329: ✓ GET /api/v1/wafhost/sslexpire/sync_host 200 从站点同步SSL监控 + api_routes_test.go:329: ✓ POST /api/v1/tunnel/tunnel/add 200 新增隧道 + api_routes_test.go:329: ✓ GET /api/v1/tunnel/tunnel/detail 200 获取隧道详情 + api_routes_test.go:329: ✓ POST /api/v1/tunnel/tunnel/list 200 获取隧道列表 + api_routes_test.go:329: ✓ GET /api/v1/tunnel/tunnel/del 200 删除隧道 + api_routes_test.go:329: ✓ POST /api/v1/tunnel/tunnel/edit 200 编辑隧道 + api_routes_test.go:329: ✓ GET /api/v1/tunnel/tunnel/connections 200 获取隧道连接数 + api_routes_test.go:329: ✓ POST /api/v1/notify/channel/add 200 新增通知渠道 + api_routes_test.go:329: ✓ GET /api/v1/notify/channel/detail 200 获取通知渠道详情 + api_routes_test.go:329: ✓ POST /api/v1/notify/channel/list 200 获取通知渠道列表 + api_routes_test.go:329: ✓ GET /api/v1/notify/channel/del 200 删除通知渠道 + api_routes_test.go:329: ✓ POST /api/v1/notify/channel/edit 200 编辑通知渠道 + api_routes_test.go:329: ✓ POST /api/v1/notify/subscription/add 200 新增通知订阅 + api_routes_test.go:329: ✓ POST /api/v1/notify/subscription/list 200 获取通知订阅列表 + api_routes_test.go:329: ✓ GET /api/v1/notify/subscription/del 200 删除通知订阅 + api_routes_test.go:329: ✓ POST /api/v1/notify/log/list 200 获取通知日志列表 + api_routes_test.go:329: ✓ GET /api/v1/notify/log/detail 200 获取通知日志详情 + api_routes_test.go:329: ✓ GET /api/v1/notify/log/del 200 删除通知日志 + api_routes_test.go:329: ✓ POST /api/v1/vipconfig/updateIpWhitelist 200 更新管理IP白名单 + api_routes_test.go:329: ✓ GET /api/v1/vipconfig/getIpWhitelist 200 获取管理IP白名单 + api_routes_test.go:329: ✓ POST /api/v1/vipconfig/updateSslEnable 200 更新SSL启用状态 + api_routes_test.go:329: ✓ GET /api/v1/vipconfig/getSslStatus 200 获取SSL启用状态 + api_routes_test.go:329: ✓ GET /api/v1/vipconfig/getSecurityEntry 200 获取安全入口 + api_routes_test.go:329: ✓ POST /api/v1/vipconfig/updateSecurityEntry 200 更新安全入口 + api_routes_test.go:329: ✓ POST /api/v1/systemconfig/list 200 获取系统配置列表 + api_routes_test.go:329: ✓ POST /api/v1/systemconfig/edit 200 更新系统配置 + api_routes_test.go:329: ✓ POST /api/v1/systemconfig/editByItem 200 通过item更新系统配置 + api_routes_test.go:329: ✓ GET /api/v1/monitor/system_info 200 获取系统监控信息 + api_routes_test.go:329: ✓ GET /api/v1/wafstatsumday 200 获取今日访问统计 + api_routes_test.go:329: ✓ GET /api/v1/wafstatsumdayrange 200 按日期范围统计访问量 + api_routes_test.go:329: ✓ GET /api/v1/wafstatsumdaytopiprange 200 统计攻击IP排行 + api_routes_test.go:329: ✓ GET /api/v1/statsysinfo 200 获取首页系统基本信息 + api_routes_test.go:329: ✓ GET /api/v1/statrumtimesysinfo 200 获取运行时系统基本信息 + api_routes_test.go:329: ✓ GET /api/v1/wafstatsiteoverview 200 站点综合概览统计 + api_routes_test.go:329: ✓ GET /api/v1/wafstatsitedetail 200 站点详情趋势查询 + api_routes_test.go:329: ✓ GET /api/v1/sysinfo/version 200 获取版本信息 + api_routes_test.go:329: ✓ GET /api/v1/sys_log/list 200 获取系统日志列表 + api_routes_test.go:329: ✓ GET /api/v1/sys_log/detail 200 获取系统日志详情 + api_routes_test.go:329: ✓ POST /api/v1/waflog/attack/list 200 获取攻击日志列表 + api_routes_test.go:329: ✓ GET /api/v1/waflog/attack/detail 200 获取攻击日志详情 + api_routes_test.go:329: ✓ GET /api/v1/logfilewrite/preview 200 预览日志文件 + api_routes_test.go:329: ✓ GET /api/v1/logfilewrite/currentfile 200 获取当前日志文件 + api_routes_test.go:329: ✓ GET /api/v1/logfilewrite/backupfiles 200 获取备份日志文件列表 + api_routes_test.go:329: ✓ POST /api/v1/logfilewrite/clear 200 清空日志文件 + api_routes_test.go:329: ✓ GET /api/v1/logfilewrite/variables 200 获取日志变量 + api_routes_test.go:329: ✓ GET /api/v1/resetWAF 200 重启WAF引擎 + api_routes_test.go:331: ──────────────────────────────────────────────────────────────────────────────── + api_routes_test.go:332: 合计 149 条,通过 149 条,失败 0 条 +--- PASS: TestAllRoutes (0.12s) +PASS +ok SamWaf/test/apicheck 1.273s +``` \ No newline at end of file