def test_001_pptpL2tp(self):
        u'''PPTP/L2TP'''
        L2tpP = getParameter('L2tpP')
        pptpP = getParameter('pptpP')
        SupportL = getExcelValue(L2tpP)
        SupportP = getExcelValue(pptpP)
        pptpL2tp = pptpL2tpPage(self.driver, self.url)
        # print(SupportL,SupportP)
        if SupportL == '√' and SupportP == '√':
            logger.info(u'参数支持PPTP/L2TP')
            try:
                self.driver.implicitly_wait(2)
                pptpL2tp.click_VPNConfig()
            except NoSuchElementException:
                CapPic(self.driver)
                logger.info(u'不支持VPN配置,则不支持pptp/l2tp,与参数表不相符')
                raise Exception('不支持VPN配置,则不支持pptp/l2tp,与参数表不相符')
            else:
                time.sleep(0.5)
                try:
                    self.driver.implicitly_wait(2)
                    pptpL2tp.click_pptpL2tp()
                except NoSuchElementException:
                    CapPic(self.driver)
                    logger.info(u'不支持pptp/l2tp,与参数表不相符')
                    raise Exception('不支持pptp/l2tp,与参数表不相符')
                else:
                    logger.info(u'支持pptp/l2tp,与参数表相符')
                    time.sleep(1)
                    pptpL2tp.click_PPTPGlobalSet()
                    time.sleep(0.5)
                    selauthtypeP = pptpL2tp.selelement_byXpath(
                        pptpL2tp.selauthtypeP)
                    Select(selauthtypeP).select_by_value('PAP')
                    time.sleep(0.2)
                    Select(selauthtypeP).select_by_value('MS-CHAPV2')
                    time.sleep(0.2)
                    Select(selauthtypeP).select_by_value('CHAP')
                    time.sleep(0.2)
                    Select(selauthtypeP).select_by_value('THRIN')
                    time.sleep(0.2)
                    pptpL2tp.click_pptpEncryS()
                    time.sleep(0.2)
                    pptpL2tp.click_l2tpGlobalSet()
                    time.sleep(0.5)
                    selauthtypeL = pptpL2tp.selelement_byXpath(
                        pptpL2tp.selauthtypeL)
                    Select(selauthtypeL).select_by_value('PAP')
                    time.sleep(0.2)
                    Select(selauthtypeL).select_by_value('NONE')
                    time.sleep(0.2)
                    Select(selauthtypeL).select_by_value('CHAP')
                    time.sleep(0.2)
                    Select(selauthtypeL).select_by_value('EITHER')
                    time.sleep(0.2)

                    pptpL2tp.click_Tunnellist()
                    time.sleep(0.5)
                    pptpL2tp.click_add()
                    time.sleep(1)
                    #服务端
                    pptpL2tp.click_workMode1()  #拨入
                    pptpL2tp.click_workModepptp()
                    seluserType = pptpL2tp.selelement_byName(
                        pptpL2tp.seluserType)
                    Select(seluserType).select_by_value('mobile')  #移动用户
                    time.sleep(0.5)
                    pptpL2tp.input_staticIPs('1.2.3.4')  #固定IP地址
                    pptpL2tp.input_LanMac('1')  #硬件特征码
                    Select(seluserType).select_by_value('lantolan')  # LAN到LAN
                    time.sleep(0.5)
                    pptpL2tp.input_staticIPs('1.2.3.4')  # 固定IP地址
                    pptpL2tp.click_workModel2tp()
                    seluserType = pptpL2tp.selelement_byName(
                        pptpL2tp.seluserType)
                    Select(seluserType).select_by_value('mobile')  # 移动用户
                    time.sleep(0.5)
                    Select(seluserType).select_by_value('lantolan')  # LAN到LAN
                    time.sleep(0.5)
                    #客户端
                    pptpL2tp.click_workMode2()  # 拨出
                    time.sleep(0.5)
                    pptpL2tp.click_workModepptp()
                    time.sleep(0.5)
                    pptpL2tp.click_natEn()  #nat模式
                    pptpL2tp.click_pptpEncryC()
                    time.sleep(0.5)
                    selPPTP2AuthType = pptpL2tp.selelement_byName(
                        pptpL2tp.PPTP2AuthType)
                    Select(selPPTP2AuthType).select_by_value('PAP')
                    time.sleep(0.2)
                    Select(selPPTP2AuthType).select_by_value('MS-CHAPV2')
                    time.sleep(0.2)
                    Select(selPPTP2AuthType).select_by_value('CHAP')
                    time.sleep(0.2)
                    Select(selPPTP2AuthType).select_by_value('THRIN')
                    time.sleep(0.2)
                    pptpL2tp.click_workModel2tp()
                    time.sleep(0.5)
                    pptpL2tp.click_natEn()  # nat模式
                    selL2TPAuthTypes = pptpL2tp.selelement_byName(
                        pptpL2tp.L2TPAuthTypes)
                    Select(selL2TPAuthTypes).select_by_value('PAP')
                    time.sleep(0.2)
                    Select(selL2TPAuthTypes).select_by_value('NONE')
                    time.sleep(0.2)
                    Select(selL2TPAuthTypes).select_by_value('CHAP')
                    time.sleep(0.2)
                    Select(selL2TPAuthTypes).select_by_value('EITHER')
                    time.sleep(0.2)
        elif SupportL == '×' and SupportP == '×':
            logger.info(u'参数不支持PPTP/L2TP')
            try:
                self.driver.implicitly_wait(2)
                pptpL2tp.click_VPNConfig()
            except AttributeError:
                logger.info('不支持VPN配置,则不支持pptp/l2tp,与参数表相符')
            else:
                time.sleep(1)
                try:
                    pptpL2tp.click_pptpL2tp()
                except AttributeError:
                    logger.info('不支持pptp/l2tp,与参数表相符')
                else:
                    CapPic(self.driver)
                    logger.info(u'支持pptp/l2tp,与参数表不相符')
                    raise Exception('支持pptp/l2tp,与参数表不相符')
        else:
            logger.info(u'参数表读取异常')
            logger.info(u'参数表读取值为:', SupportL, SupportP)
            raise Exception(u'参数表读取异常')

        self.driver.quit()
        logger.info('test_001_vlanInterface passed')
 def test_003_IPSec_binding_pptp(self):
     u'''IPSec可以绑定在pptp虚接口(某些设备可能不支持)'''
     nodata = getAssertText('nodata')
     ibindingPp = getParameter('ibindingPp')
     Support = getExcelValue(ibindingPp)
     pptpL2tp = pptpL2tpPage(self.driver, self.url)
     #新增pptp
     if Support == '√':
         logger.info(u'参数支持IPSec可以绑定在pptp虚接口')
         try:
             self.driver.implicitly_wait(2)
             pptpL2tp.click_VPNConfig()
             time.sleep(0.5)
             pptpL2tp.click_pptpL2tp()
         except NoSuchElementException:
             CapPic(self.driver)
             logger.info(
                 u'不支持VPN配置或不支持pptp/l2tp 则不能支持ipsec绑定pptp接口,与参数表不相符')
             raise Exception(
                 '不支持VPN配置或不支持pptp/l2tp 则不能支持ipsec绑定pptp接口,与参数表不相符')
         else:
             time.sleep(1)
             # 操作删除 以访已有规则
             pptpL2tp.click_selall()
             time.sleep(0.2)
             pptpL2tp.click_delall()
             time.sleep(2)
             try:
                 self.driver.implicitly_wait(2)
                 pptpL2tp.find_ok()
             except NoSuchElementException:
                 try:
                     pptpL2tp.find_tipsshowin()
                     time.sleep(1)
                 except NoSuchElementException:
                     pass
             else:
                 time.sleep(1)
                 print('VPN隧道列表为空')
             pptpL2tp.click_add()
             time.sleep(1)
             pptpL2tp.click_workMode1()  # 拨入
             pptpL2tp.click_workModepptp()
             pptpL2tp.input_TunNames('test1')
             seluserType = pptpL2tp.selelement_byName(pptpL2tp.seluserType)
             Select(seluserType).select_by_value('mobile')  # 移动用户
             time.sleep(0.5)
             pptpL2tp.input_userNames('test1')
             pptpL2tp.input_password('test1')
             pptpL2tp.click_save()
             time.sleep(1)
             try:
                 self.driver.implicitly_wait(2)
                 #ipsec调用pptp接口
                 ipsecpage = IPsecPage(self.driver, self.url)
                 ipsecpage.click_IPSec()
             except NoSuchElementException:
                 CapPic(self.driver)
                 logger.info(u'不支持IPsec,与参数表不相符')
                 raise Exception('不支持IPsec,与参数表不相符')
             else:
                 logger.info(u'支持IPsec,与参数表相符')
                 time.sleep(1)
                 ipsecpage.click_add()
                 time.sleep(1)
                 sellocalBing = ipsecpage.selelement_byName(
                     ipsecpage.localBind)
                 Select(sellocalBing).select_by_value('PPTPS_test1')
                 time.sleep(0.3)
                 #删除PPTP
                 pptpL2tp = pptpL2tpPage(self.driver, self.url)
                 pptpL2tp.click_pptpL2tp()
                 time.sleep(1)
                 pptpL2tp.click_delete1()
                 time.sleep(1)
                 pptpL2tp.click_ok()
                 time.sleep(1)
                 listnodata = str(
                     pptpL2tp.getText_byXpath(pptpL2tp.list_nodata))
                 self.assertEqual(listnodata, nodata, msg='删除失败')
     elif Support == '×':
         logger.info(u'参数不支持IPSec可以绑定在pptp虚接口')
         try:
             self.driver.implicitly_wait(2)
             pptpL2tp.click_VPNConfig()
             time.sleep(0.5)
             pptpL2tp.click_pptpL2tp()
             time.sleep(0.5)
         except AttributeError:
             logger.info(u'不支持VPN配置或不支持pptp/l2tp 则不能支持ipsec绑定pptp接口,与参数表相符')
         else:
             time.sleep(1)
             # 操作删除 以访已有规则
             pptpL2tp.click_selall()
             time.sleep(0.2)
             pptpL2tp.click_delall()
             time.sleep(2)
             try:
                 self.driver.implicitly_wait(2)
                 pptpL2tp.find_ok()
             except NoSuchElementException:
                 try:
                     pptpL2tp.find_tipsshowin()
                     time.sleep(1)
                 except NoSuchElementException:
                     pass
             else:
                 time.sleep(1)
                 print('VPN隧道列表为空')
             pptpL2tp.click_add()
             time.sleep(1)
             pptpL2tp.click_workMode1()  # 拨入
             pptpL2tp.click_workModepptp()
             pptpL2tp.input_TunNames('test1')
             seluserType = pptpL2tp.selelement_byName(pptpL2tp.seluserType)
             Select(seluserType).select_by_value('mobile')  # 移动用户
             time.sleep(0.5)
             pptpL2tp.input_userNames('test1')
             pptpL2tp.input_password('test1')
             pptpL2tp.click_save()
             time.sleep(1)
             try:
                 self.driver.implicitly_wait(2)
                 # ipsec调用pptp接口
                 ipsecpage = IPsecPage(self.driver, self.url)
                 ipsecpage.click_IPSec()
             except NoSuchElementException:
                 logger.info('不支持ipsec则不支持绑定到pptp接口,与参数表相符')
             else:
                 try:
                     time.sleep(1)
                     ipsecpage.click_add()
                     time.sleep(1)
                     sellocalBing = ipsecpage.selelement_byName(
                         ipsecpage.localBind)
                     Select(sellocalBing).select_by_value('PPTPS_test1')
                 except NoSuchElementException:
                     logger.info('不支持ipsec则不支持绑定到pptp接口,与参数表相符')
                 else:
                     CapPic(self.driver)
                     logger.info(u'支持ipsec则不支持绑定到pptp接口,与参数表不相符')
                     raise Exception('支持ipsec则不支持绑定到pptp接口,与参数表不相符')
     else:
         logger.info(u'参数表读取异常')
         logger.info(u'参数表读取值为:', Support)
         raise Exception(u'参数表读取异常')
     self.driver.quit()
     logger.info('test_003_IPSec_binding_pptp passed')
