# Path: neutron_vpnaas/services/vpn/plugin.py
# LOG = logging.getLogger(__name__)
# def add_provider_configuration(type_manager, service_type):
#     def __init__(self):
#     def _flavors_plugin(self):
#     def _check_orphan_vpnservice_associations(self):
#     def _get_provider_for_flavor(self, context, flavor_id):
#     def _get_driver_for_vpnservice(self, context, vpnservice):
#     def _get_driver_for_ipsec_site_connection(self, context,
#                                               ipsec_site_connection):
#     def create_ipsec_site_connection(self, context, ipsec_site_connection):
#     def delete_ipsec_site_connection(self, context, ipsec_conn_id):
#     def update_ipsec_site_connection(
#             self, context,
#             ipsec_conn_id, ipsec_site_connection):
#     def create_vpnservice(self, context, vpnservice):
#     def update_vpnservice(self, context, vpnservice_id, vpnservice):
#     def delete_vpnservice(self, context, vpnservice_id):
# class VPNPlugin(vpn_db.VPNPluginDb):
# class VPNDriverPlugin(VPNPlugin, vpn_db.VPNPluginRpcDbMixin):
# 
# Path: neutron_vpnaas/services/vpn/service_drivers/ipsec.py
# IPSEC = 'ipsec'
# BASE_IPSEC_VERSION = '1.0'
# class IPsecVPNDriver(base_ipsec.BaseIPsecVPNDriver):
#     def __init__(self, service_plugin):
#     def create_rpc_conn(self):
# 
# Path: neutron_vpnaas/services/vpn/service_drivers/ipsec_validator.py
# class IpsecValidationFailure(nexception.BadRequest):
# class IpsecVpnValidator(driver_validator.VpnDriverValidator):
#     def _check_transform_protocol(self, context, transform_protocol):
#     def validate_ipsec_policy(self, context, ipsec_policy):
#     def validate_ipsec_site_connection(self, context, ipsec_sitecon):
# 
# Path: neutron_vpnaas/tests/base.py
# class BaseTestCase(n_base.BaseTestCase):
# class ExtensionTestCase(test_api_v2_extension.ExtensionTestCase):
# class NeutronDbPluginV2TestCase(test_db_plugin.NeutronDbPluginV2TestCase):


from unittest import mock
from neutron.db import servicetype_db as st_db
from neutron_lib import context as n_ctx
from neutron_lib.plugins import constants
from neutron_lib.plugins import directory
from oslo_utils import uuidutils
from neutron_vpnaas.services.vpn import plugin as vpn_plugin
from neutron_vpnaas.services.vpn.service_drivers import ipsec as ipsec_driver
from neutron_vpnaas.services.vpn.service_drivers import ipsec_validator
from neutron_vpnaas.tests import base
                                                   {'ip_address': '2001::1'}]}
        v4_ip, v6_ip = self.driver._get_gateway_ips(vpnservice.router)
        self.assertEqual('10.0.0.99', v4_ip)
        self.assertEqual('2001::1', v6_ip)

    def test_use_first_gw_ips_when_multiples(self):
        vpnservice = mock.Mock()
        vpnservice.router.gw_port = {'fixed_ips': [{'ip_address': '10.0.0.99'},
                                                   {'ip_address': '20.0.0.99'},
                                                   {'ip_address': '2001::1'},
                                                   {'ip_address': 'fd00::4'}]}
        v4_ip, v6_ip = self.driver._get_gateway_ips(vpnservice.router)
        self.assertEqual('10.0.0.99', v4_ip)
        self.assertEqual('2001::1', v6_ip)

    def test_store_gw_ips_on_service_create(self):
        vpnservice = mock.Mock()
        self.svc_plugin._get_vpnservice.return_value = vpnservice
        vpnservice.router.gw_port = {'fixed_ips': [{'ip_address': '10.0.0.99'},
                                                   {'ip_address': '2001::1'}]}
        ctxt = n_ctx.Context('', 'somebody')
        vpnservice_dict = {'id': FAKE_SERVICE_ID,
                           'router_id': FAKE_ROUTER_ID}
        self.driver.create_vpnservice(ctxt, vpnservice_dict)
        self.svc_plugin.set_external_tunnel_ips.assert_called_once_with(
            ctxt, FAKE_SERVICE_ID, v4_ip='10.0.0.99', v6_ip='2001::1')

    def test_validate_ipsec_policy(self):
        # Validate IPsec Policy transform_protocol
        ipsec_policy = {'transform_protocol': 'ah-esp'}

