def test_bgpaas_update_with_valid_2_byte_local_asn(self): # Create bgpaas object with ASN 64512 and Local ASN 64500 bgpaas_uuid, bgpaas_obj = self.create_bgpaas_with_local_asn() # Update Local ASN with a valid value bgp_session_attr = BgpSessionAttributes(local_autonomous_system=64000) bgpaas_obj.set_bgpaas_session_attributes(bgp_session_attr) self.api.bgp_as_a_service_update(bgpaas_obj) # Finally, delete the bgpaas object self.api.bgp_as_a_service_delete(id=bgpaas_uuid)
def test_bgpaas_create_with_invalid_2_byte_asn(self): proj = self.api.project_read( fq_name=["default-domain", "default-project"]) bgp_session_attr = BgpSessionAttributes(local_autonomous_system=64500) bgpaas_obj = BgpAsAService(name='bgpaas', parent_obj=proj, bgpaas_session_attributes=bgp_session_attr) # Set a invalid ASN and create bgpaas object bgpaas_obj.autonomous_system = 700000 self.assertRaises(BadRequest, self.api.bgp_as_a_service_create, bgpaas_obj)
def create_bgpaas_with_local_asn(self): proj = self.api.project_read( fq_name=["default-domain", "default-project"]) bgp_session_attr = BgpSessionAttributes(local_autonomous_system=64500) bgpaas_obj = BgpAsAService(name='bgpaas', parent_obj=proj, bgpaas_session_attributes=bgp_session_attr) bgpaas_obj.autonomous_system = 64512 bgpaas_uuid = self.api.bgp_as_a_service_create(bgpaas_obj) return bgpaas_uuid, bgpaas_obj
def test_bgpaas_create_with_valid_2_byte_asn(self): proj = self.api.project_read( fq_name=["default-domain", "default-project"]) bgp_session_attr = BgpSessionAttributes(local_autonomous_system=64500) bgpaas_obj = BgpAsAService(name='bgpaas', parent_obj=proj, bgpaas_session_attributes=bgp_session_attr) # Set a valid ASN and create bgpaas object bgpaas_obj.autonomous_system = 64512 bgpaas_uuid = self.api.bgp_as_a_service_create(bgpaas_obj) # Now delete the bgpaas object self.api.bgp_as_a_service_delete(id=bgpaas_uuid)
def test_bgpaas_update_with_hold_time(self): # Create bgpaas object proj = self.api.project_read( fq_name=['default-domain', 'default-project']) bgpaas_obj = BgpAsAService(name='bgpaas_update', parent_obj=proj) bgpaas_uuid = self.api.bgp_as_a_service_create(bgpaas_obj) for test in self.hold_time_test_cases: # Update hold time with valid and invalid values bgp_session_attr = BgpSessionAttributes( hold_time=test['hold_time']) bgpaas_obj.set_bgpaas_session_attributes(bgp_session_attr) if test['should_pass']: self.api.bgp_as_a_service_update(bgpaas_obj) else: self.assertRaises(BadRequest, self.api.bgp_as_a_service_update, bgpaas_obj) # Finally, delete the bgpaas object self.api.bgp_as_a_service_delete(id=bgpaas_uuid)
def test_bgpaas_create_with_hold_time(self): proj = self.api.project_read( fq_name=["default-domain", "default-project"]) for test in self.hold_time_test_cases: bgp_session_attr = BgpSessionAttributes( hold_time=test['hold_time']) bgpaas_obj = BgpAsAService( name='bgpaas', parent_obj=proj, bgpaas_session_attributes=bgp_session_attr) if test['should_pass']: # Create bgpaas object with proper hold time bgpaas_uuid = self.api.bgp_as_a_service_create(bgpaas_obj) # Now delete the bgpaas object self.api.bgp_as_a_service_delete(id=bgpaas_uuid) else: # Try to create bgpaas object with improper hold time # and expect error self.assertRaises(BadRequest, self.api.bgp_as_a_service_create, bgpaas_obj)
def test_bgpaas_update_with_valid_4_byte_local_asn(self): gsc = self.api.global_system_config_read(GlobalSystemConfig().fq_name) # Enable 4 byte ASN flag in GSC gsc.enable_4byte_as = True self.api.global_system_config_update(gsc) # Create bgpaas object with ASN 64512 and Local ASN 64500 bgpaas_uuid, bgpaas_obj = self.create_bgpaas_with_local_asn() # Update Local ASN with a valid value bgp_session_attr = BgpSessionAttributes(local_autonomous_system=700002) bgpaas_obj.set_bgpaas_session_attributes(bgp_session_attr) self.api.bgp_as_a_service_update(bgpaas_obj) # Disable 4 byte ASN flag gsc.enable_4byte_as = False self.api.global_system_config_update(gsc) # Finally, delete the bgpaas object self.api.bgp_as_a_service_delete(id=bgpaas_uuid)
def test_bgpaas_create_with_valid_4_byte_asn(self): gsc = self.api.global_system_config_read(GlobalSystemConfig().fq_name) # Enable 4 byte ASN flag in GSC gsc.enable_4byte_as = True self.api.global_system_config_update(gsc) proj = self.api.project_read( fq_name=["default-domain", "default-project"]) bgp_session_attr = BgpSessionAttributes(local_autonomous_system=700001) bgpaas_obj = BgpAsAService(name='bgpaas', parent_obj=proj, bgpaas_session_attributes=bgp_session_attr) # Set a valid ASN and create bgpaas object bgpaas_obj.autonomous_system = 700000 bgpaas_uuid = self.api.bgp_as_a_service_create(bgpaas_obj) # Now delete the bgpaas object and disable 4 byte ASN flag self.api.bgp_as_a_service_delete(id=bgpaas_uuid) gsc.enable_4byte_as = False self.api.global_system_config_update(gsc)
def test_bgpaas_create_with_invalid_4_byte_local_asn(self): gsc = self.api.global_system_config_read(GlobalSystemConfig().fq_name) # Enable 4 byte ASN flag in GSC gsc.enable_4byte_as = True self.api.global_system_config_update(gsc) # Set a invalid Local ASN and create bgpaas object proj = self.api.project_read( fq_name=["default-domain", "default-project"]) bgp_session_attr = BgpSessionAttributes( local_autonomous_system=0x1FFFFFFFF) bgpaas_obj = BgpAsAService(name='bgpaas', parent_obj=proj, bgpaas_session_attributes=bgp_session_attr) bgpaas_obj.autonomous_system = 0x7000001 self.assertRaises(BadRequest, self.api.bgp_as_a_service_create, bgpaas_obj) # Finally, disable 4 byte ASN flag gsc.enable_4byte_as = False self.api.global_system_config_update(gsc)