Beispiel #3
0
    def test_003_bandingInter(self):
        u'''静态路由绑定vpn接口(L2TP/PPTP)'''
        bandingVPNp = getParameter('bandingVPNp')
        nodata = getAssertText('nodata')
        Support = getExcelValue(bandingVPNp)
        if Support == '√':
            logger.info(u'参数支持静态路由可绑定PPTP/L2TP接口')
            vpn = pptpL2tpPage(self.driver,self.url)
            vpn.click_VPNConfig()
            time.sleep(0.5)
            try:
                self.driver.implicitly_wait(2)
                vpn.click_pptpL2tp()
            except AttributeError or NoSuchElementException:
                CapPic(self.driver)
                logger.info(u'软件不支持L2TP/PPTP 静态路由无法绑定vpn接口,与参数表不符')
                raise Exception(u'软件不支持L2TP/PPTP 静态路由无法绑定vpn接口,与参数表不符')
            else:
                self.driver.implicitly_wait(10)
                time.sleep(1)
                #配置 VPN
                # 操作删除 以访已有规则
                vpn.click_selall()
                time.sleep(0.2)
                vpn.click_delall()
                time.sleep(2)
                try:
                    self.driver.implicitly_wait(2)
                    vpn.find_ok()
                except NoSuchElementException:
                    try:
                        vpn.find_tipsshowin()
                        time.sleep(1)
                    except NoSuchElementException:
                        pass
                else:
                    time.sleep(1)
                    print('VPN隧道列表为空')
                vpn.click_add()
                time.sleep(1)
                vpn.input_TunNames('staticRoute')
                vpn.input_userNames('staticRoute')
                vpn.input_password('staticRoute')
                vpn.input_remoteInIp('1.2.3.4')
                vpn.input_remoteInIPMask('255.255.255.0')
                vpn.click_save()
                time.sleep(3)
                listtips1 = str(vpn.getText_byXpath(vpn.listtips1))
                self.assertEqual(listtips1, 'staticRoute', msg='VPN名称不为staticRoute')
                print('PPTP已添加')
                vpn.click_add()
                time.sleep(1)
                vpn.click_l2tpB()
                vpn.input_TunNames('staticRoute2')
                vpn.input_userNames('staticRoute2')
                vpn.input_password('staticRoute2')
                vpn.input_remoteInIp('4.3.2.1')
                vpn.input_remoteInIPMask('255.255.255.0')
                vpn.click_save()
                time.sleep(3)
                listtips2 = str(vpn.getText_byXpath(vpn.listtips2))
                self.assertEqual(listtips2, 'staticRoute2', msg='VPN2名称不为staticRoute2')
                print('L2TP已添加')
                # 修改静态路由 绑定PPTP接口
                routeconfig = RouteConfigPage(self.driver, self.url)
                routeconfig.click_NetworkConfig()
                time.sleep(0.5)
                routeconfig.click_Routeconfig()
                time.sleep(1)
                routeconfig.click_add()
                time.sleep(1)
                selProfiles = routeconfig.selelement_byName(routeconfig.selProfiles)
                time.sleep(1)
                try:
                    self.driver.implicitly_wait(2)
                    Select(selProfiles).select_by_value('(PPTPS)staticRoute')
                    time.sleep(0.5)
                    Select(selProfiles).select_by_value('(L2TPS)staticRoute2')
                except NoSuchElementException:
                    CapPic(self.driver)
                    logger.info(u'静态路由无法绑定vpn接口(L2TP/PPTP)')
                    raise Exception(u'静态路由无法绑定vpn接口(L2TP/PPTP)')
                else:
                    self.driver.implicitly_wait(10)
                    time.sleep(1)
                    routeconfig.click_modalhide()
                    time.sleep(0.5)
                    # 删除两条VPN
                    vpn = pptpL2tpPage(self.driver, self.url)
                    vpn.click_VPNConfig()
                    time.sleep(0.5)
                    vpn.click_pptpL2tp()
                    time.sleep(1)
                    vpn.click_delete1()
                    time.sleep(1)
                    vpn.click_ok()
                    time.sleep(2)
                    vpn.click_delete1()
                    time.sleep(1)
                    vpn.click_ok()
                    time.sleep(3)
                    # 断言
                    list_nodata = str(vpn.getText_byXpath(vpn.list_nodata))
                    self.assertEqual(list_nodata, nodata, msg='静态路由删除失败')
                    print('VPN已删除')
        elif Support == '×':
            logger.info(u'参数不支持静态路由可绑定PPTP/L2TP接口')
            vpn = pptpL2tpPage(self.driver, self.url)
            try:
                self.driver.implicitly_wait(2)
                vpn.click_pptpL2tp()
            except AttributeError or NoSuchElementException:
                logger.info(u'软件不支持L2TP/PPTP 静态路由无法绑定vpn接口,与参数表相符')
            else:
                self.driver.implicitly_wait(10)
                time.sleep(1)
                # 配置 VPN
                # 操作删除 以访已有规则
                vpn.click_selall()
                time.sleep(0.2)
                vpn.click_delall()
                time.sleep(2)
                try:
                    self.driver.implicitly_wait(2)
                    vpn.find_ok()
                except NoSuchElementException:
                    try:
                        vpn.find_tipsshowin()
                        time.sleep(1)
                    except NoSuchElementException:
                        pass
                else:
                    time.sleep(1)
                    print('VPN隧道列表为空')
                vpn.click_add()
                time.sleep(1)
                vpn.input_TunNames('staticRoute')
                vpn.input_userNames('staticRoute')
                vpn.input_password('staticRoute')
                vpn.input_remoteInIp('1.2.3.4')
                vpn.input_remoteInIPMask('255.255.255.0')
                vpn.click_save()
                time.sleep(3)
                listtips1 = str(vpn.getText_byXpath(vpn.listtips1))
                self.assertEqual(listtips1, 'staticRoute', msg='VPN名称不为staticRoute')
                print('PPTP已添加')
                vpn.click_add()
                time.sleep(1)
                vpn.click_l2tpB()
                vpn.input_TunNames('staticRoute2')
                vpn.input_userNames('staticRoute2')
                vpn.input_password('staticRoute2')
                vpn.input_remoteInIp('4.3.2.1')
                vpn.input_remoteInIPMask('255.255.255.0')
                vpn.click_save()
                time.sleep(3)
                listtips2 = str(vpn.getText_byXpath(vpn.listtips2))
                self.assertEqual(listtips2, 'staticRoute2', msg='VPN2名称不为staticRoute2')
                print('L2TP已添加')
                # 修改静态路由 绑定PPTP接口
                routeconfig = RouteConfigPage(self.driver, self.url)
                routeconfig.click_NetworkConfig()
                time.sleep(0.5)
                routeconfig.click_Routeconfig()
                time.sleep(1)
                routeconfig.click_add()
                time.sleep(1)
                selProfiles = routeconfig.selelement_byName(routeconfig.selProfiles)
                time.sleep(1)
                try:
                    self.driver.implicitly_wait(2)
                    Select(selProfiles).select_by_value('(PPTPS)staticRoute')
                    time.sleep(0.5)
                    Select(selProfiles).select_by_value('(L2TPS)staticRoute2')
                except NoSuchElementException:
                    logger.info(u'静态路由无法绑定vpn接口(L2TP/PPTP),与参数表相符')
                    self.driver.implicitly_wait(10)
                    time.sleep(1)
                    routeconfig.click_modalhide()
                    time.sleep(0.5)
                    # 删除两条VPN
                    vpn = pptpL2tpPage(self.driver, self.url)
                    vpn.click_VPNConfig()
                    time.sleep(0.5)
                    vpn.click_pptpL2tp()
                    time.sleep(1)
                    vpn.click_delete1()
                    time.sleep(1)
                    vpn.click_ok()
                    time.sleep(2)
                    vpn.click_delete1()
                    time.sleep(1)
                    vpn.click_ok()
                    time.sleep(3)
                    # 断言
                    list_nodata = str(vpn.getText_byXpath(vpn.list_nodata))
                    self.assertEqual(list_nodata, nodata, msg='静态路由删除失败')
                    print('VPN已删除')
                else:
                    CapPic(self.driver)
                    logger.info(u'软件支持L2TP/PPTP 静态路由绑定vpn接口,与参数表不符')
                    raise Exception(u'软件支持L2TP/PPTP 静态路由绑定vpn接口,与参数表不符')
        else:
            logger.info(u'参数表读取异常')
            logger.info(u'参数表读取值为:',Support)
            raise Exception(u'参数表读取异常')

        self.driver.quit()

        logger.info('test_003_bandingInter passed')
