Files
opsx-vpn/backend/internal/service/gre/gre_test.go
T
opsx ef7eb378d2 feat: 新增 GRE 隧道协议,管理端口调整为 18080
- backend: 新增 GRE 隧道实现(ip tunnel 点对点互联),binmgr 支持 iproute2
- backend: api/identity 调整,各协议 service(gre/ikev2/ipsec/l2tp/openvpn)统一改动
- backend: OpenVPN 认证辅助与用户口令同步逻辑完善
- frontend: 协议图标/向导/编辑器支持 GRE,VPN 用户页重构(234 行)
- frontend: 新增 RouteListInput 路由列表输入组件,Dashboard/Layout 优化
- i18n: 中英文文案同步更新
- test: 新增 binmgr/common/gre 单测,openvpn 测试补充
- docs: README 补充 GRE 说明,默认监听端口 8080 → 18080
- chore: .gitignore 增加 opsx-vpn.previous(构建备份二进制)
2026-10-20 20:58:58 +08:00

32 lines
803 B
Go

package gre
import "testing"
func TestValidateGRE(t *testing.T) {
cfg, err := New().Validate(map[string]interface{}{
"local_endpoint": "198.51.100.10",
"remote_endpoint": "203.0.113.20",
"local_tunnel_ip": "10.255.0.1/30",
"remote_tunnel_ip": "10.255.0.2/30",
"remote_subnet": "192.168.10.0/24",
})
if err != nil {
t.Fatal(err)
}
if cfg["ttl"] != 255 || cfg["mtu"] != 1476 {
t.Fatalf("defaults not applied: %#v", cfg)
}
}
func TestValidateGRERejectsDifferentTunnelNetworks(t *testing.T) {
_, err := New().Validate(map[string]interface{}{
"local_endpoint": "198.51.100.10",
"remote_endpoint": "203.0.113.20",
"local_tunnel_ip": "10.255.0.1/30",
"remote_tunnel_ip": "10.255.1.2/30",
})
if err == nil {
t.Fatal("expected tunnel subnet validation error")
}
}