2016-07-13 12:25:43 +02:00
# -*- 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 . agent_functions import create_agent , search_agent
from include . user_functions import create_user
2016-07-15 14:33:19 +02:00
from include . module_functions import *
2016-07-13 12:25:43 +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
import unittest , time , re
class PAN8 ( PandoraWebDriverTestCase ) :
test_name = u ' PAN_8 '
test_description = 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 '
tickets_associated = [ ]
def test_pan8 ( self ) :
driver = self . driver
login ( driver )
detect_and_pass_all_wizards ( driver )
create_agent ( driver , " PAN_8 " , group = " Applications " , ip = " 192.168.50.50 " )
#We create a module without a tag
2016-07-15 14:33:19 +02:00
create_module ( " network_server " , driver , agent_name = " PAN_8 " , module_name = " Without tag " , component_group = " Network Management " , network_component = " Host Alive " , ip = " 192.168.50.50 " )
2016-07-13 12:25:43 +02:00
#We now create a modulo with tag "critical"
2016-07-15 14:33:19 +02:00
create_module ( " network_server " , driver , agent_name = " PAN_8 " , module_name = " With tag " , component_group = " Network Management " , network_component = " Host Alive " , ip = " 192.168.50.50 " , tag_name = " critical " )
2016-07-13 12:25:43 +02:00
l = [ ( " Operator (Read) " , " All " , [ " critical " ] ) ]
create_user ( driver , " PAN8_user " , " pandora " , profile_list = l )
logout ( driver , self . base_url )
login ( driver , user = " PAN8_user " )
detect_and_pass_all_wizards ( driver )
search_agent ( driver , " PAN_8 " )
2016-07-14 12:10:29 +02:00
time . sleep ( 6 )
2016-07-14 12:05:39 +02:00
2016-07-13 12:25:43 +02:00
try :
#The user should be able to see the module with Tag
2016-07-14 12:10:29 +02:00
module = driver . find_element_by_xpath ( ' //td[contains(., " With tag " )] ' )
2016-07-13 12:25:43 +02:00
self . assertEqual ( " With tag " in driver . page_source , True )
2016-07-14 12:10:29 +02:00
2016-07-13 12:25:43 +02:00
except AssertionError as e :
self . verificationErrors . append ( str ( e ) )
try :
#The user should NOT be able to see the module without tag
self . assertEqual ( " Without tag " in driver . page_source , False )
except AssertionError as e :
self . verificationErrors . append ( str ( e ) )
2016-07-14 12:10:29 +02:00
2016-07-13 12:25:43 +02:00
if __name__ == " __main__ " :
unittest . main ( )