mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-10 15:34:56 +02:00
Moving forward to 2.0 Framework
This commit is contained in:
parent
af5b3ec31f
commit
bbe02ab8ff
@ -1,71 +0,0 @@
|
|||||||
"""
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
from include.common_classes_60 import PandoraWebDriverTestCase
|
|
||||||
from include.common_functions_60 import login, click_menu_element, detect_and_pass_all_wizards, logout
|
|
||||||
from include.module_functions import create_module
|
|
||||||
from include.agent_functions import create_agent_group
|
|
||||||
from include.policy_functions import *
|
|
||||||
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
|
|
||||||
import unittest, time, re
|
|
||||||
|
|
||||||
class PAN10(PandoraWebDriverTestCase):
|
|
||||||
|
|
||||||
test_name = u'PAN_10'
|
|
||||||
test_description = u'Policy tests'
|
|
||||||
tickets_associated = []
|
|
||||||
|
|
||||||
def test_1_create_policy(self):
|
|
||||||
|
|
||||||
driver = self.driver
|
|
||||||
login(driver)
|
|
||||||
detect_and_pass_all_wizards(driver)
|
|
||||||
|
|
||||||
create_policy(driver,"policy_PAN_10","Applications",description="Policy for test PAN_10")
|
|
||||||
|
|
||||||
search_policy(driver,"policy_PAN_10",go_to_policy=False)
|
|
||||||
|
|
||||||
time.sleep(6)
|
|
||||||
|
|
||||||
try:
|
|
||||||
element = driver.find_element_by_xpath('//a[contains(.,"policy_PAN_10")]')
|
|
||||||
self.assertIsInstance(element,WebElement)
|
|
||||||
|
|
||||||
except AssertionError as e:
|
|
||||||
self.verificationErrors.append(str(e))
|
|
||||||
|
|
||||||
except NoSuchElementException as e:
|
|
||||||
self.verificationErrors.append(str(e))
|
|
||||||
|
|
||||||
def test_2_add_module_policy(self):
|
|
||||||
|
|
||||||
driver = self.driver
|
|
||||||
login(driver)
|
|
||||||
detect_and_pass_all_wizards(driver)
|
|
||||||
|
|
||||||
add_module_policy(driver,"policy_PAN_10","network_server",driver,module_name="PAN10",component_group="Network Management",network_component="Host Alive")
|
|
||||||
|
|
||||||
search_policy(driver,"policy_PAN_10")
|
|
||||||
|
|
||||||
driver.find_element_by_xpath('//*[@id="menu_tab"]/ul/li[2]/a/img').click()
|
|
||||||
|
|
||||||
time.sleep(6)
|
|
||||||
|
|
||||||
try:
|
|
||||||
element = driver.find_element_by_xpath('//a[contains(.,"PAN10")]')
|
|
||||||
self.assertIsInstance(element,WebElement)
|
|
||||||
|
|
||||||
except AssertionError as e:
|
|
||||||
self.verificationErrors.append(str(e))
|
|
||||||
|
|
||||||
except NoSuchElementException as e:
|
|
||||||
self.verificationErrors.append(str(e))
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
unittest.main()
|
|
||||||
"""
|
|
@ -1,26 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
from include.common_classes_60 import PandoraWebDriverTestCase
|
|
||||||
from include.common_functions_60 import login, click_menu_element, detect_and_pass_all_wizards
|
|
||||||
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
|
|
||||||
import unittest, time, re
|
|
||||||
|
|
||||||
class PAN1(PandoraWebDriverTestCase):
|
|
||||||
test_name = u'PAN_1'
|
|
||||||
test_description = u'Tests that an Administrator user can access the Setup'
|
|
||||||
tickets_associated = []
|
|
||||||
|
|
||||||
def test_pan1(self):
|
|
||||||
driver = self.driver
|
|
||||||
self.login()
|
|
||||||
detect_and_pass_all_wizards(driver)
|
|
||||||
click_menu_element(driver,"General Setup")
|
|
||||||
self.assertEqual("IP list with API access", driver.find_element_by_id("table2-15-0").text)
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
unittest.main()
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from include.common_classes_60 import PandoraWebDriverTestCase
|
from include.common_classes_60 import PandoraWebDriverTestCase
|
||||||
from include.common_functions_60 import login, detect_and_pass_all_wizards, gen_random_string
|
from include.common_functions_60 import login, detect_and_pass_all_wizards, gen_random_string, is_enterprise
|
||||||
from include.policy_functions import *
|
from include.policy_functions import *
|
||||||
|
from include.agent_functions import *
|
||||||
from selenium import webdriver
|
from selenium import webdriver
|
||||||
from selenium.webdriver.common.by import By
|
from selenium.webdriver.common.by import By
|
||||||
from selenium.webdriver.common.keys import Keys
|
from selenium.webdriver.common.keys import Keys
|
||||||
@ -20,8 +21,13 @@ class Policies(PandoraWebDriverTestCase):
|
|||||||
policy_name = gen_random_string(6)
|
policy_name = gen_random_string(6)
|
||||||
network_server_module_name = gen_random_string(6)
|
network_server_module_name = gen_random_string(6)
|
||||||
|
|
||||||
def test_1_create_policy(self):
|
|
||||||
|
|
||||||
|
@is_enterprise
|
||||||
|
def test_A_create_policy(self):
|
||||||
|
|
||||||
|
u"""
|
||||||
|
Create a policy and verify that it is created
|
||||||
|
"""
|
||||||
driver = self.driver
|
driver = self.driver
|
||||||
self.login()
|
self.login()
|
||||||
detect_and_pass_all_wizards(driver)
|
detect_and_pass_all_wizards(driver)
|
||||||
@ -33,8 +39,13 @@ class Policies(PandoraWebDriverTestCase):
|
|||||||
element = driver.find_element_by_xpath('//a[contains(.,"'+self.policy_name+'")]')
|
element = driver.find_element_by_xpath('//a[contains(.,"'+self.policy_name+'")]')
|
||||||
self.assertIsInstance(element,WebElement)
|
self.assertIsInstance(element,WebElement)
|
||||||
|
|
||||||
def test_2_add_network_server_module_to_policy(self):
|
|
||||||
|
|
||||||
|
@is_enterprise
|
||||||
|
def test_B_add_network_server_module_to_policy(self):
|
||||||
|
|
||||||
|
u"""
|
||||||
|
Add network server module to previous policy
|
||||||
|
"""
|
||||||
driver = self.driver
|
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")
|
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")
|
||||||
@ -43,5 +54,79 @@ class Policies(PandoraWebDriverTestCase):
|
|||||||
self.assertIsInstance(element,WebElement)
|
self.assertIsInstance(element,WebElement)
|
||||||
|
|
||||||
|
|
||||||
|
@is_enterprise
|
||||||
|
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)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@is_enterprise
|
||||||
|
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)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
@ -15,10 +15,7 @@ is_enterprise = '1' == getenv('ENTERPRISE', False)
|
|||||||
|
|
||||||
a = TestLoader()
|
a = TestLoader()
|
||||||
|
|
||||||
if is_enterprise:
|
|
||||||
tests = a.discover(start_dir='console',pattern='*.py')
|
tests = a.discover(start_dir='console',pattern='*.py')
|
||||||
else:
|
|
||||||
tests = a.discover(start_dir='console',pattern='PAN*.py')
|
|
||||||
|
|
||||||
c = ArticaTestResult()
|
c = ArticaTestResult()
|
||||||
tests.run(c)
|
tests.run(c)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user