def test_182_datewayid(self): u"""默认网关id上报功能验证""" default_gwid = "44060430603381" gwid = general_control.get_gatewayId(self) general_control.apply(self) time.sleep(40) data = wifidog_business.redirest_network(self) assert (default_gwid in data)and(default_gwid in gwid),u"默认网关ID上报功能验证失败"
def test_189_hostname(self): u"""默认服务器地址""" default_hostname = "wifi.100msh.com" data = general_control.get_wifidog_hostname(self) general_control.apply(self) time.sleep(30) url = network_control.rand_redirect_get_url(self) assert default_hostname in (data and url),u"默认认证服务器不是%s"%default_hostname
def step_100msh0287(self): #修改门户认证的检查间隔为60s general_control.set_checkInterval(self,'60') general_control.apply(self) time.sleep(60) #上传tcpdump到路由器 #调用ssh的默认登录ip,用户名和密码 d = data.ssh_user() tcpdump_control.scp_to_remote('./data/BHU_tcpdump/tcpdump',d[0],d[1],d[2],'/usr/sbin/') tcpdump_control.scp_to_remote('./data/BHU_tcpdump/libpcap.so.1.3',d[0],d[1],d[2],'/usr/lib/') #ssh登录路由输入tcpdump抓包 wanlog = capture_wan_packet() #将抓到的封包传输回本地pc tcpdump_control.scp_to_local(d[0],d[1],d[2],wanlog,'./data/') #打开本地下载的文件,读取文件内容 f = open('./data/wanlog') log = f.read() f.close() '''#获取路由网关ID gw = general_control.get_gatewayId(self) #路由mac r_mac = ssh.ssh_cmd2("ifconfig eth0 | grep HWaddr | awk '{print$5}'") R_MAC = r_mac.upper() #路由版本 r_version = ssh.ssh_cmd2('cat /etc/version/version') R_VERSION = r_version.upper() #路由无线mac wlan_mac = ssh.ssh_cmd2("ifconfig wlan0 | grep HWaddr | awk '{print$5}'") WLAN_MAC = wlan_mac.upper()''' #正确的心跳ping信息字符如下 ping_str1 = 'GET /index/ping/?gw_id=' #ping_str2 = 'route_mac=%s&route_version=%s&wlan_mac_0=%s'%(R_MAC,R_VERSION,WLAN_MAC) if ping_str1 in log: #ping信息在log信息中,说明有心跳信息,结果赋值1 result = 1 else: #ping信息不在log信息中,说明没有心跳信息,结果赋值0 result = 0 #结果返回给函数 return result
def test_testore_func(self): general_control.wifidog_menu(self) gatewayId1 = general_control.get_gatewayId(self) general_control.set_gatewayId(self,'11111111111') general_control.apply(self) restore_control.menu(self) restore_control.set_restore(self) alert = restore_control.get_alert(self) alert.accept() #time.sleep(60) self.driver.implicitly_wait(50) self.driver.get(url) login_control.set_user(self,user,pwd) login_control.submit(self) general_control.wifidog_menu(self) gatewayId2 = general_control.get_gatewayId(self) assert gatewayId1==gatewayId2,u'恢复出场设置后网关ID恢复默认值'
def test(self): print '1' ip = '192.168.11.1' user = '******' password = '******' #上传tcpdump到路由器 tcpdump_control.scp_to_remote( '/home/zeng/PycharmProjects/BHU/data/BHU_tcpdump/tcpdump', ip, user, password, '/usr/sbin/') print '2' tcpdump_control.scp_to_remote( '/home/zeng/PycharmProjects/BHU/data/BHU_tcpdump/libpcap.so.1.3', ip, user, password, '/usr/lib/') print '3' #默认IP登录路由web页面 web_user_password = data.default_web_user_password() interface_business.open_router_web(self, web_user_password[0]) #登录路由 login_control.set_user(self, web_user_password[1], web_user_password[2]) login_control.submit(self) time.sleep(3) #进入门户认证,修改网关ID general_control.wifidog_menu(self) print '4' #修改门户认证的检查间隔为60s general_control.set_checkInterval(self, '60') general_control.apply(self) time.sleep(60) print '5' #ssh登录路由输入tcpdump抓包 tcpdump_control.tcpdump_command(user, ip, password, 'tcpdump -i eth1 -s0 -w /tmp/wanlog') tcpdump_control.scp_to_local(ip, user, password, '/tmp/wanlog', '/home/zeng/') f = open('/home/zeng/wanlog') log = f.read() f.close() if 'GET /index/ping/?gw_id=' in log: print 'pass' else: print 'failed'
def test(self): i = 0 while True: ping = public.get_ping('192.168.11.1') #如果能够ping通路由,则表示未失败 if ping == 0: #打开reboot.txt文件,写入pass f = open('reboot.txt', 'a') f.writelines('第%d次测试pass\n' % i) f.close() D = data.default_web_user_password() try: #打开路由页面,确认路由页面是否能显示 self.driver.get('http://%s:8088' % D[0]) time.sleep(5) self.driver.find_element_by_name('username') except: #不能显示路由页面,则登录ssh重启路由 wifidog_business.reboot(self) finally: #登录路由页面 self.driver.get('http://%s:8088' % D[0]) login_control.set_user(self, D[1], D[2]) login_control.submit(self) time.sleep(3) #进入门户认证,修改网关ID general_control.wifidog_menu(self) general_control.set_rand_gatewayId(self) general_control.apply(self) time.sleep(60) #再次重启路由 wifidog_business.reboot(self) #不能ping通则打开reboot.txt文件写入fail,退出循环 else: f = open('reboot.txt', 'a') f.writelines('第%d次测试fail\n' % i) f.closed() break i += 1
def test(self): print '1' ip ='192.168.11.1' user = '******' password = '******' #上传tcpdump到路由器 tcpdump_control.scp_to_remote('/home/zeng/PycharmProjects/BHU/data/BHU_tcpdump/tcpdump',ip,user,password,'/usr/sbin/') print '2' tcpdump_control.scp_to_remote('/home/zeng/PycharmProjects/BHU/data/BHU_tcpdump/libpcap.so.1.3',ip,user,password,'/usr/lib/') print '3' #默认IP登录路由web页面 web_user_password = data.default_web_user_password() interface_business.open_router_web(self,web_user_password[0]) #登录路由 login_control.set_user(self,web_user_password[1],web_user_password[2]) login_control.submit(self) time.sleep(3) #进入门户认证,修改网关ID general_control.wifidog_menu(self) print '4' #修改门户认证的检查间隔为60s general_control.set_checkInterval(self,'60') general_control.apply(self) time.sleep(60) print '5' #ssh登录路由输入tcpdump抓包 tcpdump_control.tcpdump_command(user,ip,password,'tcpdump -i eth1 -s0 -w /tmp/wanlog') tcpdump_control.scp_to_local(ip,user,password,'/tmp/wanlog','/home/zeng/') f = open('/home/zeng/wanlog') log = f.read() f.close() if 'GET /index/ping/?gw_id=' in log: print 'pass' else: print 'failed'