Пример #1
0
 def setUp(self):
     logger.info('setUp start')
     #开启web 认证
     login.loginWeb(self)  # admin账号登录
     self.driver.implicitly_wait(10)
     self.driver.maximize_window()
     freeauth = Organization_userAuthPage(self.driver, self.url)
     # 打开用户管理 - 用户认证
     freeauth.click_UserManage()
     time.sleep(0.5)
     freeauth.click_userAuth()
     time.sleep(1)
     # 开启web认证
     freeauth.click_WebAuthEn()
     time.sleep(0.5)
     # 断言 提示信息是否有误
     status1 = str(
         freeauth.getAttribute_byXpath(freeauth.WebAuthEs, 'checked'))
     self.assertEqual(status1, 'true', msg='web认证开启出错')
     print('web认证开启')
     time.sleep(1)
     #开启免认证
     freeauth.click_FreeAuthEn()
     time.sleep(0.5)
     # 断言 提示信息是否有误
     status2 = str(
         freeauth.getAttribute_byXpath(freeauth.FreeAuthEs, 'checked'))
     self.assertEqual(status2, 'true', msg='免认证开启出错')
     print('免认证开启')
Пример #2
0
    def test_001_openWebAuth(self):
        u'''web认证开启'''
        host = gettelnet('host').split(r'.')
        host1 = host[0] + '.' + host[1] + '.' + host[2] +'.'
        # 006中设置了指定IP,这里增加一个判断联网
        pcaddr = socket.gethostbyname(socket.getfqdn(socket.gethostname()))
        print(pcaddr)
        pingTestIP()  # 避免判断失误

        p = pingTestIP()
        if p == 'N' or host1 not in pcaddr:  # 如果不通 or 地址不为lan口网段
            # 1、改回DHCP, 调用bat脚本
            os.system('%s' % (batpath + 'changeDhcpIp.bat'))
            time.sleep(5)
            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('未获取到地址')

        if Support == '√':
            logger.info(u'参数支持本地认证')
            organization_group.import_empty_template(self)  # 判断组织架构是否有其他组 有则清空

            # 打开用户管理 - 用户认证
            login.loginWeb(self)  # admin账号登录
            self.driver.implicitly_wait(10)
            webauth = Organization_userAuthPage(self.driver, self.url)
            # 打开用户管理 - 用户认证
            webauth.click_UserManage()
            time.sleep(0.5)
            webauth.click_userAuth()
            time.sleep(1)
            #开启web认证
            webauth.click_WebAuthEn()
            time.sleep(1)
            # 断言 提示信息是否有误
            status = str(webauth.getAttribute_byXpath(webauth.WebAuthEs,'checked'))
            time.sleep(1)
            self.assertEqual(status,'true',msg='web认证开启出错')
            self.driver.quit()
        elif Support == '×':
            logger.info(u'参数不支持本地认证')
        logger.info('test_001_openWebAuth passed')