@@ -50,30 +50,30 @@ def collector(system_info, conn_mock):
5050 )
5151
5252
53- # Sample command outputs for testing
54- IP_ADDR_OUTPUT = """1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
53+ # Sample command outputs for testing (mock data)
54+ IP_ADDR_OUTPUT = """1: lo: <LOOPBACK,UP,LOWER_UP> mtu 12345 qdisc noqueue state UNKNOWN group default qlen 1000
5555 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
5656 inet 127.0.0.1/8 scope host lo
5757 valid_lft forever preferred_lft forever
5858 inet6 ::1/128 scope host
5959 valid_lft forever preferred_lft forever
60- 2: enp129s0 : <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
61- link/ether 00:40:a6:96:d7:5a brd ff:ff:ff:ff:ff:ff
62- inet 10.228.152.67/22 brd 10.228.155 .255 scope global noprefixroute enp129s0
60+ 2: eth0 : <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 5678 qdisc mq state UP group default qlen 1000
61+ link/ether aa:bb:cc:dd:ee:ff brd ff:ff:ff:ff:ff:ff
62+ inet 1.123.123.100/24 brd 1.123.123 .255 scope global noprefixroute eth0
6363 valid_lft forever preferred_lft forever
64- inet6 fe80::240:a6ff:fe96:d75a /64 scope link
64+ inet6 fe80::aabb:ccff /64 scope link
6565 valid_lft forever preferred_lft forever"""
6666
67- IP_ROUTE_OUTPUT = """default via 10.228.152 .1 dev enp129s0 proto static metric 100
68- 10.228.152 .0/22 dev enp129s0 proto kernel scope link src 10.228.152.67 metric 100
69- 172.17 .0.0/16 dev docker0 proto kernel scope link src 172.17 .0.1 linkdown"""
67+ IP_ROUTE_OUTPUT = """default via 2.123.123 .1 dev eth0 proto static metric 100
68+ 2.123.123 .0/24 dev eth0 proto kernel scope link src 2.123.123.100 metric 100
69+ 7.8 .0.0/16 dev docker0 proto kernel scope link src 7.8 .0.1 linkdown"""
7070
7171IP_RULE_OUTPUT = """0: from all lookup local
72- 32766 : from all lookup main
73- 32767 : from all lookup default"""
72+ 89145 : from all lookup main
73+ 56789 : from all lookup default"""
7474
75- IP_NEIGHBOR_OUTPUT = """10.228.152.44 dev enp129s0 lladdr 00:50:56:b4:ed:cc STALE
76- 10.228.152 .1 dev enp129s0 lladdr 64:3a:ea:74:e6:bf REACHABLE"""
75+ IP_NEIGHBOR_OUTPUT = """50.50.1.50 dev eth0 lladdr 11:22:33:44:55:66 STALE
76+ 50.50.1 .1 dev eth0 lladdr 99:88:77:66:55:44 REACHABLE"""
7777
7878
7979def test_parse_ip_addr_loopback (collector ):
@@ -85,7 +85,7 @@ def test_parse_ip_addr_loopback(collector):
8585 assert lo is not None
8686 assert lo .index == 1
8787 assert lo .state == "UNKNOWN"
88- assert lo .mtu == 65536
88+ assert lo .mtu == 12345
8989 assert lo .qdisc == "noqueue"
9090 assert lo .mac_address == "00:00:00:00:00:00"
9191 assert "LOOPBACK" in lo .flags
@@ -105,22 +105,22 @@ def test_parse_ip_addr_ethernet(collector):
105105 interfaces = collector ._parse_ip_addr (IP_ADDR_OUTPUT )
106106
107107 # Find ethernet interface
108- eth = next ((i for i in interfaces if i .name == "enp129s0 " ), None )
108+ eth = next ((i for i in interfaces if i .name == "eth0 " ), None )
109109 assert eth is not None
110110 assert eth .index == 2
111111 assert eth .state == "UP"
112- assert eth .mtu == 1500
112+ assert eth .mtu == 5678
113113 assert eth .qdisc == "mq"
114- assert eth .mac_address == "00:40:a6:96:d7:5a "
114+ assert eth .mac_address == "aa:bb:cc:dd:ee:ff "
115115 assert "BROADCAST" in eth .flags
116116 assert "MULTICAST" in eth .flags
117117
118118 # Check IPv4 address
119119 ipv4 = next ((a for a in eth .addresses if a .family == "inet" ), None )
120120 assert ipv4 is not None
121- assert ipv4 .address == "10.228.152.67 "
122- assert ipv4 .prefix_len == 22
123- assert ipv4 .broadcast == "10.228.155 .255"
121+ assert ipv4 .address == "1.123.123.100 "
122+ assert ipv4 .prefix_len == 24
123+ assert ipv4 .broadcast == "1.123.123 .255"
124124 assert ipv4 .scope == "global"
125125
126126
@@ -131,8 +131,8 @@ def test_parse_ip_route_default(collector):
131131 # Find default route
132132 default_route = next ((r for r in routes if r .destination == "default" ), None )
133133 assert default_route is not None
134- assert default_route .gateway == "10.228.152 .1"
135- assert default_route .device == "enp129s0 "
134+ assert default_route .gateway == "2.123.123 .1"
135+ assert default_route .device == "eth0 "
136136 assert default_route .protocol == "static"
137137 assert default_route .metric == 100
138138
@@ -142,13 +142,13 @@ def test_parse_ip_route_network(collector):
142142 routes = collector ._parse_ip_route (IP_ROUTE_OUTPUT )
143143
144144 # Find network route
145- net_route = next ((r for r in routes if r .destination == "10.228.152 .0/22 " ), None )
145+ net_route = next ((r for r in routes if r .destination == "2.123.123 .0/24 " ), None )
146146 assert net_route is not None
147147 assert net_route .gateway is None # Direct route, no gateway
148- assert net_route .device == "enp129s0 "
148+ assert net_route .device == "eth0 "
149149 assert net_route .protocol == "kernel"
150150 assert net_route .scope == "link"
151- assert net_route .source == "10.228.152.67 "
151+ assert net_route .source == "2.123.123.100 "
152152 assert net_route .metric == 100
153153
154154
@@ -157,13 +157,13 @@ def test_parse_ip_route_docker(collector):
157157 routes = collector ._parse_ip_route (IP_ROUTE_OUTPUT )
158158
159159 # Find docker route
160- docker_route = next ((r for r in routes if r .destination == "172.17 .0.0/16" ), None )
160+ docker_route = next ((r for r in routes if r .destination == "7.8 .0.0/16" ), None )
161161 assert docker_route is not None
162162 assert docker_route .gateway is None
163163 assert docker_route .device == "docker0"
164164 assert docker_route .protocol == "kernel"
165165 assert docker_route .scope == "link"
166- assert docker_route .source == "172.17 .0.1"
166+ assert docker_route .source == "7.8 .0.1"
167167
168168
169169def test_parse_ip_rule_basic (collector ):
@@ -181,12 +181,12 @@ def test_parse_ip_rule_basic(collector):
181181 assert local_rule .action == "lookup"
182182
183183 # Check main rule
184- main_rule = next ((r for r in rules if r .priority == 32766 ), None )
184+ main_rule = next ((r for r in rules if r .priority == 89145 ), None )
185185 assert main_rule is not None
186186 assert main_rule .table == "main"
187187
188188 # Check default rule
189- default_rule = next ((r for r in rules if r .priority == 32767 ), None )
189+ default_rule = next ((r for r in rules if r .priority == 56789 ), None )
190190 assert default_rule is not None
191191 assert default_rule .table == "default"
192192
@@ -218,9 +218,9 @@ def test_parse_ip_neighbor_reachable(collector):
218218 # Check REACHABLE neighbor
219219 reachable = next ((n for n in neighbors if n .state == "REACHABLE" ), None )
220220 assert reachable is not None
221- assert reachable .ip_address == "10.228.152 .1"
222- assert reachable .device == "enp129s0 "
223- assert reachable .mac_address == "64:3a:ea:74:e6:bf "
221+ assert reachable .ip_address == "50.50.1 .1"
222+ assert reachable .device == "eth0 "
223+ assert reachable .mac_address == "99:88:77:66:55:44 "
224224 assert reachable .state == "REACHABLE"
225225
226226
@@ -231,9 +231,9 @@ def test_parse_ip_neighbor_stale(collector):
231231 # Check STALE neighbor
232232 stale = next ((n for n in neighbors if n .state == "STALE" ), None )
233233 assert stale is not None
234- assert stale .ip_address == "10.228.152.44 "
235- assert stale .device == "enp129s0 "
236- assert stale .mac_address == "00:50:56:b4:ed:cc "
234+ assert stale .ip_address == "50.50.1.50 "
235+ assert stale .device == "eth0 "
236+ assert stale .mac_address == "11:22:33:44:55:66 "
237237 assert stale .state == "STALE"
238238
239239
@@ -395,16 +395,16 @@ def test_network_data_model_creation(collector):
395395 name = "eth0" ,
396396 index = 1 ,
397397 state = "UP" ,
398- mtu = 1500 ,
399- addresses = [IpAddress (address = "192.168.1 .100" , prefix_len = 24 , family = "inet" )],
398+ mtu = 5678 ,
399+ addresses = [IpAddress (address = "1.123.123 .100" , prefix_len = 24 , family = "inet" )],
400400 )
401401
402- route = Route (destination = "default" , gateway = "192.168.1 .1" , device = "eth0" )
402+ route = Route (destination = "default" , gateway = "2.123.123 .1" , device = "eth0" )
403403
404- rule = RoutingRule (priority = 100 , source = "192.168.1 .0/24" , table = "main" )
404+ rule = RoutingRule (priority = 100 , source = "1.123.123 .0/24" , table = "main" )
405405
406406 neighbor = Neighbor (
407- ip_address = "192.168 .1.1" , device = "eth0" , mac_address = "11:22:33:44:55:66" , state = "REACHABLE"
407+ ip_address = "50.50 .1.1" , device = "eth0" , mac_address = "11:22:33:44:55:66" , state = "REACHABLE"
408408 )
409409
410410 data = NetworkDataModel (
0 commit comments