Skip to content

Commit 7c07e9d

Browse files
author
Ritwick DSouza
committed
[raspbian] Added tests for dhcp interface static routes
1 parent 65f4a9b commit 7c07e9d

1 file changed

Lines changed: 68 additions & 4 deletions

File tree

tests/raspbian/test_routes.py

Lines changed: 68 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ def test_ipv4_manual_route(self):
1818
{
1919
"device": "eth0",
2020
"destination": "192.168.4.1/24",
21-
"next": "192.168.2.2",
22-
"cost": 2,
21+
"next": "192.168.2.2"
2322
},
2423
]
2524
})
@@ -54,8 +53,7 @@ def test_ipv4_static_route(self):
5453
{
5554
"device": "eth0",
5655
"destination": "192.168.4.1/24",
57-
"next": "192.168.2.2",
58-
"cost": 2,
56+
"next": "192.168.2.2"
5957
},
6058
]
6159
})
@@ -69,6 +67,39 @@ def test_ipv4_static_route(self):
6967
post-up route add -net 192.168.4.1 netmask 255.255.255.0 gw 192.168.2.2
7068
pre-up route del -net 192.168.4.1 netmask 255.255.255.0 gw 192.168.2.2
7169
70+
'''
71+
self.assertEqual(o.render(), expected)
72+
73+
def test_ipv4_dchp_route(self):
74+
o = Raspbian({
75+
"interfaces": [
76+
{
77+
"name": "eth0",
78+
"type": "ethernet",
79+
"addresses": [
80+
{
81+
"family": "ipv4",
82+
"proto": "dhcp"
83+
}
84+
]
85+
}
86+
],
87+
"routes": [
88+
{
89+
"device": "eth0",
90+
"destination": "192.168.4.1/24",
91+
"next": "192.168.2.2"
92+
},
93+
]
94+
})
95+
96+
expected = '''# config: /etc/network/interfaces
97+
98+
auto eth0
99+
iface eth0 inet dhcp
100+
post-up route add -net 192.168.4.1 netmask 255.255.255.0 gw 192.168.2.2
101+
pre-up route del -net 192.168.4.1 netmask 255.255.255.0 gw 192.168.2.2
102+
72103
'''
73104
self.assertEqual(o.render(), expected)
74105

@@ -136,6 +167,39 @@ def test_ipv6_static_route(self):
136167
up ip -6 route add fd89::1/128 via fd88::1 dev eth0
137168
down ip -6 route del fd89::1/128 via fd88::1 dev eth0
138169
170+
'''
171+
self.assertEqual(o.render(), expected)
172+
173+
def test_ipv6_dhcp_route(self):
174+
o = Raspbian({
175+
"interfaces": [
176+
{
177+
"name": "eth0",
178+
"type": "ethernet",
179+
"addresses": [
180+
{
181+
"family": "ipv6",
182+
"proto": "dhcp"
183+
}
184+
]
185+
}
186+
],
187+
"routes": [
188+
{
189+
"device": "eth0",
190+
"destination": "fd89::1/128",
191+
"next": "fd88::1"
192+
}
193+
]
194+
})
195+
196+
expected = '''# config: /etc/network/interfaces
197+
198+
auto eth0
199+
iface eth0 inet6 dhcp
200+
up ip -6 route add fd89::1/128 via fd88::1 dev eth0
201+
down ip -6 route del fd89::1/128 via fd88::1 dev eth0
202+
139203
'''
140204
self.assertEqual(o.render(), expected)
141205

0 commit comments

Comments
 (0)