# Path: neutron_vpnaas/services/vpn/plugin.py
# LOG = logging.getLogger(__name__)
# def add_provider_configuration(type_manager, service_type):
#     def __init__(self):
#     def _flavors_plugin(self):
#     def _check_orphan_vpnservice_associations(self):
#     def _get_provider_for_flavor(self, context, flavor_id):
#     def _get_driver_for_vpnservice(self, context, vpnservice):
#     def _get_driver_for_ipsec_site_connection(self, context,
#                                               ipsec_site_connection):
#     def create_ipsec_site_connection(self, context, ipsec_site_connection):
#     def delete_ipsec_site_connection(self, context, ipsec_conn_id):
#     def update_ipsec_site_connection(
#             self, context,
#             ipsec_conn_id, ipsec_site_connection):
#     def create_vpnservice(self, context, vpnservice):
#     def update_vpnservice(self, context, vpnservice_id, vpnservice):
#     def delete_vpnservice(self, context, vpnservice_id):
# class VPNPlugin(vpn_db.VPNPluginDb):
# class VPNDriverPlugin(VPNPlugin, vpn_db.VPNPluginRpcDbMixin):
# 
# Path: neutron_vpnaas/services/vpn/service_drivers/ipsec.py
# IPSEC = 'ipsec'
# BASE_IPSEC_VERSION = '1.0'
# class IPsecVPNDriver(base_ipsec.BaseIPsecVPNDriver):
#     def __init__(self, service_plugin):
#     def create_rpc_conn(self):
# 
# Path: neutron_vpnaas/services/vpn/service_drivers/ipsec_validator.py
# class IpsecValidationFailure(nexception.BadRequest):
# class IpsecVpnValidator(driver_validator.VpnDriverValidator):
#     def _check_transform_protocol(self, context, transform_protocol):
#     def validate_ipsec_policy(self, context, ipsec_policy):
#     def validate_ipsec_site_connection(self, context, ipsec_sitecon):
# 
# Path: neutron_vpnaas/tests/base.py
# class BaseTestCase(n_base.BaseTestCase):
# class ExtensionTestCase(test_api_v2_extension.ExtensionTestCase):
# class NeutronDbPluginV2TestCase(test_db_plugin.NeutronDbPluginV2TestCase):


# Path: neutron_vpnaas/tests/unit/services/vpn/service_drivers/test_ipsec.py
from unittest import mock
from neutron.db import servicetype_db as st_db
from neutron_lib import context as n_ctx
from neutron_lib.plugins import constants
from neutron_lib.plugins import directory
from oslo_utils import uuidutils
from neutron_vpnaas.services.vpn import plugin as vpn_plugin
from neutron_vpnaas.services.vpn.service_drivers import ipsec as ipsec_driver
from neutron_vpnaas.services.vpn.service_drivers import ipsec_validator
from neutron_vpnaas.tests import base

                                                   {'ip_address': '2001::1'}]}
        v4_ip, v6_ip = self.driver._get_gateway_ips(vpnservice.router)
        self.assertEqual('10.0.0.99', v4_ip)
        self.assertEqual('2001::1', v6_ip)

    def test_use_first_gw_ips_when_multiples(self):
        vpnservice = mock.Mock()
        vpnservice.router.gw_port = {'fixed_ips': [{'ip_address': '10.0.0.99'},
                                                   {'ip_address': '20.0.0.99'},
                                                   {'ip_address': '2001::1'},
                                                   {'ip_address': 'fd00::4'}]}
        v4_ip, v6_ip = self.driver._get_gateway_ips(vpnservice.router)
        self.assertEqual('10.0.0.99', v4_ip)
        self.assertEqual('2001::1', v6_ip)

    def test_store_gw_ips_on_service_create(self):
        vpnservice = mock.Mock()
        self.svc_plugin._get_vpnservice.return_value = vpnservice
        vpnservice.router.gw_port = {'fixed_ips': [{'ip_address': '10.0.0.99'},
                                                   {'ip_address': '2001::1'}]}
        ctxt = n_ctx.Context('', 'somebody')
        vpnservice_dict = {'id': FAKE_SERVICE_ID,
                           'router_id': FAKE_ROUTER_ID}
        self.driver.create_vpnservice(ctxt, vpnservice_dict)
        self.svc_plugin.set_external_tunnel_ips.assert_called_once_with(
            ctxt, FAKE_SERVICE_ID, v4_ip='10.0.0.99', v6_ip='2001::1')

    def test_validate_ipsec_policy(self):
        # Validate IPsec Policy transform_protocol
        ipsec_policy = {'transform_protocol': 'ah-esp'}

        self.assertRaises(ipsec_validator.IpsecValidationFailure,