Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 6
0
def step_impl(context, destination, device):
    route = Route(destination, device)
    assert route.exists()
Ejemplo n.º 7
0
def step_impl(context, destination, device):
    route = Route(destination, device)
    try:
        route.unreachable()
    except Exception as e:
        context.exception = e
Ejemplo n.º 8
0
def step_impl(context, destination, device):
    route = Route(destination, device)
    try:
        route.prohibit()
    except Exception as e:
        context.exception = e
Ejemplo n.º 9
0
def step_impl(context):
    context.routes = Route.discover()
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 16
0
def step_impl(context, destination, device):
    route = Route(destination, device)
    if route.exists():
        route.delete()
Ejemplo n.º 17
0
def step_impl(context, destination, device):
    route = Route(destination, device)
    if route not in Route.discover():
        route.create()
Ejemplo n.º 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)