def test_003_samba(self):
        u'''samba服务器(部分型号暂未支持)'''

        host = gettelnet('host')
        ftpSmaba = NetworkSharingPage(self.driver, self.url)
        #1、未开启验证无法登录
        user_name = "anonymous"
        pass_word = ""
        my_name = "anyname"
        domain_name = ""
        remote_smb_IP = host
        smb = SMBConnection(user_name,
                            pass_word,
                            my_name,
                            domain_name,
                            use_ntlm_v2=True)
        try:
            smb.connect(remote_smb_IP, 139, timeout=3)
        except ConnectionRefusedError:
            print('未开启samba 无法访问 验证通过')

        #2、打开samba
        sambaEn = ftpSmaba.getAttribute_byName(ftpSmaba.sambaEnS, 'checked')
        if sambaEn != 'true':
            ftpSmaba.click_sambaEn()
            ftpSmaba.click_save()
        time.sleep(13)
        sambaEn = str(
            ftpSmaba.getAttribute_byName(ftpSmaba.sambaEnS, 'checked'))
        self.assertEqual(sambaEn, 'true', msg='samba开启 失败')
        #samba登录
        smb = SMBConnection(user_name,
                            pass_word,
                            my_name,
                            domain_name,
                            use_ntlm_v2=True)
        try:
            smb.connect(remote_smb_IP, 139, timeout=3)
        except socket.timeout:
            raise Exception('samba服务无法访问')
        shareslist = smb.listShares()  # 列出共享目录 这里只能看到1级菜单“1”
        smb.close()
        n = []
        for i in shareslist:
            n.append(i.name)
        print(n)
        nn = []
        for x in n:
            if '$' not in x:
                nn.append(x)
                print(nn)
        #3、打开验证
        if '1' in nn:
            pass
        else:
            raise Exception('samba验证失败')  # 如果没有则报错

        self.driver.quit()
        logger.info('test_003_samba passed')
Beispiel #2
0
    def test_001_AccountSettings(self):
        u'''账号设置:新建、删除、修改'''

        reachMaxA = getAssertText('reachMaxA')
        roleA = getAssertText('roleA')
        account = NetworkSharingPage(self.driver, self.url)
        #新建
        n = 2
        while n < 6:
            n += 1
            if n < 6:
                account.click_add()
                time.sleep(1)
                account.input_username(n)
                account.input_passwd1(n)
                account.input_passwd2(n)
                authority = account.selelement_byName(account.authority)
                Select(authority).select_by_value('1')  #0 读 1 读写
                account.click_save()
                time.sleep(1)
            else:
                account.click_add()
                time.sleep(1)
                account.input_username(n)
                account.input_passwd1(n)
                account.input_passwd2(n)
                authority = account.selelement_byName(account.authority)
                Select(authority).select_by_value('0')  # 0 读 1 读写
                account.click_save()
                time.sleep(1)
                tips = str(account.getText_byClass(account.tips_show_in))
                self.assertEqual(tips, reachMaxA, msg='最大账号为5个 验证失败')
                account.click_modal_hide()
                time.sleep(1)
        Acc3 = str(account.getText_byXpath(account.Acc3))
        auth3 = str(account.getText_byXpath(account.auth3))
        self.assertEqual(Acc3, '3', msg='新增账号失败')
        self.assertEqual(auth3, roleA, msg='新增账号权限失败')
        Acc4 = str(account.getText_byXpath(account.Acc4))
        auth4 = str(account.getText_byXpath(account.auth4))
        self.assertEqual(Acc4, '4', msg='新增账号名失败')
        self.assertEqual(auth4, roleA, msg='新增账号权限失败')
        Acc5 = str(account.getText_byXpath(account.Acc5))
        auth5 = str(account.getText_byXpath(account.auth5))
        self.assertEqual(Acc5, '5', msg='新增账号名失败')
        self.assertEqual(auth5, roleA, msg='新增账号权限失败')

        self.driver.quit()
        logger.info('test_001_AccountSettings passed')
