예제 #1
0
	def __init__(self, driver):
		self.driver = driver
		self.log = log()
		self.cmf = commonFun(driver)
		self.frameElem = frameElement(driver)
		self.resource = Resource(driver)
		self.net = NetworkResource(driver)
예제 #2
0
 def __init__(self, driver):
     self.driver = driver
     self.dataFile = dataFileName()
     self.cmf = commonFun(self.driver)
     self.initDriver = initDriver()
     self.loginElem = loginPage(self.driver)
     self.roleElem = Role(self.driver)
     self.userElem = UserPage(self.driver)
     self.frameElem = frameElement(self.driver)
     self.authElem = AuthMethodPage(self.driver)
     self.dptment = Department(self.driver)
     self.resource = Resource(self.driver)
     self.account = Accountmgr(self.driver)
     self.windowsElem = WindowsResource(self.driver)
     self.databaseElem = DatabaseResource(self.driver)
     self.usergroup = Usergroup(self.driver)
     self.regroup = Regroup(self.driver)
     self.appElem = AppPage(self.driver)
     self.authorizationElem = AuthorizationPage(self.driver)
     self.testAutho = testAuthorization(self.driver)
     self.clientElem = ClientPage(self.driver)
     self.command = CommandRule(self.driver)
     self.ntp = NtpService(self.driver)
     self.mail = MailPage(self.driver)
     self.syslog = Syslog(driver)
     self.ssoElem = SsoPage(self.driver)
     self.alarm = AlarmPage(self.driver)
     self.PwdStr = PwdStrategy(self.driver)
     self.passwdenvelope = EnvelopePage(self.driver)
예제 #3
0
 def __init__(self, driver):
     self.driver = driver
     self.getElem = getElement(driver)
     self.selectElem = selectElement(driver)
     self.frameElem = frameElement(driver)
     self.resource = Resource(driver)
     self.cnEn = cnEncode()
예제 #4
0
 def __init__(self, driver):
     self.driver = driver
     self.log = log()
     self.cmf = commonFun(driver)
     self.frameElem = frameElement(driver)
     self.resource = Resource(driver)
     self.window = WindowsResource(driver)
 def __init__(self, driver):
     self.driver = driver
     self.log = log()
     self.cmf = commonFun(driver)
     self.frameElem = frameElement(driver)
     self.resource = Resource(driver)
     self.linux = LinuxResource(driver)
     self.data = dataFileName()
예제 #6
0
	def __init__(self, driver):
		self.driver = driver
		self.log = log()
		self.cmf = commonFun(driver)
		self.getElem = getElement(driver)
		self.frameElem = frameElement(driver)
		self.resource = Resource(driver)
		self.database = DatabaseResource(driver)
예제 #7
0
 def __init__(self, driver):
     self.driver = driver
     self.getElem = getElement(driver)
     self.selectElem = selectElement(driver)
     self.frameElem = frameElement(driver)
     self.log = log()
     self.resource = Resource(driver)
     self.account = Accountmgr(driver)
     self.cnEn = cnEncode()
예제 #8
0
 def __init__(self, driver):
     self.driver = driver
     self.log = log()
     self.PwdStr = PwdStrategy(self.driver)
     self.cmf = commonFun(driver)
     self.dataFile = dataFileName()
     self.frameElem = frameElement(self.driver)
     self.commonsuite = CommonSuiteData(driver)
     self.user = UserPage(self.driver)
     self.session = sessionConfig(self.driver)
     self.conuser = User(driver)
     self.resource = Resource(driver)
     self.account = Accountmgr(driver)
예제 #9
0
	def __init__(self, driver):
		self.driver = driver
		self.getElem = getElement(driver)
		self.selectElem = selectElement(driver)
		self.frameElem = frameElement(driver)
		self.resource = Resource(driver)
		self.cnEn = cnEncode()
예제 #10
0
	def __init__(self,driver):
		self.driver = driver
		self.log = log()
		self.cmf = commonFun(driver)
		self.getElem = getElement(driver)
		self.cnEnde = cnEncode()
		self.userElem = UserPage(driver)
		self.systemLog = SystemLogPage(self.driver)
		self.auditLog = AuditLogPage(self.driver)
		self.systemLog = SystemLogPage(self.driver)
		self.tableElem = tableElement(self.driver)
		self.selectElem = selectElement(driver)
		self.dataFile = dataFileName()
		self.frameElem = frameElement(self.driver)
		self.resource = Resource(driver)
		self.commonSuite = CommonSuiteData(self.driver)
예제 #11
0
	def __init__(self, driver):
		self.driver = driver
		self.log = log()
		self.cmf = commonFun(driver)
		self.frameElem = frameElement(driver)
		self.testrole = testRole(driver)
		self.resource = Resource(driver)
		self.net = NetworkResource(driver)
예제 #12
0
	def __init__(self, driver):
		self.driver = driver
		self.log = log()
		self.cmf = commonFun(driver)
		self.getElem = getElement(driver)
		self.frameElem = frameElement(driver)
		self.testrole = testRole(driver)
		self.resource = Resource(driver)
		self.database = DatabaseResource(driver)
예제 #13
0
	def __init__(self, driver):
		self.driver = driver
		self.getElem = getElement(driver)
		self.selectElem = selectElement(driver)
		self.frameElem = frameElement(driver)
		self.log = log()
		self.resource = Resource(driver)
		self.account = Accountmgr(driver)
		self.cnEn = cnEncode()
예제 #14
0
	def __init__(self, driver):
		self.driver = driver
		self.log = log()
		self.cmf = commonFun(driver)
		self.frameElem = frameElement(driver)
		self.testrole = testRole(driver)
		self.resource = Resource(driver)
		self.linux = LinuxResource(driver)
		self.role = Role(driver)
		self.data = dataFileName()
예제 #15
0
	def __init__(self,driver):
		self.driver = driver
		self.log = log()
		self.cmf = commonFun(driver)
		self.getElem = getElement(driver)
		self.cnEnde = cnEncode()
		self.userElem = UserPage(driver)
		self.systemLog = SystemLogPage(self.driver)
		self.auditLog = AuditLogPage(self.driver)
		self.systemLog = SystemLogPage(self.driver)
		self.tableElem = tableElement(self.driver)
		self.selectElem = selectElement(driver)
		self.dataFile = dataFileName()
		self.frameElem = frameElement(self.driver)
		self.resource = Resource(driver)
		self.commonSuite = CommonSuiteData(self.driver)
예제 #16
0
class testWindowsResource(object):

	def __init__(self, driver):
		self.driver = driver
		self.log = log()
		self.cmf = commonFun(driver)
		self.frameElem = frameElement(driver)
		self.testrole = testRole(driver)
		self.resource = Resource(driver)
		self.window = WindowsResource(driver)

	u'''获取测试数据
	   Parameters:
	      - sheetname:sheet名称
	   return:表格数据
	'''
	def get_windows_table_data(self, sheetname):
		dataFile = dataFileName()
		windowsPath = dataFile.get_windows_resource_test_data_url()
		windowsData = dataFile.get_data(windowsPath, sheetname)
		return windowsData

	u'''添加windows资源'''
	def add_windows_resource_001(self):

		#日志开始记录
		self.log.log_start("add_windows_resource")
		#获取添加windows资源测试数据
		windowsData = self.get_windows_table_data("add_windows_resource")
		#保存成功的弹出框
		windowsMsg = self.testrole.popup()

		#无检查点的测试项标识,如果为True说明通过
		flag = False

		for dataRow in range(len(windowsData)):
			data = windowsData[dataRow]
			try:
				#如果不是第一行标题,则读取数据
				if dataRow != 0:
					self.resource.click_add_edit_button()
					self.resource.select_resource_type(data[2])
					self.window.add_edit_windows_resource(data)
					self.frameElem.switch_to_content()
					self.cmf.test_win_check_point("xpath", windowsMsg, data, flag)
					self.cmf.back()
			except Exception as e:
				print ("add_windows_resource fail:" + str(e))

		self.log.log_end("add_windows_resource")

	u'''编辑windows资源'''
	def edit_windows_resource_002(self):

		#日志开始记录
		self.log.log_start("edit_windows_resource")
		#获取编辑windows资源测试数据
		windowsData = self.get_windows_table_data("edit_windows_resource")
		#保存成功的弹出框
		windowsMsg = self.testrole.popup()

		#无检查点的测试项标识,如果为True说明通过
		flag = False

		for dataRow in range(len(windowsData)):
			data = windowsData[dataRow]
			try:
				#如果不是第一行标题,则读取数据
				if dataRow != 0:
					self.resource.click_add_edit_button(data[2])
					self.window.add_edit_windows_resource(data)
					self.frameElem.switch_to_content()
					self.cmf.test_win_check_point("xpath", windowsMsg, data, flag)
					self.cmf.back()
			except Exception as e:
				print ("edit_windows_resource fail:" + str(e))

		self.log.log_end("edit_windows_resource")

	u'''检验windows资源'''
	def check_windows_resource_003(self):

		#日志开始记录
		self.log.log_start("check_windows_resource")
		#获取校验windows资源测试数据
		windowsData = self.get_windows_table_data("check_windows_resource")
		#保存成功的弹出框
		windowsMsg = self.testrole.popup()

		#无检查点的测试项标识,如果为True说明通过
		flag = False

		#点击添加按钮
		self.resource.click_add_edit_button()
		#选择windows类型
		self.resource.select_resource_type("Windows Server 2008")

		for dataRow in range(len(windowsData)):
			data = windowsData[dataRow]
			try:
				#如果不是第一行标题,则读取数据
				if dataRow != 0:
					self.window.check_windows_resource(dataRow, data)
					self.frameElem.switch_to_content()
					self.cmf.test_win_check_point("xpath", windowsMsg, data, flag)
			except Exception as e:
				print ("check_windows_resource fail:" + str(e))
		time.sleep(5)
		self.cmf.back()

		self.log.log_end("check_windows_resource")
예제 #17
0
class DatabaseResource(object):
    #数据库名称
    DATABASE_NAME = "fortDatabaseName"
    #服务名
    SERVICE_NAME = "fortDatabaseServerName"
    #全选应用发布
    SELECT_ALL_APP = "add_app_release"
    #应用发布添加到右侧
    ADD_APP = "add"
    #服务名
    SERVICE_NAME = "fortDatabaseServerName"
    #BS账号属性
    ACCOUNT_ATTRIBUTE = "fortBsAccountAttribute"
    #BS表单名称
    FORM_NAME = "fortBsFormName"
    #口令属性
    PWD_ATTRIBUTE = "fortBsPasswordAttribute"
    #表单提交方式
    SUBMIT_METHOD = "fortBsFormSubmitMethod"
    #登录URL
    LOGIN_URL = "fortBsLoginUrl"
    #连接端口
    CONNECT_PORT = "fortDatabasePort"
    #选择归属操作系统
    SELECT_SYSTEM = "system_data_select_system"
    #归属资源IP
    SYSTEM_IP = "fortResourceIp"
    #归属资源检索
    SYSTEM_QUERY = "quick_query"
    #全选按钮
    SYSTEM_CHECK_ALL = "resource_check_all"
    #确认按钮
    SYSTEM_OK_BUTTON = "okButton"
    #取消按钮
    SYSTEM_QUIT_BUTTON = "cancelButton"

    def __init__(self, driver):
        self.driver = driver
        self.getElem = getElement(driver)
        self.selectElem = selectElement(driver)
        self.frameElem = frameElement(driver)
        self.log = log()
        self.resource = Resource(driver)
        self.account = Accountmgr(driver)
        self.cnEn = cnEncode()

    u'''添加和编辑database资源
		Parameters:
			- data:excel中的一行数据
	'''

    def add_edit_database_resource(self, data):
        self.frameElem.from_frame_to_otherFrame("mainFrame")
        #资源名称
        self.resource.set_resource_name(data[3])
        #归属部门
        if data[4] != "":
            self.resource.set_depart(data[4])
        #资源ip
        if data[5] != "":
            self.resource.set_resource_ip(data[5])
        #库名
        if data[6] != "":
            self.set_database_name(data[6])
        #服务名
        if data[7] != "":
            self.set_service_name(data[7])
        #密码策略
        if data[8] != "":
            self.resource.select_pwd_strategy(data[8])
        #账号属性
        if data[9] != "":
            self.set_account_attribute(data[9])
            self.set_form_name(data[10])
            self.set_pwd_attribute(data[11])
            self.set_submit_method(data[12])
            self.set_login_url(data[13])
        #选择客户端
        if data[14] != "":
            self.select_protocol(data[14])
        #选择应用发布
        if data[15] != "":
            self.select_application(data[15])
        #依附操作系统IP
        if data[16] != "":
            self.click_select_button()
            self.set_system_ip(data[16])
            self.click_query_button()
            self.click_check_all_button()
            self.click_confirm_button()
        #管理员帐号
        if data[17] != "":
            self.resource.click_account_sync()
            self.resource.set_admin_account(data[17])
            #管理员口令
            self.resource.set_admin_pwd(data[18])
            #口令确认
            self.resource.set_confirm_pwd(data[19])
        time.sleep(1)
        self.resource.click_save_button()

    u'''填写资源名称'''

    def set_resource_name(self, resourceName):
        reName = self.cnEn.is_float(resourceName)
        self.frameElem.from_frame_to_otherFrame("mainFrame")
        name = self.getElem.find_element_with_wait_EC('id', 'fortResourceName')
        name.clear()
        name.send_keys(reName)

    u'''填写资源IP'''

    def set_resource_ip(self, resourceIp):
        reIp = self.cnEn.is_float(resourceIp)
        ip = self.getElem.find_element_with_wait_EC('id', 'fortResourceIp')
        ip.clear()
        ip.send_keys(reIp)
        self.getElem.find_element_wait_and_click_EC("id", "spanid")
        self.getElem.find_element_with_wait_EC("classname", "ip_succ")
        time.sleep(3)
        #self.driver.implicitly_wait(5)

    u'''填写database库名
		parameter:
			- databaseName:数据库库名
	'''

    def set_database_name(self, databaseName):
        try:
            reName = self.cnEn.is_float(databaseName)
            self.frameElem.from_frame_to_otherFrame("mainFrame")
            name = self.getElem.find_element_with_wait_EC(
                'id', self.DATABASE_NAME)
            name.clear()
            name.send_keys(reName)
        except Exception as e:
            print "DatabaseName is error :" + str(e)

    u'''填写database服务名
		parameter:
			- serviceName:数据库库名
	'''

    def set_service_name(self, serviceName):
        reName = self.cnEn.is_float(serviceName)
        try:
            self.frameElem.from_frame_to_otherFrame("mainFrame")
            serviceName = self.getElem.find_element_with_wait_EC(
                'id', self.SERVICE_NAME)
            serviceName.clear()
            serviceName.send_keys(reName)
        except Exception as e:
            print "ServiceName is error :" + str(e)

    u'''点击添加到应用发布到右侧'''

    def add_application(self):
        self.getElem.find_element_wait_and_click_EC('id', self.ADD_APP)

    u'''选择客户端'''

    def select_protocol(self, proName):
        reName = self.cnEn.is_float(proName)
        parent_xpath = "//table[@id='trees']/tbody/tr[7]/td[2]"
        parent_elem = self.getElem.find_element_with_wait_EC(
            'xpath', parent_xpath)
        elems = parent_elem.find_elements_by_tag_name("span")
        for index in range(len(elems)):
            if elems[index].text == reName:
                protocol_xpath = parent_xpath + "/" + "span[" + str(
                    index + 1) + "]/input[1]"
                protocol_elem = self.getElem.find_element_with_wait_EC(
                    'xpath', protocol_xpath)
                if not protocol_elem.is_selected():
                    protocol_elem.click()

    u'''选择应用发布
		parameter:
			- appStr:应用发布
	'''

    def select_application(self, appStr):
        reappStr = self.cnEn.is_float(appStr)
        appList = reappStr.split(',')
        appSelect = self.getElem.find_element_with_wait_EC(
            'id', self.SELECT_ALL_APP)
        try:
            if appStr != "":
                for appName in appList:
                    self.selectElem.select_element_by_visible_text(
                        appSelect, appName)
                    self.add_application()

        except Exception as e:
            print "Domian select error:" + str(e)

#---------------------------------BS属性--------------------------------------

    u'''填写BS账号属性
		parameter:
			- accountAtt:账号属性
	'''
    def set_account_attribute(self, accountAtt):
        reName = self.cnEn.is_float(accountAtt)
        try:
            accountArrbt = self.getElem.find_element_with_wait_EC(
                'id', self.ACCOUNT_ATTRIBUTE)
            accountArrbt.clear()
            accountArrbt.send_keys(reName)
        except Exception as e:
            print "Set BS Account Attribute is error :" + str(e)

    u'''填写BS表单名称
		parameter:
			- formName:表单名称
	'''

    def set_form_name(self, formName):
        reName = self.cnEn.is_float(formName)
        try:
            accountArrbt = self.getElem.find_element_with_wait_EC(
                'id', self.FORM_NAME)
            accountArrbt.clear()
            accountArrbt.send_keys(reName)
        except Exception as e:
            print "Set BS form name is error :" + str(e)

    u'''填写BS口令属性
		parameter:
			- pwdAtt:口令属性
	'''

    def set_pwd_attribute(self, pwdAtt):
        reATtt = self.cnEn.is_float(pwdAtt)
        try:
            pwdArrbt = self.getElem.find_element_with_wait_EC(
                'id', self.PWD_ATTRIBUTE)
            pwdArrbt.clear()
            pwdArrbt.send_keys(reATtt)
        except Exception as e:
            print "Set BS Pwd Attribute is error :" + str(e)

    u'''填写BS表单提交方式
		parameter:
			- submitMethod:提交方式
	'''

    def set_submit_method(self, submitMethod):
        reMethod = self.cnEn.is_float(submitMethod)
        try:
            smtMethod = self.getElem.find_element_with_wait_EC(
                'id', self.SUBMIT_METHOD)
            smtMethod.clear()
            smtMethod.send_keys(reMethod)
        except Exception as e:
            print "Set BS submit method error :" + str(e)

    u'''填写BS登录URL
		parameter:
			- loginUrl:登录url
	'''

    def set_login_url(self, loginUrl):
        reUrl = self.cnEn.is_float(loginUrl)
        try:
            url = self.getElem.find_element_with_wait_EC('id', self.LOGIN_URL)
            url.clear()
            url.send_keys(reUrl)
        except Exception as e:
            print "Set BS login url error :" + str(e)

#--------------------------------依附操作系统----------------------------------

    u'''点击选择'''
    def click_select_button(self):

        self.getElem.find_element_wait_and_click_EC('id', self.SELECT_SYSTEM)

    u'''检索的依附操作系统IP'''

    def set_system_ip(self, systemIp):
        self.frameElem.from_frame_to_otherFrame("artIframe")
        reIp = self.cnEn.is_float(systemIp)
        try:
            system_ip = self.getElem.find_element_with_wait_EC(
                'id', self.SYSTEM_IP)
            system_ip.clear()
            system_ip.send_keys(reIp)
        except Exception as e:
            print "Set system ip error :" + str(e)

    u'''点击检索按钮'''

    def click_query_button(self):
        self.getElem.find_element_wait_and_click_EC('id', self.SYSTEM_QUERY)

    u'''点击全选按钮'''

    def click_check_all_button(self):
        self.getElem.find_element_wait_and_click_EC('id',
                                                    self.SYSTEM_CHECK_ALL)

    u'''点击确认按钮'''

    def click_confirm_button(self):
        self.frameElem.switch_to_content()
        self.getElem.find_element_wait_and_click_EC('id',
                                                    self.SYSTEM_OK_BUTTON)

    u'''点击取消按钮'''

    def click_quit_button(self):
        self.frameElem.switch_to_content()
        self.getElem.find_element_wait_and_click_EC('id',
                                                    self.SYSTEM_QUIT_BUTTON)

    u'''判断是否是有ip可用性校验'''

    def is_pop_up(self):
        xpath = "html/body/div[1]/div/table/tbody/tr[2]/td[2]/div/table/tbody/tr[2]/td[2]/div"
        flag = self.getElem.find_element_wait_and_compare_text(
            "xpath", xpath, [0, "ip可用性校验失败!"])
        if flag:
            self.cmf.click_login_msg_button()
#--------------------------windows资源-----------------------------------------

    u'''填写windows域名
	   parameter:
	       - domainname:windows域名
	'''
    def set_domain_name(self, domainname):
        try:
            doname = self.cnEn.is_float(domainname)
            self.frameElem.from_frame_to_otherFrame("mainFrame")
            self.getElem.find_element_wait_and_clear_EC('id', "fortDomainName")
            self.getElem.find_element_wait_and_sendkeys(
                'id', "fortDomainName", doname)
        except Exception as e:
            print "domainname is error :" + str(e)

    u'''填写主机名称
	   parameter:
	       - hostname:主机名称
	'''

    def set_host_name(self, hostname):
        try:
            host = self.cnEn.is_float(hostname)
            self.frameElem.from_frame_to_otherFrame("mainFrame")
            self.getElem.find_element_wait_and_clear_EC(
                'id', "window_host_name")
            self.getElem.find_element_wait_and_sendkeys(
                'id', "window_host_name", host)
        except Exception as e:
            print "window_host_name is error :" + str(e)
