示例#1
0
 def test_001_test1(self):
     u'''添加管理员账号'''
     roleA = getAssertText('roleA')
     # 添加管理员账号test/test,读写权限
     login.loginWeb(self)  #admin账号登录
     self.driver.implicitly_wait(10)
     administrator = ManagementPolicyPage(self.driver, self.url)
     #进入系统配置-网管策略-系统管理员
     administrator.click_sysConfig()
     time.sleep(0.5)
     administrator.click_ManagementPolicy()
     time.sleep(1)
     # 添加管理员账号test/test
     administrator.click_add()
     time.sleep(1)
     administrator.input_username('test')
     administrator.input_passwd1('test')
     administrator.input_passwd2('test')
     #设置权限变量,选择 读写 权限
     selrole = administrator.selelement_byName(administrator.role)
     Select(selrole).select_by_value('adm')
     administrator.click_save()
     time.sleep(1)
     # 断言 再点击编辑 确认元素不为空(账号确实是test):代表账号确实是test
     list_name1 = administrator.getText_byXpath(administrator.list_name1)
     list_role1 = administrator.getText_byXpath(administrator.list_role1)
     self.assertEqual(list_name1, 'test', msg='新建账号不为test')
     self.assertEqual(list_role1, roleA, msg='新建账号权限不为读写')
     #注销当前登录
     login.logoutWeb(self)
     time.sleep(1)
     self.driver.quit()
示例#2
0
    def test_003_test3(self):
        u'''已删除账号验证 只读权限验证'''
        pageTipWarnA = getAssertText('pageTipWarnA')
        #使用test账号不能登陆管理DUT
        login.test_unableLoginWeb(self, username='******', password='******')
        self.driver.implicitly_wait(10)
        self.driver.quit()

        #使用test1账号可以登陆管理DUT
        login.test_enableLoginWeb(self, username='******', password='******')
        self.driver.implicitly_wait(10)
        # 只读权限test1 尝试删除test1/test1账号,应该不成功
        administrator = ManagementPolicyPage(self.driver, self.url)
        administrator.click_sysConfig()
        time.sleep(0.5)
        administrator.click_ManagementPolicy()
        time.sleep(1)
        #尝试删除test1/test1账号,应该不成功
        administrator.click_listDelete1()
        time.sleep(1)
        administrator.click_ok()
        time.sleep(1)
        # 断言删除时候提示信息(logout_span)元素不为空:代表无法删除
        pageTip_warn = administrator.getText_byClass(
            administrator.pageTip_warn)
        if pageTip_warn != pageTipWarnA:
            CapPic(self.driver)
            logger.info(u'只读权限删除提示有误')
            raise Exception('只读权限删除提示有误')
        else:
            print('已删除账号验证、只读权限验证 通过')
        self.driver.quit()
 def setUp(self):
     logger.info('setUp start')
     login.loginWeb(self)
     self.driver.implicitly_wait(10)
     accessStrategy = ManagementPolicyPage(self.driver, self.url)
     # 进入系统配置-网管策略
     accessStrategy.click_sysConfig()
     time.sleep(0.5)
     accessStrategy.click_ManagementPolicy()
     time.sleep(1)
示例#4
0
 def setUp(self):
     logger.info('setUp start')
     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)
示例#5
0
 def setUp(self):
     logger.info('setUp start')
     login.loginWeb(self)  #admin账号登录
     language = ManagementPolicyPage(self.driver, self.url)
     self.driver.implicitly_wait(10)
     #进入系统配置-网管策略-语言选择
     language.click_sysConfig()
     time.sleep(0.5)
     language.click_ManagementPolicy()
     time.sleep(1)
     language.click_Language()
     time.sleep(1)
示例#6
0
 def setUp(self):
     logger.info('setUp start')
     login.loginWeb(self)  # admin账号登录
     self.driver.implicitly_wait(10)
     remoteManage = ManagementPolicyPage(self.driver, self.url)
     # 进入系统配置-网管策略-远程管理
     remoteManage.click_sysConfig()
     time.sleep(0.5)
     remoteManage.click_ManagementPolicy()
     time.sleep(1)
     remoteManage.click_RemoteManagement()
     time.sleep(1)
