github.com/TeaOSLab/EdgeNode@v1.3.8/internal/waf/waf_manager_test.go (about)

     1  package waf_test
     2  
     3  import (
     4  	"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/firewallconfigs"
     5  	"github.com/TeaOSLab/EdgeNode/internal/waf"
     6  	"github.com/iwind/TeaGo/logs"
     7  	"testing"
     8  )
     9  
    10  func TestWAFManager_convert(t *testing.T) {
    11  	p := &firewallconfigs.HTTPFirewallPolicy{
    12  		Id:   1,
    13  		IsOn: true,
    14  		Inbound: &firewallconfigs.HTTPFirewallInboundConfig{
    15  			IsOn: true,
    16  			Groups: []*firewallconfigs.HTTPFirewallRuleGroup{
    17  				{
    18  					Id: 1,
    19  					Sets: []*firewallconfigs.HTTPFirewallRuleSet{
    20  						{
    21  							Id: 1,
    22  						},
    23  						{
    24  							Id: 2,
    25  							Rules: []*firewallconfigs.HTTPFirewallRule{
    26  								{
    27  									Id: 1,
    28  								},
    29  								{
    30  									Id: 2,
    31  								},
    32  							},
    33  						},
    34  					},
    35  				},
    36  			},
    37  		},
    38  	}
    39  	w, err := waf.SharedWAFManager.ConvertWAF(p)
    40  	if err != nil {
    41  		t.Fatal(err)
    42  	}
    43  
    44  	logs.PrintAsJSON(w, t)
    45  }