예제 #18
0
class NetworkResource(object):
    def __init__(self, driver):
        self.driver = driver
        self.getElem = getElement(driver)
        self.selectElem = selectElement(driver)
        self.frameElem = frameElement(driver)
        self.resource = Resource(driver)
        self.cnEn = cnEncode()

    u'''添加和编辑网络设备资源
	   Parameters:
	      - data:excel中的一行数据
	'''

    def add_edit_network_resource(self, data):
        self.frameElem.from_frame_to_otherFrame("mainFrame")
        #资源名称
        if data[3] != 'no':
            self.resource.set_resource_name(data[3])
        #资源ip
        if data[5] != 'no':
            self.resource.set_resource_ip(data[5])
        #从IP
        if data[6] != 'no':
            self.resource.set_resource_fortIps(data[6])
        #归属部门
        if data[4] != 'no':
            self.resource.set_depart(data[4])

        self.resource.select_all_agreement()
        #系统版本
        if data[7] != 'no':
            self.resource.set_sys_version(data[7])
        #改密驱动名称
        if data[8] != 'no':
            self.resource.set_changePwd_driver(data[8])

        #管理员帐号
        if data[9] != 'no':
            self.resource.click_account_sync()
            self.resource.set_admin_account(data[9])
        #管理员口令
        if data[10] != 'no':
            self.resource.set_admin_pwd(data[10])
        #口令确认
        if data[11] != 'no':
            self.resource.set_confirm_pwd(data[11])
        #提权
        if data[12] != 'no':
            self.resource.click_up_super()
            #提权账号口令
            self.resource.set_super_pwd(data[12])
            #确认口令
            self.resource.set_super_confirm_pwd(data[13])
        if data[5] != 'no':
            self.resource.resoure_save_button()
        else:
            self.resource.click_save_button()

    u'''校验网络设备资源
	   Parameters:
	      - datarow:excel数据位于第几行
	      - data:excel中的一行数据
	'''

    def check_network_resource(self, datarow, data):
        self.frameElem.from_frame_to_otherFrame("mainFrame")
        #资源名称
        self.resource.set_resource_name(data[2])
        #资源ip
        self.resource.set_resource_ip(data[3])
        #协议类型
        if data[4] != 'no':
            self.resource.select_agreement(data[4])
        #协议类型 端口
        if datarow == 7:
            self.resource.set_port(data[4], data[5])
        if datarow == 8:
            self.resource.clear_port("Ssh2")
        if datarow == 9:
            self.resource.set_port("Ssh2", data[5])
        if datarow == 12:
            self.resource.click_account_sync()
            self.resource.click_up_super()
        if datarow == 13:
            #提权账号口令
            if data[6] != 'no':
                self.resource.set_super_pwd(data[6])
            #确认口令
            if data[7] != 'no':
                self.resource.set_super_confirm_pwd(data[7])
            self.resource.set_super_prompt()
        self.resource.resoure_save_button()

    u'''选择telnet登录模式
	   Parameters:
	      - mode:value属性
	'''

    def telnet_login_type(self, mode):
        model = self.cnEn.is_float(mode)
        self.frameElem.from_frame_to_otherFrame("mainFrame")
        selectelem = self.getElem.find_element_with_wait_EC(
            "id", "fortInputModelTelnet")
        self.selectElem.select_element_by_value(selectelem, model)

    u'''勾选匿名认证'''

    def check_anonymous(self):
        self.frameElem.from_frame_to_otherFrame("mainFrame")
        self.getElem.find_element_wait_and_click_EC("id", "anonymous_auth")
예제 #19
0
class DatabaseResource(object):
	#数据库名称
	DATABASE_NAME = "fortDatabaseName"
	#服务名
	SERVICE_NAME = "fortDatabaseServerName"
	#全选应用发布
	SELECT_ALL_APP = "add_app_release"
	#应用发布添加到右侧
	ADD_APP = "add"
	#服务名
	SERVICE_NAME = "fortDatabaseServerName"
	#BS账号属性
	ACCOUNT_ATTRIBUTE = "fortBsAccountAttribute"
	#BS表单名称
	FORM_NAME = "fortBsFormName"
	#口令属性
	PWD_ATTRIBUTE = "fortBsPasswordAttribute"
	#表单提交方式
	SUBMIT_METHOD = "fortBsFormSubmitMethod"
	#登录URL
	LOGIN_URL = "fortBsLoginUrl"
	#连接端口
	CONNECT_PORT = "fortDatabasePort"
	#选择归属操作系统
	SELECT_SYSTEM = "system_data_select_system"
	#归属资源IP
	SYSTEM_IP = "fortResourceIp"
	#归属资源检索
	SYSTEM_QUERY = "quick_query"
	#全选按钮
	SYSTEM_CHECK_ALL= "resource_check_all"
	#确认按钮
	SYSTEM_OK_BUTTON = "okButton"
	#取消按钮
	SYSTEM_QUIT_BUTTON = "cancelButton"
	

	def __init__(self, driver):
		self.driver = driver
		self.getElem = getElement(driver)
		self.selectElem = selectElement(driver)
		self.frameElem = frameElement(driver)
		self.log = log()
		self.resource = Resource(driver)
		self.account = Accountmgr(driver)
		self.cnEn = cnEncode()

	u'''添加和编辑database资源
		Parameters:
			- data:excel中的一行数据
	'''
	def add_edit_database_resource(self, data):
		self.frameElem.from_frame_to_otherFrame("mainFrame")
		#资源名称
		self.resource.set_resource_name(data[3])
		#归属部门
		if data[4] != "":
			self.resource.set_depart(data[4])
		#资源ip
		if data[5] != "":
			self.resource.set_resource_ip(data[5])			
		#库名
		if data[6] != "":
			self.set_database_name(data[6])
		#服务名
		if data[7] != "":
			self.set_service_name(data[7])
		#密码策略
		if data[8] != "":
			self.resource.select_pwd_strategy(data[8])
		#账号属性
		if data[9] != "":
			self.set_account_attribute(data[9])
			self.set_form_name(data[10])
			self.set_pwd_attribute(data[11])
			self.set_submit_method(data[12])
			self.set_login_url(data[13])
		#选择客户端
		if data[14] != "":
			self.select_protocol(data[14])
		#选择应用发布
		if data[15] != "":
			self.select_application(data[15])
		#依附操作系统IP
		if data[16] != "":
			self.click_select_button()
			self.set_system_ip(data[16])
			self.click_query_button()
			self.click_check_all_button()
			self.click_confirm_button()
		#管理员帐号
		if data[17] != "":
			self.resource.click_account_sync()
			self.resource.set_admin_account(data[17])
			#管理员口令
			self.resource.set_admin_pwd(data[18])
			#口令确认
			self.resource.set_confirm_pwd(data[19])
		time.sleep(1)
		self.resource.click_save_button()

	u'''填写资源名称'''
	def set_resource_name(self,resourceName):
		reName = self.cnEn.is_float(resourceName)
		self.frameElem.from_frame_to_otherFrame("mainFrame")
		name = self.getElem.find_element_with_wait_EC('id','fortResourceName')
		name.clear()
		name.send_keys(reName)
	
	u'''填写资源IP'''
	def set_resource_ip(self,resourceIp):
		reIp = self.cnEn.is_float(resourceIp)
		ip = self.getElem.find_element_with_wait_EC('id','fortResourceIp')
		ip.clear()
		ip.send_keys(reIp)
		self.getElem.find_element_wait_and_click_EC("id", "spanid")
		self.getElem.find_element_with_wait_EC("classname", "ip_succ")
		time.sleep(3)
		#self.driver.implicitly_wait(5)
		
	u'''填写database库名
		parameter:
			- databaseName:数据库库名
	'''
	def set_database_name(self, databaseName):
		try:
			reName = self.cnEn.is_float(databaseName)
			self.frameElem.from_frame_to_otherFrame("mainFrame")
			name = self.getElem.find_element_with_wait_EC('id', self.DATABASE_NAME)
			name.clear()
			name.send_keys(reName)
		except Exception as e:
			print "DatabaseName is error :" + str(e)
	
	u'''填写database服务名
		parameter:
			- serviceName:数据库库名
	'''
	def set_service_name(self, serviceName):
		reName = self.cnEn.is_float(serviceName)
		try:
			self.frameElem.from_frame_to_otherFrame("mainFrame")
			serviceName = self.getElem.find_element_with_wait_EC('id', self.SERVICE_NAME)
			serviceName.clear()
			serviceName.send_keys(reName)
		except Exception as e:
			print "ServiceName is error :" + str(e)
	
	
	u'''点击添加到应用发布到右侧'''
	def add_application(self):
		self.getElem.find_element_wait_and_click_EC('id',self.ADD_APP)
	
	u'''选择客户端'''
	def select_protocol(self,proName):
		reName = self.cnEn.is_float(proName)
		parent_xpath = "//table[@id='trees']/tbody/tr[7]/td[2]"
		parent_elem = self.getElem.find_element_with_wait_EC('xpath',parent_xpath)
		elems = parent_elem.find_elements_by_tag_name("span")
		for index in range(len(elems)):
			if elems[index].text == reName:
				protocol_xpath = parent_xpath + "/" + "span[" + str(index+1) + "]/input[1]"
				protocol_elem = self.getElem.find_element_with_wait_EC('xpath',protocol_xpath)
				if not protocol_elem.is_selected():
					protocol_elem.click()

	u'''选择应用发布
		parameter:
			- appStr:应用发布
	'''
	def select_application(self, appStr):
		reappStr = self.cnEn.is_float(appStr)
		appList = reappStr.split(',')
		appSelect = self.getElem.find_element_with_wait_EC('id',self.SELECT_ALL_APP)
		try:
			if appStr != "":
				for appName in appList:
					self.selectElem.select_element_by_visible_text(appSelect, appName)
					self.add_application()

		except Exception as e:
			print "Domian select error:" + str(e)

#---------------------------------BS属性--------------------------------------
	
	u'''填写BS账号属性
		parameter:
			- accountAtt:账号属性
	'''
	def set_account_attribute(self, accountAtt):
		reName = self.cnEn.is_float(accountAtt)
		try:
			accountArrbt = self.getElem.find_element_with_wait_EC('id', self.ACCOUNT_ATTRIBUTE)
			accountArrbt.clear()
			accountArrbt.send_keys(reName)
		except Exception as e:
			print "Set BS Account Attribute is error :" + str(e)
	
	u'''填写BS表单名称
		parameter:
			- formName:表单名称
	'''
	def set_form_name(self, formName):
		reName = self.cnEn.is_float(formName)
		try:
			accountArrbt = self.getElem.find_element_with_wait_EC('id', self.FORM_NAME)
			accountArrbt.clear()
			accountArrbt.send_keys(reName)
		except Exception as e:
			print "Set BS form name is error :" + str(e)
	
	u'''填写BS口令属性
		parameter:
			- pwdAtt:口令属性
	'''
	def set_pwd_attribute(self, pwdAtt):
		reATtt = self.cnEn.is_float(pwdAtt)
		try:
			pwdArrbt = self.getElem.find_element_with_wait_EC('id', self.PWD_ATTRIBUTE)
			pwdArrbt.clear()
			pwdArrbt.send_keys(reATtt)
		except Exception as e:
			print "Set BS Pwd Attribute is error :" + str(e)
	
	u'''填写BS表单提交方式
		parameter:
			- submitMethod:提交方式
	'''
	def set_submit_method(self, submitMethod):
		reMethod = self.cnEn.is_float(submitMethod)
		try:
			smtMethod = self.getElem.find_element_with_wait_EC('id', self.SUBMIT_METHOD)
			smtMethod.clear()
			smtMethod.send_keys(reMethod)
		except Exception as e:
			print "Set BS submit method error :" + str(e)
	
	u'''填写BS登录URL
		parameter:
			- loginUrl:登录url
	'''
	def set_login_url(self, loginUrl):
		reUrl = self.cnEn.is_float(loginUrl)
		try:
			url = self.getElem.find_element_with_wait_EC('id', self.LOGIN_URL)
			url.clear()
			url.send_keys(reUrl)
		except Exception as e:
			print "Set BS login url error :" + str(e)

#--------------------------------依附操作系统----------------------------------
	
	u'''点击选择'''
	def click_select_button(self):
		
		self.getElem.find_element_wait_and_click_EC('id',self.SELECT_SYSTEM)
	
	u'''检索的依附操作系统IP'''
	def set_system_ip(self,systemIp):
		self.frameElem.from_frame_to_otherFrame("artIframe")
		reIp = self.cnEn.is_float(systemIp)
		try:
			system_ip = self.getElem.find_element_with_wait_EC('id', self.SYSTEM_IP)
			system_ip.clear()
			system_ip.send_keys(reIp)
		except Exception as e:
			print "Set system ip error :" + str(e)
	
	u'''点击检索按钮'''
	def click_query_button(self):
		self.getElem.find_element_wait_and_click_EC('id',self.SYSTEM_QUERY)
	
	u'''点击全选按钮'''
	def click_check_all_button(self):
		self.getElem.find_element_wait_and_click_EC('id',self.SYSTEM_CHECK_ALL)
	
	u'''点击确认按钮'''
	def click_confirm_button(self):
		self.frameElem.switch_to_content()
		self.getElem.find_element_wait_and_click_EC('id',self.SYSTEM_OK_BUTTON)
	
	u'''点击取消按钮'''
	def click_quit_button(self):
		self.frameElem.switch_to_content()
		self.getElem.find_element_wait_and_click_EC('id',self.SYSTEM_QUIT_BUTTON)
	
	u'''判断是否是有ip可用性校验'''
	def is_pop_up(self):
		xpath = "html/body/div[1]/div/table/tbody/tr[2]/td[2]/div/table/tbody/tr[2]/td[2]/div"
		flag = self.getElem.find_element_wait_and_compare_text("xpath", xpath, [0, "ip可用性校验失败!"])
		if flag:
			self.cmf.click_login_msg_button()
#--------------------------windows资源-----------------------------------------
	u'''填写windows域名
	   parameter:
	       - domainname:windows域名
	'''
	def set_domain_name(self, domainname):
		try:
			doname = self.cnEn.is_float(domainname)
			self.frameElem.from_frame_to_otherFrame("mainFrame")
			self.getElem.find_element_wait_and_clear_EC('id', "fortDomainName")
			self.getElem.find_element_wait_and_sendkeys('id', "fortDomainName", doname)
		except Exception as e:
			print "domainname is error :" + str(e)
	
	u'''填写主机名称
	   parameter:
	       - hostname:主机名称
	'''
	def set_host_name(self, hostname):
		try:
			host = self.cnEn.is_float(hostname)
			self.frameElem.from_frame_to_otherFrame("mainFrame")
			self.getElem.find_element_wait_and_clear_EC('id', "window_host_name")
			self.getElem.find_element_wait_and_sendkeys('id', "window_host_name", host)
		except Exception as e:
			print "window_host_name is error :" + str(e)
예제 #20
0
class PasswordStr():
    def __init__(self, driver):
        self.driver = driver
        self.log = log()
        self.PwdStr = PwdStrategy(self.driver)
        self.cmf = commonFun(driver)
        self.getElem = getElement(driver)
        self.cnEnde = cnEncode()
        self.dataFile = dataFileName()
        self.frameElem = frameElement(self.driver)
        self.commonsuite = CommonSuiteData(driver)
        self.user = UserPage(self.driver)
        self.session = sessionConfig(self.driver)
        self.conStr = conversationStrategy(driver)
        self.conuser = User(driver)
        self.resource = Resource(driver)
        self.account = Accountmgr(driver)

    u'''提示框元素路径'''

    def save_msg(self):
        save_msg = "html/body/div[1]/div/table/tbody/tr[2]/td[2]/div/table/tbody/tr[2]/td[2]/div"
        return save_msg

    u'''获取测试数据
        Parameters:
            sheetname:sheet名称
            return:表格数据
    '''

    def get_table_data(self, sheetname):
        dataFile = dataFileName()
        filePath = dataFile.get_password_stratrgy_test_data_url()
        authFileData = dataFile.get_data(filePath, sheetname)
        return authFileData

    u'''切换至会话配置模块'''

    def switch_to_session_module(self):
        self.frameElem.switch_to_content()
        self.frameElem.switch_to_top()
        self.cmf.select_menu(u"策略配置")
        self.cmf.select_menu(u"策略配置", u"会话配置")

    u'''切换至资源模块'''

    def switch_to_resource_module(self):
        self.frameElem.switch_to_content()
        self.frameElem.switch_to_top()
        self.cmf.select_menu(u"运维管理")
        self.cmf.select_menu(u"运维管理", u"资源")

    u'''切换至密码策略'''

    def switch_to_pwdStr_module(self):
        self.frameElem.switch_to_content()
        self.frameElem.switch_to_top()
        self.cmf.select_menu(u"策略配置")
        self.cmf.select_menu(u"策略配置", u"密码策略")

    #添加策略
    def add_strategy_001(self):
        #日志开始记录
        self.log.log_start("pwdStrategy")
        #获取数据
        strategy_data = self.get_table_data("add_strategy")
        #保存弹框
        saveMsg = self.save_msg()
        #无检查点的测试项标识,如果为True说明通过
        flag = False
        for dataRow in range(len(strategy_data)):
            data = strategy_data[dataRow]
            try:
                #如果不是第一行标题,则读取数据
                if dataRow != 0:
                    self.frameElem.from_frame_to_otherFrame("mainFrame")
                    self.PwdStr.add_pwd_button()
                    self.PwdStr.set_pwd_name(data[2])
                    self.PwdStr.term_of_validity(data[3])
                    self.PwdStr.password_length_min(data[4])
                    self.PwdStr.password_length_max(data[5])
                    self.PwdStr.set_lower_case(data[6])
                    self.PwdStr.set_capital(data[7])
                    self.PwdStr.set_minimum_digital(data[8])
                    self.PwdStr.set_Minimum_symbol(data[9])
                    self.PwdStr.set_prohibition_of_using_keywords(data[10])
                    self.PwdStr.add_using_keywords_button()
                    self.PwdStr.save_button()
                    self.frameElem.switch_to_content()
                    self.cmf.test_win_check_point("xpath", saveMsg, data, flag)
                    self.PwdStr.return_button()
            except Exception as e:
                print("Policy adding error: ") + str(e)
        self.log.log_end("pwdStrategy")

    #编辑策略test
    def edit_strategy_002(self):
        #日志开始记录
        self.log.log_start("editPwdStrategy")
        #获取数据
        strategy_data = self.get_table_data("edit_strategy")
        #保存弹框
        saveMsg = self.save_msg()
        #无检查点的测试项标识,如果为True说明通过
        flag = False
        for dataRow in range(len(strategy_data)):
            data = strategy_data[dataRow]
            try:
                #如果不是第一行标题,则读取数据
                if dataRow != 0:
                    self.frameElem.from_frame_to_otherFrame("mainFrame")
                    self.PwdStr.edit(data[2])
                    self.PwdStr.set_pwd_name(data[3])
                    self.PwdStr.term_of_validity(data[4])
                    self.PwdStr.password_length_min(data[5])
                    self.PwdStr.password_length_max(data[6])
                    self.PwdStr.set_lower_case(data[7])
                    self.PwdStr.set_capital(data[8])
                    self.PwdStr.set_minimum_digital(data[9])
                    self.PwdStr.set_Minimum_symbol(data[10])
                    self.PwdStr.set_prohibition_of_using_keywords(data[11])
                    self.PwdStr.add_using_keywords_button()
                    self.PwdStr.save_button()
                    self.frameElem.switch_to_content()
                    self.cmf.test_win_check_point("xpath", saveMsg, data, flag)
                    self.PwdStr.return_button()
            except Exception as e:
                print("Policy edit error: ") + str(e)
        self.log.log_end("editPwdStrategy")

    #策略校验
    def check_strategy_003(self):
        #日志开始记录
        self.log.log_start("checkPwdStrategy")
        #获取数据
        strategy_data = self.get_table_data("check_strategy")
        #保存弹框
        saveMsg = self.save_msg()
        #无检查点的测试项标识,如果为True说明通过
        flag = False
        for dataRow in range(len(strategy_data)):
            data = strategy_data[dataRow]
            try:
                #如果不是第一行标题,则读取数据
                if dataRow != 0:
                    self.frameElem.from_frame_to_otherFrame("mainFrame")
                    self.PwdStr.add_pwd_button()
                    self.PwdStr.set_pwd_name(data[2])
                    self.PwdStr.term_of_validity(data[3])
                    self.PwdStr.password_length_min(data[4])
                    self.PwdStr.password_length_max(data[5])
                    self.PwdStr.set_lower_case(data[6])
                    self.PwdStr.set_capital(data[7])
                    self.PwdStr.set_minimum_digital(data[8])
                    self.PwdStr.set_Minimum_symbol(data[9])
                    self.PwdStr.set_prohibition_of_using_keywords(data[10])
                    self.PwdStr.add_using_keywords_button()
                    self.PwdStr.save_button()
                    self.frameElem.switch_to_content()
                    self.cmf.test_win_check_point("xpath", saveMsg, data, flag)
                    self.PwdStr.return_button()
            except Exception as e:
                print("Policy checkout error: ") + str(e)
        self.log.log_end("checkeditPwdStrategy")

    #检索名称test
    def search_strategy_004(self):
        #日志开始记录
        self.log.log_start("searchPwdStrategy")
        #获取数据
        strategy_data = self.get_table_data("search_strategy")
        #无检查点的测试项标识,如果为True说明通过
        flag = False
        for dataRow in range(len(strategy_data)):
            data = strategy_data[dataRow]
            try:
                #如果不是第一行标题,则读取数据
                if dataRow != 0:
                    self.PwdStr.search_name(data[2])
                    self.PwdStr.click_search_button()
                    self.PwdStr.click_reset_button()
                    self.PwdStr.click_search_button()
                    #清空标识状态
                    flag = False
                    self.log.log_detail(data[0], True)
            except Exception as e:
                print("Policy search error: ") + str(e)
        self.log.log_end("searchPwdStrategy")

    #删除单个策略
    def del_sing_policy_005(self):
        #日志开始记录
        self.log.log_start("delPwdStrategy")
        #获取数据
        strategy_data = self.get_table_data("del_strategy")
        #保存弹框
        saveMsg = self.save_msg()
        #无检查点的测试项标识,如果为True说明通过
        flag = False
        for dataRow in range(len(strategy_data)):
            data = strategy_data[dataRow]
            try:
                #如果不是第一行标题,则读取数据
                if dataRow != 0:
                    self.frameElem.from_frame_to_otherFrame("mainFrame")
                    self.PwdStr.del_sing_strategy(data[2])
                    self.frameElem.switch_to_content()
                    self.cmf.click_msg_button(1)
                    self.cmf.test_win_check_point("xpath", saveMsg, data, flag)
                    #校验删除后的名称是否存在
                    if self.cmf.is_namevalue_exsit(data[2],
                                                   "fortStrategyPasswordName"):
                        print("Delete success")
            except Exception as e:
                print("Policy del error: ") + str(e)
        self.log.log_end("delPwdStrategy")

    #与密码策略关联的会话配置
    def session_association_007(self):
        #日志开始记录
        self.log.log_start("sessionAssociation")
        #获取数据
        strate_data = self.get_table_data("configure_strateg")
        #保存弹框
        saveMsg = self.save_msg()
        #无检查点的测试项标识,如果为True说明通过
        flag = False
        for dataRow in range(len(strate_data)):
            data = strate_data[dataRow]
            try:
                #如果不是第一行标题,则读取数据
                if dataRow != 0:
                    self.switch_to_session_module()
                    self.frameElem.from_frame_to_otherFrame("mainFrame")
                    self.PwdStr.set_pwd_strategy(data[4])
                    self.session.add_session(data[2])
                    self.session.add_locking_time(data[3])
                    self.session.save_global_button()
                    self.frameElem.switch_to_content()
                    self.cmf.test_win_check_point("xpath", saveMsg, data, flag)
            except Exception as e:
                print("session association error: ") + str(e)
        self.log.log_end("sessionAssociation")

    #与密码策略关联的用户
    def user_association_008(self):
        #日志开始记录
        self.log.log_start("userAssociation")
        #获取数据
        strate_data = self.get_table_data("user_association")
        #保存弹框
        saveMsg = self.save_msg()
        #无检查点的测试项标识,如果为True说明通过
        flag = False
        for dataRow in range(len(strate_data)):
            data = strate_data[dataRow]
            try:
                #如果不是第一行标题,则读取数据
                if dataRow != 0:
                    self.conuser.switch_to_user_module()
                    self.frameElem.from_frame_to_otherFrame("mainFrame")
                    self.PwdStr.user_edit(data[2])
                    self.PwdStr.set_pwd(data[9])
                    self.PwdStr.set_pwd_agin(data[10])
                    self.user.save_button()
                    self.frameElem.switch_to_content()
                    self.cmf.test_win_check_point("xpath", saveMsg, data, flag)
                    self.user.click_back_button()
            except Exception as e:
                print("user association error: ") + str(e)
        self.log.log_end("userAssociation")

    #为Windows资源添加密码策略
    def resource_association_009(self):
        #日志开始记录
        self.log.log_start("resourAcessociation")
        #获取数据
        strate_data = self.get_table_data("resource_association")
        #保存弹框
        saveMsg = self.save_msg()
        #无检查点的测试项标识,如果为True说明通过
        flag = False
        for dataRow in range(len(strate_data)):
            data = strate_data[dataRow]
            try:
                #如果不是第一行标题,则读取数据
                if dataRow != 0:
                    self.commonsuite.sys_switch_to_dep()
                    self.switch_to_resource_module()
                    self.frameElem.from_frame_to_otherFrame("mainFrame")
                    self.PwdStr.resource_edit(data[2])
                    self.PwdStr.set_resource_strategy(data[8])
                    self.resource.click_save_button()
                    self.frameElem.switch_to_content()
                    self.cmf.test_win_check_point("xpath", saveMsg, data, flag)
                    self.PwdStr.return_button()
            except Exception as e:
                print("resour acessociation error: ") + str(e)
        self.log.log_end("resourAcessociation")

    #为Windows资源账号添加密码策略
    def resource_account_association_010(self):
        #日志开始记录
        self.log.log_start("resourAceccountAssociation")
        #获取数据
        strate_data = self.get_table_data("resource_account_association")
        #保存弹框
        saveMsg = self.save_msg()
        #无检查点的测试项标识,如果为True说明通过
        flag = False
        for dataRow in range(len(strate_data)):
            data = strate_data[dataRow]
            try:
                #如果不是第一行标题,则读取数据
                if dataRow != 0:
                    self.PwdStr.account_manage(data[2])
                    self.account.click_account_add()
                    self.PwdStr.set_resource_account_name(data[3])
                    self.PwdStr.set_resource_account_pwd(data[4])
                    self.PwdStr.set_resource_account_pwdagin(data[5])
                    self.PwdStr.save_account()
                    self.frameElem.switch_to_content()
                    self.cmf.test_win_check_point("xpath", saveMsg, data, flag)
                    #点击资源账号编辑页面返回
                    self.PwdStr.return_button()
                    #点击资源账号页面返回
                    self.PwdStr.return_button()
            except Exception as e:
                print("resour aceccount association error: ") + str(e)
        self.log.log_end("resourAceccountAssociation")

    #删除全部策略
    def del_all_policy_006(self):
        #日志开始记录
        self.log.log_start("delAllPwdStrategy")
        #获取数据
        strategy_data = self.get_table_data("del_all_strategy")
        #保存弹框
        saveMsg = self.save_msg()
        #无检查点的测试项标识,如果为True说明通过
        flag = False
        for dataRow in range(len(strategy_data)):
            data = strategy_data[dataRow]
            try:
                #如果不是第一行标题,则读取数据
                if dataRow != 0:
                    self.commonsuite.dep_switch_to_sys()
                    self.switch_to_pwdStr_module()
                    self.frameElem.from_frame_to_otherFrame("mainFrame")
                    self.PwdStr.select_all_button()
                    self.PwdStr.del_button()
                    self.frameElem.switch_to_content()
                    self.cmf.click_msg_button(1)
                    self.cmf.test_win_check_point("xpath", saveMsg, data, flag)
                    #校验删除后的名称是否存在
                    if self.cmf.is_namevalue_exsit(data[2],
                                                   "fortStrategyPasswordName"):
                        print("Delete all success")
            except Exception as e:
                print("Policy delAll error: ") + str(e)
        self.log.log_end("delAllPwdStrategy")