Beispiel #4
0
    def test_002_bindingVPNinterface(self):
        u'''静态路由可绑定PPTP/L2TP接口'''
        nodata = getAssertText('nodata')
        bandingVPNp = getParameter('bandingVPNp')
        Support = getExcelValue(bandingVPNp)

        if Support == '√':
            logger.info(u'参数支持静态路由可绑定PPTP/L2TP接口')
            login.loginWeb(self)  # admin账号登录
            self.driver.implicitly_wait(10)
            pptpl2tp = pptpL2tpPage(self.driver, self.url)
            # 配置PPTP VPN
            pptpl2tp.click_VPNConfig()
            time.sleep(0.5)
            pptpl2tp.click_pptpL2tp()
            time.sleep(1)
            pptpl2tp.click_add()
            time.sleep(1)
            pptpl2tp.input_TunNames('staticRoute')
            pptpl2tp.input_userNames('staticRoute')
            pptpl2tp.input_password('staticRoute')
            pptpl2tp.input_remoteInIp('1.2.3.4')
            pptpl2tp.input_remoteInIPMask('255.255.255.0')
            pptpl2tp.click_save()
            time.sleep(3)
            # 断言
            listtips1 = str(pptpl2tp.getText_byXpath(pptpl2tp.listtips1))
            self.assertEqual(listtips1,
                             'staticRoute',
                             msg='VPN名称不为staticRoute')
            print('PPTP已添加')
            # 配置L2TP VPN
            pptpl2tp.click_add()
            time.sleep(1)
            pptpl2tp.click_l2tpB()
            pptpl2tp.input_TunNames('staticRoute2')
            pptpl2tp.input_userNames('staticRoute2')
            pptpl2tp.input_password('staticRoute2')
            pptpl2tp.input_remoteInIp('4.3.2.1')
            pptpl2tp.input_remoteInIPMask('255.255.255.0')
            pptpl2tp.click_save()
            time.sleep(3)
            # 断言
            listtips2 = str(pptpl2tp.getText_byXpath(pptpl2tp.listtips2))
            self.assertEqual(listtips2,
                             'staticRoute2',
                             msg='VPN名称不为staticRoute2')
            print('L2TP已添加')

            # 修改静态路由 绑定PPTP接口
            routeconfig = RouteConfigPage(self.driver, self.url)
            routeconfig.click_NetworkConfig()
            time.sleep(0.5)
            routeconfig.click_Routeconfig()
            time.sleep(1)
            routeconfig.click_edit()
            time.sleep(1)
            se1Profiles = routeconfig.selelement_byName('Profiles')
            time.sleep(1)
            Select(se1Profiles).select_by_value('(PPTPS)staticRoute')
            time.sleep(1)
            routeconfig.click_save()
            time.sleep(3)
            #断言
            interface = str(
                routeconfig.getText_byXpath(routeconfig.list_Interface))
            self.assertEqual(interface,
                             '(PPTPS)staticRoute',
                             msg='绑定接口不为VPN接口')
            print('静态路由绑定PPTP接口 验证通过')

            # 修改静态路由 绑定L2TP接口
            routeconfig.click_edit()
            time.sleep(1)
            se1Profiles = routeconfig.selelement_byName('Profiles')
            time.sleep(1)
            Select(se1Profiles).select_by_value('(L2TPS)staticRoute2')
            time.sleep(1)
            routeconfig.click_save()
            time.sleep(3)
            # 断言
            interface = str(
                routeconfig.getText_byXpath(routeconfig.list_Interface))
            self.assertEqual(interface,
                             '(L2TPS)staticRoute2',
                             msg='绑定接口不为VPN接口')
            print('静态路由绑定L2TP接口 验证通过')

            #删除静态路由
            routeconfig.click_delete()
            time.sleep(1)
            routeconfig.click_ok()
            time.sleep(2)
            # 断言
            list_tips = str(
                routeconfig.getText_byXpath(routeconfig.list_nodata))
            self.assertEqual(list_tips, nodata, msg='静态路由删除失败')
            print('静态路由已删除')
            #删除两条VPN
            pptpl2tp = pptpL2tpPage(self.driver, self.url)
            pptpl2tp.click_VPNConfig()
            time.sleep(0.5)
            pptpl2tp.click_pptpL2tp()
            time.sleep(1)
            pptpl2tp.click_delete1()
            time.sleep(1)
            pptpl2tp.click_ok()
            time.sleep(2)
            pptpl2tp.click_delete1()
            time.sleep(1)
            pptpl2tp.click_ok()
            time.sleep(3)
            # 断言
            list_nodata = str(pptpl2tp.getText_byXpath(pptpl2tp.list_nodata))
            self.assertEqual(list_nodata, nodata, msg='静态路由删除失败')
            print('VPN已删除')
            self.driver.quit()
        elif Support == '×':
            logger.info(u'参数不支持静态路由可绑定PPTP/L2TP接口')
        logger.info('test_002_bindingVPNinterface passed')
