Example #1
0
 def check_portal_client_block_function(self, ssid, password, wlan, eth):
     #通过免认证方式上网
     CPBusiness.\
         access_No_auth_portal(self,ssid,password,wlan,eth,"wpa")
     #无线网卡释放ip地址
     CPControl.dhcp_release_wlan(self, wlan)
     #断开无线连接
     CPControl.disconnect_ap(self)
     #启用有线网卡
     CPControl.wlan_enable(self, eth)
     tmp = ClientsBusiness(self.driver)
     #使用无线网卡能够连接上ssid,并正常使用
     tmp.connect_DHCP_WPA_AP(ssid, password, wlan)
     #无线网卡释放ip地址
     CPControl.dhcp_release_wlan(self, wlan)
     #刷新页面重新登录ap页面
     Lg = LoginBusiness(self.driver)
     Lg.refresh_login_ap()
     #只有一个客户端,阻塞该客户端
     wlan_mac = tmp.get_wlan_mac(wlan)
     tmp.block_client(wlan_mac)
     time.sleep(60)
     #测试机上判断无线客户端是否依然是连接上的
     result = tmp.get_client_cmd_result("iw dev %s link" % wlan)
     #无线网卡释放ip地址
     CPControl.dhcp_release_wlan(self, wlan)
     #断开无线连接
     CPControl.disconnect_ap(self)
     #刷新页面重新登录ap页面
     Lg = LoginBusiness(self.driver)
     Lg.refresh_login_ap()
     tmp1 = ClientAccessBusiness(self.driver)
     #删除Global Blacklist里面的所有的mac
     tmp1.del_Global_Blacklist_mac()
     return result
Example #2
0
 def check_STA_unblock_no_need_auth(self, ssid, password, wlan, eth):
     #无线STA通过group0的认证
     tmp = CPBusiness(self.driver)
     tmp.access_No_auth_portal(ssid, password, wlan, eth, "wpa")
     #无线网卡释放ip地址
     CPControl.dhcp_release_wlan(self, wlan)
     #断开无线连接
     CPControl.disconnect_ap(self)
     #启用有线网卡
     CPControl.wlan_enable(self, eth)
     #刷新页面重新登录ap页面
     Lg = LoginBusiness(self.driver)
     Lg.refresh_login_ap()
     #block STA
     tmp.connect_WPA_AP(ssid, password, wlan)
     tmp3 = ClientsBusiness(self.driver)
     wlan_mac = tmp3.get_wlan_mac(wlan)
     tmp3.block_client(wlan_mac)
     #unblock STA
     tmp4 = ClientAccessBusiness(self.driver)
     #删除Global Blacklist里面的所有的mac
     tmp4.del_Global_Blacklist_mac()
     #使用免认证的规则,腾讯首页,判断是否跳转到portal页面
     result = tmp.check_jump_to_No_auth_portal(ssid, password, wlan, eth)
     return result
Example #3
0
 def check_No_auth_portal(self, ssid, password, wlan, eth, t,
                          wifi_encryption):
     #通过免认证方式上网
     portal_title,redirect_title = CPBusiness.\
         access_No_auth_portal(self,ssid,password,wlan,eth,wifi_encryption)
     #再次确定能否访问腾讯首页
     again_title = CPBusiness.wait_for_title(self, "http://www.qq.com")
     print "Access tencent webpage again, goin to %s" % again_title
     current_time = time.strftime('%m-%d %H:%M',
                                  time.localtime(time.time()))
     print "-----------rick.zeng portal debug:finished access tencent again time:%s-----------" % current_time
     #验证过期时间
     #再次等待一段时间
     time.sleep(t)
     #打开http的页面http://www.qq.com
     expiration_title = CPBusiness.wait_for_title(self, "http://www.qq.com")
     print "wait %s seconds,access tencent webpage again, goin to %s" % (
         t, expiration_title)
     current_time = time.strftime('%m-%d %H:%M',
                                  time.localtime(time.time()))
     print "-----------rick.zeng portal debug:wait expiration time,finished access tencent time:%s-----------" % current_time
     #无线网卡释放ip地址
     CPControl.dhcp_release_wlan(self, wlan)
     #断开无线连接
     CPControl.disconnect_ap(self)
     #启用有线网卡
     CPControl.wlan_enable(self, eth)
     print "portal_title is %s" % portal_title
     print "redirect_title is %s" % redirect_title
     print "again_title is %s" % again_title
     print "expiration_title is %s" % expiration_title
     return portal_title, redirect_title, again_title, expiration_title