#if __name__ == "__main__":
#    browser = setDriver().set_local_driver()
#    commonSuite = CommonSuiteData(browser)
#    pwdCase = PasswordStr(browser)
#    commonSuite.pwdstr_module_prefix_condition()
#    pwdCase.add_strategy_001()
#    pwdCase.edit_strategy_002()
#    pwdCase.check_strategy_003()
#    pwdCase.search_strategy_004()
#    pwdCase.del_sing_policy_005()
#    pwdCase.session_association_007()
#    pwdCase.user_association_008()
#    pwdCase.resource_association_009()
#    pwdCase.resource_account_association_010()
#    pwdCase.del_all_policy_006()
#    commonSuite.pwdstr_module_post_condition()
예제 #21
0
class testLinuxResource(object):
    def __init__(self, driver):
        self.driver = driver
        self.log = log()
        self.cmf = commonFun(driver)
        self.frameElem = frameElement(driver)
        self.testrole = testRole(driver)
        self.resource = Resource(driver)
        self.linux = LinuxResource(driver)
        self.role = Role(driver)
        self.data = dataFileName()

    u'''获取测试数据
	   Parameters:
	      - sheetname:sheet名称
	   return:表格数据
	'''

    def get_resource_table_data(self, sheetname):
        dataFile = dataFileName()
        resourcePath = dataFile.get_linux_resource_test_data_url()
        resourceData = dataFile.get_data(resourcePath, sheetname)
        return resourceData

    u'''添加linux资源'''

    def add_linux_resource_001(self):

        #日志开始记录
        self.log.log_start("add_resource")
        #获取添加资源测试数据
        resourceData = self.get_resource_table_data("add_linux_resource")
        #保存成功的弹出框
        resourceMsg = self.testrole.popup()

        #无检查点的测试项标识,如果为True说明通过
        flag = False

        for dataRow in range(len(resourceData)):
            data = resourceData[dataRow]
            try:
                #如果不是第一行标题,则读取数据
                if dataRow != 0:
                    self.resource.click_add_edit_button()
                    self.resource.select_resource_type(data[2])
                    self.linux.add_edit_linux_resource(data)
                    self.frameElem.switch_to_content()
                    self.cmf.test_win_check_point("xpath", resourceMsg, data,
                                                  flag)
                    self.cmf.back()
            except Exception as e:
                print("add_resource fail:" + str(e))

        self.log.log_end("add_resource")

    u'''编辑linux资源'''

    def edit_linux_resource_002(self):

        #日志开始记录
        self.log.log_start("edit_resource")
        #获取添加资源测试数据
        resourceData = self.get_resource_table_data("edit_linux_resource")
        #保存成功的弹出框
        resourceMsg = self.testrole.popup()

        #无检查点的测试项标识,如果为True说明通过
        flag = False

        for dataRow in range(len(resourceData)):
            data = resourceData[dataRow]
            try:
                #如果不是第一行标题,则读取数据
                if dataRow != 0:
                    self.resource.click_add_edit_button(data[2])
                    self.linux.add_edit_linux_resource(data)
                    self.frameElem.switch_to_content()
                    self.cmf.test_win_check_point("xpath", resourceMsg, data,
                                                  flag)
                    self.cmf.back()
            except Exception as e:
                print("edit_resource fail:" + str(e))

        self.log.log_end("edit_resource")

    u'''检验linux资源'''

    def check_linux_resource_003(self):

        #日志开始记录
        self.log.log_start("check_linux_resource")
        #获取检验资源测试数据
        resourceData = self.get_resource_table_data("check_linux_resource")
        #保存成功的弹出框
        resourceMsg = self.testrole.popup()

        #无检查点的测试项标识,如果为True说明通过
        flag = False

        #点击添加按钮
        self.resource.click_add_edit_button()
        #选择debian类型
        self.resource.select_resource_type("Debian")

        for dataRow in range(len(resourceData)):
            data = resourceData[dataRow]
            try:
                #如果不是第一行标题,则读取数据
                if dataRow != 0:
                    self.linux.check_linux_resource(dataRow, data)
                    self.frameElem.switch_to_content()
                    self.cmf.test_win_check_point("xpath", resourceMsg, data,
                                                  flag)
            except Exception as e:
                print("check_linux_resource fail:" + str(e))

        self.cmf.back()

        self.log.log_end("check_linux_resource")

    u'''查询资源'''

    def query_resource_004(self, dataPath, sheetName):

        #日志开始记录
        self.log.log_start("query_resource")
        #获取添加资源测试数据
        resourceData = self.data.get_data(dataPath, sheetName)

        for dataRow in range(len(resourceData)):
            data = resourceData[dataRow]
            try:
                #如果不是第一行标题,则读取数据
                if dataRow != 0:
                    if dataRow == 1:
                        self.resource.query_depart(data[1])
                    if dataRow == 2:
                        self.resource.click_child_node()
                        self.resource.query_depart(data[1])
                    if dataRow == 3:
                        self.resource.query_type(data[2], data[3], data[4])
                    if dataRow >= 4 and dataRow <= 7:
                        self.resource.query_ip_rename(data[5])
                    if dataRow == 8:
                        self.resource.query_type(data[2], data[3], data[4])
                        self.resource.query_ip_rename(data[5])
                    self.resource.click_resource_query()
                    self.role.click_reset()
                    self.log.log_detail(data[0], True)
            except Exception as e:
                print("query_resource fail:" + str(e))
        self.resource.click_resource_query()
        self.log.log_end("query_resource")

    u'''删除资源'''

    def del_resource_005(self, dataPath, sheetName):

        #日志开始记录
        self.log.log_start("del_resource")
        #获取添加资源测试数据
        resourceData = self.data.get_data(dataPath, sheetName)
        #保存成功的弹出框
        resourceMsg = self.testrole.popup()

        #无检查点的测试项标识,如果为True说明通过
        flag = False

        for dataRow in range(len(resourceData)):
            data = resourceData[dataRow]
            try:
                #如果不是第一行标题,则读取数据
                if dataRow != 0:
                    self.resource.click_del_button(data[2])
                    self.frameElem.switch_to_content()
                    self.cmf.test_win_check_point("xpath", resourceMsg, data,
                                                  flag)
                    self.cmf.click_msg_button(1)
            except Exception as e:
                print("del_resource fail:" + str(e))

        self.log.log_end("del_resource")

    u'''全选删除资源'''

    def bulkdel_resource_006(self):

        #日志开始记录
        self.log.log_start("bulkdel_resource")
        #获取添加资源测试数据
        resourceData = self.get_resource_table_data("bulkdel_resource")
        #保存成功的弹出框
        resourceMsg = self.testrole.popup()

        #无检查点的测试项标识,如果为True说明通过
        flag = False

        for dataRow in range(len(resourceData)):
            data = resourceData[dataRow]
            try:
                #如果不是第一行标题,则读取数据
                if dataRow != 0:
                    self.cmf.check_all()
                    self.cmf.bulkdel("delete_resource")
                    self.frameElem.switch_to_content()
                    self.cmf.test_win_check_point("xpath", resourceMsg, data,
                                                  flag)
                    self.cmf.click_msg_button(1)
            except Exception as e:
                print("bulkdel_resource failure:" + str(e))

        self.log.log_end("bulkdel_resource")
예제 #22
0
class testNetworkResource(object):
    def __init__(self, driver):
        self.driver = driver
        self.log = log()
        self.cmf = commonFun(driver)
        self.frameElem = frameElement(driver)
        self.testrole = testRole(driver)
        self.resource = Resource(driver)
        self.net = NetworkResource(driver)

    u'''获取测试数据
	   Parameters:
	      - sheetname:sheet名称
	   return:表格数据
	'''

    def get_network_table_data(self, sheetname):
        dataFile = dataFileName()
        networkPath = dataFile.get_network_resource_test_data_url()
        networkData = dataFile.get_data(networkPath, sheetname)
        return networkData

    u'''添加网络设备资源'''

    def add_network_resource_001(self):

        #日志开始记录
        self.log.log_start("add_network_resource")
        #获取添加网络设备资源测试数据
        networkData = self.get_network_table_data("add_network_resource")
        #保存成功的弹出框
        networkMsg = self.testrole.popup()

        #无检查点的测试项标识,如果为True说明通过
        flag = False

        for dataRow in range(len(networkData)):
            data = networkData[dataRow]
            try:
                #如果不是第一行标题,则读取数据
                if dataRow != 0:
                    self.resource.click_add_edit_button()
                    self.resource.select_resource_type(data[2])
                    self.net.add_edit_network_resource(data)
                    self.frameElem.switch_to_content()
                    self.cmf.test_win_check_point("xpath", networkMsg, data,
                                                  flag)
                    self.cmf.back()
            except Exception as e:
                print("add_network_resource fail:" + str(e))

        self.log.log_end("add_network_resource")

    u'''编辑网络设备资源'''

    def edit_network_resource_002(self):

        #日志开始记录
        self.log.log_start("edit_network_resource")
        #获取编辑网络设备资源测试数据
        networkData = self.get_network_table_data("edit_network_resource")
        #保存成功的弹出框
        networkMsg = self.testrole.popup()

        #无检查点的测试项标识,如果为True说明通过
        flag = False

        for dataRow in range(len(networkData)):
            data = networkData[dataRow]
            try:
                #如果不是第一行标题,则读取数据
                if dataRow != 0:
                    self.resource.click_add_edit_button(data[2])
                    self.net.add_edit_network_resource(data)
                    self.frameElem.switch_to_content()
                    self.cmf.test_win_check_point("xpath", networkMsg, data,
                                                  flag)
                    self.cmf.back()
            except Exception as e:
                print("edit_network_resource fail:" + str(e))

        self.log.log_end("edit_network_resource")

    u'''检验网络设备资源'''

    def check_network_resource_003(self):

        #日志开始记录
        self.log.log_start("check_network_resource")
        #获取校验网络设备资源测试数据
        networkData = self.get_network_table_data("check_network_resource")
        #保存成功的弹出框
        networkMsg = self.testrole.popup()

        #无检查点的测试项标识,如果为True说明通过
        flag = False

        #点击添加按钮
        self.resource.click_add_edit_button()
        #选择debian类型
        self.resource.select_resource_type("迈普")

        for dataRow in range(len(networkData)):
            data = networkData[dataRow]
            try:
                #如果不是第一行标题,则读取数据
                if dataRow != 0:
                    self.net.check_network_resource(dataRow, data)
                    self.frameElem.switch_to_content()
                    self.cmf.test_win_check_point("xpath", networkMsg, data,
                                                  flag)
            except Exception as e:
                print("check_network_resource fail:" + str(e))

        self.cmf.back()

        self.log.log_end("check_network_resource")
예제 #23
0
class WindowsResource(object):
    def __init__(self, driver):
        self.driver = driver
        self.getElem = getElement(driver)
        self.selectElem = selectElement(driver)
        self.frameElem = frameElement(driver)
        self.resource = Resource(driver)
        self.cnEn = cnEncode()

    u'''添加和编辑windows资源
	   Parameters:
	      - data:excel中的一行数据
	'''

    def add_edit_windows_resource(self, data):
        self.frameElem.from_frame_to_otherFrame("mainFrame")
        #资源名称
        if data[3] != 'no':
            self.resource.set_resource_name(data[3])
        #资源ip
        if data[5] != 'no':
            self.resource.set_resource_ip(data[5])
        #从IP
        if data[6] != 'no':
            self.resource.set_resource_fortIps(data[6])
        #归属部门
        if data[4] != 'no':
            self.resource.set_depart(data[4])
        #密码策略
        if data[7] != 'no':
            self.resource.select_pwd_strategy(data[7])
        #选择所要运维协议
        self.resource.select_all_agreement()
        #windows域名
        if data[8] != 'no':
            self.set_domain_name(data[8])
        #账号分类
        if data[9] != 'no':
            self.resource.click_account_sync()
            self.select_account_type(data[9])
        #归属域控主机
        if data[10] != 'no':
            self.select_attach_domian(data[10])
        #主机名称
        if data[11] != 'no':
            self.set_host_name(data[11])
        #管理员帐号
        if data[12] != 'no':
            if data[9] == 'no':
                self.resource.click_account_sync()
            self.resource.set_admin_account(data[12])
        #管理员帐号
        if data[16] != 'no':
            self.resource.click_account_sync()
            self.select_account_protocol(data[16])
            self.set_port(data[17])
            if data[16] == "Ldap":
                self.set_ldap_account(data[18])
            else:
                self.set_ssh_account(data[18])
        #管理员口令
        if data[13] != 'no':
            self.resource.set_admin_pwd(data[13])
        #口令确认
        if data[14] != 'no':
            self.resource.set_confirm_pwd(data[14])
        #BaseDN
        if data[15] != 'no':
            self.set_base_dn(data[15])
        self.resource.click_save_button()

    u'''校验windows资源
	   Parameters:
	      - datarow:excel数据位于第几行
	      - data:excel中的一行数据
	'''

    def check_windows_resource(self, datarow, data):
        self.frameElem.from_frame_to_otherFrame("mainFrame")
        #资源名称
        self.resource.set_resource_name(data[2])
        #资源ip
        self.resource.set_resource_ip(data[3])
        #协议类型
        if data[4] != 'no':
            self.resource.select_agreement(data[4])
        #协议类型 端口
        if datarow == 7:
            self.resource.set_port(data[4], data[5])
        if datarow == 8:
            self.resource.clear_port("Vnc")
        if datarow == 9:
            self.resource.set_port("Vnc", data[5])
        if datarow == 12:
            self.resource.click_account_sync()
            self.select_account_type(data[6])
        if datarow == 13:
            self.select_attach_domian(data[7])
        self.resource.click_save_button()

    u'''填写windows域名
	   parameter:
	       - domainname:windows域名
	'''

    def set_domain_name(self, domainname):
        try:
            doname = self.cnEn.is_float(domainname)
            self.frameElem.from_frame_to_otherFrame("mainFrame")
            self.getElem.find_element_wait_and_clear('id', "fortDomainName")
            self.getElem.find_element_wait_and_sendkeys(
                'id', "fortDomainName", doname)
        except Exception as e:
            print "domainname is error :" + str(e)

    u'''选择账号分类
	   Parameters:
	      - value:value属性
	'''

    def select_account_type(self, value):
        type = self.cnEn.is_float(value)
        self.frameElem.from_frame_to_otherFrame("mainFrame")
        selectelem = self.getElem.find_element_with_wait_EC(
            "id", "selectDisplay")
        self.selectElem.select_element_by_value(selectelem, type)

    u'''选择归属域控主机
	   parameter:
	       - text:归属域控主机的名称
	'''

    def select_attach_domian(self, text):
        try:
            domiantext = self.cnEn.is_float(text)
            self.frameElem.from_frame_to_otherFrame("mainFrame")
            selectelem = self.getElem.find_element_with_wait_EC(
                'id', "window_select_dc")
            self.selectElem.select_element_by_visible_text(
                selectelem, domiantext)
        except Exception as e:
            print "Domian select error:" + str(e)

    u'''填写主机名称
	   parameter:
	       - hostname:主机名称
	'''

    def set_host_name(self, hostname):
        try:
            host = self.cnEn.is_float(hostname)
            self.frameElem.from_frame_to_otherFrame("mainFrame")
            self.getElem.find_element_wait_and_clear('id', "window_host_name")
            self.getElem.find_element_wait_and_sendkeys(
                'id', "window_host_name", host)
        except Exception as e:
            print "window_host_name is error :" + str(e)

    u'''填写Base DN
	   parameter:
	       - basedn:Base DN名称
	'''

    def set_base_dn(self, basedn):
        try:
            base = self.cnEn.is_float(basedn)
            self.frameElem.from_frame_to_otherFrame("mainFrame")
            self.getElem.find_element_wait_and_clear('id', "fortBaseDn")
            self.getElem.find_element_wait_and_sendkeys(
                'id', "fortBaseDn", base)
        except Exception as e:
            print "fortBaseDn is error :" + str(e)

    u'''填写连接端口
	   parameter:
	       - portname:连接端口名称
	'''

    def set_port(self, portname):
        try:
            port = self.cnEn.is_float(portname)
            self.frameElem.from_frame_to_otherFrame("mainFrame")
            self.getElem.find_element_wait_and_clear('id',
                                                     "fortConnectionPort")
            self.getElem.find_element_wait_and_sendkeys(
                'id', "fortConnectionPort", port)
        except Exception as e:
            print "port is error :" + str(e)

    u'''填写ldap账号
	   parameter:
	       - actname:管理员账号
	'''

    def set_ldap_account(self, actname):
        try:
            act = self.cnEn.is_float(actname)
            self.frameElem.from_frame_to_otherFrame("mainFrame")
            self.getElem.find_element_wait_and_clear('id',
                                                     "fortAdminAccount_ldap")
            self.getElem.find_element_wait_and_sendkeys(
                'id', "fortAdminAccount_ldap", act)
        except Exception as e:
            print "name is error :" + str(e)

    u'''填写ssh账号
	   parameter:
	       - actname:管理员账号
	'''

    def set_ssh_account(self, actname):
        try:
            act = self.cnEn.is_float(actname)
            self.frameElem.from_frame_to_otherFrame("mainFrame")
            self.getElem.find_element_wait_and_clear('id',
                                                     "fortAdminAccount_ssh")
            self.getElem.find_element_wait_and_sendkeys(
                'id', "fortAdminAccount_ssh", act)
        except Exception as e:
            print "name is error :" + str(e)

    u'''选择账号同步连接协议
	   parameter:
	       - proname:同步
	'''

    def select_account_protocol(self, proname):
        try:
            pro = self.cnEn.is_float(proname)
            self.frameElem.from_frame_to_otherFrame("mainFrame")
            selem = self.getElem.find_element_with_wait_EC(
                'id', "fortConnectionProtocol")
            self.selectElem.select_element_by_visible_text(selem, pro)
        except Exception as e:
            print " protocol is error :" + str(e)

    u'''是否勾选获取所有账号'''

    def check_all_account(self):
        try:
            self.frameElem.from_frame_to_otherFrame("mainFrame")
            self.getElem.find_element_wait_and_click_EC(
                'id', "get_all_accounts")
        except Exception as e:
            print " Check failure :" + str(e)