Beispiel #5
0
    def test_syslog(self):
        u'''日志服务器'''
        pcNetworkID = getweb('pcNetworkID')
        wiresharkpath = getpath('wiresharkpath')
        host = gettelnet('host')

        #0、清理tmp下的syslog.pcapng\log文件
        call_Firefox.del_syslog_log(self)
        #1、开启syslog server
        pcaddr = socket.gethostbyname(socket.getfqdn(socket.gethostname()))
        login.loginWeb(self)
        self.driver.implicitly_wait(10)
        syslog = syslogPage(self.driver,self.url)
        syslog.click_sysConfig()
        time.sleep(0.5)
        syslog.click_Syslog()
        time.sleep(1)
        syslog.click_SyslogServer()
        time.sleep(1)
        syslog.click_syslogEn()
        syslog.input_ServerIp(pcaddr)
        syslog.input_ServerPort('514')
        syslog.click_save()
        time.sleep(1)
        syslogEs = syslog.getAttribute_byXpath(syslog.syslogEs,'checked')
        self.assertEqual(syslogEs,'true',msg = 'syslog服务器启用失败')

        #2、新建一条vpn 使生成syslog
        pptpl2tp = pptpL2tpPage(self.driver, self.url)
        pptpl2tp.click_VPNConfig()
        time.sleep(0.5)
        pptpl2tp.click_pptpL2tp()
        time.sleep(1)
        # 操作删除 以访已有规则
        pptpl2tp.click_selall()
        time.sleep(0.2)
        pptpl2tp.click_delall()
        time.sleep(2)
        try:
            self.driver.implicitly_wait(2)
            pptpl2tp.find_ok()
        except NoSuchElementException:
            try:
                pptpl2tp.find_tipsshowin()
                time.sleep(1)
            except NoSuchElementException:
                pass
        else:
            time.sleep(1)
            print('VPN隧道列表为空')
        pptpl2tp.click_add()
        time.sleep(2)
        pptpl2tp.click_workMode2()
        pptpl2tp.click_workModepptp()
        pptpl2tp.input_TunNames('testS')
        pptpl2tp.input_TunNamesIP('11.2.3.4')
        pptpl2tp.input_userNames('test')
        pptpl2tp.input_password('test')
        pptpl2tp.input_remoteInIp('11.2.3.4')
        pptpl2tp.input_remoteInIPMask('255.255.255.0')
        pptpl2tp.click_save()
        time.sleep(0.5)

        # 3、调用wireshark 开启抓包,必须要抓到包之后才会进行下一步,因此放在设置vpn之后,通过抓下一次的log
        packetfile = tmppath + 'syslogtest.pcapng'
        dir = wiresharkpath[0:2]
        getpacket = ('tshark -i%s -f "udp port 514" -w %s -c 2' % (pcNetworkID, packetfile))
        os.system('%s && cd %s && %s' % (dir,wiresharkpath, getpacket))

        #4、读取抓包显示 并存为log文件
        logfile = tmppath + 'syslogtest.log'
        savepacket = ('tshark -r %s -T fields -e "ip.src" -e ip.dst -Y "syslog" > %s ' % (packetfile,logfile))
        os.system('%s && cd %s && %s' % (dir,wiresharkpath,savepacket))

        #5、读取判断syslog生效
        with open(logfile, 'r') as file_to_read:
            while True:
                lines = file_to_read.readline()  # 整行读取数据
                print(lines)
                if not lines:
                    break
                if host + pcaddr in lines:
                    print(u'验证通过')
        #删除vpn 关闭syslog
        nodata = getAssertText('nodata')
        # 删除VPN
        pptpl2tp = pptpL2tpPage(self.driver, self.url)
        pptpl2tp.click_pptpL2tp()
        time.sleep(1)
        pptpl2tp.click_selall()
        time.sleep(0.2)
        pptpl2tp.click_delall()
        time.sleep(1)
        pptpl2tp.click_ok()
        time.sleep(2)
        list_nodata = pptpl2tp.getText_byXpath(pptpl2tp.list_nodata)
        if list_nodata == nodata:
            logger.info(u'VPN 已删除')
        else:
            CapPic(self.driver)
            logger.info(u'VPN删除失败')
            raise Exception(u'VPN删除失败')
        syslog = syslogPage(self.driver, self.url)
        syslog.click_sysConfig()
        time.sleep(0.5)
        syslog.click_Syslog()
        time.sleep(1)
        syslog.click_SyslogServer()
        time.sleep(1)
        syslog.click_syslogC()
        syslog.click_save()
        time.sleep(1)
        syslogCs = syslog.getAttribute_byXpath(syslog.SyslogCs, 'checked')
        self.assertEqual(syslogCs, 'true', msg='syslog服务器关闭失败')

        self.driver.quit()
        logger.info('test_reboot1 passed')
    def test_003_VPNStatus(self):
        u'''VPN状态 显示及跳转'''
        WillReboottips = getAssertText('WillReboottips')
        login.loginWeb(self)
        sysstatic = sysStaticPage(self.driver, self.url)
        sysstatic.click_systemWatch()
        time.sleep(0.5)
        sysstatic.click_sysStatic()
        time.sleep(1)

        sysstatic.click_more3()
        time.sleep(2)
        url = self.driver.current_url
        if '#/VPN/IPSec' in url or '#/VPN/PPTP/L2TP' in url:
            logger.info(u'VPN状态 跳转到VPN配置 验证正常')
        else:
            CapPic(self.driver)
            logger.info(u'VPN状态 跳转到VPN配置 验证正常')
            raise Exception(u'VPN状态 跳转到VPN配置 验证正常')

        #配置VPN
        if '#/VPN/IPSec' in url:
            ipsec = IPsecPage(self.driver, self.url)
            # 操作删除 以访已有规则
            ipsec.click_selall()
            time.sleep(0.2)
            ipsec.click_delall()
            time.sleep(2)
            try:
                self.driver.implicitly_wait(2)
                ipsec.find_ok()
            except NoSuchElementException:
                try:
                    ipsec.find_tipsshowin()
                    time.sleep(1)
                except NoSuchElementException:
                    pass
            else:
                time.sleep(1)
                print('ipsec VPN列表为空')
            ipsec.click_add()
            time.sleep(1)
            ipsec.input_ids('test')
            ipsec.input_peer('123.5.3.6')
            ipsec.input_remoteAddr('123.5.3.6')
            # ipsec.input_remoteMask('255.255.255.0')
            ipsec.input_preshareKey('12345678')
            ipsec.click_save()
            time.sleep(2)
            try:  # 无线设备增加ac功能后 配置第一条ipsec时会提示重启
                ipsec.find_no()
            except NoSuchElementException:
                pass
            time.sleep(2)
        else:
            pptpl2tp = pptpL2tpPage(self.driver, self.url)
            # 操作删除 以访已有规则
            pptpl2tp.click_selall()
            time.sleep(0.2)
            pptpl2tp.click_delall()
            time.sleep(2)
            try:
                self.driver.implicitly_wait(2)
                pptpl2tp.find_ok()
            except NoSuchElementException:
                try:
                    pptpl2tp.find_tipsshowin()
                    time.sleep(1)
                except NoSuchElementException:
                    pass
            else:
                time.sleep(1)
                print('VPN隧道列表为空')
            pptpl2tp.click_add()
            time.sleep(1)
            pptpl2tp.click_workMode1()
            pptpl2tp.click_workModepptp()
            pptpl2tp.input_TunNames('test')
            seluserType = pptpl2tp.selelement_byName(pptpl2tp.seluserType)
            Select(seluserType).select_by_value('lantolan')
            pptpl2tp.input_userNames('test')
            pptpl2tp.input_password('test')
            pptpl2tp.input_remoteInIp('1.2.3.4')
            pptpl2tp.input_remoteInIPMask('255.255.255.0')
            pptpl2tp.click_saveS()
            time.sleep(2)

        sysstatic = sysStaticPage(self.driver, self.url)
        sysstatic.click_sysStatic()
        time.sleep(1)
        try:
            self.driver.implicitly_wait(2)
            list_name = sysstatic.getText_byXpath(sysstatic.list_name)
        except NoSuchElementException:
            CapPic(self.driver)
            logger.info(u'系统状态-VPN状态 未显示数据')
            raise Exception(u'系统状态-VPN状态 未显示数据')
        else:
            if list_name == 'test':
                logger.info(u'系统状态-VPN状态 显示数据验证通过 ')
            else:
                CapPic(self.driver)
                logger.info(u'系统状态-VPN状态 显示数据 异常')
                raise Exception(u'系统状态-VPN状态 显示数据 异常')

        # 删除VPN
        if '#/VPN/IPSec' in url:
            ipsec = IPsecPage(self.driver, self.url)
            ipsec.click_VPNConfig()
            time.sleep(0.5)
            ipsec.click_IPSec()
            time.sleep(1)
            # 操作删除 以访已有规则
            ipsec.click_selall()
            time.sleep(0.2)
            ipsec.click_delall()
            time.sleep(2)
            try:
                self.driver.implicitly_wait(2)
                ipsec.find_ok()
            except NoSuchElementException:
                try:
                    ipsec.find_tipsshowin()
                    time.sleep(1)
                except NoSuchElementException:
                    pass
            else:
                time.sleep(1)
                print('ipsec VPN列表为空')
        else:
            pptpl2tp = pptpL2tpPage(self.driver, self.url)
            pptpl2tp.click_VPNConfig()
            time.sleep(0.5)
            pptpl2tp.click_pptpL2tp()
            time.sleep(1)
            # 操作删除 以访已有规则
            pptpl2tp.click_selall()
            time.sleep(0.2)
            pptpl2tp.click_delall()
            time.sleep(2)
            try:
                self.driver.implicitly_wait(2)
                pptpl2tp.find_ok()
            except NoSuchElementException:
                try:
                    pptpl2tp.find_tipsshowin()
                    time.sleep(1)
                except NoSuchElementException:
                    pass
            else:
                time.sleep(1)
                print('VPN隧道列表为空')

        self.driver.quit()
        logger.info('VPNStatus passed')