Beispiel #3
0
    def test_002_systemAccount(self):
        u'''系统账号不能删除/不能修改账号名'''

        CannotdeleteA = getAssertText('CannotdeleteA')
        Cannotdelete2A = getAssertText('Cannotdelete2A')
        UnableChangeA = getAssertText('UnableChangeA')
        account = NetworkSharingPage(self.driver, self.url)
        #系统账号不能删除
        account.click_listdel1()
        time.sleep(1)
        tips = str(account.getText_byClass(account.tips_show_in))
        self.assertEqual(tips, CannotdeleteA, msg='admin账号不能删除 异常')
        account.click_listdel2()
        time.sleep(1)
        tips = str(account.getText_byClass(account.tips_show_in))
        self.assertEqual(tips, Cannotdelete2A, msg='guest账号不能删除 异常')
        #系统账号名不能修改
        account.click_listedit1()
        time.sleep(1)
        try:
            account.input_username('1')
        except InvalidElementStateException:
            print('admin账号不可修改 验证通过')
            account.click_modal_hide()
            time.sleep(1)
        else:
            raise Exception('admin账号可修改')
        account.click_listedit2()
        time.sleep(1)
        account.input_username('guest1')
        account.click_save()
        time.sleep(1)
        try:
            tips = str(account.getText_byClass(account.tips_show_in))
            self.assertEqual(tips, UnableChangeA, msg='guest账号修改提示信息 异常')
        except NoSuchElementException:
            raise Exception('guest账号可修改')
        account.click_modal_hide()
        time.sleep(1)

        self.driver.quit()
        logger.info('test_002_systemAccount passed')