예제 #24
0
class WindowsResource(object):

	def __init__(self, driver):
		self.driver = driver
		self.getElem = getElement(driver)
		self.selectElem = selectElement(driver)
		self.frameElem = frameElement(driver)
		self.resource = Resource(driver)
		self.cnEn = cnEncode()

	u'''添加和编辑windows资源
	   Parameters:
	      - data:excel中的一行数据
	'''
	def add_edit_windows_resource(self, data):
		self.frameElem.from_frame_to_otherFrame("mainFrame")
		#资源名称
		if data[3] != 'no':
			self.resource.set_resource_name(data[3])
		#资源ip
		if data[5] != 'no':
			self.resource.set_resource_ip(data[5])
		#从IP
		if data[6] != 'no':
			self.resource.set_resource_fortIps(data[6])
		#归属部门
		if data[4] != 'no':
			self.resource.set_depart(data[4])
		#密码策略
		if data[7] != 'no':
			self.resource.select_pwd_strategy(data[7])
		#选择所要运维协议
		self.resource.select_all_agreement()
		#windows域名
		if data[8] != 'no':
			self.set_domain_name(data[8])
		#账号分类
		if data[9] != 'no':
			self.resource.click_account_sync()
			self.select_account_type(data[9])
		#归属域控主机
		if data[10] != 'no':
			self.select_attach_domian(data[10])
		#主机名称
		if data[11] != 'no':
			self.set_host_name(data[11])
		#管理员帐号
		if data[12] != 'no':
			if data[9] == 'no':
				self.resource.click_account_sync()
			self.resource.set_admin_account(data[12])
		#管理员帐号
		if data[16] != 'no':
			self.resource.click_account_sync()
			self.select_account_protocol(data[16])
			self.set_port(data[17])
			if data[16] == "Ldap":
				self.set_ldap_account(data[18])
			else:
				self.set_ssh_account(data[18])
		#管理员口令
		if data[13] != 'no':
			self.resource.set_admin_pwd(data[13])
		#口令确认
		if data[14] != 'no':
			self.resource.set_confirm_pwd(data[14])
		#BaseDN
		if data[15] != 'no':
			self.set_base_dn(data[15])
		self.resource.click_save_button()

	u'''校验windows资源
	   Parameters:
	      - datarow:excel数据位于第几行
	      - data:excel中的一行数据
	'''
	def check_windows_resource(self, datarow, data):
		self.frameElem.from_frame_to_otherFrame("mainFrame")
		#资源名称
		self.resource.set_resource_name(data[2])
		#资源ip
		self.resource.set_resource_ip(data[3])
		#协议类型
		if data[4] != 'no':
			self.resource.select_agreement(data[4])
		#协议类型 端口
		if datarow == 7:
			self.resource.set_port(data[4], data[5])
		if datarow == 8:
			self.resource.clear_port("Vnc")
		if datarow == 9:
			self.resource.set_port("Vnc", data[5])
		if datarow == 12:
			self.resource.click_account_sync()
			self.select_account_type(data[6])
		if datarow == 13:
			self.select_attach_domian(data[7])
		self.resource.click_save_button()

	u'''填写windows域名
	   parameter:
	       - domainname:windows域名
	'''
	def set_domain_name(self, domainname):
		try:
			doname = self.cnEn.is_float(domainname)
			self.frameElem.from_frame_to_otherFrame("mainFrame")
			self.getElem.find_element_wait_and_clear('id', "fortDomainName")
			self.getElem.find_element_wait_and_sendkeys('id', "fortDomainName", doname)
		except Exception as e:
			print "domainname is error :" + str(e)

	u'''选择账号分类
	   Parameters:
	      - value:value属性
	'''
	def select_account_type(self, value):
		type = self.cnEn.is_float(value)
		self.frameElem.from_frame_to_otherFrame("mainFrame")
		selectelem = self.getElem.find_element_with_wait_EC("id", "selectDisplay")
		self.selectElem.select_element_by_value(selectelem, type)

	u'''选择归属域控主机
	   parameter:
	       - text:归属域控主机的名称
	'''
	def select_attach_domian(self, text):
		try:
			domiantext = self.cnEn.is_float(text)
			self.frameElem.from_frame_to_otherFrame("mainFrame")
			selectelem = self.getElem.find_element_with_wait_EC('id', "window_select_dc")
			self.selectElem.select_element_by_visible_text(selectelem, domiantext)
		except Exception as e:
			print "Domian select error:" + str(e)

	u'''填写主机名称
	   parameter:
	       - hostname:主机名称
	'''
	def set_host_name(self, hostname):
		try:
			host = self.cnEn.is_float(hostname)
			self.frameElem.from_frame_to_otherFrame("mainFrame")
			self.getElem.find_element_wait_and_clear('id', "window_host_name")
			self.getElem.find_element_wait_and_sendkeys('id', "window_host_name", host)
		except Exception as e:
			print "window_host_name is error :" + str(e)

	u'''填写Base DN
	   parameter:
	       - basedn:Base DN名称
	'''
	def set_base_dn(self, basedn):
		try:
			base = self.cnEn.is_float(basedn)
			self.frameElem.from_frame_to_otherFrame("mainFrame")
			self.getElem.find_element_wait_and_clear('id', "fortBaseDn")
			self.getElem.find_element_wait_and_sendkeys('id', "fortBaseDn", base)
		except Exception as e:
			print "fortBaseDn is error :" + str(e)

	u'''填写连接端口
	   parameter:
	       - portname:连接端口名称
	'''
	def set_port(self, portname):
		try:
			port = self.cnEn.is_float(portname)
			self.frameElem.from_frame_to_otherFrame("mainFrame")
			self.getElem.find_element_wait_and_clear('id', "fortConnectionPort")
			self.getElem.find_element_wait_and_sendkeys('id', "fortConnectionPort", port)
		except Exception as e:
			print "port is error :" + str(e)

	u'''填写ldap账号
	   parameter:
	       - actname:管理员账号
	'''
	def set_ldap_account(self, actname):
		try:
			act = self.cnEn.is_float(actname)
			self.frameElem.from_frame_to_otherFrame("mainFrame")
			self.getElem.find_element_wait_and_clear('id', "fortAdminAccount_ldap")
			self.getElem.find_element_wait_and_sendkeys('id', "fortAdminAccount_ldap", act)
		except Exception as e:
			print "name is error :" + str(e)

	u'''填写ssh账号
	   parameter:
	       - actname:管理员账号
	'''
	def set_ssh_account(self, actname):
		try:
			act = self.cnEn.is_float(actname)
			self.frameElem.from_frame_to_otherFrame("mainFrame")
			self.getElem.find_element_wait_and_clear('id', "fortAdminAccount_ssh")
			self.getElem.find_element_wait_and_sendkeys('id', "fortAdminAccount_ssh", act)
		except Exception as e:
			print "name is error :" + str(e)

	u'''选择账号同步连接协议
	   parameter:
	       - proname:同步
	'''
	def select_account_protocol(self, proname):
		try:
			pro = self.cnEn.is_float(proname)
			self.frameElem.from_frame_to_otherFrame("mainFrame")
			selem = self.getElem.find_element_with_wait_EC('id', "fortConnectionProtocol")
			self.selectElem.select_element_by_visible_text(selem, pro)
		except Exception as e:
			print " protocol is error :" + str(e)

	u'''是否勾选获取所有账号'''
	def check_all_account(self):
		try:
			self.frameElem.from_frame_to_otherFrame("mainFrame")
			self.getElem.find_element_wait_and_click_EC('id', "get_all_accounts")
		except Exception as e:
			print " Check failure :" + str(e)
예제 #25
0
class testDatabaseResource(object):

	def __init__(self, driver):
		self.driver = driver
		self.log = log()
		self.cmf = commonFun(driver)
		self.getElem = getElement(driver)
		self.frameElem = frameElement(driver)
		self.testrole = testRole(driver)
		self.resource = Resource(driver)
		self.database = DatabaseResource(driver)

	u'''获取测试数据
	   Parameters:
	      - sheetname:sheet名称
	   return:表格数据
	'''
	def get_database_table_data(self, sheetname):
		dataFile = dataFileName()
		databasePath = dataFile.get_database_test_url()
		databaseData = dataFile.get_data(databasePath, sheetname)
		return databaseData

	u'''添加database资源'''
	def add_database_resource_001(self):

		#日志开始记录
		self.log.log_start("add_database_resource")
		#获取添加windows资源测试数据
		databaseData = self.get_database_table_data("add_database_resource")
		#保存成功的弹出框
		windowsMsg = self.testrole.popup()

		#无检查点的测试项标识,如果为True说明通过
		flag = False

		for dataRow in range(len(databaseData)):
			data = databaseData[dataRow]
			try:
				#如果不是第一行标题,则读取数据
				if dataRow != 0:
					self.resource.click_add_edit_button()
					self.resource.select_resource_type(data[2])
					self.database.add_edit_database_resource(data)
					self.frameElem.switch_to_content()
					self.cmf.test_win_check_point("xpath", windowsMsg, data, flag)
					time.sleep(2)
					self.cmf.back()
			except Exception as e:
				print ("add_database_resource fail:" + str(e))

		self.log.log_end("add_database_resource")

	u'''编辑database资源'''
	def edit_database_resource_002(self):

		#日志开始记录
		self.log.log_start("edit_database_resource")
		#获取编辑windows资源测试数据
		databaseData = self.get_database_table_data("edit_database_resource")
		#保存成功的弹出框
		windowsMsg = self.testrole.popup()

		#无检查点的测试项标识,如果为True说明通过
		flag = False

		for dataRow in range(len(databaseData)):
			data = databaseData[dataRow]
			try:
				#如果不是第一行标题,则读取数据
				if dataRow != 0:
					self.frameElem.from_frame_to_otherFrame("mainFrame")
					self.resource.click_add_edit_button(data[2])
					self.database.add_edit_database_resource(data)
					self.frameElem.switch_to_content()
					self.cmf.test_win_check_point("xpath", windowsMsg, data, flag)
#					time.sleep(1)
					self.cmf.back()
			except Exception as e:
				print ("edit_database_resource fail:" + str(e))

		self.log.log_end("edit_database_resource")
	
	'''数据库校验'''
	def check_database_resource_003(self):
		#日志开始记录
		self.log.log_start("check_database_resource")
		#获取编辑windows资源测试数据
		databaseData = self.get_database_table_data("check_database_resource")
		#保存成功的弹出框
		windowsMsg = self.testrole.popup()
		
		#无检查点的测试项标识,如果为True说明通过
		flag = False
		#点击添加按钮
		self.resource.click_add_edit_button()
		#选择windows类型
		self.resource.select_resource_type("Oracle10g")	
		
		for dataRow in range(len(databaseData)):
			data = databaseData[dataRow]
			try:
				#如果不是第一行标题,则读取数据
				if dataRow != 0:
					#资源名称
					self.database.set_resource_name(data[2])				
					self.database.set_resource_ip(data[3])
					self.database.set_database_name(data[4])
					self.database.set_service_name(data[5])
					if data[6] != "":
						self.database.select_protocol(data[6])
					if data[7] !="":
						self.database.select_application(data[7])
					
					self.resource.click_save_button()
					self.frameElem.switch_to_content()
					self.cmf.test_win_check_point("xpath", windowsMsg, data, flag)
					
			except Exception as e:
				print ("check_database_resource fail:" + str(e))
		self.cmf.back()
		self.database.is_pop_up()			
		self.log.log_end("check_database_resource")
예제 #26
0
class testDatabaseResource(object):
    def __init__(self, driver):
        self.driver = driver
        self.log = log()
        self.cmf = commonFun(driver)
        self.getElem = getElement(driver)
        self.frameElem = frameElement(driver)
        self.testrole = testRole(driver)
        self.resource = Resource(driver)
        self.database = DatabaseResource(driver)

    u'''获取测试数据
	   Parameters:
	      - sheetname:sheet名称
	   return:表格数据
	'''

    def get_database_table_data(self, sheetname):
        dataFile = dataFileName()
        databasePath = dataFile.get_database_test_url()
        databaseData = dataFile.get_data(databasePath, sheetname)
        return databaseData

    u'''添加database资源'''

    def add_database_resource_001(self):

        #日志开始记录
        self.log.log_start("add_database_resource")
        #获取添加windows资源测试数据
        databaseData = self.get_database_table_data("add_database_resource")
        #保存成功的弹出框
        windowsMsg = self.testrole.popup()

        #无检查点的测试项标识,如果为True说明通过
        flag = False

        for dataRow in range(len(databaseData)):
            data = databaseData[dataRow]
            try:
                #如果不是第一行标题,则读取数据
                if dataRow != 0:
                    self.resource.click_add_edit_button()
                    self.resource.select_resource_type(data[2])
                    self.database.add_edit_database_resource(data)
                    self.frameElem.switch_to_content()
                    self.cmf.test_win_check_point("xpath", windowsMsg, data,
                                                  flag)
                    time.sleep(2)
                    self.cmf.back()
            except Exception as e:
                print("add_database_resource fail:" + str(e))

        self.log.log_end("add_database_resource")

    u'''编辑database资源'''

    def edit_database_resource_002(self):

        #日志开始记录
        self.log.log_start("edit_database_resource")
        #获取编辑windows资源测试数据
        databaseData = self.get_database_table_data("edit_database_resource")
        #保存成功的弹出框
        windowsMsg = self.testrole.popup()

        #无检查点的测试项标识,如果为True说明通过
        flag = False

        for dataRow in range(len(databaseData)):
            data = databaseData[dataRow]
            try:
                #如果不是第一行标题,则读取数据
                if dataRow != 0:
                    self.frameElem.from_frame_to_otherFrame("mainFrame")
                    self.resource.click_add_edit_button(data[2])
                    self.database.add_edit_database_resource(data)
                    self.frameElem.switch_to_content()
                    self.cmf.test_win_check_point("xpath", windowsMsg, data,
                                                  flag)
                    #					time.sleep(1)
                    self.cmf.back()
            except Exception as e:
                print("edit_database_resource fail:" + str(e))

        self.log.log_end("edit_database_resource")

    '''数据库校验'''

    def check_database_resource_003(self):
        #日志开始记录
        self.log.log_start("check_database_resource")
        #获取编辑windows资源测试数据
        databaseData = self.get_database_table_data("check_database_resource")
        #保存成功的弹出框
        windowsMsg = self.testrole.popup()

        #无检查点的测试项标识,如果为True说明通过
        flag = False
        #点击添加按钮
        self.resource.click_add_edit_button()
        #选择windows类型
        self.resource.select_resource_type("Oracle10g")

        for dataRow in range(len(databaseData)):
            data = databaseData[dataRow]
            try:
                #如果不是第一行标题,则读取数据
                if dataRow != 0:
                    #资源名称
                    self.database.set_resource_name(data[2])
                    self.database.set_resource_ip(data[3])
                    self.database.set_database_name(data[4])
                    self.database.set_service_name(data[5])
                    if data[6] != "":
                        self.database.select_protocol(data[6])
                    if data[7] != "":
                        self.database.select_application(data[7])

                    self.resource.click_save_button()
                    self.frameElem.switch_to_content()
                    self.cmf.test_win_check_point("xpath", windowsMsg, data,
                                                  flag)

            except Exception as e:
                print("check_database_resource fail:" + str(e))
        self.cmf.back()
        self.database.is_pop_up()
        self.log.log_end("check_database_resource")
