Пример #1
0
	def test_A_create_network_component(self):

		u"""
		Create and search new network component module
		"""

		logging.basicConfig(filename="Network_components.log", level=logging.INFO, filemode='w')	
	
		driver = self.driver
		self.login()
		detect_and_pass_all_wizards(driver)
		
		agent_name = gen_random_string(6)
		network_component_name = gen_random_string(6)

		activate_api(driver,"1234")

		params = [agent_name,"127.0.0.1","0","4","0","300","2","pandorafms","2","0","0","pruebas"]
		create_agent_api(driver,params,user="******",pwd="pandora")

		lista = driver.current_url.split('/')

		url = lista[0]+'//'+lista[2]+'/pandora_console'

		driver.get(url)
			
		create_network_component(driver,network_component_name,"Remote TCP network agent, boolean data","Network Management","Application",min_warning=10,max_critical=100,description="New network component by test")

		search_agent(driver,agent_name,go_to_agent=True)

		driver.find_element_by_xpath('//ul[@class="mn"]/li/a/img[@data-title="Manage"]').click()
		driver.find_element_by_xpath('//ul[@class="mn"]/li/a/img[@data-title="Modules"]').click()

		Select(driver.find_element_by_id("moduletype")).select_by_visible_text("Create a new network server module")

		driver.find_element_by_xpath('//*[@id="main"]/form/table/tbody/tr/td[5]/input').click()

		driver.find_element_by_xpath('//a[contains(.,"Advanced options")]').click()

		Select(driver.find_element_by_id("network_component_group")).select_by_visible_text("Network Management")

		time.sleep(3)
			
		Select(driver.find_element_by_id("network_component")).select_by_visible_text(network_component_name)

		driver.find_element_by_id("submit-crtbutton").click()

		search_module (driver,agent_name,network_component_name,go_to_module=False)

		self.assertEqual(network_component_name in driver.page_source,True)

		logging.info("test_A_create_network_component is correct")
Пример #2
0
	def test_D_plugin_component_with_parameters(self):
	
		u"""
		Create and search new plug-in component with parameters
		"""

		driver = self.driver
	
		agent_name = gen_random_string(6)
		plugin_component_name = gen_random_string(6)

		activate_api(driver,"1234")

		params = [agent_name,"127.0.0.1","0","4","0","300","2","pandorafms","2","0","0","pruebas"]
		create_agent_api(driver,params,user="******",pwd="pandora")

		lista = driver.current_url.split('/')
		
		url = lista[0]+'//'+lista[2]+'/pandora_console'
		
		driver.get(url)
		
		create_plugin_component(driver,plugin_component_name,"Generic numeric","Network Management","Application",description="New plugin component",plugin="UDP port check",target_ip="127.0.0.1",port="80")
		
		search_agent(driver,agent_name,go_to_agent=True)

		driver.find_element_by_xpath('//ul[@class="mn"]/li/a/img[@data-title="Manage"]').click()
		driver.find_element_by_xpath('//ul[@class="mn"]/li/a/img[@data-title="Modules"]').click()

		Select(driver.find_element_by_id("moduletype")).select_by_visible_text("Create a new plug-in server module")
					
		driver.find_element_by_xpath('//*[@id="main"]/form/table/tbody/tr/td[5]/input').click()

		driver.find_element_by_xpath('//a[contains(.,"Advanced options")]').click()

		Select(driver.find_element_by_id("network_component_group")).select_by_visible_text("Network Management")

		time.sleep(3)
		
		Select(driver.find_element_by_id("network_component")).select_by_visible_text(plugin_component_name)
			
		self.assertEqual("80" in driver.page_source,True)
	
		driver.find_element_by_id("submit-crtbutton").click()
		
		search_module (driver,agent_name,plugin_component_name)
		
		self.assertEqual(plugin_component_name in driver.page_source,True)

		logging.info("test_D_plugin_component_with_parameters is correct")
Пример #3
0
    def test_C_edit_agent_description_bulk_operation(self):
        u"""
		Create two agents and edit description with bulk operation
		"""

        agent_name_1 = gen_random_string(6)
        agent_name_2 = gen_random_string(6)

        driver = self.driver

        activate_api(driver, "1234")

        params = [
            agent_name_1, "127.0.0.1", "0", "4", "0", "300", "2", "pandorafms",
            "2", "0", "0", "pruebas"
        ]
        create_agent_api(driver, params, user="******", pwd="pandora")

        params = [
            agent_name_2, "127.0.0.1", "0", "4", "0", "300", "2", "pandorafms",
            "2", "0", "0", "pruebas"
        ]
        create_agent_api(driver, params, user="******", pwd="pandora")

        lista = driver.current_url.split('/')

        url = lista[0] + '//' + lista[2] + '/pandora_console'

        driver.get(url)

        agent_names_list = [agent_name_1, agent_name_2]

        edit_agents_in_bulk(
            driver,
            agent_names_list,
            new_description="test C edit description bulk operation")
        self.assertRegexpMatches(self.close_alert_and_get_its_text(),
                                 r"^Are you sure[\s\S]$")
        self.assertEqual(
            self.driver.find_element_by_xpath(
                '//div[@id="main"]//td[contains(.,"Agents updated successfully(2)")]'
            ).text, "Agents updated successfully(2)")

        search_agent(driver, agent_name_1, go_to_agent=True)

        self.assertEqual(
            "test C edit description bulk operation" in driver.page_source,
            True)

        logging.info("test_C_edit_agent_description_bulk_operation is correct")
