Exemple #1
0
 def test_delete_non_existing_route(self, execute_command):
     execute_command.return_value = self.ip_route_list_output
     route = Route('1.2.3.4', 'wlo1')
     route.gateway = '192.168.0.254'
     with self.assertRaises(ObjectNotFoundException):
         route.delete()
         execute_command.assert_called_with('ip route del 1.2.3.4', namespace=None)
Exemple #2
0
 def test_add_existing_route(self, execute_command):
     execute_command.return_value = self.ip_route_list_output
     route = Route('default', 'wlo1')
     route.gateway = '192.168.0.254'
     with self.assertRaises(ObjectAlreadyExistsException):
         route.create()
         execute_command.assert_called_once_with('ip route list', namespace=None)
Exemple #3
0
def step_impl(context, destination, device):
    route = Route(destination, device)
    route.refresh()
    assert not route.is_reachable()
    response = None
    try:
        response = os.system('ping -c 1 %s  2>/dev/null' % destination.split('/')[0])
    except:
        assert response == 2
    assert response is not None
Exemple #4
0
 def test_refresh_route(self, execute_command):
     execute_command.return_value = self.ip_route_list_output
     route = Route('default', 'wlo1')
     route.refresh()
     execute_command.assert_called_once_with("ip route list", namespace=None)
     self.assertEqual(route.metric, '600')
     self.assertEqual(route.gateway, '192.168.0.254')
     self.assertIsNone(route.source)
     self.assertIsNone(route.scope)
     self.assertIsNone(route.namespace)
Exemple #5
0
 def test_route_discovery(self, destination, device, scope, source, metric, gateway, default, prohibit, reachable, execute_command):
     execute_command.return_value = self.ip_route_list_output
     route = Route(destination, device)
     route.scope = scope
     route.source = source
     route.gateway = gateway
     route.metric = metric
     routes = Route.discover()
     self.assertEqual(len(routes), 6)
     found_route = routes[routes.index(route)]
     self.assertTrue(self.deep_equality(route, found_route))
     self.assertEqual(found_route.is_default(), default)
     self.assertEqual(found_route.is_prohibited(), prohibit)
     self.assertEqual(found_route.is_reachable(), reachable)
Exemple #6
0
def step_impl(context, destination, device):
    route = Route(destination, device)
    assert route.exists()
Exemple #7
0
def step_impl(context, destination, device):
    route = Route(destination, device)
    try:
        route.unreachable()
    except Exception as e:
        context.exception = e
Exemple #8
0
def step_impl(context, destination, device):
    route = Route(destination, device)
    try:
        route.prohibit()
    except Exception as e:
        context.exception = e
Exemple #9
0
def step_impl(context):
    context.routes = Route.discover()
Exemple #10
0
 def test_delete_existing_route(self, execute_command):
     execute_command.return_value = self.ip_route_list_output
     route = Route('default', 'wlo1')
     route.gateway = '192.168.0.254'
     route.delete()
     execute_command.assert_called_with('ip route del default', namespace=None)
Exemple #11
0
 def test_prohibit_non_existing_route(self, execute_command):
     execute_command.return_value = self.ip_route_list_output
     route = Route('10.10.10.10/24', 'wlo1')
     route.prohibit()
     execute_command.assert_called_with('ip route add prohibit 10.10.10.10/24', namespace=None)
Exemple #12
0
 def test_contains_route(self, execute_command):
     execute_command.return_value = self.ip_route_list_output
     route = Route('default', 'wlo1')
     route.gateway = '192.168.0.254'
     self.assertTrue(route.exists())
     execute_command.assert_called_once_with('ip route list', namespace=None)
Exemple #13
0
 def test_refresh_non_existing_route(self, execute_command):
     execute_command.return_value = self.ip_route_list_output
     route = Route('destination', 'device')
     with self.assertRaises(ObjectNotFoundException):
         route.refresh()
         execute_command.assert_called_once_with("ip route list", namespace=None)
Exemple #14
0
 def test_unreachable_existing_route(self, execute_command):
     execute_command.return_value = self.ip_route_list_output
     route = Route('1.2.3.4/30', None)
     with self.assertRaises(ObjectAlreadyExistsException):
         route.unreachable()
         execute_command.assert_called_with('ip route del 1.2.3.4', namespace=None)
Exemple #15
0
 def test_unreachable_non_existing_route(self, execute_command):
     execute_command.return_value = self.ip_route_list_output
     route = Route('10.10.10.10/24', 'wlo1')
     route.unreachable()
     execute_command.assert_called_with('ip route add unreachable 10.10.10.10/24', namespace=None)
Exemple #16
0
def step_impl(context, destination, device):
    route = Route(destination, device)
    if route.exists():
        route.delete()
Exemple #17
0
def step_impl(context, destination, device):
    route = Route(destination, device)
    if route not in Route.discover():
        route.create()
Exemple #18
0
 def test_add_non_existing_route(self, execute_command):
     execute_command.return_value = self.ip_route_list_output
     route = Route('1.2.3.4', 'wlo1')
     route.gateway = '192.168.0.254'
     route.create()
     execute_command.assert_called_with('ip route add 1.2.3.4 dev wlo1 via 192.168.0.254', namespace=None)