示例#7
0
 def test_006_RemoteManagement(self):
     u'''远程管理'''
     management = ManagementPolicyPage(self.driver, self.url)
     management.click_ManagementPolicy()
     time.sleep(1)
     management.click_RemoteManagement()
     time.sleep(0.5)
     switch = str(
         management.getAttribute_byXpath(management.httpCs, 'checked'))
     port = str(management.getAttribute_byName(management.OutPort1,
                                               'value'))
     self.assertEqual(switch, 'true', msg='远程管理默认关闭 有误')
     self.assertEqual(port, '8081', msg='远程管理端口 默认不为8081')
     self.driver.quit()
     logger.info('test_006_RemoteManagement passed')
    def test_001_AccessMode(self):
        u'''https模式登录'''
        host = gettelnet('host')
        RouteUrls = 'https://' + host + '/'

        # 修改网管模式,端口切换到443,https模式下可登录设备
        accessStrategy = ManagementPolicyPage(self.driver, self.url)
        accessStrategy.click_httpswebEn()
        accessStrategy.click_save()
        # 加个判断 某些型号等待时间长(6550G)
        time.sleep(1)
        x = 0
        while x < 15:
            now_url = str(self.driver.current_url)
            print(now_url, x)
            if '/noAuth/login.html' not in now_url:  # 如果不同
                time.sleep(2)
            else:
                break
            x += 1
        self.driver.quit()

        #https模式下验证登录设备
        login.test_enableLoginWeb(self, url=RouteUrls)  #https登录
        accessStrategy = ManagementPolicyPage(self.driver, self.url)
        # 改回http 方式登录
        accessStrategy.click_sysConfig()
        time.sleep(0.5)
        accessStrategy.click_ManagementPolicy()
        time.sleep(1)
        accessStrategy.click_AccessPolicy()
        time.sleep(1)
        accessStrategy.click_httpwebEn()
        accessStrategy.click_save()
        time.sleep(1)
        i = 0
        while i < 30:
            url = self.driver.current_url
            if '/login.html' in url:
                break
            else:
                time.sleep(2)
            i += 1

        self.driver.quit()
        logger.info('test_001_AccessMode passed')
    def test_003_WEBtimeout(self, timeout='1'):  #因为字母顺序问题 该项会在最后执行
        u'''修改UI超时时间'''
        #修改UI超时时间
        accessStrategy = ManagementPolicyPage(self.driver, self.url)
        accessStrategy.input_sessionLife(timeout)
        accessStrategy.click_save()
        self.driver.quit()

        login.loginWeb(self)
        #任意点击一个页面,这里点击网络配置-内网配置
        lanconfig = NetworkConfig_LANpage(self.driver, self.url)
        lanconfig.click_NetworkConfig()
        time.sleep(0.5)
        lanconfig.click_LANconfig()
        time.sleep(1)
        print('等待超时时间,在这里等待80s')
        time.sleep(120)
        #等待超时时间后,任意点击其他页面 测试超时(返回登录页面)
        accessStrategy = ManagementPolicyPage(self.driver, self.url)
        accessStrategy.click_sysConfig()
        time.sleep(0.5)
        accessStrategy.click_ManagementPolicy()
        time.sleep(2)
        url = self.driver.current_url
        if '/login.html' not in url:
            CapPic(self.driver)
            logger.info(u"未跳回登录页面")
            raise Exception('未跳回登录页面')
        self.driver.quit()

        # 将超时时间改回默认值
        login.loginWeb(self)  # admin账号登录
        self.driver.implicitly_wait(10)
        accessStrategy = ManagementPolicyPage(self.driver, self.url)
        # 进入系统配置-网管策略-网管访问策略
        accessStrategy.click_sysConfig()
        time.sleep(0.5)
        accessStrategy.click_ManagementPolicy()
        time.sleep(1)
        accessStrategy.click_AccessPolicy()
        time.sleep(1)
        accessStrategy.input_sessionLife('10')
        accessStrategy.click_save()
        self.driver.quit()
        logger.info('test_003_WEBtimeout passed')
示例#10
0
 def test_002_test2(self):
     u'''新增账号登录 修改权限'''
     RouteUrl = getweb('RouteUrl')
     self.url = RouteUrl
     #能使用test该账号登陆管理DUT
     login.test_enableLoginWeb(self, username='******', password='******')
     # self.url = RouteUrl
     self.driver.implicitly_wait(10)
     administrator = ManagementPolicyPage(self.driver, self.url)
     administrator.click_sysConfig()
     time.sleep(0.5)
     administrator.click_ManagementPolicy()
     time.sleep(1)
     #修改test/test为test1/test1,(测试:账号权限一起改 提交时候权限未改成功,这里分两步完成)
     administrator.click_listEdit1()
     time.sleep(1)
     administrator.input_username('test1')
     administrator.input_passwd1('test1')
     administrator.input_passwd2('test1')
     administrator.click_save()
     time.sleep(1)
     self.driver.quit()
     #重新登录--只为修改test1的权限(可以使用test1登录也验证了上一步修改成功)
     login.test_enableLoginWeb(self, username='******', password='******')
     self.driver.implicitly_wait(10)
     administrator = ManagementPolicyPage(self.driver, self.url)
     administrator.click_sysConfig()
     time.sleep(0.5)
     administrator.click_ManagementPolicy()
     time.sleep(1)
     #修改test1/test1,为只读权限。
     administrator.click_listEdit1()
     time.sleep(1)
     selrole = administrator.selelement_byName(administrator.role)
     Select(selrole).select_by_value('viewer')  #改为只读权限
     time.sleep(1)
     administrator.click_input_group()  #修改后点击下其他元素,避免没有保存成功
     time.sleep(1)
     administrator.click_save()
     time.sleep(1)
     self.driver.quit()
示例#11
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))
示例#12
0
    def test_004_test4(self):
        u'''删除新增账号 admin登录验证'''
        #删除test1/test1,会退出当前登陆(test1已经修改了权限 用admin删除)
        login.loginWeb(self)  # admin账号登录
        self.driver.implicitly_wait(10)
        administrator = ManagementPolicyPage(self.driver, self.url)
        # 进入系统配置-网管策略-系统管理员
        administrator.click_sysConfig()
        time.sleep(0.5)
        administrator.click_ManagementPolicy()
        time.sleep(1)
        #删除test1/test1
        administrator.click_listDelete1()
        time.sleep(1)
        administrator.click_ok()
        time.sleep(1)
        # 断言列表框里第二行没有值、元素为空:代表删除成功
        list2_nodata = administrator.getText_byXpath(
            administrator.list2_nodata)
        if list2_nodata != ' ':
            CapPic(self.driver)
            logger.info(u'删除test1/test1 有误')
            raise Exception('删除test1/test1 有误')
        else:
            print('删除test1/test1 通过')
        self.driver.quit()

        #删除后使用test1不可以登录
        login.test_unableLoginWeb(self, username='******', password='******')
        time.sleep(1)
        self.driver.quit()
        #使用admin/admin可以登陆
        login.test_enableLoginWeb(self, username='******', password='******')
        time.sleep(1)
        self.driver.quit()
        print('管理员账号测试 验证通过')
示例#13
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')