예제 #27
0
class Flowcontrol(object):
    def __init__(self, driver):
        self.driver = driver
        self.getElem = getElement(driver)
        self.selectElem = selectElement(driver)
        self.frameElem = frameElement(driver)
        self.cmf = commonFun(driver)
        self.cnEn = cnEncode()
        self.resource = Resource(driver)

    u'''查询审批状态
	   Parameters:
	      - status:审批状态文本
	'''

    def query_approval_status(self, status):
        self.frameElem.from_frame_to_otherFrame("mainFrame")
        statu = self.cnEn.is_float(status)
        selem = self.getElem.find_element_with_wait_EC("id",
                                                       "fortApprovalStatus")
        self.selectElem.select_element_by_visible_text(selem, statu)

    u'''查询申请类型
	   Parameters:
	      - type:申请类型value值-1代表请选择,0代表双人授权,1代表访问审批,2代表命令审批,3代表审计下载审批
	'''

    def query_application_type(self, type):
        self.frameElem.from_frame_to_otherFrame("mainFrame")
        value = self.cnEn.is_float(type)
        selem = self.getElem.find_element_with_wait_EC("id", "fortApplyType")
        self.selectElem.select_element_by_value(selem, value)

    u'''查询申请人
	   Parameters:
	      - aplname:申请人名称
	'''

    def query_applicant(self, aplname):
        self.frameElem.from_frame_to_otherFrame("mainFrame")
        name = self.cnEn.is_float(aplname)
        self.getElem.find_element_wait_and_clear("id", "fortApplicantName")
        self.getElem.find_element_wait_and_sendkeys("id", "fortApplicantName",
                                                    name)

    u'''查询审批人
	   Parameters:
	      - approver:审批人名称
	'''

    def query_approver(self, approver):
        self.frameElem.from_frame_to_otherFrame("mainFrame")
        name = self.cnEn.is_float(approver)
        self.getElem.find_element_wait_and_clear("id", "fortApproverName")
        self.getElem.find_element_wait_and_sendkeys("id", "fortApproverName",
                                                    name)

    u'''查询目标IP
	   Parameters:
	      - targetip:目标IP
	'''

    def query_targetip(self, targetip):
        self.frameElem.from_frame_to_otherFrame("mainFrame")
        target = self.cnEn.is_float(targetip)
        self.getElem.find_element_wait_and_clear("id", "fortResourceIp")
        self.getElem.find_element_wait_and_sendkeys("id", "fortResourceIp",
                                                    target)

    u'''查询流程号
	   Parameters:
	      - number:流程号
	'''

    def query_process_number(self, number):
        self.frameElem.from_frame_to_otherFrame("mainFrame")
        processid = self.cnEn.is_float(number)
        self.getElem.find_element_wait_and_clear("id", "fortProcessApprovalId")
        self.getElem.find_element_wait_and_sendkeys("id",
                                                    "fortProcessApprovalId",
                                                    processid)

    u'''查询部门
	   Parameters:
	      - deptname:部门名称
	'''

    def query_process_depart(self, deptname):
        self.frameElem.from_frame_to_otherFrame("mainFrame")
        depart = self.cnEn.is_float(deptname)
        time.sleep(4)
        self.resource.select_depart_common("department_name", "tree_1_switch",
                                           depart)

    u'''查询审批时间
	   Parameters:
	      - year:年的value值
	      - month:月的value值
	      - day:日的value值
	'''

    def query_time(self, year, month='no', day='no'):
        self.frameElem.from_frame_to_otherFrame("mainFrame")
        y = self.cnEn.is_float(year)
        yselem = self.getElem.find_element_with_wait_EC("id", "fortLogYear")
        self.selectElem.select_element_by_value(yselem, y)
        if month != 'no':
            m = self.cnEn.is_float(month)
            if int(m) < 10:
                m = '0' + str(m)

            dselem = self.getElem.find_element_with_wait_EC(
                "id", "fortLogMonth")
            self.selectElem.select_element_by_value(dselem, m)
        if day != 'no':
            d = self.cnEn.is_float(day)
            selem = self.getElem.find_element_with_wait_EC("id", "fortLogDay")
            self.selectElem.select_element_by_value(selem, d)

    u'''点击高级'''

    def click_advanced(self):
        self.frameElem.from_frame_to_otherFrame("mainFrame")
        self.getElem.find_element_wait_and_click_EC("id", "btn_qh")

    u'''点击检索'''

    def click_process_search(self):
        self.frameElem.from_frame_to_otherFrame("mainFrame")
        self.getElem.find_element_wait_and_click_EC("id", "quick_check")

    u'''点击重置'''

    def click_process_reset(self):
        self.frameElem.from_frame_to_otherFrame("mainFrame")
        self.getElem.find_element_wait_and_click_EC("id", "resetting")

    u'''流程任务查询
	   Parameters:
	      - data:excel一行数据集
	'''

    def query_process_task(self, data):
        self.driver.implicitly_wait(5)
        self.cmf.select_menu(u"流程控制", u"流程任务")
        self.click_advanced()
        if data[2] != 'no':
            self.query_approval_status(data[2])
        if data[3] != 'no':
            self.query_applicant(data[3])
        if data[4] != 'no':
            self.query_process_depart(data[4])
        if data[5] != 'no':
            self.query_process_number(data[5])
        if data[6] != 'no':
            self.query_application_type(data[6])
        if data[7] != 'no':
            self.query_targetip(data[7])
        if data[8] != 'no':
            self.query_time(data[8], data[9], data[10])
        self.click_process_search()
        self.click_process_reset()

    u'''申请历史查询
	   Parameters:
	      - data:excel一行数据集
	'''

    def query_apply_history(self, data):
        self.driver.implicitly_wait(5)
        self.cmf.select_menu(u"流程控制", u"申请历史")
        self.click_advanced()
        if data[1] != 'no':
            self.query_approval_status(data[1])
        if data[2] != 'no':
            self.query_approver(data[2])
        if data[3] != 'no':
            self.query_targetip(data[3])
        if data[4] != 'no':
            self.query_process_number(data[4])
        if data[5] != 'no':
            self.query_application_type(data[5])
        if data[6] != 'no':
            self.query_time(data[6], data[7], data[8])
        self.click_process_search()
        self.click_process_reset()

    u'''个人历史查询
	   Parameters:
	      - data:excel一行数据集
	'''

    def query_personal_history(self, data):
        self.driver.implicitly_wait(5)
        self.cmf.select_menu(u"流程控制", u"个人历史")
        self.query_common(data)

    u'''全部历史查询
	   Parameters:
	      - data:excel一行数据集
	'''

    def query_all_history(self, data):
        self.driver.implicitly_wait(5)
        self.cmf.select_menu(u"流程控制", u"全部历史")
        self.query_common(data)

    u'''部门历史查询
	   Parameters:
	      - data:excel一行数据集
	'''

    def query_department_history(self, data):
        self.driver.implicitly_wait(5)
        self.cmf.select_menu(u"流程控制", u"部门历史")
        self.query_common(data)

    u'''查询公共方法
	   Parameters:
	      - data:excel一行数据集
	'''

    def query_common(self, data):
        self.click_advanced()
        if data[2] != 'no':
            self.query_approval_status(data[2])
        if data[3] != 'no':
            self.query_applicant(data[3])
        if data[4] != 'no':
            self.query_approver(data[4])
        if data[5] != 'no':
            self.query_process_depart(data[5])
        if data[6] != 'no':
            self.query_process_number(data[6])
        if data[7] != 'no':
            self.query_targetip(data[7])
        if data[8] != 'no':
            self.query_application_type(data[8])
        if data[9] != 'no':
            self.query_time(data[9], data[10], data[11])
        self.click_process_search()
        self.click_process_reset()
예제 #28
0
class testAuditLog():
	def __init__(self,driver):
		self.driver = driver
		self.log = log()
		self.cmf = commonFun(driver)
		self.getElem = getElement(driver)
		self.cnEnde = cnEncode()
		self.userElem = UserPage(driver)
		self.systemLog = SystemLogPage(self.driver)
		self.auditLog = AuditLogPage(self.driver)
		self.systemLog = SystemLogPage(self.driver)
		self.tableElem = tableElement(self.driver)
		self.selectElem = selectElement(driver)
		self.dataFile = dataFileName()
		self.frameElem = frameElement(self.driver)
		self.resource = Resource(driver)
		self.commonSuite = CommonSuiteData(self.driver)
	
	u'''校验没有弹出框类型用例是否通过
			parameters: 
				data : 检查点
				count :正确的行数
	'''
	def check_without_pop_up(self,count,data):
		#获取行数
		table_count = str(self.systemLog.get_table_count())
		if count == table_count:
			self.cmf.test_win_check_point("","",data,True)
		else:
			self.cmf.test_win_check_point("","",data,False)

	u'''获取测试数据
		Parameters:
			- sheetname:sheet名称
			return:表格数据
	'''
	def get_table_data(self,sheetname):
		dataFile = dataFileName()
		filePath = dataFile.get_audit_log_test_url()
		queryData = dataFile.get_data(filePath,sheetname)
		return queryData

	u'''运维审计检索功能'''
	def Audit_log_query_001(self):#query_type
		#日志开始记录
		self.log.log_start("AuditLogQuery_001")
		#获取配置审计检索的数据
		ad_data = self.get_table_data("audit_log_query")
		#无检查点的测试项标识,如果为True说明通过
		flag = False
		for dataRow in range(len(ad_data)):
			data = ad_data[dataRow]
			try:
				#如果不是第一行标题,则读取数据
				if dataRow != 0 :
					self.auditLog.select_date(data[2])
					if data[3] != "":
						self.auditLog.select_depmt(data[3])
					if data[4] != "":
						self.auditLog.click_select_audit()
						self.auditLog.select_audit(data[4])
					if data[2] == "":
						self.auditLog.click_high_level(data[17])
						self.auditLog.select_audit_type(data[5])
						if data[6] != "":
							self.resource.query_type(data[6],data[7],data[8])
						self.auditLog.set_res_account(data[9])
						self.auditLog.set_user_name(data[10])
						self.auditLog.set_client_ip(data[11])
						self.userElem.set_start_time(data[12])
						self.userElem.set_end_time(data[13])
						self.auditLog.set_key_word(data[14])
						self.auditLog.set_source_ip(data[15])
						self.auditLog.set_user_account(data[16])
					self.auditLog.click_search()
					#判断测试项是否通过
					self.check_without_pop_up(data[18],data)
					#清空标识状态
					flag = False
					self.frameElem.from_frame_to_otherFrame("mainFrame")
					self.userElem.click_reset_button()
			except Exception as e:
				print ("Audit Log query fail: ") + str(e)
		self.log.log_end("AuditLogQuery_001")
예제 #29
0
class LinuxResource(object):
    def __init__(self, driver):
        self.driver = driver
        self.frameElem = frameElement(driver)
        self.resource = Resource(driver)
        self.account = Accountmgr(driver)

    u'''添加和编辑Linux资源
	   Parameters:
	      - data:excel中的一行数据
	'''

    def add_edit_linux_resource(self, data):
        self.frameElem.from_frame_to_otherFrame("mainFrame")
        #资源名称
        self.resource.set_resource_name(data[3])
        #资源ip
        self.resource.set_resource_ip(data[4])
        #归属部门
        if data[5] != 'no':
            self.resource.set_depart(data[5])
        self.resource.select_all_agreement()
        #从IP
        if data[6] != 'no':
            self.resource.set_resource_fortIps(data[6])
        #系统版本
        if data[7] != 'no':
            self.resource.set_sys_version(data[7])
        #密码策略
        if data[8] != 'no':
            self.resource.select_pwd_strategy(data[8])
        #改密驱动名称
        if data[9] != 'no':
            self.resource.set_changePwd_driver(data[9])

        #管理员帐号
        if data[10] != 'no':
            self.resource.click_account_sync()
            self.resource.set_admin_account(data[10])
        #管理员口令
        if data[11] != 'no':
            self.resource.set_admin_pwd(data[11])
        #口令确认
        if data[12] != 'no':
            self.resource.set_confirm_pwd(data[12])
            self.resource.click_up_super()
            #提权账号口令
            self.resource.set_super_pwd(data[13])
            #确认口令
            self.resource.set_super_confirm_pwd(data[14])
        self.resource.resoure_save_button()

    u'''校验Linux资源
	   Parameters:
	      - datarow:excel数据位于第几行
	      - data:excel中的一行数据
	'''

    def check_linux_resource(self, datarow, data):
        self.frameElem.from_frame_to_otherFrame("mainFrame")
        #资源名称
        self.resource.set_resource_name(data[2])
        #资源ip
        self.resource.set_resource_ip(data[3])
        #协议类型
        if data[4] != 'no':
            self.resource.select_agreement(data[4])
        #协议类型 端口
        if datarow == 7:
            self.resource.set_port(data[4], data[5])
        if datarow == 8:
            self.resource.clear_port("Ssh1")
        if datarow == 9:
            self.resource.set_port("Ssh1", data[5])
        if datarow == 12:
            self.resource.click_account_sync()
            self.resource.click_up_super()
        if datarow == 13:
            #提权账号口令
            if data[6] != 'no':
                self.resource.set_super_pwd(data[6])
            #确认口令
            if data[7] != 'no':
                self.resource.set_super_confirm_pwd(data[7])
            self.resource.set_super_prompt()
        self.resource.resoure_save_button()

    u'''添加资源账号
	   Parameters:
	      - editacttname:编辑的资源账号名称
	      - value:选择编辑方式的value值
	      - addactname:填写的资源账号名称
	      - pwd:账号口令
	      - cmfpwd:确认口令
	'''

    def add_edit_resource_account(self,
                                  editacttname='no',
                                  value='no',
                                  addactname='no',
                                  pwd='no',
                                  cmfpwd='no'):
        self.account.click_account_add_edit_button(editacttname)
        if value != 'no':
            self.account.select_edit_way(value)
        if addactname != 'no':
            self.account.set_account_name(addactname)
        if pwd != 'no':
            self.account.set_account_pwd(pwd)
        if cmfpwd != 'no':
            self.account.set_account_confirm_pwd(cmfpwd)
        self.account.set_authorize()
        self.account.click_save_account()

    u'''校验资源账号
	   Parameters:
	      - value:选择编辑方式的value值
	      - addactname:填写的资源账号名称
	      - pwd:账号口令
	      - cmfpwd:确认口令
	'''

    def check_resource_account(self,
                               value='no',
                               addactname='no',
                               pwd='no',
                               cmfpwd='no'):
        if addactname == 'no':
            self.account.clear_account_name()
        if pwd == 'no':
            self.account.clear_account_pwd()
        if cmfpwd == 'no':
            self.account.clear_account_confirm_pwd()
        if value != 'no':
            self.account.select_edit_way(value)
        if addactname != 'no':
            self.account.set_account_name(addactname)
        if pwd != 'no':
            self.account.set_account_pwd(pwd)
        if cmfpwd != 'no':
            self.account.set_account_confirm_pwd(cmfpwd)
        self.account.set_authorize()
        self.account.click_save_account()
예제 #30
0
class testLinuxResource(object):

	def __init__(self, driver):
		self.driver = driver
		self.log = log()
		self.cmf = commonFun(driver)
		self.frameElem = frameElement(driver)
		self.testrole = testRole(driver)
		self.resource = Resource(driver)
		self.linux = LinuxResource(driver)
		self.role = Role(driver)
		self.data = dataFileName()

	u'''获取测试数据
	   Parameters:
	      - sheetname:sheet名称
	   return:表格数据
	'''
	def get_resource_table_data(self, sheetname):
		dataFile = dataFileName()
		resourcePath = dataFile.get_linux_resource_test_data_url()
		resourceData = dataFile.get_data(resourcePath, sheetname)
		return resourceData

	u'''添加linux资源'''
	def add_linux_resource_001(self):

		#日志开始记录
		self.log.log_start("add_resource")
		#获取添加资源测试数据
		resourceData = self.get_resource_table_data("add_linux_resource")
		#保存成功的弹出框
		resourceMsg = self.testrole.popup()

		#无检查点的测试项标识,如果为True说明通过
		flag = False

		for dataRow in range(len(resourceData)):
			data = resourceData[dataRow]
			try:
				#如果不是第一行标题,则读取数据
				if dataRow != 0:
					self.resource.click_add_edit_button()
					self.resource.select_resource_type(data[2])
					self.linux.add_edit_linux_resource(data)
					self.frameElem.switch_to_content()
					self.cmf.test_win_check_point("xpath", resourceMsg, data, flag)
					self.cmf.back()
			except Exception as e:
				print ("add_resource fail:" + str(e))

		self.log.log_end("add_resource")

	u'''编辑linux资源'''
	def edit_linux_resource_002(self):

		#日志开始记录
		self.log.log_start("edit_resource")
		#获取添加资源测试数据
		resourceData = self.get_resource_table_data("edit_linux_resource")
		#保存成功的弹出框
		resourceMsg = self.testrole.popup()

		#无检查点的测试项标识,如果为True说明通过
		flag = False

		for dataRow in range(len(resourceData)):
			data = resourceData[dataRow]
			try:
				#如果不是第一行标题,则读取数据
				if dataRow != 0:
					self.resource.click_add_edit_button(data[2])
					self.linux.add_edit_linux_resource(data)
					self.frameElem.switch_to_content()
					self.cmf.test_win_check_point("xpath", resourceMsg, data, flag)
					self.cmf.back()
			except Exception as e:
				print ("edit_resource fail:" + str(e))

		self.log.log_end("edit_resource")

	u'''检验linux资源'''
	def check_linux_resource_003(self):

		#日志开始记录
		self.log.log_start("check_linux_resource")
		#获取检验资源测试数据
		resourceData = self.get_resource_table_data("check_linux_resource")
		#保存成功的弹出框
		resourceMsg = self.testrole.popup()

		#无检查点的测试项标识,如果为True说明通过
		flag = False

		#点击添加按钮
		self.resource.click_add_edit_button()
		#选择debian类型
		self.resource.select_resource_type("Debian")

		for dataRow in range(len(resourceData)):
			data = resourceData[dataRow]
			try:
				#如果不是第一行标题,则读取数据
				if dataRow != 0:
					self.linux.check_linux_resource(dataRow, data)
					self.frameElem.switch_to_content()
					self.cmf.test_win_check_point("xpath", resourceMsg, data, flag)
			except Exception as e:
				print ("check_linux_resource fail:" + str(e))

		self.cmf.back()

		self.log.log_end("check_linux_resource")

	u'''查询资源'''
	def query_resource_004(self, dataPath, sheetName):

		#日志开始记录
		self.log.log_start("query_resource")
		#获取添加资源测试数据
		resourceData = self.data.get_data(dataPath, sheetName)

		for dataRow in range(len(resourceData)):
			data = resourceData[dataRow]
			try:
				#如果不是第一行标题,则读取数据
				if dataRow != 0:
					if dataRow == 1:
						self.resource.query_depart(data[1])
					if dataRow == 2:
						self.resource.click_child_node()
						self.resource.query_depart(data[1])
					if dataRow == 3:
						self.resource.query_type(data[2], data[3], data[4])
					if dataRow >= 4 and dataRow <= 7:
						self.resource.query_ip_rename(data[5])
					if dataRow == 8:
						self.resource.query_type(data[2], data[3], data[4])
						self.resource.query_ip_rename(data[5])
					self.resource.click_resource_query()
					self.role.click_reset()
					self.log.log_detail(data[0], True)
			except Exception as e:
				print ("query_resource fail:" + str(e))
		self.resource.click_resource_query()
		self.log.log_end("query_resource")

	u'''删除资源'''
	def del_resource_005(self, dataPath, sheetName):

		#日志开始记录
		self.log.log_start("del_resource")
		#获取添加资源测试数据
		resourceData = self.data.get_data(dataPath, sheetName)
		#保存成功的弹出框
		resourceMsg = self.testrole.popup()

		#无检查点的测试项标识,如果为True说明通过
		flag = False

		for dataRow in range(len(resourceData)):
			data = resourceData[dataRow]
			try:
				#如果不是第一行标题,则读取数据
				if dataRow != 0:
					self.resource.click_del_button(data[2])
					self.frameElem.switch_to_content()
					self.cmf.test_win_check_point("xpath", resourceMsg, data, flag)
					self.cmf.click_msg_button(1)
			except Exception as e:
				print ("del_resource fail:" + str(e))

		self.log.log_end("del_resource")

	u'''全选删除资源'''
	def bulkdel_resource_006(self):

		#日志开始记录
		self.log.log_start("bulkdel_resource")
		#获取添加资源测试数据
		resourceData = self.get_resource_table_data("bulkdel_resource")
		#保存成功的弹出框
		resourceMsg = self.testrole.popup()

		#无检查点的测试项标识,如果为True说明通过
		flag = False

		for dataRow in range(len(resourceData)):
			data = resourceData[dataRow]
			try:
				#如果不是第一行标题,则读取数据
				if dataRow != 0:
					self.cmf.check_all()
					self.cmf.bulkdel("delete_resource")
					self.frameElem.switch_to_content()
					self.cmf.test_win_check_point("xpath", resourceMsg, data, flag)
					self.cmf.click_msg_button(1)
			except Exception as e:
				print ("bulkdel_resource failure:" + str(e))

		self.log.log_end("bulkdel_resource")
예제 #31
0
 def __init__(self, driver):
     self.driver = driver
     self.frameElem = frameElement(driver)
     self.resource = Resource(driver)
     self.account = Accountmgr(driver)
예제 #32
0
class LinuxResource(object):

	def __init__(self, driver):
		self.driver = driver
		self.frameElem = frameElement(driver)
		self.resource = Resource(driver)
		self.account = Accountmgr(driver)

	u'''添加和编辑Linux资源
	   Parameters:
	      - data:excel中的一行数据
	'''
	def add_edit_linux_resource(self, data):
		self.frameElem.from_frame_to_otherFrame("mainFrame")
		#资源名称
		self.resource.set_resource_name(data[3])
		#资源ip
		self.resource.set_resource_ip(data[4])
		#归属部门
		if data[5] != 'no':
			self.resource.set_depart(data[5])
		self.resource.select_all_agreement()
		#从IP
		if data[6] != 'no':
			self.resource.set_resource_fortIps(data[6])
		#系统版本
		if data[7] != 'no':
			self.resource.set_sys_version(data[7])
		#密码策略
		if data[8] != 'no':
			self.resource.select_pwd_strategy(data[8])
		#改密驱动名称
		if data[9] != 'no':
			self.resource.set_changePwd_driver(data[9])

		#管理员帐号
		if data[10] != 'no':
			self.resource.click_account_sync()
			self.resource.set_admin_account(data[10])
		#管理员口令
		if data[11] != 'no':
			self.resource.set_admin_pwd(data[11])
		#口令确认
		if data[12] != 'no':
			self.resource.set_confirm_pwd(data[12])
			self.resource.click_up_super()
			#提权账号口令
			self.resource.set_super_pwd(data[13])
			#确认口令
			self.resource.set_super_confirm_pwd(data[14])
		self.resource.click_save_button()

	u'''校验Linux资源
	   Parameters:
	      - datarow:excel数据位于第几行
	      - data:excel中的一行数据
	'''
	def check_linux_resource(self, datarow, data):
		self.frameElem.from_frame_to_otherFrame("mainFrame")
		#资源名称
		self.resource.set_resource_name(data[2])
		#资源ip
		self.resource.set_resource_ip(data[3])
		#协议类型
		if data[4] != 'no':
			self.resource.select_agreement(data[4])
		#协议类型 端口
		if datarow == 7:
			self.resource.set_port(data[4], data[5])
		if datarow == 8:
			self.resource.clear_port("Ssh1")
		if datarow == 9:
			self.resource.set_port("Ssh1", data[5])
		if datarow == 12:
			self.resource.click_account_sync()
			self.resource.click_up_super()
		if datarow == 13:
			#提权账号口令
			if data[6] != 'no':
				self.resource.set_super_pwd(data[6])
			#确认口令
			if data[7] != 'no':
				self.resource.set_super_confirm_pwd(data[7])
			self.resource.set_super_prompt()
		self.resource.click_save_button()

	u'''添加资源账号
	   Parameters:
	      - editacttname:编辑的资源账号名称
	      - value:选择编辑方式的value值
	      - addactname:填写的资源账号名称
	      - pwd:账号口令
	      - cmfpwd:确认口令
	'''
	def add_edit_resource_account(self, editacttname='no', value='no', addactname='no', pwd='no', cmfpwd='no'):
		self.account.click_account_add_edit_button(editacttname)
		if value != 'no':
			self.account.select_edit_way(value)
		if addactname != 'no':
			self.account.set_account_name(addactname)
		if pwd != 'no':
			self.account.set_account_pwd(pwd)
		if cmfpwd != 'no':
			self.account.set_account_confirm_pwd(cmfpwd)
		self.account.set_authorize()
		self.account.click_save_account()

	u'''校验资源账号
	   Parameters:
	      - value:选择编辑方式的value值
	      - addactname:填写的资源账号名称
	      - pwd:账号口令
	      - cmfpwd:确认口令
	'''
	def check_resource_account(self, value='no', addactname='no', pwd='no', cmfpwd='no'):
		if addactname == 'no':
			self.account.clear_account_name()
		if pwd == 'no':
			self.account.clear_account_pwd()
		if cmfpwd == 'no':
			self.account.clear_account_confirm_pwd()
		if value != 'no':
			self.account.select_edit_way(value)
		if addactname != 'no':
			self.account.set_account_name(addactname)
		if pwd != 'no':
			self.account.set_account_pwd(pwd)
		if cmfpwd != 'no':
			self.account.set_account_confirm_pwd(cmfpwd)
		self.account.set_authorize()
		self.account.click_save_account()