Beispiel #7
0
    def tearDown(self):
        nodata = getAssertText('nodata')

        #删除VPN
        login.loginWeb(self)
        self.driver.implicitly_wait(10)
        pptpl2tp = pptpL2tpPage(self.driver, self.url)
        pptpl2tp.click_VPNConfig()
        time.sleep(0.5)
        pptpl2tp.click_pptpL2tp()
        time.sleep(1)
        pptpl2tp.click_selall()
        time.sleep(0.2)
        pptpl2tp.click_delall()
        time.sleep(1)
        pptpl2tp.click_ok()
        time.sleep(2)
        list_nodata = pptpl2tp.getText_byXpath(pptpl2tp.list_nodata)
        if list_nodata == nodata:
            logger.info(u'R1 VPN 已删除')
        else:
            CapPic(self.driver)
            logger.info(u'R1 VPN删除失败')
            raise Exception(u'R1 VPN删除失败')

        pptpl2tp.click_PPTPGlobalSet()
        time.sleep(0.5)
        pptpl2tp.click_pptpserverC()
        pptpl2tp.click_save()
        time.sleep(1)
        pptpl2tp.click_PPTPGlobalSet()
        time.sleep(0.5)
        pptpSs = pptpl2tp.getAttribute_byXpath(pptpl2tp.pptpserverCs,
                                               'checked')
        if pptpSs == 'true':
            logger.info(u'pptpserver已关闭')
        else:
            CapPic(self.driver)
            logger.info(u'pptpserver未关闭')
            return Exception(u'pptpserver未关闭')
        pptpl2tp.click_l2tpGlobalSet()
        time.sleep(0.5)
        pptpl2tp.click_L2tpserverC()
        pptpl2tp.click_saveSl2tp()
        time.sleep(1)
        pptpl2tp.click_l2tpGlobalSet()
        time.sleep(0.5)
        l2tpSs = pptpl2tp.getAttribute_byXpath(pptpl2tp.L2tpserverCs,
                                               'checked')
        if l2tpSs == 'true':
            logger.info(u'L2tpserver已关闭')
        else:
            CapPic(self.driver)
            logger.info(u'L2tpserver未关闭')
            return Exception(u'L2tpserver未关闭')
        self.driver.quit()

        login.test_enableLoginWeb(self, url=vpnRouteUrl)
        pptpl2tp = pptpL2tpPage(self.driver, self.url)
        pptpl2tp.click_VPNConfig()
        time.sleep(0.5)
        pptpl2tp.click_pptpL2tp()
        time.sleep(1)
        pptpl2tp.click_selall()
        time.sleep(0.2)
        pptpl2tp.click_delall()
        time.sleep(1)
        pptpl2tp.click_ok()
        time.sleep(2)
        try:  #VPN 路由器是中文简体,在测试其他语言版本时,删除后的nodata会不一致
            pptpl2tp.find_list_nodataX()
        except NoSuchElementException:
            CapPic(self.driver)
            logger.info(u'R2 ipsec删除失败')
            raise Exception(u'R2 ipsec删除失败')
        else:
            logger.info(u'R2 ipsec 已删除')
        # list_nodata = pptpl2tp.getText_byXpath(pptpl2tp.list_nodata)
        # if list_nodata == nodata:
        #     logger.info(u'R2 VPN 已删除')
        # else:
        #     CapPic(self.driver)
        #     logger.info(u'R2 VPN删除失败')
        #     raise Exception(u'R2 VPN删除失败')
        self.driver.quit()

        logger.info('tearDown over')
        logger.info('%s' % ('=' * 50))
