vpnservice['vpnservice'].items()
if k in expected),
expected)
- return vpnservice
+
+ def test_create_vpnservice_with_invalid_router(self):
+ """Test case to create a vpnservice with invalid router"""
+ with self.network(
+ set_context=True,
+ tenant_id='tenant_a') as network:
+ with self.subnet(network=network,
+ cidr='10.2.0.0/24') as subnet:
+ with self.router(
+ set_context=True, tenant_id='tenant_a') as router:
+ router_id = router['router']['id']
+ subnet_id = subnet['subnet']['id']
+ self._create_vpnservice(
+ self.fmt, 'fake',
+ True, router_id, subnet_id,
+ expected_res_status=webob.exc.HTTPNotFound.code,
+ set_context=True, tenant_id='tenant_b')
+
+ def test_create_vpnservice_with_nonconnected_subnet(self):
+ """Test case to create a vpnservice with nonconnected subnet."""
+ with self.network() as network:
+ with self.subnet(network=network,
+ cidr='10.2.0.0/24') as subnet:
+ with self.router() as router:
+ router_id = router['router']['id']
+ subnet_id = subnet['subnet']['id']
+ self._create_vpnservice(
+ self.fmt, 'fake',
+ True, router_id, subnet_id,
+ expected_res_status=webob.exc.HTTPBadRequest.code)
+ def test_delete_router_in_use_by_vpnservice(self):
+ """Test delete router in use by vpn service."""
+ with self.subnet(cidr='10.2.0.0/24') as subnet:
+ with self.router() as router:
+ with self.vpnservice(subnet=subnet,
+ router=router):
+ self._delete('routers', router['router']['id'],
+ expected_code=webob.exc.HTTPConflict.code)
+
def _set_active(self, model, resource_id):
service_plugin = manager.NeutronManager.get_service_plugins()[
constants.VPN]