defaultroute_test.go 852 B

1234567891011121314151617181920212223242526272829
  1. package adapters
  2. import (
  3. "testing"
  4. "github.com/gnacho/netpulse/agent/probe"
  5. )
  6. // #1791: el siguiente salto WAN del gateway no es un cliente LAN. Su MAC
  7. // aparece en ARP y, sin este filtro, buildDevices la publica como un
  8. // dispositivo desconocido.
  9. func TestBuildDevicesAbsorbsDefaultRoute(t *testing.T) {
  10. l := NewLive(nil, nil, nil, nil)
  11. polled := map[string]*routerPolled{
  12. "gw": {
  13. cfg: RouterConfig{ID: "gw", IsGateway: true},
  14. wanInfo: probe.WanInfo{Gateway: "192.168.2.1"},
  15. arp: map[string]string{
  16. "04:F4:1C:F3:46:65": "192.168.2.1", // siguiente salto WAN
  17. "AA:BB:CC:00:00:09": "192.168.1.50", // cliente real
  18. },
  19. arpStale: map[string]bool{},
  20. },
  21. }
  22. devs := l.buildDevices(polled, "")
  23. if len(devs) != 1 || devs[0].MAC != "AA:BB:CC:00:00:09" {
  24. t.Fatalf("devices: %+v, want solo el cliente real", devs)
  25. }
  26. }