mirror of
				https://github.com/TeaOSLab/EdgeNode.git
				synced 2025-11-04 16:00:25 +08:00 
			
		
		
		
	
		
			
	
	
		
			45 lines
		
	
	
		
			771 B
		
	
	
	
		
			Go
		
	
	
	
	
	
		
		
			
		
	
	
			45 lines
		
	
	
		
			771 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| 
								 | 
							
								package nodes
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								import (
							 | 
						||
| 
								 | 
							
									"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/firewallconfigs"
							 | 
						||
| 
								 | 
							
									"github.com/iwind/TeaGo/logs"
							 | 
						||
| 
								 | 
							
									"testing"
							 | 
						||
| 
								 | 
							
								)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								func TestWAFManager_convert(t *testing.T) {
							 | 
						||
| 
								 | 
							
									p := &firewallconfigs.HTTPFirewallPolicy{
							 | 
						||
| 
								 | 
							
										Id:   1,
							 | 
						||
| 
								 | 
							
										IsOn: true,
							 | 
						||
| 
								 | 
							
										Inbound: &firewallconfigs.HTTPFirewallInboundConfig{
							 | 
						||
| 
								 | 
							
											IsOn: true,
							 | 
						||
| 
								 | 
							
											Groups: []*firewallconfigs.HTTPFirewallRuleGroup{
							 | 
						||
| 
								 | 
							
												{
							 | 
						||
| 
								 | 
							
													Id: 1,
							 | 
						||
| 
								 | 
							
													Sets: []*firewallconfigs.HTTPFirewallRuleSet{
							 | 
						||
| 
								 | 
							
														{
							 | 
						||
| 
								 | 
							
															Id: 1,
							 | 
						||
| 
								 | 
							
														},
							 | 
						||
| 
								 | 
							
														{
							 | 
						||
| 
								 | 
							
															Id: 2,
							 | 
						||
| 
								 | 
							
															Rules: []*firewallconfigs.HTTPFirewallRule{
							 | 
						||
| 
								 | 
							
																{
							 | 
						||
| 
								 | 
							
																	Id: 1,
							 | 
						||
| 
								 | 
							
																},
							 | 
						||
| 
								 | 
							
																{
							 | 
						||
| 
								 | 
							
																	Id: 2,
							 | 
						||
| 
								 | 
							
																},
							 | 
						||
| 
								 | 
							
															},
							 | 
						||
| 
								 | 
							
														},
							 | 
						||
| 
								 | 
							
													},
							 | 
						||
| 
								 | 
							
												},
							 | 
						||
| 
								 | 
							
											},
							 | 
						||
| 
								 | 
							
										},
							 | 
						||
| 
								 | 
							
									}
							 | 
						||
| 
								 | 
							
									w, err := sharedWAFManager.convertWAF(p)
							 | 
						||
| 
								 | 
							
									if err != nil {
							 | 
						||
| 
								 | 
							
										t.Fatal(err)
							 | 
						||
| 
								 | 
							
									}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
									logs.PrintAsJSON(w, t)
							 | 
						||
| 
								 | 
							
								}
							 |