예제 #33
0
class CommonSuiteData():
    def __init__(self, driver):
        self.driver = driver
        self.dataFile = dataFileName()
        self.cmf = commonFun(self.driver)
        self.initDriver = initDriver()
        self.loginElem = loginPage(self.driver)
        self.roleElem = Role(self.driver)
        self.userElem = UserPage(self.driver)
        self.frameElem = frameElement(self.driver)
        self.authElem = AuthMethodPage(self.driver)
        self.dptment = Department(self.driver)
        self.resource = Resource(self.driver)
        self.account = Accountmgr(self.driver)
        self.windowsElem = WindowsResource(self.driver)
        self.databaseElem = DatabaseResource(self.driver)
        self.usergroup = Usergroup(self.driver)
        self.regroup = Regroup(self.driver)
        self.appElem = AppPage(self.driver)
        self.authorizationElem = AuthorizationPage(self.driver)
        self.testAutho = testAuthorization(self.driver)
        self.clientElem = ClientPage(self.driver)
        self.command = CommandRule(self.driver)
        self.ntp = NtpService(self.driver)
        self.mail = MailPage(self.driver)
        self.syslog = Syslog(driver)
        self.ssoElem = SsoPage(self.driver)
        self.alarm = AlarmPage(self.driver)
        self.PwdStr = PwdStrategy(self.driver)
        self.passwdenvelope = EnvelopePage(self.driver)

    u'''切换模块
            parameter:
                levelText1 : 一级模块名称
                levelText2 : 二级模块名称
    '''

    def switch_to_moudle(self, levelText1, levelText2):
        time.sleep(2)
        self.frameElem.from_frame_to_otherFrame("topFrame")

        self.cmf.select_menu(levelText1)
        self.cmf.select_menu(levelText1, levelText2)

#----------------------------------------用户相关------------------------------

    u'''填写用户信息
            parameters:
                data[1] : 用户名称
                data[3] : 用户账号
                data[4] : 用户密码
                data[5] : 确认密码
                data[6] : 开始时间
                data[7] : 访问方式
                data[8] : AD域账号
                roleText : 用户角色
    '''
    def set_user_basic_info(self, data, roleText, status='no'):
        self.frameElem.from_frame_to_otherFrame("mainFrame")
        if status != 'no':
            self.userElem.add_role_button()
        else:
            self.userElem.add_button()
        self.userElem.set_user_account(data[3])
        self.userElem.set_user_name(data[1])
        self.userElem.set_user_pwd(data[4])
        self.userElem.set_user_enquire_pwd(data[5])
        self.userElem.set_start_time(data[6])
        if data[12] != "":
            self.userElem.set_user_email(data[12])
        if data[10] != "":
            self.userElem.set_dep(data[10])
        if data[7] != "":
            #设置访问方式
            self.userElem.click_advanced_option()
            self.userElem.set_auth_method_rule(data[7])

            #访问方式不是默认方式
            if int(data[7]) != 2:
                self.userElem.set_ad_name(data[8])
        if data[9] != "":
            self.userElem.set_user_role(roleText)
            self.userElem.click_role_add_button()
        self.userElem.save_button()
        self.cmf.click_login_msg_button()

    u'''删除用户'''

    def del_user(self):
        self.switch_to_moudle(u"运维管理", u"用户")
        self.frameElem.from_frame_to_otherFrame("mainFrame")
        self.userElem.select_all_button()
        self.userElem.del_button()
        self.frameElem.switch_to_content()
        self.cmf.click_login_msg_button()
        self.cmf.click_login_msg_button()

    u'''用户退出'''

    def user_quit(self):
        self.loginElem.quit()

#-----------------------------部门--------------------------------------------

    u'''填写部门名称
            parameters :
                data[0] : 部门名称
                data[1] : 操作类型(添加:0)
                data[2] : 添加的部门名称
    '''
    def set_dep(self, data):
        self.switch_to_moudle(u"运维管理", u"组织定义")
        self.dptment.click_left_department()
        #点击展开按钮
        self.dptment.click_dept_switch()
        self.dptment.click_basic_operation(data[0], int(data[1]))
        self.dptment.popup_sendkey(data[2])
        self.dptment.click_ok_button()
        self.cmf.click_login_msg_button()

    def set_del_dep(self, data):
        self.switch_to_moudle(u"运维管理", u"组织定义")
        self.dptment.click_left_department()
        self.dptment.click_dept_switch()
        self.dptment.click_basic_operation(data[0], int(data[1]))
        self.cmf.click_login_msg_button()
        self.cmf.click_login_msg_button()

#-----------------------------用户组------------------------------------------

    u'''添加用户到用户组'''
    def set_user_to_group(self, data):
        #        self.usergroup.click_left_usergroup()
        #        self.usergroup.click_usergroup_switch()
        self.usergroup.click_usergroup_add_user(data[3], data[4])
        self.regroup.check_depart(data[5])
        self.usergroup.click_usergroup_add_user_query()
        self.regroup.check_all_resource()
        self.regroup.click_resource_okbutton()
        self.cmf.click_login_msg_button()

    u'''填写用户组信息
            parameters:
                data[0] : 操作类型(添加:0)
                data[1] : 部门名称
                data[2] : 编辑的用户组名称
                data[3] : 添加的用户组名称
    '''

    def set_add_user_group(self, data):
        self.switch_to_moudle(u"运维管理", u"组织定义")
        self.usergroup.click_left_usergroup()
        self.usergroup.click_usergroup_switch()
        self.usergroup.usergroup_click_basic_operation(int(data[0]), data[1],
                                                       data[2])
        self.dptment.popup_sendkey(data[3])
        self.dptment.click_ok_button()
        self.cmf.click_login_msg_button()
        if data[4] != "":
            self.set_user_to_group(data)

    u'''删除用户组
            parameters :
                data[0] : 操作类型(删除:4)
                data[1] : 部门名称
                data[2] : 删除的用户组名称
    '''

    def set_del_user_group(self, data):
        self.switch_to_moudle(u"运维管理", u"组织定义")
        self.usergroup.click_left_usergroup()
        self.usergroup.click_usergroup_switch()
        self.usergroup.usergroup_click_basic_operation(int(data[0]), data[1],
                                                       data[2])
        self.cmf.click_login_msg_button()
        self.cmf.click_login_msg_button()

#-----------------------------资源组------------------------------------------

    u'''添加资源到资源组'''
    def set_res_to_group(self, data):
        self.regroup.click_regroup_add_resouce(data[3], data[4])
        self.regroup.check_depart(data[5])
        self.regroup.click_regroup_add_resouce_query()
        self.regroup.check_all_resource()
        self.regroup.click_resource_okbutton()
        time.sleep(1)
        self.cmf.click_login_msg_button()

    u'''填写资源组信息
            parameters:
                data[0] : 操作类型(添加:0)
                data[1] : 部门名称
                data[2] : 编辑的资源组名称
                data[3] : 添加的资源组名称
    '''

    def set_add_res_group(self, data):
        self.switch_to_moudle(u"运维管理", u"组织定义")
        self.regroup.click_left_regroup()
        self.regroup.click_regroup_switch()
        self.regroup.regroup_click_basic_operation(int(data[0]), data[1],
                                                   data[2])
        self.dptment.popup_sendkey(data[3])
        self.dptment.click_ok_button()
        self.cmf.click_login_msg_button()
        if data[4] != "":
            self.set_res_to_group(data)

    u'''删除资源组
            parameters :
                data[0] : 操作类型(删除:4)
                data[1] : 部门名称
                data[2] : 删除的资源组名称
    '''

    def set_del_res_group(self, data):
        self.switch_to_moudle(u"运维管理", u"组织定义")
        self.regroup.click_left_regroup()
        self.regroup.click_regroup_switch()
        self.regroup.regroup_click_basic_operation(int(data[0]), data[1],
                                                   data[2])
        self.cmf.click_login_msg_button()
        self.cmf.click_login_msg_button()

#-----------------------------资源--------------------------------------------

    u'''填写资源基本信息
            parameters : 
                data[0]:资源类型
                data[1]:资源名称
                data[2]:资源IP
                data[3]:部门
    '''
    def set_resource_info(self, data):
        self.switch_to_moudle(u"运维管理", u"资源")
        self.frameElem.from_frame_to_otherFrame("mainFrame")
        self.resource.click_add_edit_button()
        self.resource.select_resource_type(data[0])
        self.resource.set_resource_name(data[1])
        self.resource.set_resource_ip(data[2])
        if data[3] != 'no':
            time.sleep(5)
            self.resource.set_depart(data[3])
        #选择协议
        if data[4] != "":
            self.resource.select_agreement(data[4])
        if data[5] != "":
            self.resource.click_account_sync()
            self.resource.set_admin_account(data[5])
            self.resource.set_admin_pwd(data[6])
            self.resource.set_confirm_pwd(data[7])
        #提权口令
        if data[8] != "":
            self.resource.click_up_super()
            self.resource.set_super_pwd(data[8])
            self.resource.set_super_confirm_pwd(data[9])
        #填写域名
        if data[10] != "":
            self.databaseElem.set_domain_name(data[10])
        #账号分类
        if data[11] != "":
            self.resource.click_account_sync()
            self.windowsElem.select_account_type(data[11])
        #归属域控主机
        if data[12] != "":
            self.windowsElem.select_attach_domian(data[12])
        #主机名
        if data[13] != "":
            self.databaseElem.set_host_name(data[13])

        self.resource.click_save_button()
        self.cmf.click_login_msg_button()
        time.sleep(3)
        #        self.driver.implicitly_wait(3)
        self.cmf.back()

    u'''填写数据库基本信息'''

    def set_database_res_info(self, data):
        self.switch_to_moudle(u"运维管理", u"资源")
        self.frameElem.from_frame_to_otherFrame("mainFrame")
        self.resource.click_add_edit_button()
        self.resource.select_resource_type(data[2])
        self.databaseElem.add_edit_database_resource(data)
        self.cmf.click_login_msg_button()
        time.sleep(3)
        self.cmf.back()

    u'''填写资源账号基本信息
            parameters: 
                data[1]:资源名称
                data[4] : 账号编辑方式
                data[5] : 账号名称
                data[6] : 口令
                data[7] : 确认口令
    '''

    def set_res_account(self, data):
        self.switch_to_moudle(u"运维管理", u"资源")
        self.account.click_account_manage_button(data[0])
        time.sleep(1)
        self.account.click_account_add_edit_button(data[2])
        self.account.select_edit_way(data[1])
        if data[2] != "no":
            self.account.set_account_name(data[2])
        self.account.set_account_pwd(data[3])
        self.account.set_account_confirm_pwd(data[4])
        self.account.set_authorize()
        self.account.click_save_account()
        self.cmf.click_login_msg_button()

#-----------------------------授权----------------------------------------

    u'''填写授权基本信息
            parameters:
                data[1]:授权名称
                data[2]:部门名称
                data[3]:状态
    '''
    def set_authorization(self, data):
        self.switch_to_moudle(u'运维管理', u'授权')
        self.authorizationElem.add_button()
        self.authorizationElem.set_auth_name(data[1])
        self.authorizationElem.set_dep(data[2], data[3])
        self.authorizationElem.click_add_user()
        self.authorizationElem.set_select_user_search_button()
        self.authorizationElem.set_user_check_all_button()
        self.authorizationElem.set_ok_button()
        #添加资源
        self.authorizationElem.click_add_res()
        self.authorizationElem.set_select_res_search_button()
        self.authorizationElem.set_res_check_all_button()
        self.authorizationElem.set_ok_button()
        self.authorizationElem.save_button()
        self.cmf.click_login_msg_button()
        self.cmf.back()
#---------------------------------填写应用发布信息----------------------------

    u'''填写应用发布信息'''
    def set_application_info(self, data):
        self.switch_to_moudle(u"系统配置", u"关联服务")
        self.appElem.app_module_button()
        self.appElem.click_add_button()
        self.appElem.set_name(data[0])
        self.appElem.set_ip(data[1])
        self.appElem.set_app_account(data[3])
        self.appElem.set_pwd(data[4])
        self.appElem.set_repwd(data[5])
        self.appElem.ip_is_succ()
        self.appElem.click_save_button()
        self.cmf.click_login_msg_button()

    u'''删除应用发布'''

    def del_application(self, rowList):
        self.switch_to_moudle(u"系统配置", u"关联服务")
        self.appElem.app_module_button()
        self.frameElem.from_frame_to_otherFrame("rigthFrame")
        app_data = self.get_table_data("add_application")
        for dataRow in rowList:
            data = app_data[dataRow]
            if dataRow != 0:
                self.appElem.operate_del(data[0])
                self.cmf.click_login_msg_button()
                self.cmf.click_login_msg_button()

#-------------------------------------客户端-----------------------------------

    u'''填写客户端基本信息'''
    def set_client_info(self, data):
        #self.switch_to_moudle(u"系统配置",u"客户端配置")
        self.frameElem.from_frame_to_otherFrame("mainFrame")
        self.clientElem.add_button()
        self.clientElem.set_client_name(data[2])
        self.clientElem.set_action_stream(data[3])
        self.clientElem.set_database_res_type(data[0], data[1])
        self.clientElem.save_button()

    u'''删除客户端'''

    def set_delete_client_info(self, data):
        #self.switch_to_moudle(u"系统配置",u"客户端配置")
        self.frameElem.from_frame_to_otherFrame("mainFrame")
        self.clientElem.select_query_res_type(data[0], data[1])
        self.clientElem.click_query_button()
        self.clientElem.del_operation(data[2])
        self.cmf.click_login_msg_button()

#------------------------------资源账号授权------------------------------------

    u'''添加用户和资源账号类型的授权'''
    def set_authorization_info(self, data):
        self.switch_to_moudle(u"运维管理", u"授权")
        self.testAutho.common_part(data)
        self.testAutho.add_user(data)
        self.authorizationElem.click_add_res_account()
        self.authorizationElem.set_select_res_ip(data[6])
        self.authorizationElem.set_select_res_account(data[8])
        self.authorizationElem.set_select_res_search_button()
        self.authorizationElem.set_res_check_all_button()
        self.authorizationElem.set_ok_button()
        self.authorizationElem.res_account_status()
        self.authorizationElem.save_button()
        self.cmf.click_login_msg_button()

    u'''删除授权'''

    def del_authorization(self):
        self.switch_to_moudle(u"运维管理", u"授权")
        self.frameElem.from_frame_to_otherFrame("mainFrame")
        self.authorizationElem.check_all()
        self.authorizationElem.del_button()
        self.cmf.click_login_msg_button()
        self.cmf.click_login_msg_button()

