<s> import netaddr <EOL> import neutron . common <EOL> from gbpservice . neutron . services . grouppolicy import config <EOL> from gbpservice . neutron . tests . unit . services . grouppolicy import ( <EOL> test_group_proxy_extension as test_gp_ext ) <EOL> from gbpservice . neutron . tests . unit . services . grouppolicy import ( <EOL> test_resource_mapping as test_resource_mapping ) <EOL> class ResourceMappingProxyGroupGBPTestCase ( <EOL> test_resource_mapping . ResourceMappingTestCase ) : <EOL> def setUp ( self ) : <EOL> config . cfg . CONF . set_override ( '<STR_LIT>' , <EOL> [ '<STR_LIT>' ] , <EOL> group = '<STR_LIT>' ) <EOL> super ( ResourceMappingProxyGroupGBPTestCase , self ) . setUp ( ) <EOL> def _get_l3p_from_ptg ( self , ptg ) : <EOL> l2p = self . show_l2_policy ( ptg [ '<STR_LIT>' ] ) [ '<STR_LIT>' ] <EOL> return self . show_l3_policy ( l2p [ '<STR_LIT>' ] ) [ '<STR_LIT>' ] <EOL> def _is_router_attached_to_any_subnet ( self , router_ports , subnet_ids ) : <EOL> subnet_ids = set ( subnet_ids ) <EOL> for port in router_ports : <EOL> if any ( [ x for x in port [ '<STR_LIT>' ] <EOL> if x [ '<STR_LIT>' ] in subnet_ids ] ) : <EOL> return True <EOL> return False <EOL> def _is_router_attached_to_all_subnets ( self , router_ports , subnet_ids ) : <EOL> subnet_ids = set ( subnet_ids ) <EOL> for port in router_ports : <EOL> for subnet_id in [ x [ '<STR_LIT>' ] for x in port [ '<STR_LIT>' ] if <EOL> x [ '<STR_LIT>' ] in subnet_ids ] : <EOL> subnet_ids . remove ( subnet_id ) <EOL> return not bool ( subnet_ids ) <EOL> def _ptg_to_cidrs ( self , ptg ) : <EOL> cidrs = [ ] <EOL> for sub_id in ptg [ '<STR_LIT>' ] : <EOL> cidrs . append ( <EOL> self . _get_object ( <EOL> '<STR_LIT>' , sub_id , self . api ) [ '<STR_LIT>' ] [ '<STR_LIT>' ] ) <EOL> return cidrs <EOL> def _are_subnets_same ( self , ptg1 , ptg2 ) : <EOL> cidrs1 = netaddr . IPSet ( iterable = self . _ptg_to_cidrs ( ptg1 ) ) <EOL> cidrs2 = netaddr . IPSet ( iterable = self . _ptg_to_cidrs ( ptg2 ) ) <EOL> return cidrs1 == cidrs2 <EOL> def _are_subnets_disjoint ( self , ptg1 , ptg2 ) : <EOL> cidrs1 = netaddr . IPSet ( iterable = self . _ptg_to_cidrs ( ptg1 ) ) <EOL> cidrs2 = netaddr . IPSet ( iterable = self . _ptg_to_cidrs ( ptg2 ) ) <EOL> return len ( cidrs1 & cidrs2 ) == <NUM_LIT:0> <EOL> def _ptg_gateway_pt ( self , ptg ) : <EOL> pt_list = self . _list ( '<STR_LIT>' , <EOL> query_params = '<STR_LIT>' % <EOL> ptg [ '<STR_LIT:id>' ] ) <EOL> if pt_list [ '<STR_LIT>' ] : <EOL> return pt_list [ '<STR_LIT>' ] [ <NUM_LIT:0> ] <EOL> def _get_pt_ip ( self , pt ) : <EOL> port = self . _get_object ( '<STR_LIT>' , pt [ '<STR_LIT>' ] , self . api ) [ '<STR_LIT:port>' ] <EOL> return port [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] <EOL> def _get_ptg_subnets ( self , ptg ) : <EOL> return [ self . _get_object ( '<STR_LIT>' , x , self . api ) [ '<STR_LIT>' ] <EOL> for x in ptg [ '<STR_LIT>' ] ] <EOL> def _are_cidr_routed_in_ptg_via_pt ( self , ptg , pt , cidrs ) : <EOL> nexthop = self . _get_pt_ip ( pt ) <EOL> subnets = self . _get_ptg_subnets ( ptg ) <EOL> expected_routes = set ( ( destination , nexthop ) for destination in cidrs ) <EOL> for subnet in subnets : <EOL> expected_routes = ( <EOL> expected_routes - set ( ( x [ '<STR_LIT>' ] , x [ '<STR_LIT>' ] ) <EOL> for x in subnet [ '<STR_LIT>' ] ) ) <EOL> return not expected_routes <EOL> def _are_cidr_routed_in_router_via_pt ( self , router , pt , cidrs ) : <EOL> nexthop = self . _get_pt_ip ( pt ) <EOL> expected_routes = set ( ( destination , nexthop ) for destination in cidrs ) <EOL> routes = set ( ( x [ '<STR_LIT>' ] , x [ '<STR_LIT>' ] ) <EOL> for x in router [ '<STR_LIT>' ] ) <EOL> return not expected_routes - routes <EOL> def _verify_correct_proxy_chain ( self , original_ptg_id , <EOL> expected_chain_length = None ) : <EOL> original_ptg = self . show_policy_target_group ( <EOL> original_ptg_id ) [ '<STR_LIT>' ] <EOL> l3p = self . _get_l3p_from_ptg ( original_ptg ) <EOL> router = self . _get_object ( <EOL> '<STR_LIT>' , l3p [ '<STR_LIT>' ] [ <NUM_LIT:0> ] , self . ext_api ) [ '<STR_LIT>' ] <EOL> router_ports = self . _list ( <EOL> '<STR_LIT>' , query_params = '<STR_LIT>' % router [ '<STR_LIT:id>' ] ) [ '<STR_LIT>' ] <EOL> cumulative_cidrs = set ( ) <EOL> curr = original_ptg <EOL> chain_length = <NUM_LIT:1> <EOL> while curr [ '<STR_LIT>' ] : <EOL> chain_length += <NUM_LIT:1> <EOL> proxy = self . show_policy_target_group ( <EOL> curr [ '<STR_LIT>' ] ) [ '<STR_LIT>' ] <EOL> self . assertFalse ( <EOL> self . _is_router_attached_to_any_subnet ( <EOL> router_ports , curr ) , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" % <EOL> ( router_ports , curr [ '<STR_LIT>' ] ) ) <EOL> if proxy [ '<STR_LIT>' ] == '<STR_LIT>' : <EOL> self . assertTrue ( <EOL> self . _are_subnets_same ( proxy , curr ) , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" % <EOL> ( self . _ptg_to_cidrs ( proxy ) , ( self . _ptg_to_cidrs ( curr ) ) ) ) <EOL> else : <EOL> self . assertTrue ( <EOL> self . _are_subnets_disjoint ( proxy , curr ) , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" % <EOL> ( self . _ptg_to_cidrs ( proxy ) , ( self . _ptg_to_cidrs ( curr ) ) ) ) <EOL> curr_gateway_pt = self . _ptg_gateway_pt ( curr ) <EOL> if curr_gateway_pt : <EOL> self . assertTrue ( <EOL> self . _are_cidr_routed_in_ptg_via_pt ( curr , curr_gateway_pt , <EOL> cumulative_cidrs ) , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" % ( self . _get_ptg_subnets ( curr ) , <EOL> cumulative_cidrs , <EOL> self . _get_pt_ip ( curr_gateway_pt ) ) ) <EOL> cumulative_cidrs . update ( self . _ptg_to_cidrs ( curr ) ) <EOL> curr = proxy <EOL> self . assertTrue ( <EOL> self . _is_router_attached_to_all_subnets ( <EOL> router_ports , curr [ '<STR_LIT>' ] ) , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" % ( router_ports , <EOL> curr [ '<STR_LIT>' ] ) ) <EOL> curr_gateway_pt = self . _ptg_gateway_pt ( curr ) <EOL> if curr_gateway_pt : <EOL> self . assertTrue ( <EOL> self . _are_cidr_routed_in_ptg_via_pt ( curr , curr_gateway_pt , <EOL> cumulative_cidrs ) , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" % ( self . _get_ptg_subnets ( curr ) , <EOL> cumulative_cidrs , <EOL> self . _get_pt_ip ( curr_gateway_pt ) ) ) <EOL> self . assertTrue ( <EOL> self . _are_cidr_routed_in_router_via_pt ( <EOL> router , curr_gateway_pt , cumulative_cidrs ) , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" % ( router , cumulative_cidrs , <EOL> self . _get_pt_ip ( curr_gateway_pt ) ) ) <EOL> if expected_chain_length : <EOL> self . assertEqual ( expected_chain_length , chain_length ) <EOL> class TestProxyGroupSubnetPrefixRMD ( ResourceMappingProxyGroupGBPTestCase ) : <EOL> def setUp ( self ) : <EOL> config . cfg . CONF . set_override ( <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> group = '<STR_LIT>' ) <EOL> config . cfg . CONF . set_override ( <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> group = '<STR_LIT>' ) <EOL> super ( TestProxyGroupSubnetPrefixRMD , self ) . setUp ( ) <EOL> def test_proxy_group_updated_prefix_length ( self ) : <EOL> l3p = self . create_l3_policy ( ip_pool = '<STR_LIT>' ) [ '<STR_LIT>' ] <EOL> self . assertEqual ( '<STR_LIT>' , l3p [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( <NUM_LIT> , l3p [ '<STR_LIT>' ] ) <EOL> l2p = self . create_l2_policy ( l3_policy_id = l3p [ '<STR_LIT:id>' ] ) [ '<STR_LIT>' ] <EOL> ptg = self . create_policy_target_group ( <EOL> l2_policy_id = l2p [ '<STR_LIT:id>' ] ) [ '<STR_LIT>' ] <EOL> l2p2 = self . create_l2_policy ( l3_policy_id = l3p [ '<STR_LIT:id>' ] ) [ '<STR_LIT>' ] <EOL> ptg_proxy = self . create_policy_target_group ( <EOL> proxied_group_id = ptg [ '<STR_LIT:id>' ] , <EOL> l2_policy_id = l2p2 [ '<STR_LIT:id>' ] ) [ '<STR_LIT>' ] <EOL> subnet = self . _get_object ( '<STR_LIT>' , ptg_proxy [ '<STR_LIT>' ] [ <NUM_LIT:0> ] , <EOL> self . api ) [ '<STR_LIT>' ] <EOL> self . assertEqual ( str ( l3p [ '<STR_LIT>' ] ) , <EOL> subnet [ '<STR_LIT>' ] . split ( '<STR_LIT:/>' ) [ <NUM_LIT:1> ] ) <EOL> class TestProxyGroupRMD ( ResourceMappingProxyGroupGBPTestCase , <EOL> test_gp_ext . ExtensionDriverTestCaseMixin ) : <EOL> def test_proxy_group_extension ( self ) : <EOL> l3p = self . create_l3_policy ( ip_pool = '<STR_LIT>' ) [ '<STR_LIT>' ] <EOL> self . assertEqual ( '<STR_LIT>' , l3p [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( <NUM_LIT> , l3p [ '<STR_LIT>' ] ) <EOL> l2p = self . create_l2_policy ( l3_policy_id = l3p [ '<STR_LIT:id>' ] ) [ '<STR_LIT>' ] <EOL> ptg = self . create_policy_target_group ( <EOL> l2_policy_id = l2p [ '<STR_LIT:id>' ] ) [ '<STR_LIT>' ] <EOL> self . assertIsNone ( ptg [ '<STR_LIT>' ] ) <EOL> self . assertIsNone ( ptg [ '<STR_LIT>' ] ) <EOL> self . assertIsNone ( ptg [ '<STR_LIT>' ] ) <EOL> l3p = self . show_l3_policy ( l3p [ '<STR_LIT:id>' ] ) [ '<STR_LIT>' ] <EOL> self . assertEqual ( '<STR_LIT>' , l3p [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( <NUM_LIT> , l3p [ '<STR_LIT>' ] ) <EOL> l2p2 = self . create_l2_policy ( l3_policy_id = l3p [ '<STR_LIT:id>' ] ) [ '<STR_LIT>' ] <EOL> ptg_proxy = self . create_policy_target_group ( <EOL> proxied_group_id = ptg [ '<STR_LIT:id>' ] , <EOL> l2_policy_id = l2p2 [ '<STR_LIT:id>' ] ) [ '<STR_LIT>' ] <EOL> self . assertIsNone ( ptg_proxy [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( ptg [ '<STR_LIT:id>' ] , ptg_proxy [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( '<STR_LIT>' , ptg_proxy [ '<STR_LIT>' ] ) <EOL> subnet = self . _get_object ( '<STR_LIT>' , ptg_proxy [ '<STR_LIT>' ] [ <NUM_LIT:0> ] , <EOL> self . api ) [ '<STR_LIT>' ] <EOL> self . assertEqual ( str ( l3p [ '<STR_LIT>' ] ) , <EOL> subnet [ '<STR_LIT>' ] . split ( '<STR_LIT:/>' ) [ <NUM_LIT:1> ] ) <EOL> ptg = self . show_policy_target_group ( ptg [ '<STR_LIT:id>' ] ) [ '<STR_LIT>' ] <EOL> self . assertEqual ( ptg_proxy [ '<STR_LIT:id>' ] , ptg [ '<STR_LIT>' ] ) <EOL> self . assertIsNone ( ptg [ '<STR_LIT>' ] ) <EOL> pt = self . create_policy_target ( <EOL> policy_target_group_id = ptg_proxy [ '<STR_LIT:id>' ] ) [ '<STR_LIT>' ] <EOL> self . assertFalse ( pt [ '<STR_LIT>' ] ) <EOL> pt = self . create_policy_target ( <EOL> policy_target_group_id = ptg_proxy [ '<STR_LIT:id>' ] , <EOL> proxy_gateway = True ) [ '<STR_LIT>' ] <EOL> self . assertTrue ( pt [ '<STR_LIT>' ] ) <EOL> pt = self . show_policy_target ( pt [ '<STR_LIT:id>' ] ) [ '<STR_LIT>' ] <EOL> self . assertTrue ( pt [ '<STR_LIT>' ] ) <EOL> class TestPolicyTarget ( ResourceMappingProxyGroupGBPTestCase , <EOL> test_resource_mapping . TestPolicyTarget ) : <EOL> def test_proxy_gateway ( self ) : <EOL> ptg = self . create_policy_target_group ( ) [ '<STR_LIT>' ] <EOL> proxy = self . create_policy_target_group ( <EOL> proxied_group_id = ptg [ '<STR_LIT:id>' ] , proxy_type = '<STR_LIT>' ) [ '<STR_LIT>' ] <EOL> self . create_policy_target ( policy_target_group_id = proxy [ '<STR_LIT:id>' ] , <EOL> proxy_gateway = True ) <EOL> self . _verify_correct_proxy_chain ( ptg [ '<STR_LIT:id>' ] , expected_chain_length = <NUM_LIT:2> ) <EOL> proxy2 = self . create_policy_target_group ( <EOL> proxied_group_id = proxy [ '<STR_LIT:id>' ] , <EOL> proxy_type = '<STR_LIT>' ) [ '<STR_LIT>' ] <EOL> self . create_policy_target ( policy_target_group_id = proxy2 [ '<STR_LIT:id>' ] , <EOL> proxy_gateway = True ) <EOL> self . _verify_correct_proxy_chain ( ptg [ '<STR_LIT:id>' ] , expected_chain_length = <NUM_LIT:3> ) <EOL> def test_group_default_gateway ( self ) : <EOL> ptg = self . create_policy_target_group ( ) [ '<STR_LIT>' ] <EOL> self . create_policy_target_group ( <EOL> proxied_group_id = ptg [ '<STR_LIT:id>' ] , proxy_type = '<STR_LIT>' ) <EOL> pt = self . create_policy_target ( <EOL> policy_target_group_id = ptg [ '<STR_LIT:id>' ] , <EOL> group_default_gateway = True ) [ '<STR_LIT>' ] <EOL> port = self . _get_object ( '<STR_LIT>' , pt [ '<STR_LIT>' ] , self . api ) [ '<STR_LIT:port>' ] <EOL> self . assertTrue ( len ( port [ '<STR_LIT>' ] ) > <NUM_LIT:0> ) <EOL> for fixed_ip in port [ '<STR_LIT>' ] : <EOL> subnet = self . _get_object ( '<STR_LIT>' , fixed_ip [ '<STR_LIT>' ] , <EOL> self . api ) [ '<STR_LIT>' ] <EOL> self . assertEqual ( subnet [ '<STR_LIT>' ] , fixed_ip [ '<STR_LIT>' ] ) <EOL> def test_group_default_gateway_fails ( self ) : <EOL> ptg = self . create_policy_target_group ( ) [ '<STR_LIT>' ] <EOL> self . create_policy_target ( policy_target_group_id = ptg [ '<STR_LIT:id>' ] , <EOL> group_default_gateway = True , <EOL> expected_res_status = <NUM_LIT> ) <EOL> def test_proxy_gateway_deleted ( self ) : <EOL> ptg = self . create_policy_target_group ( ) [ '<STR_LIT>' ] <EOL> proxy = self . create_policy_target_group ( <EOL> proxied_group_id = ptg [ '<STR_LIT:id>' ] , proxy_type = '<STR_LIT>' ) [ '<STR_LIT>' ] <EOL> pt = self . create_policy_target ( <EOL> policy_target_group_id = proxy [ '<STR_LIT:id>' ] , <EOL> proxy_gateway = True ) [ '<STR_LIT>' ] <EOL> nexthop = self . _get_pt_ip ( pt ) <EOL> l3p = self . _get_l3p_from_ptg ( ptg ) <EOL> router = self . _get_object ( <EOL> '<STR_LIT>' , l3p [ '<STR_LIT>' ] [ <NUM_LIT:0> ] , self . ext_api ) [ '<STR_LIT>' ] <EOL> subnet = self . _get_object ( <EOL> '<STR_LIT>' , proxy [ '<STR_LIT>' ] [ <NUM_LIT:0> ] , self . api ) [ '<STR_LIT>' ] <EOL> self . assertTrue ( <EOL> any ( [ x for x in router [ '<STR_LIT>' ] if x [ '<STR_LIT>' ] == nexthop ] ) , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" % ( nexthop , router [ '<STR_LIT>' ] ) ) <EOL> self . assertTrue ( <EOL> any ( [ x for x in subnet [ '<STR_LIT>' ] if x [ '<STR_LIT>' ] == nexthop ] ) , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" % ( nexthop , subnet [ '<STR_LIT>' ] ) ) <EOL> self . delete_policy_target ( pt [ '<STR_LIT:id>' ] ) <EOL> router = self . _get_object ( <EOL> '<STR_LIT>' , l3p [ '<STR_LIT>' ] [ <NUM_LIT:0> ] , self . ext_api ) [ '<STR_LIT>' ] <EOL> subnet = self . _get_object ( <EOL> '<STR_LIT>' , ptg [ '<STR_LIT>' ] [ <NUM_LIT:0> ] , self . api ) [ '<STR_LIT>' ] <EOL> self . assertFalse ( <EOL> any ( [ x for x in router [ '<STR_LIT>' ] if x [ '<STR_LIT>' ] == nexthop ] ) , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" % ( nexthop , router [ '<STR_LIT>' ] ) ) <EOL> self . assertFalse ( <EOL> any ( [ x for x in subnet [ '<STR_LIT>' ] if x [ '<STR_LIT>' ] == nexthop ] ) , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" % ( nexthop , subnet [ '<STR_LIT>' ] ) ) <EOL> def test_implicit_port_lifecycle ( self ) : <EOL> super ( TestPolicyTarget , self ) . test_implicit_port_lifecycle ( <EOL> proxy_ip_pool = '<STR_LIT>' ) <EOL> def test_weird_port_extra_attributes_ignored ( self ) : <EOL> super ( TestPolicyTarget , self ) . test_weird_port_extra_attributes_ignored ( <EOL> extra = { '<STR_LIT>' : False , '<STR_LIT>' : False } ) <EOL> def test_port_extra_attributes ( self ) : <EOL> super ( TestPolicyTarget , self ) . test_port_extra_attributes ( <EOL> extra = { '<STR_LIT>' : False , '<STR_LIT>' : False } ) <EOL> def test_port_extra_attributes_fixed_ips ( self ) : <EOL> super ( TestPolicyTarget , self ) . test_port_extra_attributes_fixed_ips ( <EOL> extra = { '<STR_LIT>' : False , '<STR_LIT>' : False } ) <EOL> def test_port_extra_attributes_implicit ( self ) : <EOL> super ( TestPolicyTarget , self ) . test_port_extra_attributes_implicit ( <EOL> extra = { '<STR_LIT>' : False , '<STR_LIT>' : False } ) <EOL> class TestPolicyTargetGroup ( ResourceMappingProxyGroupGBPTestCase , <EOL> test_resource_mapping . TestPolicyTargetGroup ) : <EOL> def test_l3_proxy_stitching ( self ) : <EOL> ptg = self . create_policy_target_group ( ) [ '<STR_LIT>' ] <EOL> self . create_policy_target_group ( proxied_group_id = ptg [ '<STR_LIT:id>' ] , <EOL> proxy_type = '<STR_LIT>' ) <EOL> self . _verify_correct_proxy_chain ( ptg [ '<STR_LIT:id>' ] , expected_chain_length = <NUM_LIT:2> ) <EOL> def test_l2_proxy_stitching ( self ) : <EOL> ptg = self . create_policy_target_group ( ) [ '<STR_LIT>' ] <EOL> self . create_policy_target_group ( proxied_group_id = ptg [ '<STR_LIT:id>' ] , <EOL> proxy_type = '<STR_LIT>' ) <EOL> self . _verify_correct_proxy_chain ( ptg [ '<STR_LIT:id>' ] , expected_chain_length = <NUM_LIT:2> ) <EOL> def test_multi_type_stitcing ( self ) : <EOL> ptg = self . create_policy_target_group ( ) [ '<STR_LIT>' ] <EOL> proxy1 = self . create_policy_target_group ( <EOL> proxied_group_id = ptg [ '<STR_LIT:id>' ] , proxy_type = '<STR_LIT>' ) [ '<STR_LIT>' ] <EOL> proxy2 = self . create_policy_target_group ( <EOL> proxied_group_id = proxy1 [ '<STR_LIT:id>' ] , <EOL> proxy_type = '<STR_LIT>' ) [ '<STR_LIT>' ] <EOL> self . assertEqual ( '<STR_LIT>' , proxy2 [ '<STR_LIT>' ] ) <EOL> self . _verify_correct_proxy_chain ( ptg [ '<STR_LIT:id>' ] , expected_chain_length = <NUM_LIT:3> ) <EOL> proxy3 = self . create_policy_target_group ( <EOL> proxied_group_id = proxy2 [ '<STR_LIT:id>' ] , <EOL> proxy_type = '<STR_LIT>' ) [ '<STR_LIT>' ] <EOL> self . assertEqual ( '<STR_LIT>' , proxy3 [ '<STR_LIT>' ] ) <EOL> self . _verify_correct_proxy_chain ( ptg [ '<STR_LIT:id>' ] , expected_chain_length = <NUM_LIT:4> ) <EOL> def test_multi_type_stitcing_delete_head ( self ) : <EOL> ptg = self . create_policy_target_group ( ) [ '<STR_LIT>' ] <EOL> proxy1 = self . create_policy_target_group ( <EOL> proxied_group_id = ptg [ '<STR_LIT:id>' ] , proxy_type = '<STR_LIT>' ) [ '<STR_LIT>' ] <EOL> proxy2 = self . create_policy_target_group ( <EOL> proxied_group_id = proxy1 [ '<STR_LIT:id>' ] , <EOL> proxy_type = '<STR_LIT>' ) [ '<STR_LIT>' ] <EOL> proxy3 = self . create_policy_target_group ( <EOL> proxied_group_id = proxy2 [ '<STR_LIT:id>' ] , <EOL> proxy_type = '<STR_LIT>' ) [ '<STR_LIT>' ] <EOL> self . delete_policy_target_group ( ptg [ '<STR_LIT:id>' ] , expected_res_status = <NUM_LIT> ) <EOL> self . show_policy_target_group ( proxy1 [ '<STR_LIT:id>' ] , expected_res_status = <NUM_LIT> ) <EOL> self . show_policy_target_group ( proxy2 [ '<STR_LIT:id>' ] , expected_res_status = <NUM_LIT> ) <EOL> self . show_policy_target_group ( proxy3 [ '<STR_LIT:id>' ] , expected_res_status = <NUM_LIT> ) <EOL> def test_proxy_creation_different_l3p ( self ) : <EOL> l3p1 = self . create_l3_policy ( ) [ '<STR_LIT>' ] <EOL> l2p1 = self . create_l2_policy ( l3_policy_id = l3p1 [ '<STR_LIT:id>' ] ) [ '<STR_LIT>' ] <EOL> ptg = self . create_policy_target_group ( <EOL> l2_policy_id = l2p1 [ '<STR_LIT:id>' ] ) [ '<STR_LIT>' ] <EOL> l3p2 = self . create_l3_policy ( <EOL> ip_pool = '<STR_LIT>' , proxy_ip_pool = '<STR_LIT>' ) [ '<STR_LIT>' ] <EOL> l2p2 = self . create_l2_policy ( l3_policy_id = l3p2 [ '<STR_LIT:id>' ] ) [ '<STR_LIT>' ] <EOL> res = self . create_policy_target_group ( <EOL> l2_policy_id = l2p2 [ '<STR_LIT:id>' ] , proxied_group_id = ptg [ '<STR_LIT:id>' ] , <EOL> expected_res_status = <NUM_LIT> ) <EOL> self . assertEqual ( '<STR_LIT>' , res [ '<STR_LIT>' ] [ '<STR_LIT:type>' ] ) <EOL> def test_l2_proxy_creation_same_l2p ( self ) : <EOL> l3p1 = self . create_l3_policy ( ) [ '<STR_LIT>' ] <EOL> l2p1 = self . create_l2_policy ( l3_policy_id = l3p1 [ '<STR_LIT:id>' ] ) [ '<STR_LIT>' ] <EOL> ptg = self . create_policy_target_group ( <EOL> l2_policy_id = l2p1 [ '<STR_LIT:id>' ] ) [ '<STR_LIT>' ] <EOL> res = self . create_policy_target_group ( <EOL> l2_policy_id = l2p1 [ '<STR_LIT:id>' ] , proxied_group_id = ptg [ '<STR_LIT:id>' ] , <EOL> proxy_type = '<STR_LIT>' , expected_res_status = <NUM_LIT> ) <EOL> self . assertEqual ( '<STR_LIT>' , res [ '<STR_LIT>' ] [ '<STR_LIT:type>' ] ) <EOL> def test_l3_proxy_creation_same_l2p ( self ) : <EOL> l3p1 = self . create_l3_policy ( ) [ '<STR_LIT>' ] <EOL> l2p1 = self . create_l2_policy ( l3_policy_id = l3p1 [ '<STR_LIT:id>' ] ) [ '<STR_LIT>' ] <EOL> ptg = self . create_policy_target_group ( <EOL> l2_policy_id = l2p1 [ '<STR_LIT:id>' ] ) [ '<STR_LIT>' ] <EOL> self . create_policy_target_group ( <EOL> l2_policy_id = l2p1 [ '<STR_LIT:id>' ] , proxied_group_id = ptg [ '<STR_LIT:id>' ] , <EOL> proxy_type = '<STR_LIT>' , expected_res_status = <NUM_LIT> ) <EOL> def test_proxy_creation_implicit_l2p ( self ) : <EOL> l3p = self . create_l3_policy ( <EOL> name = '<STR_LIT>' , ip_pool = '<STR_LIT>' , <EOL> proxy_ip_pool = '<STR_LIT>' ) [ '<STR_LIT>' ] <EOL> l2p = self . create_l2_policy ( l3_policy_id = l3p [ '<STR_LIT:id>' ] ) [ '<STR_LIT>' ] <EOL> ptg = self . create_policy_target_group ( <EOL> l2_policy_id = l2p [ '<STR_LIT:id>' ] ) [ '<STR_LIT>' ] <EOL> group_noproxy = self . create_policy_target_group ( <EOL> l2_policy_id = None ) [ '<STR_LIT>' ] <EOL> l2p = self . show_l2_policy ( group_noproxy [ '<STR_LIT>' ] ) [ '<STR_LIT>' ] <EOL> self . assertNotEqual ( l3p [ '<STR_LIT:id>' ] , l2p [ '<STR_LIT>' ] ) <EOL> group_proxy = self . create_policy_target_group ( <EOL> l2_policy_id = None , <EOL> proxied_group_id = ptg [ '<STR_LIT:id>' ] ) [ '<STR_LIT>' ] <EOL> l2p = self . show_l2_policy ( group_proxy [ '<STR_LIT>' ] ) [ '<STR_LIT>' ] <EOL> self . assertEqual ( l3p [ '<STR_LIT:id>' ] , l2p [ '<STR_LIT>' ] ) <EOL> class TestL2Policy ( ResourceMappingProxyGroupGBPTestCase , <EOL> test_resource_mapping . TestL2Policy ) : <EOL> def test_l3p_update_rejected ( self ) : <EOL> super ( TestL2Policy , self ) . test_l3p_update_rejected ( <EOL> proxy_ip_pool = '<STR_LIT>' ) <EOL> class TestL3Policy ( ResourceMappingProxyGroupGBPTestCase , <EOL> test_resource_mapping . TestL3Policy ) : <EOL> def test_implicit_l3p_proxy_pool ( self ) : <EOL> default_proxy_pool = '<STR_LIT>' <EOL> default_proxy_subnet_prefix_length = <NUM_LIT> <EOL> l2p = self . create_l2_policy ( ) [ '<STR_LIT>' ] <EOL> l3p = self . show_l3_policy ( l2p [ '<STR_LIT>' ] ) [ '<STR_LIT>' ] <EOL> self . assertEqual ( default_proxy_pool , l3p [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( default_proxy_subnet_prefix_length , <EOL> l3p [ '<STR_LIT>' ] ) <EOL> class TestPolicyRuleSet ( ResourceMappingProxyGroupGBPTestCase , <EOL> test_resource_mapping . TestPolicyRuleSet ) : <EOL> pass <EOL> class TestPolicyAction ( ResourceMappingProxyGroupGBPTestCase , <EOL> test_resource_mapping . TestPolicyAction ) : <EOL> pass <EOL> class TestPolicyRule ( ResourceMappingProxyGroupGBPTestCase , <EOL> test_resource_mapping . TestPolicyRule ) : <EOL> pass <EOL> class TestExternalSegment ( ResourceMappingProxyGroupGBPTestCase , <EOL> test_resource_mapping . TestExternalSegment ) : <EOL> def test_update ( self ) : <EOL> super ( TestExternalSegment , self ) . test_update ( <EOL> proxy_ip_pool1 = '<STR_LIT>' , <EOL> proxy_ip_pool2 = '<STR_LIT>' ) <EOL> class TestExternalPolicy ( ResourceMappingProxyGroupGBPTestCase , <EOL> test_resource_mapping . TestExternalPolicy ) : <EOL> pass </s>
