diff --git a/vmware_nsx_tempest_plugin/services/nsxv_client.py b/vmware_nsx_tempest_plugin/services/nsxv_client.py index da31de2..86096da 100644 --- a/vmware_nsx_tempest_plugin/services/nsxv_client.py +++ b/vmware_nsx_tempest_plugin/services/nsxv_client.py @@ -389,3 +389,15 @@ class VSMClient(object): else: LOG.debug('spoofguard policy of nw is %s NOT found!' % network_id) return False + + def verify_static_route(self, name, cidr, nexthop): + edge_id = self.get_edge_name_substring(name)['id'] + self.__set_api_version('4.0') + self.__set_endpoint('/edges/%s/routing/config/static' % edge_id) + response = self.get() + routes = response.json()['staticRoutes']['staticRoutes'] + route = [(r['network'], r['nextHop']) for r in routes] + if (cidr, nexthop) in route: + return True + else: + return False diff --git a/vmware_nsx_tempest_plugin/tests/scenario/test_new_case_coverage.py b/vmware_nsx_tempest_plugin/tests/scenario/test_new_case_coverage.py index b37ed7f..81ed010 100644 --- a/vmware_nsx_tempest_plugin/tests/scenario/test_new_case_coverage.py +++ b/vmware_nsx_tempest_plugin/tests/scenario/test_new_case_coverage.py @@ -1790,3 +1790,36 @@ class TestNewCase(feature_manager.FeatureManager): routerIP = router_ext['external_fixed_ips'][0]['ip_address'] self.assertTrue(self.vsm.verify_default_snat_rule(name, routerIP, cidr_value)) + + @decorators.attr(type='nsxv') + @decorators.idempotent_id('2226016a-91cc-8905-b217-12344cab24a1') + def test_update_router_with_static_route_via_any_CIDR(self): + """ + Check it should not allow to add static route on router with + 10.0.0.0/24 next hop. + """ + kwargs = {"distributed": "true", + "admin_state_up": "True"} + rtr_name = 'tempest-router-dist' + network_name = data_utils.rand_name(name='tempest-net') + subnet_name = data_utils.rand_name(name='tempest-subnet') + router_state = self.create_topology_router(rtr_name, + set_gateway=False, + **kwargs) + network_state = self.create_topology_network(network_name) + subnet_state = self.create_topology_subnet( + subnet_name, network_state, router_id=router_state["id"]) + next_hop = subnet_state['allocation_pools'][0]['end'] + routes = [{ + "destination": "100.0.0.0/24", + "nexthop": next_hop + }] + router_id = router_state['id'] + self.routers_client.update_router(router_id, routes=routes) + self.assertTrue(self.vsm.verify_static_route(router_state['name'], + '100.0.0.0/24', next_hop)) + routes = [] + self.routers_client.update_router(router_id, routes=routes) + self.assertFalse(self.vsm.verify_static_route(router_state['name'], + '100.0.0.0/24', + next_hop))