package services import ( "net" "testing" ) func TestIpEsInterna(t *testing.T) { casos := []struct { ip string interna bool }{ {"127.0.0.1", true}, {"::1", true}, {"10.0.0.5", true}, {"172.16.0.5", true}, {"192.168.1.1", true}, {"169.254.1.1", true}, // link-local, típico de metadata de cloud (169.254.169.254) {"0.0.0.0", true}, {"8.8.8.8", false}, {"1.1.1.1", false}, {"93.184.216.34", false}, } for _, c := range casos { ip := net.ParseIP(c.ip) if ip == nil { t.Fatalf("IP de prueba inválida: %s", c.ip) } if got := ipEsInterna(ip); got != c.interna { t.Errorf("ipEsInterna(%s) = %v, esperaba %v", c.ip, got, c.interna) } } } func TestValidarURLTool(t *testing.T) { if _, err := validarURLTool("http://ejemplo.com/webhook"); err == nil { t.Error("esperaba error para URL http (no https)") } if _, err := validarURLTool("https://"); err == nil { t.Error("esperaba error para URL sin host") } if _, err := validarURLTool("no-es-una-url"); err == nil { t.Error("esperaba error para URL sin esquema") } if _, err := validarURLTool("https://ejemplo.com/webhook"); err != nil { t.Errorf("no esperaba error para URL https válida: %v", err) } }