def test_004_accesscontrol_Language(self):
        u'''设备访问控制/WEB语言'''
        accesscontrol = ManagementPolicyPage(self.driver, self.url)
        accesscontrol.click_lanAccessControl()
        time.sleep(1)
        switch = str(
            accesscontrol.getAttribute_byXpath(
                accesscontrol.innerAccessControlCs, 'checked'))
        self.assertEqual(switch, 'true', msg='内网访问控制默认未关闭')

        languageA = getAssertText('languageA')
        language = ManagementPolicyPage(self.driver, self.url)
        language.click_Language()
        time.sleep(1)
        languageText = str(language.getText_byXpath(language.languageText))
        self.assertEqual(languageText, languageA, msg='语言 显示字符异常')

        self.driver.quit()
        logger.info('test_004_accesscontrol_Language passed')
Esempio n. 2
0
 def tearDown(self):
     host = gettelnet('host')
     port = gettelnet('port')
     try:
         telnetlib.Telnet(host, port= port, timeout=10)
     except socket.timeout:
         # 将IP改回自动获取(设置dns为自动获取)
         os.system('%s' % (batpath + 'changeDhcpIp.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('未获取到地址')
     login.loginWeb(self)  # admin账号登录
     self.driver.implicitly_wait(10)
     accesscontrol = ManagementPolicyPage(self.driver, self.url)
     # 进入系统配置-网管策略-内网访问控制
     accesscontrol.click_sysConfig()
     time.sleep(0.5)
     accesscontrol.click_ManagementPolicy()
     time.sleep(1)
     accesscontrol.click_lanAccessControl()
     time.sleep(1)
     accesscontrol.click_innerAccessControlC()
     accesscontrol.click_save()
     time.sleep(1)
     self.driver.quit()
     logger.info('tearDown over')
     logger.info('%s' % ('=' * 50))
Esempio n. 3
0
    def test_002_usergroup(self):
        u'''内网访问控制 - 组织架构'''
        self.driver.quit()
        RouteUrl = getweb('RouteUrl')
        #增加组织架构用户
        organization_group.import_empty_template(self)
        organization_group.add_user(self)

        login.loginWeb(self)  # admin账号登录
        self.driver.implicitly_wait(10)
        accesscontrol = ManagementPolicyPage(self.driver, self.url)
        # 进入系统配置-网管策略-内网访问控制
        accesscontrol.click_sysConfig()
        time.sleep(0.5)
        accesscontrol.click_ManagementPolicy()
        time.sleep(1)
        accesscontrol.click_lanAccessControl()
        time.sleep(1)
        accesscontrol.click_choosePeople()
        time.sleep(1)
        accesscontrol.click_usergroup()
        #组织架构,这里选择的是ROOT 所有
        time.sleep(1)
        accesscontrol.click_Root()
        #弹窗中的保存
        accesscontrol.click_saveW1()
        time.sleep(1)
        accesscontrol.click_innerAccessControlEn()
        accesscontrol.click_save()
        time.sleep(1)
        self.driver.quit()

        # 调用bat脚本 地址修改为非组织架构IP 192.168.1.39 网关192.168.1.1
        if '192.168.1.1' in host:
            os.system(('%s' % batpath + 'changeStaticIP2_1duan.bat'))
        elif '192.168.16.1' in host:
            os.system(('%s' % batpath + 'changeStaticIP2_16duan.bat'))
        else:
            raise Exception('lan口非 1网段、16网段')
        time.sleep(5)
        n = 0
        while n < 30:
            # 获取本机ip 默认有线地址,有线断开会显示无线
            pcaddr1 = socket.gethostbyname(socket.getfqdn(socket.gethostname()))
            print(pcaddr1, n)
            if str(pcaddr1) != batSameIP:
                time.sleep(2)
                n += 1
            else:
                print('地址已修改为非绑定地址 192.168.1.39', n)
                break
        else:
            raise Exception('地址修改为非绑定地址 192.168.1.39失败')

        # 判断登录 切换IP后应该不能登录设备
        self.driver = webdriver.Chrome()
        # self.driver.maximize_window()
        self.driver.implicitly_wait(10)
        self.driver.get(RouteUrl)
        title=self.driver.title
        if 'Error: Forbidden' in title:
            print('非组织架构用户无法登录设备 验证通过')
        else:
            CapPic(self.driver)
            logger.info('非组织架构用户依旧可以登录设备')
            raise Exception('非组织架构用户依旧可以登录设备')
        self.driver.quit()

        # 将IP改回自动获取(设置dns为自动获取)
        # 调用bat脚本
        os.system('%s' % (batpath + 'changeDhcpIp.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('未获取到地址')

        # 验证是否可以登录 并删除添加的组织架构
        #先关闭访问控制 否则删除组织架构后 无法登录
        login.loginWeb(self)  # admin账号登录
        self.driver.implicitly_wait(10)
        accesscontrol = ManagementPolicyPage(self.driver, self.url)
        # 进入系统配置-网管策略-内网访问控制
        accesscontrol.click_sysConfig()
        time.sleep(0.5)
        accesscontrol.click_ManagementPolicy()
        time.sleep(1)
        accesscontrol.click_lanAccessControl()
        time.sleep(1)
        accesscontrol.click_innerAccessControlC()
        accesscontrol.click_save()
        time.sleep(1)
        self.driver.quit()
        #删除添加的组织架构
        organization_group.group_delete(self)
        print('访问控制 选择组织架构  验证通过')
        logger.info('test_002_usergroup passed')