Fixed create_user function and test PAN4 is completed

(cherry picked from commit db89ef2861)
This commit is contained in:
cesar991 2016-06-17 12:20:36 +02:00
parent f5874b22e3
commit f2cc6a9099
2 changed files with 65 additions and 7 deletions

57
tests/console/PAN4.py Normal file
View File

@ -0,0 +1,57 @@
# -*- coding: utf-8 -*-
from include.common_classes_60 import PandoraWebDriverTestCase
from include.common_functions_60 import login, click_menu_element, refresh_N_times_until_find_element, detect_and_pass_all_wizards, create_user, is_element_present, create_report, logout
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 StaleElementReferenceException
import unittest, time, re
class PAN4(PandoraWebDriverTestCase):
test_name = u'PAN_4'
test_description = u'Creates a user with Chief Operator permissions over the Applications group. Then creates two reports: one in the Applications group and other in the Servers group. Then, it checks that the given user can only see the Application report'
tickets_associated = []
def test_pan3(self):
driver = self.driver
login(driver,"admin","pandora")
detect_and_pass_all_wizards(driver)
#Creates a user with Chief Operator - Applications profile
profile_list = []
profile_list.append(("Chief Operator","Applications"))
create_user(driver,'test','test',email='test@pandorafms.com',profile_list=profile_list)
#Creates report
create_report(driver,"Informe applications","Applications")
create_report(driver,"Informe servers","Servers")
#Logout
logout(driver,self.base_url)
#Login
login(driver,user='test',passwd='test')
detect_and_pass_all_wizards(driver)
#Check that the report is visible
click_menu_element(driver,"Custom reporting")
driver.find_element_by_id('text-search').clear()
driver.find_element_by_id('text-search').send_keys("Informe applications")
driver.find_element_by_id('submit-search_submit').click()
self.assertEqual(is_element_present(driver, By.ID, 'report_list-0'),True)
#Check that the report is not visible
click_menu_element(driver,"Custom reporting")
driver.find_element_by_id('text-search').clear()
driver.find_element_by_id('text-search').send_keys("Informe servers")
driver.find_element_by_id('submit-search_submit').click()
# ESTE NO ESTARÁ driver.find_element_by_id('report_list-0')
self.assertEqual("No data found." in driver.page_source,True)
if __name__ == "__main__":
unittest.main()

View File

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
from selenium import selenium
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support.ui import WebDriverWait, Select
from selenium.webdriver.support import expected_conditions as EC
import random
@ -58,11 +58,11 @@ def create_report(driver,nombre,group_name):
Select(driver.find_element_by_id("id_group")).select_by_visible_text(" "+group_name)
driver.find_element_by_id("submit-add").click()
def add_user_profile(driver,user,profile,group):
def add_user_profile(driver,user_name,profile,group):
click_menu_element(driver,"Users management")
driver.find_element_by_css_selector("b").click()
driver.find_element_by_id("text-filter_search").clear()
driver.find_element_by_id("text-filter_search").send_keys(user)
driver.find_element_by_id("text-filter_search").send_keys(user_name)
driver.find_element_by_id("submit-search").click()
driver.find_element_by_xpath('//*[@id="table3-0-6"]/a[2]').click()
Select(driver.find_element_by_id("assign_profile")).select_by_visible_text(profile)
@ -73,10 +73,11 @@ def add_user_profile(driver,user,profile,group):
#TODO This will not work when choosing a group within a group within another group
Select(driver.find_element_by_id("assign_group")).select_by_visible_text(" "+group)
driver.find_element_by_id("image-add2").click()
#driver.find_element_by_id("image-add2").click()
driver.find_element_by_xpath('//*[@name="add"]').click()
def create_user(driver,userid,userpwd,email=None,profile_list=None):
def create_user(driver,user_name,userpwd,email=None,profile_list=None):
u"""
Profile list es una LISTA de TUPLAS:
l = [("Chief Operator","All"),("Read Operator","Servers")]
@ -84,7 +85,7 @@ def create_user(driver,userid,userpwd,email=None,profile_list=None):
click_menu_element(driver,"Users management")
driver.find_element_by_id("submit-crt").click()
driver.find_element_by_name("id_user").clear()
driver.find_element_by_name("id_user").send_keys(userid)
driver.find_element_by_name("id_user").send_keys(user_name)
driver.find_element_by_name("password_new").clear()
driver.find_element_by_name("password_new").send_keys(userpwd)
driver.find_element_by_name("password_confirm").clear()
@ -97,7 +98,7 @@ def create_user(driver,userid,userpwd,email=None,profile_list=None):
if profile_list != None:
for profile_name,group_name in profile_list:
add_user_profile(driver,user,profile_name,group_name)
add_user_profile(driver,user_name,profile_name,group_name)
def is_element_present(driver, how, what):
from selenium.common.exceptions import NoSuchElementException