#-----------------------------数据----------------------------------------

    u'''获取数据
        Parameters:
            - sheetname:sheet名称
            return:表格数据
    '''
    def get_table_data(self, sheetname):
        filePath = self.dataFile.get_common_suite_test_data_url()
        fileData = self.dataFile.get_data(filePath, sheetname)
        return fileData

    u'''添加应用发布'''

    def add_application(self, rowList):
        app_data = self.get_table_data('add_application')
        for dataRow in rowList:
            data = app_data[dataRow]
            if dataRow != 0:
                self.set_application_info(data)

    u'''初始化用户登录'''

    def isomper_login(self):
        login_data = self.get_table_data('add_user')
        logindata = login_data[4]
        self.loginElem.login(logindata)

    u'''添加用户数据模板'''

    def add_user_data_module(self, rowList):
        self.switch_to_moudle(u"运维管理", u"用户")
        user_data = self.get_table_data("add_user")
        for dataRow in rowList:
            data = user_data[dataRow]
            if dataRow != 0:
                self.set_user_basic_info(data, data[9], data[13])
                self.userElem.click_back_button()

    u'''添加系统管理员和部门管理员的用户'''

    def add_user_with_role(self):
        rowList = [1]
        self.add_user_data_module(rowList)

    u'''登录并切换至角色公用方法
            parameters: 
                login_status :'no'(登录状态:没有登录)
    '''

    def login_and_switch_to_common(self, login_status='no'):
        login_data = self.get_table_data("add_user")
        logindata = login_data[1]
        if login_status == 'no':
            self.loginElem.login(logindata)

        #获取角色
        roleList = logindata[9].split(',')
        return roleList

    u'''使用系统管理员登录系统'''

    def login_sysadmin(self):
        login_data = self.get_table_data('add_user')
        logindata = login_data[1]
        self.loginElem.login(logindata)

    u'''使用安全保密管理员登录系统'''

    def login_secadmin(self):
        login_data = self.get_table_data('add_user')
        logindata = login_data[2]
        self.loginElem.login(logindata)

    u'''使用安全审计员登录系统'''

    def login_sysaudit(self):
        login_data = self.get_table_data('add_user')
        logindata = login_data[3]
        self.loginElem.login(logindata)

    u'''用户登录系统'''

    def login_user(self, row):
        login_data = self.get_table_data('add_user')
        logindata = login_data[int(row)]
        self.loginElem.login(logindata)

    u'''切换至运维操作员'''

    def switch_to_operation(self):
        self.cmf.select_role_by_text(u"运维操作员")

    #使用新添加的用户登录
    def use_new_user_login(self):
        login_data = self.get_table_data("add_user")
        logindata = login_data[1]
        time.sleep(2)
        self.loginElem.login(logindata)

    u'''运维管理员登录'''

    def sso_user_login(self, rowList):
        login_data = self.get_table_data("add_user")
        logindata = login_data[rowList]
        time.sleep(1)
        self.loginElem.login(logindata)

    u'''运维管理员AD域方式登录'''

    def sso_user_ad_login(self, rowList):
        login_data = self.get_table_data("add_user")
        logindata = login_data[rowList]
        self.frameElem.switch_to_content()
        self.loginElem.set_login_method(logindata[2])
        self.loginElem.set_ad_login_username(logindata[3])
        self.loginElem.set_ad_login_pwd(logindata[11])
        time.sleep(1)
        self.loginElem.click_login_button()

    u'''添加认证配置'''

    def add_meth_method(self):
        meth_data = self.get_table_data("meth_method")
        methData = meth_data[1]

        self.switch_to_moudle(u"策略配置", u"认证强度")

        self.authElem.select_all_auth(methData)

    u'''会话配置,设置最大登录数'''

    def set_login_max_num(self):
        self.loginElem.set_max_login_count()

    u'''添加登录测试数据'''

    def add_login_data(self):
        rowList = [2, 3, 4, 5, 6, 7]
        self.add_user_data_module(rowList)

    u'''添加授权用户'''

    def add_authorization_user(self):
        rowList = [8, 9, 10, 11, 12]
        self.add_user_data_module(rowList)

    u'''添加应用发布用户'''

    def add_app_user(self):
        rowList = [3]
        self.add_user_data_module(rowList)

    u'''添加单点登录用户'''

    def add_sso_user(self):
        rowList = [6, 8, 9, 10, 11, 13]
        self.add_user_data_module(rowList)

    u'''添加部门'''

    def add_dep(self, rowList):
        dep_data = self.get_table_data("add_dep")
        for dataRow in rowList:
            data = dep_data[dataRow]
            if dataRow != 0:
                self.set_dep(data)

    u'''删除部门'''

    def del_dep(self, rowList):
        dep_data = self.get_table_data("del_dep")
        for dataRow in rowList:
            data = dep_data[dataRow]
            if dataRow != 0:
                self.set_del_dep(data)

    u'''增加资源数据模板'''

    def add_resource_modele(self, rowList):
        res_data = self.get_table_data("add_res")
        for dataRow in rowList:
            data = res_data[dataRow]
            if dataRow != 0:
                self.set_resource_info(data)

    u'''添加授权资源'''

    def add_resource(self):
        rowList = [1, 2]
        self.add_resource_modele(rowList)

    u'''添加sso资源'''

    def add_sso_resource(self):
        #rowList = [1,2,3,4,5,7,8]
        rowList = [1, 3, 4, 5]
        self.add_resource_modele(rowList)

    u'''添加依附操作系统'''

    def add_database_resource(self):
        rowList = [2]
        self.add_resource_modele(rowList)

    u'''添加资源账号数据模板'''

    def add_res_account_module(self, rowList):
        account_data = self.get_table_data("res_account")
        for dataRow in rowList:
            data = account_data[dataRow]
            if dataRow != 0:
                self.set_res_account(data)

    u'''添加授权资源账号'''

    def add_res_account(self):
        rowList = [1, 3]
        self.add_res_account_module(rowList)

    u'''添加sso资源账号'''

    def add_sso_res_account(self):
        rowList = [1, 2, 4, 5, 6, 7]
        #rowList = [1,2,3,4,5,6,7,9,10]
        self.add_res_account_module(rowList)

    u'''添加用户组'''

    def add_user_group(self, rowList):
        user_group_data = self.get_table_data("add_user_group")
        for dataRow in rowList:
            data = user_group_data[dataRow]
            if dataRow != 0:
                self.set_add_user_group(data)

    u'''删除用户组'''

    def del_user_group(self, rowList):
        user_group_data = self.get_table_data("del_user_group")
        for dataRow in rowList:
            data = user_group_data[dataRow]
            if dataRow != 0:
                self.set_del_user_group(data)

    u'''添加资源组'''

    def add_res_group(self, rowList):
        res_group_data = self.get_table_data("add_res_group")
        for dataRow in rowList:
            data = res_group_data[dataRow]
            if dataRow != 0:
                self.set_add_res_group(data)

    u'''删除资源组'''

    def del_res_group(self, rowList):
        res_group_data = self.get_table_data("del_res_group")
        for dataRow in rowList:
            data = res_group_data[dataRow]
            if dataRow != 0:
                self.set_del_res_group(data)

    u'''添加授权'''

    def add_authrization(self, rowList):
        auth_data = self.get_table_data("add_authorization")
        for dataRow in rowList:
            data = auth_data[dataRow]
            if dataRow != 0:
                self.set_authorization(data)

    u'''添加授权数据模板'''

    def add_authorization_module(self, rowList):
        autho_data = self.get_table_data("add_account_auth")
        for dataRow in rowList:
            data = autho_data[dataRow]
            if dataRow != 0:
                self.set_authorization_info(data)
                self.authorizationElem.back_button()

    u'''添加单点登录授权'''

    def add_sso_authorization(self):
        rowList = [1]
        #rowList = [1,2,3,4,5,6,7]
        self.add_authorization_module(rowList)

    u'''单点登录模板'''

    def sso_module(self, rowList):
        sso_data = self.get_table_data("sso")
        for dataRow in rowList:
            data = sso_data[dataRow]
            if dataRow != 0:
                self.frameElem.from_frame_to_otherFrame("rigthFrame")
                self.ssoElem.select_account(data[0], data[1])
                self.ssoElem.select_sso_icon(data[0], data[2])
                if data[3] != "":
                    self.ssoElem.select_protocol(data[3])
                #self.ssoElem.execute_chrome_key()
                self.ssoElem.choice_browser(data[2], data[4], data[5], data[6])

    u'''添加客户端数据模板'''

    def add_client_module(self, rowList):
        client_data = self.get_table_data("add_client")
        self.switch_to_moudle(u"系统配置", u"客户端配置")
        for dataRow in rowList:
            data = client_data[dataRow]
            if dataRow != 0:
                self.set_client_info(data)

    u'''删除客户端数据模板'''

    def del_client_module(self, rowList):
        client_data = self.get_table_data("del_client")
        self.switch_to_moudle(u"系统配置", u"客户端配置")
        for dataRow in rowList:
            data = client_data[dataRow]
            if dataRow != 0:
                self.set_delete_client_info(data)

    u'''添加数据库资源模板'''

    def add_database_res_module(self, rowList):
        database_data = self.get_table_data("add_database")
        for dataRow in rowList:
            data = database_data[dataRow]
            if dataRow != 0:
                self.set_database_res_info(data)

    u'''删除用户数据模板'''

    def del_user_data_module(self, rowList):
        self.switch_to_moudle(u"运维管理", u"用户")
        self.frameElem.from_frame_to_otherFrame("mainFrame")
        user_data = self.get_table_data("add_user")
        for dataRow in rowList:
            data = user_data[dataRow]
            if dataRow != 0:
                self.switch_to_moudle(u"运维管理", u"用户")
                self.userElem.operate_delete(data[1])
                self.frameElem.switch_to_content()
                self.cmf.click_login_msg_button()
                self.cmf.click_login_msg_button()

    u'''添加密码策略数据模板'''

    def add_strategy_data_module(self, rowList):
        self.switch_to_moudle(u"策略配置", u"密码策略")
        self.frameElem.from_frame_to_otherFrame("mainFrame")
        pwd_data = self.get_table_data("add_strategy")
        for dataRow in rowList:
            data = pwd_data[dataRow]
            if dataRow != 0:
                self.PwdStr.add_pwd_button()
                self.PwdStr.set_pwd_name(data[1])
                self.PwdStr.term_of_validity(data[2])
                self.PwdStr.password_length_min(data[3])
                self.PwdStr.password_length_max(data[4])
                self.PwdStr.set_lower_case(data[5])
                self.PwdStr.set_capital(data[6])
                self.PwdStr.set_minimum_digital(data[7])
                self.PwdStr.set_Minimum_symbol(data[8])
                self.PwdStr.save_button()
                self.frameElem.switch_to_content()
                self.cmf.click_msg_button(1)
                self.PwdStr.return_button()

    u'''删除密码策略数据模板'''

    def del_strategy_data_module(self, rowList):
        self.switch_to_moudle(u"策略配置", u"密码策略")
        self.frameElem.from_frame_to_otherFrame("mainFrame")
        pwd_data = self.get_table_data("add_strategy")
        for dataRow in rowList:
            data = pwd_data[dataRow]
            if dataRow != 0:
                self.PwdStr.del_sing_strategy(data[1])
                self.frameElem.switch_to_content()
                self.cmf.click_login_msg_button()
                self.cmf.click_login_msg_button()

    u'''删除资源数据模板'''

    def del_resource_modele(self, rowList):
        self.switch_to_moudle(u"运维管理", u"资源")
        self.frameElem.from_frame_to_otherFrame("mainFrame")
        res_data = self.get_table_data("add_res")
        for dataRow in rowList:
            data = res_data[dataRow]
            if dataRow != 0:
                self.resource.click_del_button(data[1])
                self.frameElem.switch_to_content()
                self.cmf.click_login_msg_button()
                self.cmf.click_login_msg_button()

    u'''删除授权数据模板'''

    def del_authorization_module(self, rowList):
        self.switch_to_moudle(u'运维管理', u'授权')
        self.frameElem.from_frame_to_otherFrame("mainFrame")
        autho_data = self.get_table_data("add_account_auth")
        for dataRow in rowList:
            data = autho_data[dataRow]
            if dataRow != 0:
                self.authorizationElem.click_auth_checkbox(data[2])
                self.authorizationElem.del_button()
                self.frameElem.switch_to_content()
                self.cmf.click_login_msg_button()
                self.cmf.click_login_msg_button()

#-------------------------------添加涉密版用户前置条件---------------------------------------

    u'''前置条件通用'''
    def secret_user_prefix_condition(self):
        self.isomper_login()
        self.switch_to_moudle(u'角色管理', u'角色定义')

#------------------------------部门前置条件-----------------------------------

    def depart_module_prefix_condition(self):
        #使用系统管理员登录
        self.login_sysadmin()
        #切换到组织定义
        self.switch_to_moudle(u"运维管理", u"组织定义")

#------------------------------资源组前置条件-----------------------------------

    def regroup_module_prefix_condition(self):
        #使用安全保密管理员登录
        self.login_secadmin()
        #添加资源
        self.add_resource_modele([9, 6])
        self.user_quit()
        #使用系统管理员登录
        self.login_sysadmin()
        #切换到组织定义
        self.switch_to_moudle(u"运维管理", u"组织定义")

    def regroup_module_post_condition(self):
        self.user_quit()
        #使用安全保密管理员登录
        self.login_secadmin()
        #删除资源
        self.del_resource_modele([9, 6])
        self.user_quit()

#------------------------------用户组前置条件-----------------------------------

    def usergroup_module_prefix_condition(self):
        #使用系统管理员登录
        self.login_sysadmin()
        #添加用户
        self.add_user_data_module([5, 6, 7, 8])
        #切换到组织定义
        self.switch_to_moudle(u"运维管理", u"组织定义")

    def usergroup_module_post_condition(self):
        self.del_user_data_module([5, 6, 7, 8])
        self.user_quit()

#------------------------------NTP服务前置条件---------------------------------

    def ntp_module_prefix_condition(self):
        #使用系统管理员登录
        self.login_sysadmin()
        #切换到NTP服务
        self.switch_to_moudle(u'系统配置', u'关联服务')
        self.ntp.click_left_moudle(0)

#-------------------------------SYSLOG前置条件---------------------------------

    def syslog_module_prefix_condition(self):
        #使用系统管理员登录
        self.login_sysadmin()
        #切换到NTP服务
        self.switch_to_moudle(u'系统配置', u'关联服务')
        self.ntp.click_left_moudle(1)

#------------------------------邮件前置条件---------------------------------

    def mail_module_prefix_condition(self):
        #使用系统管理员登录
        self.login_sysadmin()
        #切换到邮件服务
        self.switch_to_moudle(u'系统配置', u'关联服务')
        self.mail.click_left_moudle_test()

#------------------------------密码信封前置条件---------------------------------

    def passwd_envelope_module_prefix_condition(self):
        #使用系统管理员登录
        self.login_sysadmin()
        #切换到邮件服务
        self.switch_to_moudle(u'系统配置', u'关联服务')
        self.passwdenvelope.click_left_moudle_envelope()

#-------------------------------应用发布后置条件-------------------------------

    def application_module_prefix_condition(self):
        #使用系统管理员登录
        self.login_sysadmin()
        self.add_user_data_module([9, 10])
        self.switch_to_moudle(u"系统配置", u"关联服务")

    def application_module_post_condition(self):
        self.del_user_data_module([9, 10])
        self.user_quit()

#-------------------------------网卡配置前置条件-------------------------------

    def network_card_module_prefix_condition(self):
        #使用系统管理员登录
        self.login_sysadmin()
        #切换到网卡配置
        self.switch_to_moudle(u'系统配置', u'网络配置')

#-------------------------------路由配置前置条件-------------------------------

    def routing_module_prefix_condition(self):
        #使用系统管理员登录
        self.login_sysadmin()
        #切换到路由配置
        self.cmf.select_menu(u'系统配置', u'网络配置', u'路由配置')

#------------------------------备份还原前置条件-----------------------------------

    def backup_restore_module_prefix_condition(self):
        #使用系统管理员登录
        self.login_sysadmin()

#-----------------------------客户端配置前置条件------------------------------

    def client_module_prefix_condition(self):
        #使用系统管理员登录
        self.login_sysadmin()
        self.switch_to_moudle(u"系统配置", u"客户端配置")

#-----------------------------AD域抽取前置条件------------------------------

    def ad_module_prefix_condition(self):
        #使用系统管理员登录
        self.login_sysadmin()
        self.add_user_data_module([18])
        self.switch_to_moudle(u"系统配置", u"AD定时抽取")

    u'''AD域抽取后置条件'''

    def ad_module_post_condition(self):
        self.del_user_data_module([18])
        self.user_quit()

#------------------------------使用授权前置条件---------------------------------

    def use_auth_module_prefix_condition(self):
        #使用系统管理员登录
        self.login_sysadmin()
        self.switch_to_moudle(u'系统配置', u'使用授权')

#------------------------------用户模块前置条件--------------------------------

    u'''用户模块前置条件'''
    def user_module_prefix_condition(self):
        #使用系统管理员登录
        self.login_sysadmin()
        self.switch_to_moudle(u'运维管理', u'用户')

#--------------------------认证方式前置条件------------------------------------

    u'''认证方式前置条件'''
    def auth_method_prefix_condition(self):
        #使用安全保密管理员登录
        self.login_secadmin()
        self.add_user_data_module([11])
        self.switch_to_moudle(u"策略配置", u"认证强度")
        self.frameElem.from_frame_to_otherFrame("mainFrame")

    u'''认证方式后置条件'''

    def auth_method_post_condition(self):
        self.del_user_data_module([11])
        self.user_quit()

#---------------------------------登录模块前置条件-----------------------------

    u'''登录模块前置条件'''
    def login_module_prefix_condition(self):
        #使用安全保密管理员登录
        self.login_secadmin()
        #配置认证方式
        self.add_meth_method()
        #配置最大登录数
        self.set_login_max_num()
        #添加登录用户数据
        self.add_user_data_module([12, 13, 14, 15, 16, 17])
        #改变a的状态为关
        self.userElem.change_user_status_off("gyrlogin2")
        #系统管理员退出
        self.user_quit()

    u'''登录模块后置条件'''

    def login_module_post_condition(self):
        #使用安全保密管理员登录
        self.login_secadmin()
        #删除认证方式
        self.authElem.del_auth_method()
        self.del_user_data_module([12, 13, 14, 15, 16, 17])
        self.user_quit()

#------------------------------告警策略前置条件---------------------------------

    def alarm_strategy_module_prefix_condition(self):
        #使用安全保密管理员登录
        self.login_secadmin()

    def alarm_strategy_module_post_condition(self):
        self.alarm.del_command_config()
        self.alarm.del_default_config()
        self.alarm.del_auth_config()
        self.user_quit()

#------------------------------会话配置前置条件--------------------------------

    def session_module_prefix_condition(self):
        #使用安全保密管理员登录
        self.login_secadmin()
        self.switch_to_moudle(u"策略配置", u"会话配置")

#------------------------------密码策略前置条件--------------------------------

    def pwdstr_module_prefix_condition(self):
        #使用安全保密管理员登录
        self.login_secadmin()
        #添加资源
        self.add_resource_modele([14])
        self.add_user_data_module([19])
        self.switch_to_moudle(u"策略配置", u"密码策略")

    def pwdstr_module_post_condition(self):
        self.del_resource_modele([14])
        self.del_user_data_module([19])
        self.user_quit()

#------------------------------linux资源前置条件-----------------------------------

    def linuxre_module_prefix_condition(self):
        #使用安全保密管理员登录
        self.login_secadmin()
        #添加密码策略
        self.add_strategy_data_module([1])
        #切换到资源
        self.switch_to_moudle(u"运维管理", u"资源")

    def linuxre_module_post_condition(self):
        #删除密码策略
        self.del_strategy_data_module([1])
        self.user_quit()

#------------------------------network资源前置条件-----------------------------------

    def networkre_module_prefix_condition(self):
        #使用安全保密管理员登录
        self.login_secadmin()
        #切换到资源
        self.switch_to_moudle(u"运维管理", u"资源")

#------------------------------windows资源前置条件-----------------------------------

    def windowre_module_prefix_condition(self):
        #使用安全保密管理员登录
        self.login_secadmin()
        #添加密码策略
        self.add_strategy_data_module([2])
        #切换到资源
        self.switch_to_moudle(u"运维管理", u"资源")

    def windowre_module_post_condition(self):
        #删除密码策略
        self.del_strategy_data_module([2])
        self.user_quit()

#-----------------------------数据库前置条件----------------------------------

    def database_resource_prefix_condition(self):
        self.login_sysadmin()
        #添加应用发布
        self.add_application([1])
        self.user_quit()
        #使用安全保密管理员登录
        self.login_secadmin()
        self.add_resource_modele([17])
        self.switch_to_moudle(u"运维管理", u"资源")

    def database_resource_post_condition(self):
        self.del_resource_modele([17])
        self.user_quit()
        self.login_sysadmin()
        self.del_application([1])
        self.user_quit()

#------------------------------授权前置条件-----------------------------------

    def authori_module_prefix_condition(self):

        #使用安全保密管理员登录
        self.login_secadmin()
        self.add_resource_modele([15, 16])
        self.add_res_account_module([18, 19])
        self.user_quit()
        self.login_sysadmin()
        #添加授权用户
        self.add_user_data_module([20, 21, 22, 23, 24])
        self.add_res_group([1])
        self.add_user_group([1])
        self.user_quit()
        self.login_secadmin()
        self.switch_to_moudle(u'运维管理', u'授权')

    def authori_module_post_condition(self):

        self.del_resource_modele([15, 16])
        self.user_quit()
        self.login_sysadmin()
        self.del_res_group([1])
        self.del_user_group([1])
        self.del_user_data_module([20, 21, 22, 23, 24])
        self.user_quit()

#------------------------------命令规则前置条件-----------------------------------

    def commandrule_module_prefix_condition(self):
        self.login_sysadmin()
        #添加用户
        self.add_user_data_module([25])
        self.user_quit()
        self.login_secadmin()
        #添加资源
        self.add_resource_modele([3])
        #添加资源账号
        self.add_res_account_module([4])
        #添加授权
        self.add_authorization_module([2])
        #切换到规则定义
        self.switch_to_moudle(u'运维管理', u'规则定义')
        self.command.click_left_rule(0)

    def commandrule_module_post_condition(self):
        #删除授权
        self.del_authorization_module([2])
        #删除资源
        self.del_resource_modele([3])
        self.user_quit()
        self.login_sysadmin()
        #删除用户
        self.del_user_data_module([25])
        self.user_quit()

#------------------------------时间规则前置条件-----------------------------------

    def timerule_module_prefix_condition(self):
        self.login_secadmin()
        #添加用户
        self.add_user_data_module([26, 27, 28, 29, 30])
        #切换到规则定义
        self.switch_to_moudle(u'运维管理', u'规则定义')
        self.command.click_left_rule(1)

    def timerule_module_post_condition(self):
        #删除用户
        self.del_user_data_module([26, 27, 28, 29, 30])
        self.user_quit()

#------------------------------地址规则前置条件-----------------------------------

    def addressrule_module_prefix_condition(self):
        self.login_secadmin()
        #添加用户
        self.add_user_data_module([31, 32, 33, 34, 35, 36, 37, 38])
        #切换到规则定义
        self.switch_to_moudle(u'运维管理', u'规则定义')
        self.command.click_left_rule(2)

    def addressrule_module_post_condition(self):
        self.del_user_data_module([31, 32, 33, 34, 35, 36, 37, 38])
        self.user_quit()

#------------------------------资源时间规则前置条件-----------------------------------

    def retimerule_module_prefix_condition(self):
        self.login_sysadmin()
        #添加用户
        self.add_user_data_module([39])
        self.user_quit()
        self.login_secadmin()
        #添加资源
        self.add_resource_modele([4, 5, 10])
        #添加资源账号
        self.add_res_account_module([5, 6, 14])
        self.add_authorization_module([6])
        #切换到规则定义
        self.switch_to_moudle(u'运维管理', u'规则定义')
        self.command.click_left_rule(3)

    def retimerule_module_post_condition(self):
        self.user_quit()
        self.login_sysadmin()
        #删除用户
        self.del_user_data_module([39])
        self.user_quit()
        self.login_secadmin()
        #删除资源
        self.del_resource_modele([4, 5, 10])
        #删除授权
        self.del_authorization_module([6])
        self.user_quit()

#------------------------------流程前置条件-----------------------------------

    def process_module_prefix_condition(self):
        self.login_sysadmin()
        #添加用户
        self.add_user_data_module([40, 41, 42, 43, 44])
        self.user_quit()
        self.login_secadmin()
        #添加资源
        self.add_resource_modele([11, 12])
        #添加资源账号
        self.add_res_account_module([15, 16])
        self.add_authrization([1])

    def process_module_post_condition(self):
        #删除授权
        self.del_authorization_module([7])
        #删除资源
        self.del_resource_modele([11, 12])
        self.user_quit()
        self.login_sysadmin()
        #删除用户
        self.del_user_data_module([40, 41, 42, 43, 44])
        self.user_quit()

#------------------------------双人授权前置条件-----------------------------------

    def dualmandate_module_prefix_condition(self):
        self.login_sysadmin()
        #添加用户
        self.add_user_data_module([45, 46])
        self.user_quit()
        self.login_secadmin()
        #添加资源
        self.add_resource_modele([13])
        #添加资源账号
        self.add_res_account_module([17])
        #添加授权
        self.add_authrization([4])

    def dualmandate_module_post_condition(self):
        #删除授权
        self.del_authorization_module([8])
        #删除资源
        self.del_resource_modele([13])
        self.user_quit()
        self.login_sysadmin()
        #删除用户
        self.del_user_data_module([45, 46])
        self.user_quit()

#-----------------------------行为报表前置条件---------------------------------

    def opt_report_module_prefix_condition(self):
        self.login_secadmin()
        self.add_resource_modele([18])
        self.user_quit()
        self.login_sysadmin()
        self.add_user_data_module([47])
        self.add_res_group([2])
        self.add_user_group([2])
        self.user_quit()
        self.login_sysaudit()
        self.switch_to_moudle(u"报表管理", u"审计报表")

    def opt_report_module_post_condition(self):
        self.user_quit()
        self.login_secadmin()
        self.del_resource_modele([18])
        self.user_quit()
        self.login_sysadmin()
        self.del_user_data_module([47])
        self.del_res_group([2])
        self.del_user_group([2])
        self.user_quit()

#-----------------------------配置报表前置条件---------------------------------

    def conf_report_module_prefix_condition(self):
        self.login_sysadmin()
        self.add_user_data_module([48])
        self.add_user_group([3])
        self.user_quit()
        self.login_sysaudit()
        self.switch_to_moudle(u"报表管理", u"审计报表")

    def conf_report_module_post_condition(self):
        self.user_quit()
        self.login_sysadmin()
        self.del_user_data_module([48])
        self.del_user_group([3])
        self.user_quit()

