vigiboard / vigiboard / tests / functional / test_correvents_table.py @ a2744508
History | View | Annotate | Download (6.3 KB)
1 |
# -*- coding: utf-8 -*-
|
---|---|
2 |
# vim:set expandtab tabstop=4 shiftwidth=4:
|
3 |
# Copyright (C) 2006-2012 CS-SI
|
4 |
# License: GNU GPL v2 <http://www.gnu.org/licenses/gpl-2.0.html>
|
5 |
|
6 |
"""
|
7 |
Test du tableau d'événements de Vigiboard
|
8 |
"""
|
9 |
|
10 |
from __future__ import absolute_import |
11 |
|
12 |
from nose.tools import assert_true, assert_equal |
13 |
|
14 |
from vigiboard.tests import TestController |
15 |
|
16 |
from .utils import populate_DB |
17 |
|
18 |
|
19 |
class TestEventTable(TestController): |
20 |
"""
|
21 |
Test du tableau d'événements de Vigiboard
|
22 |
"""
|
23 |
def setUp(self): |
24 |
super(TestEventTable, self).setUp() |
25 |
populate_DB() |
26 |
|
27 |
def test_homepage(self): |
28 |
"""
|
29 |
Tableau des événements (page d'accueil).
|
30 |
"""
|
31 |
# L'utilisateur n'est pas authentifié.
|
32 |
response = self.app.get('/', status=401) |
33 |
|
34 |
# L'utilisateur est authentifié avec des permissions réduites.
|
35 |
environ = {'REMOTE_USER': 'limited_access'} |
36 |
response = self.app.get('/', extra_environ=environ) |
37 |
|
38 |
# Il doit y avoir 2 lignes de résultats.
|
39 |
rows = response.lxml.xpath('//table[@class="vigitable"]/tbody/tr')
|
40 |
print "There are %d rows in the result set" % len(rows) |
41 |
assert_equal(len(rows), 2) |
42 |
|
43 |
# Il doit y avoir plusieurs colonnes dans la ligne de résultats.
|
44 |
cols = response.lxml.xpath('//table[@class="vigitable"]/tbody/tr/td')
|
45 |
print "There are %d columns in the result set" % len(cols) |
46 |
assert_true(len(cols) > 1) |
47 |
|
48 |
# L'utilisateur est authentifié avec des permissions plus étendues.
|
49 |
environ = {'REMOTE_USER': 'access'} |
50 |
response = self.app.get('/', extra_environ=environ) |
51 |
|
52 |
# Il doit y avoir 5 lignes de résultats.
|
53 |
rows = response.lxml.xpath('//table[@class="vigitable"]/tbody/tr')
|
54 |
print "There are %d rows in the result set" % len(rows) |
55 |
assert_equal(len(rows), 5) |
56 |
|
57 |
# Il doit y avoir plusieurs colonnes dans la ligne de résultats.
|
58 |
cols = response.lxml.xpath('//table[@class="vigitable"]/tbody/tr/td')
|
59 |
print "There are %d columns in the result set" % len(cols) |
60 |
assert_true(len(cols) > 1) |
61 |
|
62 |
# L'utilisateur fait partie du groupe 'managers'
|
63 |
environ = {'REMOTE_USER': 'manager'} |
64 |
response = self.app.get('/', extra_environ=environ) |
65 |
|
66 |
# Il doit y avoir 5 lignes de résultats.
|
67 |
rows = response.lxml.xpath('//table[@class="vigitable"]/tbody/tr')
|
68 |
print "There are %d rows in the result set" % len(rows) |
69 |
assert_equal(len(rows), 5) |
70 |
|
71 |
# Il doit y avoir plusieurs colonnes dans la ligne de résultats.
|
72 |
cols = response.lxml.xpath('//table[@class="vigitable"]/tbody/tr/td')
|
73 |
print "There are %d columns in the result set" % len(cols) |
74 |
assert_true(len(cols) > 1) |
75 |
|
76 |
def test_correvents_table_for_LLS(self): |
77 |
"""
|
78 |
Tableau des événements corrélés pour un service de bas niveau.
|
79 |
"""
|
80 |
url = '/item/1/%s/%s' % ('group2_host', 'group2_service') |
81 |
|
82 |
# L'utilisateur n'est pas authentifié.
|
83 |
response = self.app.get(url, status=401) |
84 |
|
85 |
# L'utilisateur dispose de permissions restreintes.
|
86 |
# Il n'a pas accès aux événements corrélés sur le service donné.
|
87 |
# Donc, on s'attend à être redirigé avec un message d'erreur.
|
88 |
environ = {'REMOTE_USER': 'limited_access'} |
89 |
response = self.app.get(url, extra_environ=environ, status=302) |
90 |
response = response.follow(status = 200, extra_environ = environ)
|
91 |
assert_true(len(response.lxml.xpath(
|
92 |
'//div[@id="flash"]/div[@class="error"]')))
|
93 |
|
94 |
# L'utilisateur dispose de permissions plus étendues.
|
95 |
# Il doit avoir accès à l'historique.
|
96 |
# Ici, il n'y a qu'un seul événement corrélé pour ce service.
|
97 |
environ = {'REMOTE_USER': 'access'} |
98 |
response = self.app.get(url, extra_environ=environ, status=200) |
99 |
|
100 |
# Il doit y avoir 1 ligne de résultats.
|
101 |
rows = response.lxml.xpath('//table[@class="vigitable"]/tbody/tr')
|
102 |
print "There are %d rows in the result set" % len(rows) |
103 |
assert_equal(len(rows), 1) |
104 |
|
105 |
# L'utilisateur fait partie du groupe 'managers'
|
106 |
# Il doit avoir accès à l'historique.
|
107 |
# Ici, il n'y a qu'un seul événement corrélé pour ce service.
|
108 |
environ = {'REMOTE_USER': 'manager'} |
109 |
response = self.app.get(url, extra_environ=environ, status=200) |
110 |
|
111 |
# Il doit y avoir 1 ligne de résultats.
|
112 |
rows = response.lxml.xpath('//table[@class="vigitable"]/tbody/tr')
|
113 |
print "There are %d rows in the result set" % len(rows) |
114 |
assert_equal(len(rows), 1) |
115 |
|
116 |
def test_correvents_table_for_host(self): |
117 |
"""
|
118 |
Tableau des événements corrélés pour un hôte.
|
119 |
"""
|
120 |
url = '/item/1/%s/' % ('group2_host', ) |
121 |
|
122 |
# L'utilisateur n'est pas authentifié.
|
123 |
response = self.app.get(url, status=401) |
124 |
|
125 |
# L'utilisateur dispose de permissions restreintes.
|
126 |
# Il n'a pas accès aux événements corrélés sur le service donné.
|
127 |
# Donc, on s'attend à être redirigé avec un message d'erreur.
|
128 |
environ = {'REMOTE_USER': 'limited_access'} |
129 |
response = self.app.get(url, extra_environ=environ, status=302) |
130 |
response = response.follow(status = 200, extra_environ = environ)
|
131 |
assert_true(len(response.lxml.xpath(
|
132 |
'//div[@id="flash"]/div[@class="error"]')))
|
133 |
|
134 |
# L'utilisateur dispose de permissions plus étendues.
|
135 |
# Il doit avoir accès à l'historique.
|
136 |
# Ici, il n'y a qu'un seul événement corrélé pour ce service.
|
137 |
environ = {'REMOTE_USER': 'access'} |
138 |
response = self.app.get(url, extra_environ=environ, status=200) |
139 |
|
140 |
# Il doit y avoir 1 ligne de résultats.
|
141 |
rows = response.lxml.xpath('//table[@class="vigitable"]/tbody/tr')
|
142 |
print "There are %d rows in the result set" % len(rows) |
143 |
assert_equal(len(rows), 1) |
144 |
|
145 |
# L'utilisateur fait partie du groupe 'managers'.
|
146 |
# Il doit avoir accès à l'historique.
|
147 |
# Ici, il n'y a qu'un seul événement corrélé pour ce service.
|
148 |
environ = {'REMOTE_USER': 'manager'} |
149 |
response = self.app.get(url, extra_environ=environ, status=200) |
150 |
|
151 |
# Il doit y avoir 1 ligne de résultats.
|
152 |
rows = response.lxml.xpath('//table[@class="vigitable"]/tbody/tr')
|
153 |
print "There are %d rows in the result set" % len(rows) |
154 |
assert_equal(len(rows), 1) |