Beispiel #4
0
    def test_003_otherAccount(self):
        u'''修改其他新增账号名及密码'''

        role2A = getAssertText('role2A')
        account = NetworkSharingPage(self.driver, self.url)
        account.click_listedit3()
        time.sleep(1)
        account.input_username('33')
        account.input_passwd1('33')
        account.input_passwd2('33')
        authority = account.selelement_byName(account.authority)
        Select(authority).select_by_value('0')  # 0 读 1 读写
        account.click_save()
        time.sleep(1)
        Acc3 = str(account.getText_byXpath(account.Acc3))
        auth3 = str(account.getText_byXpath(account.auth3))
        self.assertEqual(Acc3, '33', msg='新增账号失败')
        self.assertEqual(auth3, role2A, msg='新增账号权限失败')

        self.driver.quit()
        logger.info('test_003_otherAccount passed')
    def test_005_WanAcessSmaba(self):
        u'''WAN口访问samba服务器(部分型号暂未支持)'''
        ftpSmaba = NetworkSharingPage(self.driver, self.url)
        #1、验证未打开 ‘wan口访问’ 无法从wan访问samba
        #1)验证未打开
        WANEnable = str(
            self.driver.find_element_by_name('WANEnable').get_attribute(
                'checked'))
        print(WANEnable)
        if WANEnable == 'true':
            self.driver.find_element_by_name('WANEnable').click()
            ftpSmaba.click_save()
            time.sleep(1)
            ftpSmaba.click_NetworkSharing2()  # 点击网络共享子页面
            time.sleep(1)
            WANEnable = str(
                self.driver.find_element_by_name('WANEnable').get_attribute(
                    'checked'))
            self.assertEqual(WANEnable, 'None', msg='允许wan口访问 关闭失败')
        #2)从外网配置页面获取WAN1口地址
        wanpage = NetworkConfig_wanpage(self.driver, self.url)
        wanpage.click_WANconfig()
        time.sleep(1)
        # WAN1 ip变量赋值,页面读取
        WAN1_ip = str(wanpage.getText_byXpath(wanpage.line1IP))
        time.sleep(1)
        #3) 更改pc 交换机接口与wan口/上联口通
        swconfig.test_LanToWan(self)
        # 重新获取地址 应获取到上层网关下发的地址
        pcaddr = str(socket.gethostbyname(socket.getfqdn(
            socket.gethostname())))
        # 调用bat脚本 IP地址释放
        os.system('%s' % (batpath + 'ipconfig_release.bat'))
        time.sleep(2)
        pcaddr1 = str(
            socket.gethostbyname(socket.getfqdn(socket.gethostname())))
        print(pcaddr1)
        if pcaddr1 != str(pcaddr):
            print('IP地址已释放')
        else:
            time.sleep(3)
        time.sleep(2)
        # 重新获取地址
        os.system('%s' % (batpath + 'ipconfig_renew.bat'))
        time.sleep(5)
        n = 0
        while n < 30:
            # 获取本机ip 默认有线地址,有线断开会显示无线
            pcaddr = socket.gethostbyname(socket.getfqdn(socket.gethostname()))
            print(pcaddr, n)
            if '192.168.' not in str(pcaddr):
                time.sleep(2)
                n += 1
            else:
                print('IP地址已自动获取成功', n)
                break
        else:
            raise Exception('未获取到地址')
        time.sleep(2)
        #4)未开启验证无法登录
        user_name = "anonymous"
        pass_word = ""
        my_name = "anyname"
        domain_name = ""
        remote_smb_IP = WAN1_ip
        smb = SMBConnection(user_name,
                            pass_word,
                            my_name,
                            domain_name,
                            use_ntlm_v2=True)
        try:
            smb.connect(remote_smb_IP, 139, timeout=3)
        except ConnectionRefusedError:
            print('未开启samba 无法访问 验证通过')
        # 5)改为lan口 并重新获取地址
        switchURL2 = gettelnet('switchURL2')
        # 调用bat脚本 地址修改为 192.168.34.39 网关192.168.34.1
        os.system('%s' % (batpath + 'changeStaticIP3_34duan.bat'))
        time.sleep(5)
        n = 0
        while n < 30:
            # 获取本机ip 默认有线地址,有线断开会显示无线
            pcaddr = socket.gethostbyname(socket.getfqdn(socket.gethostname()))
            print(pcaddr, n)
            if str(pcaddr) != '192.168.34.39':
                time.sleep(2)
                n += 1
            else:
                print('地址已修改为地址 192.168.34.39', n)
                break
        else:
            raise Exception('地址修改为192.168.34.39 失败')
        # 更改pc 交换机接口与lan口通
        p1 = subprocess.Popen('ping -n 2 -w 2 %s' % switchURL2,
                              shell=True,
                              stdout=subprocess.PIPE)
        # print('错误IP联网状态(ping通为0 不通为1):', p1.wait())  # ping通为0 不通为1
        ping = int(p1.wait())
        if ping == 0:
            swconfig.test_WanToLan(self)
        # 将IP改回自动获取 应获取到被测设备下发的地址
        os.system('%s' % (batpath + 'changeDhcpIp.bat'))
        n = 0
        while n < 30:
            # 获取本机ip 默认有线地址,有线断开会显示无线
            pcaddr_new = socket.gethostbyname(
                socket.getfqdn(socket.gethostname()))
            print(pcaddr_new, n)
            if '192.168.' not in str(pcaddr_new):
                time.sleep(2)
                n += 1
            else:
                print('IP地址已自动获取成功', n)
                break
        else:
            raise Exception('未获取到地址')
        time.sleep(3)
        #2 验证打开 ‘wan口访问’ 可以从wan口访问smaba
        #1)打开
        ftpSmaba = NetworkSharingPage(self.driver, self.url)
        ftpSmaba.click_NetworkSharing()
        time.sleep(1)
        ftpSmaba.click_NetworkSharing2()  # 点击网络共享子页面
        time.sleep(1)
        self.driver.find_element_by_name('WANEnable').click()
        ftpSmaba.click_save()
        time.sleep(1)
        WANEnable = self.driver.find_element_by_name(
            'WANEnable').get_attribute('checked')
        self.assertEqual(WANEnable, 'true', msg='允许wan口访问 启用失败')
        #2) 更改pc 交换机接口与wan口/上联口通
        swconfig.test_LanToWan(self)
        # 重新获取地址 应获取到上层网关下发的地址
        pcaddr = str(socket.gethostbyname(socket.getfqdn(
            socket.gethostname())))
        # 调用bat脚本 IP地址释放
        os.system('%s' % (batpath + 'ipconfig_release.bat'))
        time.sleep(2)
        pcaddr1 = str(
            socket.gethostbyname(socket.getfqdn(socket.gethostname())))
        print(pcaddr1)
        if pcaddr1 != str(pcaddr):
            print('IP地址已释放')
        else:
            time.sleep(3)
        time.sleep(2)
        # 重新获取地址
        os.system('%s' % (batpath + 'ipconfig_renew.bat'))
        time.sleep(5)
        n = 0
        while n < 30:
            # 获取本机ip 默认有线地址,有线断开会显示无线
            pcaddr = socket.gethostbyname(socket.getfqdn(socket.gethostname()))
            print(pcaddr, n)
            if '192.168.' not in str(pcaddr):
                time.sleep(2)
                n += 1
            else:
                print('IP地址已自动获取成功', n)
                break
        else:
            raise Exception('未获取到地址')
        time.sleep(2)
        # 3)samba验证登陆
        try:
            smb.connect(remote_smb_IP, 139, timeout=3)
        except socket.timeout:
            raise Exception('samba服务无法访问')
        smb.close()

        self.driver.quit()
        logger.info('test_004_WanaAcess passed')
    def test_001_ftpServer(self):
        u'''ftp服务器基本设置,ftp查看'''
        host = gettelnet('host')
        ftpSmaba = NetworkSharingPage(self.driver, self.url)
        # 1、设置ftp基本信息
        ftpSmaba.click_choosml()
        time.sleep(1)
        ftpSmaba.input_names('1')
        ftpSmaba.click_FTP_DIR_1_check()
        ftpSmaba.click_modal_FTP()
        time.sleep(1)
        try:  #以访第一次选中后 第二次点击被取消 从而未选中共享目录
            self.driver.implicitly_wait(1)
            ftpSmaba.find_tips_show_inf()
        except NoSuchElementException:
            pass
        else:
            ftpSmaba.click_FTP_DIR_1_check()
            ftpSmaba.click_modal_FTP()
            time.sleep(3)
        self.driver.implicitly_wait(10)
        ftpEn = ftpSmaba.getAttribute_byName(ftpSmaba.ftpEns, 'checked')
        print(ftpEn)
        if ftpEn != 'true':
            ftpSmaba.click_ftpEn()
            time.sleep(1)
        defaultPort = str(
            ftpSmaba.getAttribute_byName(ftpSmaba.ftpports, 'value'))
        self.assertEqual(defaultPort, '21', msg='ftp默认端口不为21')
        ftpSmaba.click_save()
        time.sleep(1)
        enableDevice = ftpSmaba.getAttribute_byId(ftpSmaba.enableDevices,
                                                  'checktype')
        print(enableDevice)
        if enableDevice != '1':  #1为打开网络共享
            ftpSmaba.click_enableDevice()
            time.sleep(3)
        ftpEn = ftpSmaba.getAttribute_byName(ftpSmaba.ftpEns, 'checked')
        enableDevice = ftpSmaba.getAttribute_byId(ftpSmaba.enableDevices,
                                                  'checktype')
        self.assertEqual(ftpEn, 'true', msg='启用FTP服务器 失败')
        self.assertEqual(enableDevice, '1', msg='网络共享 启用失败')
        time.sleep(10)
        #2、ftp查看目录文件
        IP = host
        Port = 21
        ftp = ftplib.FTP()
        ftp.encoding = 'utf-8'
        try:
            ftp.connect(host=IP, port=Port, timeout=5)
        except socket.error or socket.gaierror:
            raise Exception("无法访问FTP服务")
        try:
            ftp.login(user='******')  # 相当于没有验证账号密码
        except ftplib.error_perm:
            raise Exception("FTP账号密码验证错误")
        ftpFile = ftp.nlst('1')  # 获取指定目录下的文件
        # print('ftpFile', ftpFile)
        ftp.quit()
        #过滤掉中文和带空格的
        zhmodel = re.compile(u'[\u4e00-\u9fa5]')  # 检查中文
        ftpFile2 = []
        for file in ftpFile:
            if ' ' not in file:
                ftpFile2.append(file[2:])
        for i in ftpFile2:
            if zhmodel.search(i):
                ftpFile2.remove(i)
        # print('ftpFile2:',ftpFile2)
        # 3、telnet后台查看目录文件
        # 连接Telnet服务器
        hostip = gettelnet('host')
        port = gettelnet('port')
        username = bytes(getweb('User'), encoding="utf8")
        password = bytes(getweb('Passwd'), encoding="utf8")
        tn = telnetlib.Telnet(host=hostip, port=port, timeout=10)
        tn.set_debuglevel(5)  # 级别越高输出的调试信息越多,并没有看出区别
        # 输入登录用户名
        tn.read_until(b'login:'******'Password:'******'#')
        tn.write(b'cd /ftpRoot/1 ; ls' + b'\n')
        # 输出结果,判断
        time.sleep(1)
        result = str(tn.read_very_eager())  # 只会存最后一条命令的结果
        print('-------------------输出结果------------------------')
        # 命令执行结果
        # print('result:', result)
        tn.close()  # tn.write('exit\n')

        #4、判断对比 ftp查看内容在telnet查看的目录中
        for i in ftpFile2:
            if result.count(i):
                pass
            else:
                raise Exception(' 验证失败')  # 如果没有则报错

        self.driver.quit()
        logger.info('test_001_ftpServer passed')
    def test_004_WanAcessFTP(self):
        u'''WAN口访问FTP'''
        ftpSmaba = NetworkSharingPage(self.driver, self.url)
        #1、验证未打开 ‘wan口访问’ 无法从wan访问FTP
        #1)验证未打开
        WANEnable = str(
            self.driver.find_element_by_name('WANEnable').get_attribute(
                'checked'))
        print(WANEnable)
        if WANEnable == 'true':
            self.driver.find_element_by_name('WANEnable').click()
            ftpSmaba.click_save()
            time.sleep(1)
            ftpSmaba.click_NetworkSharing2()  # 点击网络共享子页面
            time.sleep(1)
            WANEnable = str(
                self.driver.find_element_by_name('WANEnable').get_attribute(
                    'checked'))
            self.assertEqual(WANEnable, 'None', msg='允许wan口访问 关闭失败')
        #2)从外网配置页面获取WAN1口地址
        wanpage = NetworkConfig_wanpage(self.driver, self.url)
        wanpage.click_WANconfig()
        time.sleep(1)
        # WAN1 ip变量赋值,页面读取
        WAN1_ip = str(wanpage.getText_byXpath(wanpage.line1IP))
        time.sleep(1)
        #3) 更改pc 交换机接口与wan口/上联口通
        swconfig.test_LanToWan(self)
        # 重新获取地址 应获取到上层网关下发的地址
        pcaddr = str(socket.gethostbyname(socket.getfqdn(
            socket.gethostname())))
        # 调用bat脚本 IP地址释放
        os.system('%s' % (batpath + 'ipconfig_release.bat'))
        time.sleep(2)
        pcaddr1 = str(
            socket.gethostbyname(socket.getfqdn(socket.gethostname())))
        print(pcaddr1)
        if pcaddr1 != str(pcaddr):
            print('IP地址已释放')
        else:
            time.sleep(3)
        time.sleep(2)
        # 重新获取地址
        os.system('%s' % (batpath + 'ipconfig_renew.bat'))
        time.sleep(5)
        n = 0
        while n < 30:
            # 获取本机ip 默认有线地址,有线断开会显示无线
            pcaddr = socket.gethostbyname(socket.getfqdn(socket.gethostname()))
            print(pcaddr, n)
            if '192.168.' not in str(pcaddr):
                time.sleep(2)
                n += 1
            else:
                print('IP地址已自动获取成功', n)
                break
        else:
            raise Exception('未获取到地址')
        time.sleep(2)
        #4)尝试访问FTP
        # ftp验证登录
        IP = WAN1_ip
        Port = 21
        ftp = ftplib.FTP()
        ftp.encoding = 'utf-8'
        try:
            ftp.connect(host=IP, port=Port, timeout=5)
            ftp.login(user='******')  # 相当于没有验证账号密码
        except socket.error or socket.gaierror:
            print("未开启“WAN口访问开关”无法访问FTP服务 验证通过")
        except ftplib.error_perm:  # 当前未开启wan口访问,wan口访问时候会弹出账号密码框,但输入会提示密码错误
            print("未开启“WAN口访问开关”访问FTP服务会密码错误 验证通过")
        else:
            raise Exception("未开启“WAN口访问开关” 依旧可以访问FTP服务")
        ftp.quit()
        #5)改为lan口 并重新获取地址
        switchURL2 = gettelnet('switchURL2')
        # 调用bat脚本 地址修改为 192.168.34.39 网关192.168.34.1
        os.system('%s' % (batpath + 'changeStaticIP3_34duan.bat'))
        time.sleep(5)
        n = 0
        while n < 30:
            # 获取本机ip 默认有线地址,有线断开会显示无线
            pcaddr = socket.gethostbyname(socket.getfqdn(socket.gethostname()))
            print(pcaddr, n)
            if str(pcaddr) != '192.168.34.39':
                time.sleep(2)
                n += 1
            else:
                print('地址已修改为地址 192.168.34.39', n)
                break
        else:
            raise Exception('地址修改为192.168.34.39 失败')
        # 更改pc 交换机接口与lan口通
        p = pingTestIP(switchURL2)
        if p == 'Y':
            swconfig.test_WanToLan(self)
        # 将IP改回自动获取 应获取到被测设备下发的地址
        os.system('%s' % (batpath + 'changeDhcpIp.bat'))
        n = 0
        while n < 30:
            # 获取本机ip 默认有线地址,有线断开会显示无线
            pcaddr_new = socket.gethostbyname(
                socket.getfqdn(socket.gethostname()))
            print(pcaddr_new, n)
            if '192.168.' not in str(pcaddr_new):
                time.sleep(2)
                n += 1
            else:
                print('IP地址已自动获取成功', n)
                break
        else:
            raise Exception('未获取到地址')
        time.sleep(3)
        #2 验证打开 ‘wan口访问’ 可以从wan口访问FTP
        #1)打开
        ftpSmaba = NetworkSharingPage(self.driver, self.url)
        ftpSmaba.click_NetworkSharing()
        time.sleep(1)
        ftpSmaba.click_NetworkSharing2()  # 点击网络共享子页面
        time.sleep(1)
        self.driver.find_element_by_name('WANEnable').click()
        ftpSmaba.click_save()
        time.sleep(2)
        WANEnable = self.driver.find_element_by_name(
            'WANEnable').get_attribute('checked')
        self.assertEqual(WANEnable, 'true', msg='允许wan口访问 启用失败')
        #2) 更改pc 交换机接口与wan口/上联口通
        swconfig.test_LanToWan(self)
        # 重新获取地址 应获取到上层网关下发的地址
        pcaddr = str(socket.gethostbyname(socket.getfqdn(
            socket.gethostname())))
        # 调用bat脚本 IP地址释放
        os.system('%s' % (batpath + 'ipconfig_release.bat'))
        time.sleep(2)
        pcaddr1 = str(
            socket.gethostbyname(socket.getfqdn(socket.gethostname())))
        print(pcaddr1)
        if pcaddr1 != str(pcaddr):
            print('IP地址已释放')
        else:
            time.sleep(3)
        time.sleep(2)
        # 重新获取地址
        os.system('%s' % (batpath + 'ipconfig_renew.bat'))
        time.sleep(5)
        n = 0
        while n < 30:
            # 获取本机ip 默认有线地址,有线断开会显示无线
            pcaddr = socket.gethostbyname(socket.getfqdn(socket.gethostname()))
            print(pcaddr, n)
            if '192.168.' not in str(pcaddr):
                time.sleep(2)
                n += 1
            else:
                print('IP地址已自动获取成功', n)
                break
        else:
            raise Exception('未获取到地址')
        time.sleep(2)
        # 3)ftp验证登陆
        try:
            ftp.connect(host=IP, port=Port, timeout=5)
        except socket.error or socket.gaierror:
            raise Exception("无法访问FTP服务")
        try:
            ftp.login(user='******')  # 相当于没有验证账号密码
        except ftplib.error_perm:
            raise Exception("FTP账号密码验证错误")
        ftpFile = ftp.nlst('1')  # 获取指定目录下的文件
        print('ftpFile', ftpFile)
        ftp.quit()

        self.driver.quit()
        logger.info('test_004_WanaAcess passed')
    def test_002_ftpPort(self):
        u'''FTP端口'''

        host = gettelnet('host')
        portwarnA = getAssertText('portwarnA')
        ftpSmaba = NetworkSharingPage(self.driver, self.url)

        # defaultPort=str(self.driver.find_element_by_name('ftpport').get_attribute('value'))
        # self.assertEqual(defaultPort,'21',msg='ftp默认端口不为21') #001已验证

        #修改端口为22
        ftpSmaba.input_ftpport('22')
        ftpSmaba.click_save()
        time.sleep(10)
        Port1 = str(ftpSmaba.getAttribute_byName(ftpSmaba.ftpports, 'value'))
        self.assertEqual(Port1, '22', msg='ftp修改端口不为22')
        # ftp验证端口
        IP = host
        ftp = ftplib.FTP()
        ftp.encoding = 'utf-8'
        try:
            ftp.connect(host=IP, port=22, timeout=5)
        except socket.error or socket.gaierror:
            raise Exception("无法访问FTP服务")
        try:
            ftp.login(user='******')  # 相当于没有验证账号密码
        except ftplib.error_perm:
            raise Exception("FTP账号密码验证错误")
        ftpFile = ftp.nlst('1')  # 获取指定目录下的文件
        print('ftpFile', ftpFile)
        ftp.quit()
        # 修改端口为65534
        ftpSmaba.input_ftpport('65534')
        ftpSmaba.click_save()
        time.sleep(10)
        Port1 = str(ftpSmaba.getAttribute_byName(ftpSmaba.ftpports, 'value'))
        self.assertEqual(Port1, '65534', msg='ftp修改端口不为65534')
        # ftp验证端口
        ftp = ftplib.FTP()
        ftp.encoding = 'utf-8'
        try:
            ftp.connect(host=IP, port=65534, timeout=5)
        except socket.error or socket.gaierror:
            raise Exception("无法访问FTP服务")
        try:
            ftp.login(user='******')  # 相当于没有验证账号密码
        except ftplib.error_perm:
            raise Exception("FTP账号密码验证错误")
        ftpFile = ftp.nlst('1')  # 获取指定目录下的文件
        print('ftpFile', ftpFile)
        ftp.quit()
        # 修改端口为1
        ftpSmaba.input_ftpport('1')
        ftpSmaba.click_save()
        time.sleep(10)
        Port1 = str(ftpSmaba.getAttribute_byName(ftpSmaba.ftpports, 'value'))
        self.assertEqual(Port1, '1', msg='ftp修改端口不为1')
        # ftp验证端口
        ftp = ftplib.FTP()
        ftp.encoding = 'utf-8'
        try:
            ftp.connect(host=IP, port=1, timeout=5)
        except socket.error or socket.gaierror:
            raise Exception("无法访问FTP服务")
        try:
            ftp.login(user='******')  # 相当于没有验证账号密码
        except ftplib.error_perm:
            raise Exception("FTP账号密码验证错误")
        ftpFile = ftp.nlst('1')  # 获取指定目录下的文件
        print('ftpFile', ftpFile)
        ftp.quit()

        #验证提示信息
        ftpSmaba.input_ftpport('65536')
        ftpSmaba.click_save()
        time.sleep(1)
        tipsport = str(ftpSmaba.getText_byXpath(ftpSmaba.tipsport))
        if portwarnA not in tipsport:
            CapPic(self.driver)
            logger.info(u'FTP端口范围提示有误')
            raise Exception('FTP端口范围提示有误')

        # 将端口改回21
        ftpSmaba.input_ftpport('21')
        ftpSmaba.click_save()
        time.sleep(2)

        self.driver.quit()
        logger.info('test_002_ftpPort passed')