def test_04_create_ntp(self, dev, state_map): state = state_map.setdefault(dev) if not state.got_device_config: pytest.xfail('failed to get device config') primary = None secondary = None for x in state.dco.children: if x.__class__ == device.NTPServerPrimary: primary = x elif x.__class__ == device.NTPServerSecondary: secondary = x state.restore_ntp = False if primary is None: state.ntp_obj = device.NTPServerPrimary( address=testlib.random_ip()) elif secondary is None: state.ntp_obj = device.NTPServerSecondary( address=testlib.random_ip()) else: state.created_ntp = True state.restore_ntp = True state.ntp_obj = secondary pytest.skip('Both primary and secondary exist, nothing to create') state.dco.add(state.ntp_obj) state.ntp_obj.create() state.created_ntp = True
def create_dependencies(self, fw, state): state.lbi = network.LoopbackInterface( 'loopback.{0}'.format(random.randint(5, 20)), ip=[testlib.random_ip(), testlib.random_ip()], ) fw.add(state.lbi) state.lbi.create()
def setup_state_obj(self, fw, state): state.obj = network.Zone( testlib.random_name(), 'layer2', state.eths[0], enable_user_identification=False, include_acl=testlib.random_ip('/24'), exclude_acl=testlib.random_ip('/24'), ) fw.add(state.obj)
def setup_state_obj(self, fw, state): state.obj = network.StaticRoute( testlib.random_name(), destination=testlib.random_ip('/32'), nexthop_type='ip-address', nexthop=testlib.random_ip(), admin_dist=random.randint(10, 240), metric=random.randint(1, 65535), ) state.vr.add(state.obj)
def setup_state_obj(self, fw, state): state.obj = network.StaticRoute( testlib.random_name(), testlib.random_ip('/32'), 'ip-address', testlib.random_ip(), state.eth, random.randint(10, 240), random.randint(1, 65535), ) state.vr.add(state.obj)
def create_dependencies(self, fw, state): state.eth_obj = None state.eth = testlib.get_available_interfaces(fw)[0] state.eth_obj = network.EthernetInterface(state.eth, 'layer3', testlib.random_ip('/24')) fw.add(state.eth_obj) state.eth_obj.create() tag = random.randint(1, 4000) state.parent = network.Layer3Subinterface( '{0}.{1}'.format(state.eth, tag), tag, testlib.random_ip('/24')) state.eth_obj.add(state.parent) state.parent.create()
def create_dependencies(self, fw, state): state.eth_obj = None state.eth = testlib.get_available_interfaces(fw)[0] state.eth_obj = network.EthernetInterface( state.eth, 'layer3', testlib.random_ip('/24')) fw.add(state.eth_obj) state.eth_obj.create() tag = random.randint(1, 4000) state.parent = network.Layer3Subinterface( '{0}.{1}'.format(state.eth, tag), tag, testlib.random_ip('/24')) state.eth_obj.add(state.parent) state.parent.create()
def setup_state_obj(self, fw, state): some_ip = testlib.random_ip() state.obj = network.RedistributionProfile( testlib.random_name(), priority=random.randint(1, 255), action='no-redist', filter_type=['ospf', 'static', 'connect'], filter_interface=random.choice(state.eths), filter_destination=testlib.random_ip(), filter_nexthop=testlib.random_ip(), ospf_filter_pathtype=('intra-area', 'ext-1'), ospf_filter_area=some_ip, ospf_filter_tag=some_ip, ) state.vr.add(state.obj)
def test_11_batch(self, fw, state_map): fw.userid.clear_registered_ip() #Fresh start fw.userid.batch_start() users = [(testlib.random_name(), testlib.random_ip()) for i in range(5)] fw.userid.logins(users) ips = [testlib.random_ip() for x in range(5)] tags = [testlib.random_name() for y in range(5)] fw.userid.register(ips, tags) fw.userid.unregister(ips[2], tags[4]) fw.userid.get_registered_ip(ips[0:3], tags[2:4]) new_ips = [testlib.random_ip() for x in range(3)] new_tags = [testlib.random_name() for y in range(3)] fw.userid.audit_registered_ip(dict([(ip, tuple(new_tags)) for ip in new_ips])) fw.userid.get_registered_ip() fw.userid.unregister(new_ips, new_tags) fw.userid.batch_end()
def create_dependencies(self, fw, state): state.eth_obj = None state.eth = testlib.get_available_interfaces(fw)[0] state.eth_obj = network.EthernetInterface( state.eth, 'layer3', testlib.random_ip('/24')) fw.add(state.eth_obj) state.eth_obj.create()
def test_03_update_secondary_dns(self, dev, state_map): state = state_map.setdefault(dev) if not state.got_device_config: pytest.xfail('failed to get device config') # Toggle the secondary ip address self.toggle_object_variable(state.dco, 'dns_secondary', testlib.random_ip())
def setup_state_obj(self, fw, state): state.obj = network.TunnelInterface( 'tunnel.{0}'.format(random.randint(20, 5000)), testlib.random_ip('/24'), mtu=random.randint(800, 1000), comment='Underground interface', ) fw.add(state.obj)
def create_dependencies(self, fw, state): state.eth_obj = None state.eth = testlib.get_available_interfaces(fw)[0] state.eth_obj = network.EthernetInterface(state.eth, 'layer3', testlib.random_ip('/24')) fw.add(state.eth_obj) state.eth_obj.create()
def create_dependencies(self, dev, state): state.aos = [ objects.AddressObject(testlib.random_name(), testlib.random_ip()) for x in range(4) ] for x in state.aos: dev.add(x) x.create()
def setup_state_obj(self, dev, state): state.obj = objects.AddressObject( testlib.random_name(), value=testlib.random_ip(), type='ip-netmask', description='This is a test', ) dev.add(state.obj)
def test_05_update_ntp(self, dev, state_map): state = state_map.setdefault(dev) if not state.got_device_config: pytest.xfail('failed to get device config') if not state.created_ntp: pytest.xfail('failed to create ntp in previous step') self.toggle_object_variable(state.ntp_obj, 'address', testlib.random_ip())
def test_11_batch(self, fw, state_map): fw.userid.clear_registered_ip() # Fresh start fw.userid.batch_start() users = [(testlib.random_name(), testlib.random_ip()) for i in range(5)] fw.userid.logins(users) ips = [testlib.random_ip() for x in range(5)] tags = [testlib.random_name() for y in range(5)] fw.userid.register(ips, tags) fw.userid.unregister(ips[2], tags[4]) fw.userid.get_registered_ip(ips[0:3], tags[2:4]) new_ips = [testlib.random_ip() for x in range(3)] new_tags = [testlib.random_name() for y in range(3)] fw.userid.audit_registered_ip( dict([(ip, tuple(new_tags)) for ip in new_ips])) fw.userid.get_registered_ip() fw.userid.unregister(new_ips, new_tags) fw.userid.batch_end()
def setup_state_obj(self, fw, state): tag = random.randint(1, 4000) name = '{0}.{1}'.format(state.eth, tag) state.obj = network.Layer3Subinterface( name, tag, testlib.random_ip('/24'), False, state.management_profile, random.randint(576, 1500), True, None, 'This is my subeth', random.randint(40, 300), random.randint(60, 300), ) state.parent.add(state.obj)
def test_09_audit_registered_ip(self, fw, state_map): state = state_map.setdefault(fw) original = set(fw.userid.get_registered_ip()) new_ips = [testlib.random_ip() for x in range(5)] new_tags = [testlib.random_name() for i in range(8)] ip_tags_pairs = dict([(ip, tuple(new_tags)) for ip in new_ips]) fw.userid.audit_registered_ip(ip_tags_pairs) state.multi_register_02 = [new_ips, new_tags] new_set = set(fw.userid.get_registered_ip()) assert len(new_set) < len(original) assert new_set == set(new_ips)
def setup_state_obj(self, fw, state): state.obj = network.LoopbackInterface( 'loopback.{0}'.format(random.randint(20, 5000)), testlib.random_ip(), mtu=random.randint(800, 1000), adjust_tcp_mss=True, comment='Some loopback interface', ipv4_mss_adjust=random.randint(100, 200), ipv6_mss_adjust=random.randint(100, 200), ) fw.add(state.obj)
def setup_state_obj(self, fw, state): state.obj = network.VlanInterface( 'vlan.{0}'.format(random.randint(20, 5000)), testlib.random_ip('/24'), mtu=random.randint(800, 1000), adjust_tcp_mss=True, comment='Vlan interface', ipv4_mss_adjust=random.randint(100, 200), ipv6_mss_adjust=random.randint(100, 200), ) fw.add(state.obj)
def setup_state_obj(self, fw, state): state.obj = network.IkeGateway( testlib.random_name(), auth_type='pre-shared-key', enable_dead_peer_detection=True, enable_liveness_check=True, enable_passive_mode=True, ikev2_crypto_profile='default', interface=state.lbi.name, liveness_check_interval=5, local_id_type='ipaddr', local_id_value=testlib.random_ip(), local_ip_address_type='ip', local_ip_address=state.lbi.ip[0], peer_ip_type='ip', peer_ip_value=testlib.random_ip(), pre_shared_key='secret', version='ikev2-preferred', ) fw.add(state.obj)
def create_dependencies(self, fw, state): state.eth_obj = None state.eth = testlib.get_available_interfaces(fw)[0] state.eth_obj = network.EthernetInterface( state.eth, 'layer3', testlib.random_ip('/24'), ipv6_enabled=True) fw.add(state.eth_obj) state.eth_obj.create() state.vr = network.VirtualRouter( testlib.random_name(), interface=state.eth) fw.add(state.vr) state.vr.create()
def create_dependencies(self, fw, state): state.eths = testlib.get_available_interfaces(fw, 2) state.eth_obj_v4 = network.EthernetInterface(state.eths[0], 'layer3', testlib.random_ip('/24')) fw.add(state.eth_obj_v4) state.eth_obj_v6 = network.EthernetInterface(state.eths[1], 'layer3', ipv6_enabled=True) fw.add(state.eth_obj_v6) state.eth_obj_v4.create_similar() state.vr = network.VirtualRouter(testlib.random_name(), state.eths) fw.add(state.vr) state.vr.create() if any((self.WITH_OSPF, self.WITH_AUTH_PROFILE, self.WITH_AREA, self.WITH_AREA_INTERFACE)): state.ospf = network.Ospf(True, testlib.random_ip()) state.vr.add(state.ospf) if self.WITH_AUTH_PROFILE: state.auth = network.OspfAuthProfile(testlib.random_name(), 'md5') state.ospf.add(state.auth) if self.WITH_AREA or self.WITH_AREA_INTERFACE: state.area = network.OspfArea(testlib.random_ip()) state.ospf.add(state.area) if self.WITH_AREA_INTERFACE: state.iface = network.OspfAreaInterface( state.eths[0], True, True, 'p2mp') state.area.add(state.iface) state.ospf.create()
def create_dependencies(self, fw, state): state.eths = testlib.get_available_interfaces(fw, 2) state.eth_obj_v4 = network.EthernetInterface( state.eths[0], 'layer3', testlib.random_ip('/24')) fw.add(state.eth_obj_v4) state.eth_obj_v6 = network.EthernetInterface( state.eths[1], 'layer3', ipv6_enabled=True) fw.add(state.eth_obj_v6) state.eth_obj_v4.create_similar() state.vr = network.VirtualRouter(testlib.random_name(), state.eths) fw.add(state.vr) state.vr.create() if any((self.WITH_OSPF, self.WITH_AUTH_PROFILE, self.WITH_AREA, self.WITH_AREA_INTERFACE)): state.ospf = network.Ospf( True, testlib.random_ip()) state.vr.add(state.ospf) if self.WITH_AUTH_PROFILE: state.auth = network.OspfAuthProfile( testlib.random_name(), 'md5') state.ospf.add(state.auth) if self.WITH_AREA or self.WITH_AREA_INTERFACE: state.area = network.OspfArea(testlib.random_ip()) state.ospf.add(state.area) if self.WITH_AREA_INTERFACE: state.iface = network.OspfAreaInterface( state.eths[0], True, True, 'p2mp') state.area.add(state.iface) state.ospf.create()
def create_dependencies(self, fw, state): state.management_profile = network.ManagementProfile( testlib.random_name(), ping=True) state.eth = None fw.add(state.management_profile) state.management_profile.create() state.eth = testlib.get_available_interfaces(fw)[0] state.parent = network.EthernetInterface( state.eth, 'layer3', ip=testlib.random_ip('/24'), ) fw.add(state.parent) state.parent.create()
def setup_state_obj(self, fw, state): state.obj = network.EthernetInterface( state.eth, 'layer3', testlib.random_ip('/24'), ipv6_enabled=False, management_profile=state.management_profiles[0], mtu=random.randint(600, 1500), adjust_tcp_mss=True, link_speed='auto', link_duplex='auto', link_state='auto', comment='This is my interface', ipv4_mss_adjust=random.randint(40, 300), ipv6_mss_adjust=random.randint(60, 300), ) fw.add(state.obj)
def create_dependencies(self, fw, state): state.eth_obj = None state.eth = testlib.get_available_interfaces(fw)[0] state.eth_obj = network.EthernetInterface(state.eth, 'layer3', testlib.random_ip('/24'), ipv6_enabled=True) fw.add(state.eth_obj) state.eth_obj.create() state.vr = network.VirtualRouter(testlib.random_name(), interface=state.eth) fw.add(state.vr) state.vr.create()
def create_dependencies(self, fw, state): state.eth_objs = [] state.vr = None state.eths = testlib.get_available_interfaces(fw, 2) for e in state.eths: state.eth_objs.append( network.EthernetInterface(e, 'layer3', testlib.random_ip('/24'))) fw.add(state.eth_objs[-1]) state.eth_objs[-1].create() state.vr = network.VirtualRouter(testlib.random_name(), state.eths) fw.add(state.vr) state.vr.create()
def create_dependencies(self, fw, state): state.ti = network.TunnelInterface( 'tunnel.{0}'.format(random.randint(5, 50)), ip=[testlib.random_ip(), testlib.random_ip()], ) fw.add(state.ti) state.lbi = network.LoopbackInterface( 'loopback.{0}'.format(random.randint(5, 20)), ip=[testlib.random_ip(), testlib.random_ip()], ) fw.add(state.lbi) state.ike_gw = network.IkeGateway( testlib.random_name(), auth_type='pre-shared-key', enable_dead_peer_detection=True, enable_liveness_check=True, enable_passive_mode=True, ikev2_crypto_profile='default', interface=state.lbi.name, liveness_check_interval=5, local_id_type='ipaddr', local_id_value=testlib.random_ip(), local_ip_address_type='ip', local_ip_address=state.lbi.ip[0], peer_ip_type='ip', peer_ip_value=testlib.random_ip(), pre_shared_key='secret', version='ikev2-preferred', ) fw.add(state.ike_gw) state.ti.create() state.lbi.create() state.ike_gw.create()
def test_07_register_lst(self, fw, state_map): state = state_map.setdefault(fw) ips = [testlib.random_ip() for x in range(10)] tags = [testlib.random_name() for i in range(15)] fw.userid.register(ips, tags) state.multi_register_01 = [ips, tags]
def setup_state_obj(self, fw, state): state.obj = network.OspfNssaExternalRange( testlib.random_ip('/24'), 'advertise') state.area.add(state.obj)
def update_state_obj(self, fw, state): state.obj.destination = testlib.random_ip('/32') state.obj.nexthop_type = 'discard' state.obj.nexthop = None
def update_state_obj(self, fw, state): state.obj.comment = 'Update the comment' state.obj.ip = testlib.random_ip('/24')
def setup_state_obj(self, fw, state): state.obj = network.OspfNeighbor(testlib.random_ip(), 10) state.iface.add(state.obj)
def setup_state_obj(self, fw, state): state.obj = network.OspfExportRules( testlib.random_netmask(), 'ext-2', testlib.random_ip(), 2048) state.ospf.add(state.obj)
def setup_state_obj(self, fw, state): state.obj = network.Ospf( True, testlib.random_ip(), True, True, True, 2, 3, False, 300, False, False, 400) state.vr.add(state.obj)
def test_01_fw_login(self, fw, state_map): state = state_map.setdefault(fw) user, ip = testlib.random_name(), testlib.random_ip() fw.userid.login(user, ip) state.single_user = [user, ip]
def update_state_obj(self, fw, state): state.obj.destination = testlib.random_ip('/32') state.obj.nexthop_type = 'discard' state.obj.nexthop = None state.obj.interface = None
def setup_state_obj(self, fw, state): state.obj = network.OspfRange(testlib.random_ip(), 'advertise') state.area.add(state.obj)
def setup_state_obj(self, fw, state): state.obj = network.Arp(testlib.random_ip(), '00:30:48:52:ab:cd') state.eth_obj.add(state.obj)
def setup_state_obj(self, fw, state): state.obj = network.OspfArea( testlib.random_ip(), 'normal') state.ospf.add(state.obj)