Beispiel #8
0
    def test_004_L2tpclient(self):
        u'''L2tpclient'''

        vpnRouteLan = getweb('vpnRouteLan')
        host = gettelnet('host')
        StateVPN2 = getAssertText('StateVPN2')
        login.loginWeb(self)
        self.driver.implicitly_wait(10)
        pptpl2tp = pptpL2tpPage(self.driver, self.url)
        pptpl2tp.click_VPNConfig()
        time.sleep(0.5)
        pptpl2tp.click_pptpL2tp()
        time.sleep(1)
        # 操作删除 以访已有规则
        pptpl2tp.click_selall()
        time.sleep(0.2)
        pptpl2tp.click_delall()
        time.sleep(2)
        try:
            self.driver.implicitly_wait(2)
            pptpl2tp.find_ok()
        except NoSuchElementException:
            try:
                pptpl2tp.find_tipsshowin()
                time.sleep(1)
            except NoSuchElementException:
                pass
        else:
            time.sleep(1)
            print('VPN隧道列表为空')

        pptpl2tp.click_add()
        time.sleep(2)
        pptpl2tp.click_workMode2()
        pptpl2tp.click_workModel2tp()
        pptpl2tp.input_TunNames('testC')
        pptpl2tp.input_TunNamesIP(vpnRouteWan)
        pptpl2tp.input_userNames('test')
        pptpl2tp.input_password('test')
        pptpl2tp.input_remoteInIp(vpnRouteLan)
        pptpl2tp.input_remoteInIPMask('255.255.255.0')
        pptpl2tp.click_save()
        time.sleep(2)
        self.driver.quit()

        # 另外一台路由器 配置pptp Server
        login.test_enableLoginWeb(self, url=vpnRouteUrl)
        pptpl2tp = pptpL2tpPage(self.driver, self.url)
        pptpl2tp.click_VPNConfig()
        time.sleep(0.5)
        pptpl2tp.click_pptpL2tp()
        time.sleep(1)
        # 操作删除 以访已有规则
        pptpl2tp.click_selall()
        time.sleep(0.2)
        pptpl2tp.click_delall()
        time.sleep(2)
        try:
            self.driver.implicitly_wait(2)
            pptpl2tp.find_ok()
        except NoSuchElementException:
            try:
                pptpl2tp.find_tipsshowin()
                time.sleep(1)
            except NoSuchElementException:
                pass
        else:
            time.sleep(1)
            print('VPN隧道列表为空')

        pptpl2tp.click_l2tpGlobalSet()  #语言问题待修改成xpath
        time.sleep(0.5)
        pptpl2tp.click_L2tpserverEn()
        pptpl2tp.input_priDns('114.114.114.114')
        pptpl2tp.click_save()
        time.sleep(1)
        pptpl2tp.click_l2tpGlobalSet()
        time.sleep(0.5)
        l2tpSs = pptpl2tp.getAttribute_byXpath(pptpl2tp.L2tpserverEs,
                                               'checked')
        if l2tpSs == 'true':
            logger.info(u'L2tpserver已开启')
        else:
            CapPic(self.driver)
            logger.info(u'L2tpserver未开启')
            return Exception(u'L2tpserver未开启')

        pptpl2tp.click_Tunnellist()
        time.sleep(0.5)
        pptpl2tp.click_add()
        time.sleep(1)
        pptpl2tp.click_workMode1()
        pptpl2tp.click_workModel2tp()
        pptpl2tp.input_TunNames('testC')
        seluserType = pptpl2tp.selelement_byName(pptpl2tp.seluserType)
        Select(seluserType).select_by_value('lantolan')
        pptpl2tp.input_userNames('test')
        pptpl2tp.input_password('test')
        pptpl2tp.input_remoteInIp(host)
        pptpl2tp.input_remoteInIPMask('255.255.255.0')
        pptpl2tp.click_saveS()
        time.sleep(2)

        i = 0
        while i < 100:
            pptpl2tp.click_pptpL2tp()
            time.sleep(1)
            list_status = pptpl2tp.getText_byXpath(pptpl2tp.list_status)
            print(list_status)
            if list_status == StateVPN2:
                logger.info(u'L2tp 已建立')
                break
            else:
                time.sleep(3)
                i += 1
        else:
            logger.info(u'L2tp 未建立成功')
            CapPic(self.driver)
            raise Exception(u'L2tp未建立成功')
        self.driver.quit()

        logger.info('test_004_L2tpclient passed')