Example #4
0
 def check_radius_portal(self,ssid,password,wlan,eth,t,radius_name,\
                         radius_password):
     #无线网卡释放ip地址
     CPControl.dhcp_release_wlan(self, wlan)
     #禁用有线网卡
     CPControl.wlan_disable(self, eth)
     time.sleep(60)
     #使用无线网卡连接group0的ssid
     CPControl.connect_WPA_AP(self, ssid, password, wlan)
     #再次禁用有线网卡--防止无线网卡的多次连接时会重启全部网络导致有限网卡再次开启
     CPControl.wlan_disable(self, eth)
     #循环三次检查无线网卡是否能够上网
     for i in range(3):
         #无线网卡释放ip地址
         CPControl.dhcp_release_wlan(self, wlan)
         #无线网卡再次获取ip地址
         CPControl.dhcp_wlan(self, wlan)
         CPControl.move_resolv(self)
         #如果不能访问网络
         tmp = CPControl.get_ping(self, "www.qq.com")
         if tmp == 0:
             break
         else:
             "check wlan card can access internet or not,again."
     #打开http的页面http://www.qq.com
     portal_title = CPBusiness.wait_for_title(self, "http://www.qq.com")
     print "Access tencent webpage first, goin to %s" % portal_title
     #radius portal页面输入用户名密码然后点击登录
     redirect_title = CPBusiness.enter_radius_portal(
         self, radius_name, radius_password)
     print "click agree, goin to %s" % redirect_title
     #再次确定能否访问腾讯首页
     again_title = CPBusiness.wait_for_title(self, "http://www.qq.com")
     print "Access tencent webpage again, goin to %s" % again_title
     current_time = time.strftime('%m-%d %H:%M',
                                  time.localtime(time.time()))
     print "-----------rick.zeng portal debug:finished access tencent again time:%s-----------" % current_time
     #验证过期时间
     #再次等待一段时间
     time.sleep(t)
     #打开http的页面http://www.qq.com
     expiration_title = CPBusiness.wait_for_title(self, "http://www.qq.com")
     print "wait %s seconds,access tencent webpage again, goin to %s" % (
         t, expiration_title)
     current_time = time.strftime('%m-%d %H:%M',
                                  time.localtime(time.time()))
     print "-----------rick.zeng portal debug:wait expiration time,finished access tencent time:%s-----------" % current_time
     #无线网卡释放ip地址
     CPControl.dhcp_release_wlan(self, wlan)
     #断开无线连接
     CPControl.disconnect_ap(self)
     #启用有线网卡
     CPControl.wlan_enable(self, eth)
     print "portal_title is %s" % portal_title
     print "redirect_title is %s" % redirect_title
     print "again_title is %s" % again_title
     print "expiration_title is %s" % expiration_title
     return portal_title, redirect_title, again_title, expiration_title
Example #5
0
    def check_jump_to_No_auth_portal_backup(self, ssid, password, wlan, eth,
                                            wifi_encryption):
        #无线网卡释放ip地址
        CPControl.dhcp_release_wlan(self, wlan)
        #禁用有线网卡
        CPControl.wlan_disable(self, eth)
        time.sleep(60)
        #使用无线网卡连接group0的ssid
        if wifi_encryption == "open":
            CPControl.connect_NONE_AP(self, ssid, wlan)
        elif wifi_encryption == "wep":
            CPControl.connect_WEP_AP(self, ssid, password, wlan)
        elif wifi_encryption == "wpa":
            CPControl.connect_WPA_AP(self, ssid, password, wlan)
        elif wifi_encryption == "wpa_hiddenssid":
            CPControl.connect_WPA_hiddenssid_AP(self, ssid, password, wlan)
        elif wifi_encryption == "802.1x":
            CPControl.connect_8021x_AP(self, ssid,
                                       data_basic['radius_usename'],
                                       data_basic['radius_password'], wlan)

        #再次禁用有线网卡--防止无线网卡的多次连接时会重启全部网络导致有限网卡再次开启
        CPControl.wlan_disable(self, eth)
        #循环三次检查无线网卡是否能够上网
        for i in range(3):
            #无线网卡释放ip地址
            CPControl.dhcp_release_wlan(self, wlan)
            #无线网卡再次获取ip地址
            CPControl.dhcp_wlan(self, wlan)
            CPControl.move_resolv(self)
            #如果不能访问网络
            tmp = CPControl.get_ping(self, "www.qq.com")
            if tmp == 0:
                break
            else:
                "check wlan card can access internet or not,again."
        #打开http的页面http://www.qq.com
        redirect_title = CPBusiness.wait_for_title(self, "http://www.qq.com")
        print "Access tencent webpage, jump to %s webpage" % redirect_title
        #无线网卡释放ip地址
        CPControl.dhcp_release_wlan(self, wlan)
        #断开无线连接
        CPControl.disconnect_ap(self)
        #启用有线网卡
        CPControl.wlan_enable(self, eth)
        print redirect_title
        if redirect_title == "gatewayname Entry":
            return True
        else:
            return False