Пример #4
0
    def test_ACL_propagation(self):
        u"""
		ACL Propagation test: Creates one group "A" with ACL propagation, then a group "B" son of "A" with no ACL propagation, and finally group "C".
		The test asserts if a user with privileges to "A" can see the agent of "B" but no agents of "C".
		"""
        group_name_A = gen_random_string(6)
        group_name_B = gen_random_string(6)
        group_name_C = gen_random_string(6)
        agent_name_A = gen_random_string(6)
        agent_name_B = gen_random_string(6)
        user_name = gen_random_string(6)

        driver = self.driver
        self.login()
        detect_and_pass_all_wizards(driver)

        create_agent_group(
            driver,
            group_name_A,
            propagate_acl=True,
            description="Group A, with propagate ACL, son of ALL")
        create_agent_group(driver,
                           group_name_B,
                           parent_group=group_name_A,
                           description="Group B, son of A")
        create_agent_group(driver,
                           group_name_C,
                           parent_group=group_name_B,
                           description="Group C, son of B")

        create_agent(driver,
                     agent_name_A,
                     description="Agent in group B",
                     group=group_name_B)

        create_agent(driver,
                     agent_name_B,
                     description="Agent in group C",
                     group=group_name_C)

        l = [("Chief Operator", group_name_A, [])]

        create_user(driver, user_name, "pandora", profile_list=l)

        self.logout()

        self.login(user=user_name)

        detect_and_pass_all_wizards(driver)

        #Is the agent listed in the agent list?
        search_agent(driver, agent_name_A, go_to_agent=False)
        element = driver.find_element_by_xpath('//a[contains(.,"' +
                                               agent_name_A + '")]')
        self.assertIsInstance(element, WebElement)

        #Is the agent accesible for the user?
        search_agent(driver, agent_name_A, go_to_agent=True)
        element = driver.find_element_by_xpath(
            '//*[@id="agent_contact_main"]/thead/tr/th')
        self.assertIsInstance(element, WebElement)

        #Is the agent invisible to the user? (It should be invisible)
        search_agent(driver, agent_name_B, go_to_agent=False)
        element = driver.find_elements_by_xpath('//a[contains(.,"' +
                                                agent_name_B + '")]')
        self.assertEqual(element, [])
Пример #5
0
    def test_ACL_tag(self):
        u"""Create agent and two modules, one without tag and with tag, create a user with tag and check this user can view module with tag and user can´t view module without tag"""

        agent_name = gen_random_string(6)
        module_name_A = gen_random_string(6)
        module_name_B = gen_random_string(6)
        user_name = gen_random_string(6)

        driver = self.driver
        self.login()
        detect_and_pass_all_wizards(driver)

        create_agent(driver,
                     agent_name,
                     group="Applications",
                     ip="192.168.50.50")

        #We create a module without a tag

        create_module("network_server",
                      driver,
                      agent_name=agent_name,
                      module_name=module_name_A,
                      component_group="Network Management",
                      network_component="Host Alive",
                      ip="192.168.50.50")

        #We now create a modulo with tag "critical"

        create_module("network_server",
                      driver,
                      agent_name=agent_name,
                      module_name=module_name_B,
                      component_group="Network Management",
                      network_component="Host Alive",
                      ip="192.168.50.50",
                      tag_name="critical")

        l = [("Operator (Read)", "All", ["critical"])]

        create_user(driver, user_name, "pandora", profile_list=l)

        self.logout()

        self.login(user=user_name)

        detect_and_pass_all_wizards(driver)

        search_agent(driver, agent_name)

        time.sleep(6)

        #The user should be able to see the module with Tag
        module = driver.find_element_by_xpath('//td[contains(.,"' +
                                              module_name_B + '")]')
        self.assertIsInstance(module, WebElement)

        #The user should NOT be able to see the module without tag
        modules = driver.find_elements_by_xpath('//td[contains(.,"' +
                                                module_name_A + '")]')
        self.assertEqual(modules, [])