#-----------------------------配置审计前置条件------------------------------

    def system_log_prefix_condition(self):
        self.login_sysadmin()
        self.add_user_data_module([49])
        self.switch_to_moudle(u"系统配置", u"关联服务")
        self.ntp.click_left_moudle(1)
        #填写syslog信息
        self.frameElem.from_frame_to_otherFrame("rigthFrame")
        self.syslog.set_ip("172.16.10.11")
        self.syslog.set_ident("aa")
        self.syslog.save_button()
        self.cmf.click_login_msg_button()
        self.user_quit()
        self.login_sysaudit()
        self.switch_to_moudle(u"审计管理", u"配置审计")

    def system_log_post_condition(self):
        self.user_quit()
        self.login_sysadmin()
        self.del_user_data_module([49])
        self.user_quit()

#-----------------------------运维审计前置条件------------------------------

    def audit_log_prefix_condition(self):
        self.login_and_switch_to_dep()
        self.add_user_data_module([43])
        self.add_resource_modele([22])
        self.add_res_account_module([20])
        self.add_authorization_module([9])
        self.switch_to_operation()
        self.sso_module([1])
        self.user_quit()
        #新添加的运维管理员登录
        self.sso_user_login(43)
        self.sso_module([1])
        #新添加的运维管理员退出
        self.user_quit()
        self.login_and_switch_to_sys()
        self.switch_to_moudle(u"审计管理", u"运维审计")

    def audit_log_post_condition(self):
        self.sys_switch_to_dep()
        self.del_authorization_module([9])
        self.del_resource_modele([22])
        self.del_user_data_module([43])
        self.user_quit()

#------------------------------命令单点登录前置条件----------------------------

    u'''单点登录前置条件'''
    def sso_prefix_condition(self):
        self.login_and_switch_to_dep()
        self.add_resource_modele([1, 3, 4, 5])
        self.add_res_account_module([1, 2, 4, 5, 6, 7])
        self.add_authorization_module([1])
        self.switch_to_operation()
        #self.user_quit()
        #self.login_and_switch_to_common()

    u'''单点登录后置条件'''

    def sso_post_condition(self):
        self.user_quit()
        self.login_and_switch_to_dep()
        self.del_resource_modele([1, 3, 4, 5])
        self.del_authorization_module([1])
        self.user_quit()

#------------------------------windows单点登录前置条件-------------------------

    u'''windows单点登录前置条件'''
    def windows_sso_prefix_condition(self):
        self.login_and_switch_to_sys()
        #配置认证方式
        self.add_meth_method()
        self.add_user_data_module([42])
        self.sys_switch_to_dep()
        #self.login_and_switch_to_dep()
        self.add_resource_modele([2, 7, 8])
        self.add_res_account_module([3, 9, 10])
        self.add_authorization_module([3, 4])
        self.switch_to_operation()
        #self.user_quit()
        #self.login_and_switch_to_common()

    u'''单点登录后置条件'''

    def windows_sso_post_condition(self):
        self.user_quit()
        self.login_and_switch_to_dep()
        self.del_authorization_module([3, 4])
        self.del_user_data_module([42])
        self.del_resource_modele([8, 7, 2])
        self.user_quit()

#------------------------------数据库单点登录前置条件-------------------------

    u'''数据库单点登录前置条件'''
    def database_sso_prefix_condition(self):
        #使用公共用户登录系统
        self.login_and_switch_to_sys()
        #添加应用发布
        self.add_application([2])
        #添加客户端
        self.add_client_module([1, 2])
        self.sys_switch_to_dep()
        self.add_database_res_module([1, 2, 3])
        self.add_res_account_module([11, 12, 13])
        self.add_authorization_module([5])
        self.switch_to_operation()

    u'''数据库单点登录后置条件'''

    def database_sso_post_condition(self):
        self.user_quit()
        self.login_and_switch_to_dep()
        self.del_authorization_module([5])
        self.del_resource_modele([19, 20, 21])
        self.dep_switch_to_sys()
        self.del_application([2])
        self.del_client_module([1, 2])
        self.user_quit()
예제 #34
0
	def __init__(self, driver):
		self.driver = driver
		self.frameElem = frameElement(driver)
		self.resource = Resource(driver)
		self.account = Accountmgr(driver)
예제 #35
0
class testNetworkResource(object):

	def __init__(self, driver):
		self.driver = driver
		self.log = log()
		self.cmf = commonFun(driver)
		self.frameElem = frameElement(driver)
		self.testrole = testRole(driver)
		self.resource = Resource(driver)
		self.net = NetworkResource(driver)

	u'''获取测试数据
	   Parameters:
	      - sheetname:sheet名称
	   return:表格数据
	'''
	def get_network_table_data(self, sheetname):
		dataFile = dataFileName()
		networkPath = dataFile.get_network_resource_test_data_url()
		networkData = dataFile.get_data(networkPath, sheetname)
		return networkData

	u'''添加网络设备资源'''
	def add_network_resource_001(self):

		#日志开始记录
		self.log.log_start("add_network_resource")
		#获取添加网络设备资源测试数据
		networkData = self.get_network_table_data("add_network_resource")
		#保存成功的弹出框
		networkMsg = self.testrole.popup()

		#无检查点的测试项标识,如果为True说明通过
		flag = False

		for dataRow in range(len(networkData)):
			data = networkData[dataRow]
			try:
				#如果不是第一行标题,则读取数据
				if dataRow != 0:
					self.resource.click_add_edit_button()
					self.resource.select_resource_type(data[2])
					self.net.add_edit_network_resource(data)
					self.frameElem.switch_to_content()
					self.cmf.test_win_check_point("xpath", networkMsg, data, flag)
					self.cmf.back()
			except Exception as e:
				print ("add_network_resource fail:" + str(e))

		self.log.log_end("add_network_resource")

	u'''编辑网络设备资源'''
	def edit_network_resource_002(self):

		#日志开始记录
		self.log.log_start("edit_network_resource")
		#获取编辑网络设备资源测试数据
		networkData = self.get_network_table_data("edit_network_resource")
		#保存成功的弹出框
		networkMsg = self.testrole.popup()

		#无检查点的测试项标识,如果为True说明通过
		flag = False

		for dataRow in range(len(networkData)):
			data = networkData[dataRow]
			try:
				#如果不是第一行标题,则读取数据
				if dataRow != 0:
					self.resource.click_add_edit_button(data[2])
					self.net.add_edit_network_resource(data)
					self.frameElem.switch_to_content()
					self.cmf.test_win_check_point("xpath", networkMsg, data, flag)
					self.cmf.back()
			except Exception as e:
				print ("edit_network_resource fail:" + str(e))

		self.log.log_end("edit_network_resource")

	u'''检验网络设备资源'''
	def check_network_resource_003(self):

		#日志开始记录
		self.log.log_start("check_network_resource")
		#获取校验网络设备资源测试数据
		networkData = self.get_network_table_data("check_network_resource")
		#保存成功的弹出框
		networkMsg = self.testrole.popup()

		#无检查点的测试项标识,如果为True说明通过
		flag = False

		#点击添加按钮
		self.resource.click_add_edit_button()
		#选择debian类型
		self.resource.select_resource_type("迈普")

		for dataRow in range(len(networkData)):
			data = networkData[dataRow]
			try:
				#如果不是第一行标题,则读取数据
				if dataRow != 0:
					self.net.check_network_resource(dataRow, data)
					self.frameElem.switch_to_content()
					self.cmf.test_win_check_point("xpath", networkMsg, data, flag)
			except Exception as e:
				print ("check_network_resource fail:" + str(e))

		self.cmf.back()

		self.log.log_end("check_network_resource")
예제 #36
0
class testAuditLog():
	def __init__(self,driver):
		self.driver = driver
		self.log = log()
		self.cmf = commonFun(driver)
		self.getElem = getElement(driver)
		self.cnEnde = cnEncode()
		self.userElem = UserPage(driver)
		self.systemLog = SystemLogPage(self.driver)
		self.auditLog = AuditLogPage(self.driver)
		self.systemLog = SystemLogPage(self.driver)
		self.tableElem = tableElement(self.driver)
		self.selectElem = selectElement(driver)
		self.dataFile = dataFileName()
		self.frameElem = frameElement(self.driver)
		self.resource = Resource(driver)
		self.commonSuite = CommonSuiteData(self.driver)
	
	u'''校验没有弹出框类型用例是否通过
			parameters: 
				data : 检查点
				count :正确的行数
	'''
	def check_without_pop_up(self,count,data):
		#获取行数
		table_count = str(self.systemLog.get_table_count())
		if count == table_count:
			self.cmf.test_win_check_point("","",data,True)
		else:
			self.cmf.test_win_check_point("","",data,False)

	u'''获取测试数据
		Parameters:
			- sheetname:sheet名称
			return:表格数据
	'''
	def get_table_data(self,sheetname):
		dataFile = dataFileName()
		filePath = dataFile.get_audit_log_test_url()
		queryData = dataFile.get_data(filePath,sheetname)
		return queryData

	u'''运维审计检索功能'''
	def Audit_log_query_001(self):#query_type
		#日志开始记录
		self.log.log_start("AuditLogQuery_001")
		#获取配置审计检索的数据
		ad_data = self.get_table_data("audit_log_query")
		#无检查点的测试项标识,如果为True说明通过
		flag = False
		for dataRow in range(len(ad_data)):
			data = ad_data[dataRow]
			try:
				#如果不是第一行标题,则读取数据
				if dataRow != 0 :
					self.auditLog.select_date(data[2])
					if data[3] != "":
						self.auditLog.select_depmt(data[3])
					if data[4] != "":
						self.auditLog.click_select_audit()
						self.auditLog.select_audit(data[4])
					if data[2] == "":
						self.auditLog.click_high_level(data[17])
						self.auditLog.select_audit_type(data[5])
						if data[6] != "":
							self.resource.query_type(data[6],data[7],data[8])
						self.auditLog.set_res_account(data[9])
						self.auditLog.set_user_name(data[10])
						self.auditLog.set_client_ip(data[11])
						self.userElem.set_start_time(data[12])
						self.userElem.set_end_time(data[13])
						self.auditLog.set_key_word(data[14])
						self.auditLog.set_source_ip(data[15])
						self.auditLog.set_user_account(data[16])
					self.auditLog.click_search()
					#判断测试项是否通过
					self.check_without_pop_up(data[18],data)
					#清空标识状态
					flag = False
					self.frameElem.from_frame_to_otherFrame("mainFrame")
					self.userElem.click_reset_button()
			except Exception as e:
				print ("Audit Log query fail: ") + str(e)
		self.log.log_end("AuditLogQuery_001")
예제 #37
0
class Flowcontrol(object):
	def __init__(self, driver):
		self.driver = driver
		self.getElem = getElement(driver)
		self.selectElem = selectElement(driver)
		self.frameElem = frameElement(driver)
		self.cmf = commonFun(driver)
		self.cnEn = cnEncode()
		self.resource = Resource(driver)

	u'''查询审批状态
	   Parameters:
	      - status:审批状态文本
	'''
	def query_approval_status(self, status):
		self.frameElem.from_frame_to_otherFrame("mainFrame")
		statu = self.cnEn.is_float(status)
		selem = self.getElem.find_element_with_wait_EC("id", "fortApprovalStatus")
		self.selectElem.select_element_by_visible_text(selem, statu)

	u'''查询申请类型
	   Parameters:
	      - type:申请类型value值-1代表请选择,0代表双人授权,1代表访问审批,2代表命令审批,3代表审计下载审批
	'''
	def query_application_type(self, type):
		self.frameElem.from_frame_to_otherFrame("mainFrame")
		value = self.cnEn.is_float(type)
		selem = self.getElem.find_element_with_wait_EC("id", "fortApplyType")
		self.selectElem.select_element_by_value(selem, value)

	u'''查询申请人
	   Parameters:
	      - aplname:申请人名称
	'''
	def query_applicant(self, aplname):
		self.frameElem.from_frame_to_otherFrame("mainFrame")
		name = self.cnEn.is_float(aplname)
		self.getElem.find_element_wait_and_clear("id", "fortApplicantName")
		self.getElem.find_element_wait_and_sendkeys("id", "fortApplicantName", name)

	u'''查询审批人
	   Parameters:
	      - approver:审批人名称
	'''
	def query_approver(self, approver):
		self.frameElem.from_frame_to_otherFrame("mainFrame")
		name = self.cnEn.is_float(approver)
		self.getElem.find_element_wait_and_clear("id", "fortApproverName")
		self.getElem.find_element_wait_and_sendkeys("id", "fortApproverName", name)

	u'''查询目标IP
	   Parameters:
	      - targetip:目标IP
	'''
	def query_targetip(self, targetip):
		self.frameElem.from_frame_to_otherFrame("mainFrame")
		target= self.cnEn.is_float(targetip)
		self.getElem.find_element_wait_and_clear("id", "fortResourceIp")
		self.getElem.find_element_wait_and_sendkeys("id", "fortResourceIp", target)

	u'''查询流程号
	   Parameters:
	      - number:流程号
	'''
	def query_process_number(self, number):
		self.frameElem.from_frame_to_otherFrame("mainFrame")
		processid = self.cnEn.is_float(number)
		self.getElem.find_element_wait_and_clear("id", "fortProcessApprovalId")
		self.getElem.find_element_wait_and_sendkeys("id", "fortProcessApprovalId", processid)

	u'''查询部门
	   Parameters:
	      - deptname:部门名称
	'''
	def query_process_depart(self, deptname):
		self.frameElem.from_frame_to_otherFrame("mainFrame")
		depart = self.cnEn.is_float(deptname)
		time.sleep(4)
		self.resource.select_depart_common("department_name", "tree_1_switch", depart)

	u'''查询审批时间
	   Parameters:
	      - year:年的value值
	      - month:月的value值
	      - day:日的value值
	'''
	def query_time(self, year, month='no', day='no'):
		self.frameElem.from_frame_to_otherFrame("mainFrame")
		y = self.cnEn.is_float(year)
		yselem = self.getElem.find_element_with_wait_EC("id", "fortLogYear")
		self.selectElem.select_element_by_value(yselem, y)
		if month != 'no':
			m = self.cnEn.is_float(month)
			if int(m) < 10:
				m = '0' + str(m)

			dselem = self.getElem.find_element_with_wait_EC("id", "fortLogMonth")
			self.selectElem.select_element_by_value(dselem, m)
		if day != 'no':
			d = self.cnEn.is_float(day)
			selem = self.getElem.find_element_with_wait_EC("id", "fortLogDay")
			self.selectElem.select_element_by_value(selem, d)

	u'''点击高级'''
	def click_advanced(self):
		self.frameElem.from_frame_to_otherFrame("mainFrame")
		self.getElem.find_element_wait_and_click_EC("id", "btn_qh")

	u'''点击检索'''
	def click_process_search(self):
		self.frameElem.from_frame_to_otherFrame("mainFrame")
		self.getElem.find_element_wait_and_click_EC("id", "quick_check")

	u'''点击重置'''
	def click_process_reset(self):
		self.frameElem.from_frame_to_otherFrame("mainFrame")
		self.getElem.find_element_wait_and_click_EC("id", "resetting")

	u'''流程任务查询
	   Parameters:
	      - data:excel一行数据集
	'''
	def query_process_task(self, data):
		self.driver.implicitly_wait(5)
		self.cmf.select_menu(u"流程控制", u"流程任务")
		self.click_advanced()
		if data[2] != 'no':
			self.query_approval_status(data[2])
		if data[3] != 'no':
			self.query_applicant(data[3])
		if data[4] != 'no':
			self.query_process_depart(data[4])
		if data[5] != 'no':
			self.query_process_number(data[5])
		if data[6] != 'no':
			self.query_application_type(data[6])
		if data[7] != 'no':
			self.query_targetip(data[7])
		if data[8] != 'no':
			self.query_time(data[8], data[9], data[10])
		self.click_process_search()
		self.click_process_reset()

	u'''申请历史查询
	   Parameters:
	      - data:excel一行数据集
	'''
	def query_apply_history(self, data):
		self.driver.implicitly_wait(5)
		self.cmf.select_menu(u"流程控制", u"申请历史")
		self.click_advanced()
		if data[1] != 'no':
			self.query_approval_status(data[1])
		if data[2] != 'no':
			self.query_approver(data[2])
		if data[3] != 'no':
			self.query_targetip(data[3])
		if data[4] != 'no':
			self.query_process_number(data[4])
		if data[5] != 'no':
			self.query_application_type(data[5])
		if data[6] != 'no':
			self.query_time(data[6], data[7], data[8])
		self.click_process_search()
		self.click_process_reset()

	u'''个人历史查询
	   Parameters:
	      - data:excel一行数据集
	'''
	def query_personal_history(self, data):
		self.driver.implicitly_wait(5)
		self.cmf.select_menu(u"流程控制", u"个人历史")
		self.query_common(data)

	u'''全部历史查询
	   Parameters:
	      - data:excel一行数据集
	'''
	def query_all_history(self, data):
		self.driver.implicitly_wait(5)
		self.cmf.select_menu(u"流程控制", u"全部历史")
		self.query_common(data)

	u'''部门历史查询
	   Parameters:
	      - data:excel一行数据集
	'''
	def query_department_history(self, data):
		self.driver.implicitly_wait(5)
		self.cmf.select_menu(u"流程控制", u"部门历史")
		self.query_common(data)

	u'''查询公共方法
	   Parameters:
	      - data:excel一行数据集
	'''
	def query_common(self, data):
		self.click_advanced()
		if data[2] != 'no':
			self.query_approval_status(data[2])
		if data[3] != 'no':
			self.query_applicant(data[3])
		if data[4] != 'no':
			self.query_approver(data[4])
		if data[5] != 'no':
			self.query_process_depart(data[5])
		if data[6] != 'no':
			self.query_process_number(data[6])
		if data[7] != 'no':
			self.query_targetip(data[7])
		if data[8] != 'no':
			self.query_application_type(data[8])
		if data[9] != 'no':
			self.query_time(data[9], data[10], data[11])
		self.click_process_search()
		self.click_process_reset()
예제 #38
0
class NetworkResource(object):

	def __init__(self, driver):
		self.driver = driver
		self.getElem = getElement(driver)
		self.selectElem = selectElement(driver)
		self.frameElem = frameElement(driver)
		self.resource = Resource(driver)
		self.cnEn = cnEncode()

	u'''添加和编辑网络设备资源
	   Parameters:
	      - data:excel中的一行数据
	'''
	def add_edit_network_resource(self, data):
		self.frameElem.from_frame_to_otherFrame("mainFrame")
		#资源名称
		if data[3] != 'no':
			self.resource.set_resource_name(data[3])
		#资源ip
		if data[5] != 'no':
			self.resource.set_resource_ip(data[5])
		#从IP
		if data[6] != 'no':
			self.resource.set_resource_fortIps(data[6])
		#归属部门
		if data[4] != 'no':
			self.resource.set_depart(data[4])

		self.resource.select_all_agreement()
		#系统版本
		if data[7] != 'no':
			self.resource.set_sys_version(data[7])
		#改密驱动名称
		if data[8] != 'no':
			self.resource.set_changePwd_driver(data[8])

		#管理员帐号
		if data[9] != 'no':
			self.resource.click_account_sync()
			self.resource.set_admin_account(data[9])
		#管理员口令
		if data[10] != 'no':
			self.resource.set_admin_pwd(data[10])
		#口令确认
		if data[11] != 'no':
			self.resource.set_confirm_pwd(data[11])
		#提权
		if data[12] != 'no':
			self.resource.click_up_super()
			#提权账号口令
			self.resource.set_super_pwd(data[12])
			#确认口令
			self.resource.set_super_confirm_pwd(data[13])
		self.resource.click_save_button()

	u'''校验网络设备资源
	   Parameters:
	      - datarow:excel数据位于第几行
	      - data:excel中的一行数据
	'''
	def check_network_resource(self, datarow, data):
		self.frameElem.from_frame_to_otherFrame("mainFrame")
		#资源名称
		self.resource.set_resource_name(data[2])
		#资源ip
		self.resource.set_resource_ip(data[3])
		#协议类型
		if data[4] != 'no':
			self.resource.select_agreement(data[4])
		#协议类型 端口
		if datarow == 7:
			self.resource.set_port(data[4], data[5])
		if datarow == 8:
			self.resource.clear_port("Ssh2")
		if datarow == 9:
			self.resource.set_port("Ssh2", data[5])
		if datarow == 12:
			self.resource.click_account_sync()
			self.resource.click_up_super()
		if datarow == 13:
			#提权账号口令
			if data[6] != 'no':
				self.resource.set_super_pwd(data[6])
			#确认口令
			if data[7] != 'no':
				self.resource.set_super_confirm_pwd(data[7])
			self.resource.set_super_prompt()
		self.resource.click_save_button()

	u'''选择telnet登录模式
	   Parameters:
	      - mode:value属性
	'''
	def telnet_login_type(self, mode):
		model = self.cnEn.is_float(mode)
		self.frameElem.from_frame_to_otherFrame("mainFrame")
		selectelem = self.getElem.find_element_with_wait_EC("id", "fortInputModelTelnet")
		self.selectElem.select_element_by_value(selectelem, model)

	u'''勾选匿名认证'''
	def check_anonymous(self):
		self.frameElem.from_frame_to_otherFrame("mainFrame")
		self.getElem.find_element_wait_and_click_EC("id", "anonymous_auth")