Example #6
0
 def check_portal_client_auth_status(self, ssid, password, wlan, eth, n):
     #通过免认证方式上网
     CPBusiness.\
         access_No_auth_portal(self,ssid,password,wlan,eth,"wpa")
     #无线网卡释放ip地址
     CPControl.dhcp_release_wlan(self, wlan)
     #断开无线连接
     CPControl.disconnect_ap(self)
     #启用有线网卡
     CPControl.wlan_enable(self, eth)
     #刷新页面重新登录ap页面
     Lg = LoginBusiness(self.driver)
     Lg.refresh_login_ap()
     #点击页面上强制网络门户
     CPControl.CP_menu(self)
     #点击强制网络门户页面上的客户端菜单
     CPControl.client_menu(self)
     auth_status1 = CPControl.get_client_auth_status(self, n)
     #禁用有线网卡
     CPControl.wlan_disable(self, eth)
     time.sleep(60)
     #使用无线网卡再次连接上
     CPControl.connect_DHCP_WPA_AP(self, ssid, password, wlan)
     #等待过期时间
     time.sleep(300)
     #使用无线网卡再次连接上
     CPControl.connect_DHCP_WPA_AP(self, ssid, password, wlan)
     #无线网卡释放ip地址
     CPControl.dhcp_release_wlan(self, wlan)
     #断开无线连接
     CPControl.disconnect_ap(self)
     #启用有线网卡
     CPControl.wlan_enable(self, eth)
     #刷新页面重新登录ap页面
     Lg = LoginBusiness(self.driver)
     Lg.refresh_login_ap()
     #点击页面上强制网络门户
     CPControl.CP_menu(self)
     #点击强制网络门户页面上的客户端菜单
     CPControl.client_menu(self)
     auth_status2 = CPControl.get_client_auth_status(self, n)
     return auth_status1, auth_status2
Example #7
0
 def check_auth_STA_not_need_auth_again(self, ssid, password, wlan, eth,
                                        radius_addr, radius_key, port,
                                        mode):
     #通过免认证方式上网
     CPBusiness.\
         access_No_auth_portal(self,ssid,password,wlan,eth,"wpa")
     #无线网卡释放ip地址
     CPControl.dhcp_release_wlan(self, wlan)
     #断开无线连接
     CPControl.disconnect_ap(self)
     #启用有线网卡
     CPControl.wlan_enable(self, eth)
     #刷新页面重新登录ap页面
     Lg = LoginBusiness(self.driver)
     Lg.refresh_login_ap()
     #将免认证改为radius认证
     CPBusiness.\
         change_radius_server(self,1,radius_addr,radius_key,port,mode)
     #验证是否需要弹出认证
     result = CPBusiness.\
         check_jump_to_No_auth_portal(self,ssid,password,wlan,eth)
     print result
     return result
Example #8
0
 def check_jump_to_No_auth_portal(self, ssid, password, wlan, eth):
     #无线网卡释放ip地址
     CPControl.dhcp_release_wlan(self, wlan)
     #禁用有线网卡
     CPControl.wlan_disable(self, eth)
     time.sleep(30)
     #使用无线网卡连接group0的ssid
     CPControl.connect_WPA_AP(self, ssid, password, wlan)
     #再次禁用有线网卡--防止无线网卡的多次连接时会重启全部网络导致有限网卡再次开启
     CPControl.wlan_disable(self, eth)
     #循环三次检查无线网卡是否能够上网
     for i in range(3):
         #无线网卡释放ip地址
         CPControl.dhcp_release_wlan(self, wlan)
         #无线网卡再次获取ip地址
         CPControl.dhcp_wlan(self, wlan)
         CPControl.move_resolv(self)
         #如果不能访问网络
         tmp = CPControl.get_ping(self, "www.qq.com")
         if tmp == 0:
             break
         else:
             print "check wlan card can access internet or not,again."
     #打开http的页面http://www.qq.com
     redirect_title = CPBusiness.wait_for_title(self, "http://www.qq.com")
     print "Access tencent webpage, jump to %s webpage" % redirect_title
     #无线网卡释放ip地址
     CPControl.dhcp_release_wlan(self, wlan)
     #断开无线连接
     CPControl.disconnect_ap(self)
     #启用有线网卡
     CPControl.wlan_enable(self, eth)
     print redirect_title
     if redirect_title == "gatewayname Entry":
         return True
     else:
         return False