Skip to content

Commit

Permalink
[raspbian] Added tests for dhcp interface static routes
Browse files Browse the repository at this point in the history
  • Loading branch information
Ritwick DSouza committed Aug 7, 2017
1 parent e59ed16 commit 9f1c86c
Showing 1 changed file with 68 additions and 4 deletions.
72 changes: 68 additions & 4 deletions tests/raspbian/test_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ def test_ipv4_manual_route(self):
{
"device": "eth0",
"destination": "192.168.4.1/24",
"next": "192.168.2.2",
"cost": 2,
"next": "192.168.2.2"
},
]
})
Expand Down Expand Up @@ -54,8 +53,7 @@ def test_ipv4_static_route(self):
{
"device": "eth0",
"destination": "192.168.4.1/24",
"next": "192.168.2.2",
"cost": 2,
"next": "192.168.2.2"
},
]
})
Expand All @@ -69,6 +67,39 @@ def test_ipv4_static_route(self):
post-up route add -net 192.168.4.1 netmask 255.255.255.0 gw 192.168.2.2
pre-up route del -net 192.168.4.1 netmask 255.255.255.0 gw 192.168.2.2
'''
self.assertEqual(o.render(), expected)

def test_ipv4_dchp_route(self):
o = Raspbian({
"interfaces": [
{
"name": "eth0",
"type": "ethernet",
"addresses": [
{
"family": "ipv4",
"proto": "dhcp"
}
]
}
],
"routes": [
{
"device": "eth0",
"destination": "192.168.4.1/24",
"next": "192.168.2.2"
},
]
})

expected = '''# config: /etc/network/interfaces
auto eth0
iface eth0 inet dhcp
post-up route add -net 192.168.4.1 netmask 255.255.255.0 gw 192.168.2.2
pre-up route del -net 192.168.4.1 netmask 255.255.255.0 gw 192.168.2.2
'''
self.assertEqual(o.render(), expected)

Expand Down Expand Up @@ -136,6 +167,39 @@ def test_ipv6_static_route(self):
up ip -6 route add fd89::1/128 via fd88::1 dev eth0
down ip -6 route del fd89::1/128 via fd88::1 dev eth0
'''
self.assertEqual(o.render(), expected)

def test_ipv6_dhcp_route(self):
o = Raspbian({
"interfaces": [
{
"name": "eth0",
"type": "ethernet",
"addresses": [
{
"family": "ipv6",
"proto": "dhcp"
}
]
}
],
"routes": [
{
"device": "eth0",
"destination": "fd89::1/128",
"next": "fd88::1"
}
]
})

expected = '''# config: /etc/network/interfaces
auto eth0
iface eth0 inet6 dhcp
up ip -6 route add fd89::1/128 via fd88::1 dev eth0
down ip -6 route del fd89::1/128 via fd88::1 dev eth0
'''
self.assertEqual(o.render(), expected)

Expand Down

0 comments on commit 9f1c86c

Please sign in to comment.