Beispiel #9
0
    def test_001_PPTPserver(self):
        u'''PPTPserver'''

        vpnRouteLan = getweb('vpnRouteLan')
        host = gettelnet('host')
        StateVPN2 = getAssertText('StateVPN2')
        login.loginWeb(self)
        self.driver.implicitly_wait(10)
        pptpl2tp = pptpL2tpPage(self.driver, self.url)
        pptpl2tp.click_VPNConfig()
        time.sleep(0.5)
        pptpl2tp.click_pptpL2tp()
        time.sleep(1)
        # 操作删除 以访已有规则
        pptpl2tp.click_selall()
        time.sleep(0.2)
        pptpl2tp.click_delall()
        time.sleep(2)
        try:
            self.driver.implicitly_wait(2)
            pptpl2tp.find_ok()
        except NoSuchElementException:
            try:
                pptpl2tp.find_tipsshowin()
                time.sleep(1)
            except NoSuchElementException:
                pass
        else:
            time.sleep(1)
            print('VPN隧道列表为空')

        pptpl2tp.click_PPTPGlobalSet()
        time.sleep(0.5)
        pptpl2tp.click_pptpserverEn()
        pptpl2tp.input_priDns('114.114.114.114')
        pptpl2tp.click_save()
        time.sleep(1)
        pptpSs = pptpl2tp.getAttribute_byXpath(pptpl2tp.pptpserverEs,
                                               'checked')
        if pptpSs == 'true':
            logger.info(u'pptpserver已开启')
        else:
            CapPic(self.driver)
            logger.info(u'pptpserver未开启')
            return Exception(u'pptpserver未开启')

        pptpl2tp.click_add()
        time.sleep(1)
        pptpl2tp.click_workMode1()
        pptpl2tp.click_workModepptp()
        pptpl2tp.input_TunNames('testS')
        seluserType = pptpl2tp.selelement_byName(pptpl2tp.seluserType)
        Select(seluserType).select_by_value('lantolan')
        pptpl2tp.input_userNames('test')
        pptpl2tp.input_password('test')
        pptpl2tp.input_remoteInIp(vpnRouteLan)
        pptpl2tp.input_remoteInIPMask('255.255.255.0')
        pptpl2tp.click_saveS()
        time.sleep(2)

        # 从外网配置页面获取WAN1口地址
        wanpage = NetworkConfig_wanpage(self.driver, self.url)
        wanpage.click_NetworkConfig()
        time.sleep(0.5)
        wanpage.click_WANconfig()
        time.sleep(1)
        # WAN1 ip变量赋值,页面读取
        # 判断联网状态
        i = 0
        while i < 21:
            wanpage.click_refresh()
            time.sleep(1)
            list_conState = wanpage.getText_byXpath(wanpage.connectState1)
            print(str(list_conState), i)
            if str(list_conState) != ConnectState:
                time.sleep(3)
                i += 1
            else:
                break
        else:
            CapPic(self.driver)
            logger.info(u"WAN口未连接")
            raise Exception('WAN1 未连接')
        WAN1_ip = str(wanpage.getText_byXpath(wanpage.line1IP))
        # print('WAN1_ip=',WAN1_ip)
        time.sleep(1)
        self.driver.quit()

        # 另外一台路由器 配置pptp Client
        login.test_enableLoginWeb(self, url=vpnRouteUrl)
        pptpl2tp = pptpL2tpPage(self.driver, self.url)
        pptpl2tp.click_VPNConfig()
        time.sleep(0.5)
        pptpl2tp.click_pptpL2tp()
        time.sleep(1)
        # 操作删除 以访已有规则
        pptpl2tp.click_selall()
        time.sleep(0.2)
        pptpl2tp.click_delall()
        time.sleep(2)
        try:
            self.driver.implicitly_wait(2)
            pptpl2tp.find_ok()
        except NoSuchElementException:
            try:
                pptpl2tp.find_tipsshowin()
                time.sleep(1)
            except NoSuchElementException:
                pass
        else:
            time.sleep(1)
            print('VPN隧道列表为空')

        pptpl2tp.click_add()
        time.sleep(2)
        pptpl2tp.click_workMode2()
        pptpl2tp.click_workModepptp()
        pptpl2tp.input_TunNames('testS')
        pptpl2tp.input_TunNamesIP(WAN1_ip)
        pptpl2tp.input_userNames('test')
        pptpl2tp.input_password('test')
        pptpl2tp.input_remoteInIp(host)
        pptpl2tp.input_remoteInIPMask('255.255.255.0')
        pptpl2tp.click_save()
        time.sleep(2)

        i = 0
        while i < 100:
            pptpl2tp.click_pptpL2tp()
            time.sleep(1)
            list_status = pptpl2tp.getText_byXpath(pptpl2tp.list_status)
            print(list_status)
            if list_status == StateVPN2:
                logger.info(u'PPTP 已建立')
                break
            else:
                time.sleep(3)
                i += 1
        else:
            logger.info(u'pptp 未建立成功')
            CapPic(self.driver)
            raise Exception(u'pptp未建立成功')
        self.driver.quit()

        logger.info('test_001_PPTPserver passed')