2016-08-08 12:39:13 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
2016-08-19 15:48:02 +02:00
|
|
|
from include.common_classes_60 import PandoraWebDriverTestCase
|
2016-08-22 11:09:42 +02:00
|
|
|
from include.common_functions_60 import login, detect_and_pass_all_wizards, gen_random_string, is_enterprise
|
2016-08-19 15:48:02 +02:00
|
|
|
from include.policy_functions import *
|
|
|
|
from include.agent_functions import *
|
|
|
|
from include.collection_functions import *
|
2016-08-08 12:39:13 +02:00
|
|
|
from selenium import webdriver
|
|
|
|
from selenium.webdriver.common.by import By
|
|
|
|
from selenium.webdriver.common.keys import Keys
|
|
|
|
from selenium.webdriver.support.ui import Select
|
|
|
|
from selenium.common.exceptions import NoSuchElementException
|
|
|
|
from selenium.common.exceptions import NoAlertPresentException
|
|
|
|
from selenium.webdriver.remote.webelement import WebElement
|
2016-09-19 15:14:01 +02:00
|
|
|
import unittest2, time, re
|
2016-08-08 12:39:13 +02:00
|
|
|
|
|
|
|
class Policies(PandoraWebDriverTestCase):
|
|
|
|
|
|
|
|
test_name = u'Policies'
|
|
|
|
test_description = u'Policy tests'
|
|
|
|
tickets_associated = []
|
|
|
|
|
|
|
|
policy_name = gen_random_string(6)
|
|
|
|
network_server_module_name = gen_random_string(6)
|
|
|
|
|
|
|
|
|
2016-08-22 11:09:32 +02:00
|
|
|
@is_enterprise
|
2016-08-16 15:04:37 +02:00
|
|
|
def test_A_create_policy(self):
|
|
|
|
|
|
|
|
u"""
|
|
|
|
Create a policy and verify that it is created
|
|
|
|
"""
|
2016-08-08 12:39:13 +02:00
|
|
|
driver = self.driver
|
2016-08-08 19:01:42 +02:00
|
|
|
self.login()
|
2016-08-10 15:17:40 +02:00
|
|
|
detect_and_pass_all_wizards(driver)
|
2016-08-08 12:39:13 +02:00
|
|
|
|
|
|
|
create_policy(driver,self.policy_name,"Applications",description="Policy for test")
|
|
|
|
|
|
|
|
search_policy(driver,self.policy_name,go_to_policy=False)
|
|
|
|
|
|
|
|
element = driver.find_element_by_xpath('//a[contains(.,"'+self.policy_name+'")]')
|
|
|
|
self.assertIsInstance(element,WebElement)
|
|
|
|
|
2016-08-16 15:04:37 +02:00
|
|
|
|
2016-08-22 11:09:32 +02:00
|
|
|
@is_enterprise
|
2016-08-16 15:04:37 +02:00
|
|
|
def test_B_add_network_server_module_to_policy(self):
|
|
|
|
|
|
|
|
u"""
|
|
|
|
Add network server module to previous policy
|
|
|
|
"""
|
2016-08-08 12:39:13 +02:00
|
|
|
driver = self.driver
|
|
|
|
|
|
|
|
add_module_policy(driver,self.policy_name,"network_server",driver,module_name=self.network_server_module_name,component_group="Network Management",network_component="Host Alive")
|
|
|
|
|
2016-08-08 13:22:45 +02:00
|
|
|
element = driver.find_element_by_xpath('//td[contains(.,"uccessfully")]')
|
2016-08-08 12:39:13 +02:00
|
|
|
self.assertIsInstance(element,WebElement)
|
|
|
|
|
2016-08-16 15:04:37 +02:00
|
|
|
|
2016-08-22 11:09:32 +02:00
|
|
|
@is_enterprise
|
2016-08-16 15:04:37 +02:00
|
|
|
def test_C_add_collection_to_policy(self):
|
|
|
|
|
|
|
|
u"""
|
|
|
|
Create policy, create collection and add collection to policy
|
|
|
|
"""
|
|
|
|
|
|
|
|
policy_name = gen_random_string(6)
|
|
|
|
collection_name = gen_random_string(6)
|
|
|
|
|
|
|
|
|
|
|
|
driver = self.driver
|
|
|
|
|
|
|
|
create_policy(driver,policy_name,"Applications",description="Policy for test")
|
|
|
|
|
|
|
|
create_collection(driver,collection_name,collection_name,group="All",description="Collection for test")
|
|
|
|
|
|
|
|
add_collection_to_policy(driver,policy_name,collection_name)
|
|
|
|
|
|
|
|
element = driver.find_element_by_xpath('//td[contains(.,"Correct: add the collection in the policy")]')
|
|
|
|
self.assertIsInstance(element,WebElement)
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-08-22 11:09:32 +02:00
|
|
|
@is_enterprise
|
2016-08-16 15:04:37 +02:00
|
|
|
def test_D_Apply_policy_to_agents(self):
|
|
|
|
|
|
|
|
u"""
|
|
|
|
Create two agent, create a policy, create two modules in policy and apply policy in new agents, check that modules is created in agents
|
|
|
|
"""
|
|
|
|
|
|
|
|
policy_name = gen_random_string(6)
|
|
|
|
agent_name_1 = gen_random_string(6)
|
|
|
|
agent_name_2 = gen_random_string(6)
|
|
|
|
module_name_1 = gen_random_string(6)
|
|
|
|
module_name_2 = gen_random_string(6)
|
|
|
|
|
|
|
|
driver = self.driver
|
|
|
|
|
|
|
|
create_agent(driver,agent_name_1,description="First agent by test")
|
|
|
|
create_agent(driver,agent_name_2,description="Second agent 2 by test")
|
|
|
|
|
|
|
|
create_policy(driver,policy_name,"Applications",description="This is policy by test")
|
|
|
|
|
|
|
|
add_module_policy(driver,policy_name,"network_server",driver,module_name=module_name_1,component_group="Network Management",network_component="Host Alive")
|
|
|
|
|
|
|
|
add_module_policy(driver,policy_name,"network_server",driver,module_name=module_name_2,component_group="Network Management",network_component="Host Latency")
|
|
|
|
|
|
|
|
list_agent = (agent_name_1,agent_name_2)
|
|
|
|
apply_policy_to_agent(driver,policy_name,list_agent)
|
|
|
|
|
|
|
|
search_agent(driver,agent_name_1,go_to_agent=True)
|
|
|
|
driver.find_element_by_xpath('//*[@id="menu_tab"]/ul/li[1]/a/img').click()
|
|
|
|
|
|
|
|
driver.find_element_by_xpath('//*[@id="menu_tab"]/ul/li[3]/a/img').click()
|
|
|
|
|
|
|
|
module = driver.find_element_by_xpath('//td[contains(.,"'+module_name_1+'")]')
|
|
|
|
self.assertIsInstance(module,WebElement)
|
|
|
|
|
|
|
|
module = driver.find_element_by_xpath('//td[contains(.,"'+module_name_2+'")]')
|
|
|
|
self.assertIsInstance(module,WebElement)
|
|
|
|
|
|
|
|
search_agent(driver,agent_name_2,go_to_agent=True)
|
|
|
|
driver.find_element_by_xpath('//*[@id="menu_tab"]/ul//img[@data-title="Manage"]').click()
|
|
|
|
|
|
|
|
driver.find_element_by_xpath('//ul[@class="mn"]/li/a/img[@data-title="Modules"]').click()
|
|
|
|
|
|
|
|
module = driver.find_element_by_xpath('//td[contains(.,"'+module_name_1+'")]')
|
|
|
|
self.assertIsInstance(module,WebElement)
|
|
|
|
|
|
|
|
module = driver.find_element_by_xpath('//td[contains(.,"'+module_name_2+'")]')
|
|
|
|
self.assertIsInstance(module,WebElement)
|
|
|
|
|
2016-08-08 12:39:13 +02:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2016-09-19 15:14:01 +02:00
|
|
|
unittest2.main()
|