|
a/AlluraTesting/alluratest/validation.py |
|
b/AlluraTesting/alluratest/validation.py |
|
... |
|
... |
22 |
from webob import Request, Response
|
22 |
from webob import Request, Response
|
23 |
from tidylib import tidy_document
|
23 |
from tidylib import tidy_document
|
24 |
from nose.tools import ok_, assert_true, assert_false
|
24 |
from nose.tools import ok_, assert_true, assert_false
|
25 |
from poster.encode import multipart_encode
|
25 |
from poster.encode import multipart_encode
|
26 |
from poster.streaminghttp import register_openers
|
26 |
from poster.streaminghttp import register_openers
|
|
|
27 |
from ming.utils import LazyProperty
|
27 |
|
28 |
|
28 |
from allura.lib import utils
|
29 |
from allura.lib import utils
|
29 |
|
30 |
|
30 |
ENABLE_CONTENT_VALIDATION = False
|
31 |
ENABLE_CONTENT_VALIDATION = False
|
31 |
# By default we want to run only validations which are fast,
|
32 |
# By default we want to run only validations which are fast,
|
|
... |
|
... |
46 |
def instance(cls):
|
47 |
def instance(cls):
|
47 |
if not cls._instance:
|
48 |
if not cls._instance:
|
48 |
cls._instance = cls()
|
49 |
cls._instance = cls()
|
49 |
return cls._instance
|
50 |
return cls._instance
|
50 |
|
51 |
|
51 |
@property
|
52 |
@LazyProperty
|
52 |
def test_ini(self):
|
53 |
def test_ini(self):
|
53 |
if not self.ini_config:
|
54 |
if not self.ini_config:
|
54 |
from . import controller
|
55 |
from . import controller
|
55 |
import ConfigParser
|
56 |
import ConfigParser
|
56 |
conf = ConfigParser.ConfigParser({'validate_html5': 'false', 'validate_js': 'true'})
|
57 |
conf = ConfigParser.ConfigParser({'validate_html5': 'false', 'validate_inlinejs': 'false'})
|
57 |
conf.read(controller.get_config_file())
|
58 |
conf.read(controller.get_config_file())
|
58 |
self.ini_config = conf
|
59 |
self.ini_config = conf
|
59 |
return self.ini_config
|
60 |
return self.ini_config
|
60 |
|
61 |
|
61 |
@property
|
62 |
@LazyProperty
|
62 |
def hostname(self):
|
63 |
def hostname(self):
|
63 |
if os.path.exists('/etc/soghost'):
|
64 |
if os.path.exists('/etc/soghost'):
|
64 |
with open('/etc/soghost') as fp:
|
65 |
with open('/etc/soghost') as fp:
|
65 |
return fp.read().strip()
|
66 |
return fp.read().strip()
|
66 |
|
67 |
|
|
... |
|
... |
262 |
report_validation_error('js', fname, msg)
|
263 |
report_validation_error('js', fname, msg)
|
263 |
|
264 |
|
264 |
def validate_page(html_or_response):
|
265 |
def validate_page(html_or_response):
|
265 |
if Config.instance().validation_enabled('html5'):
|
266 |
if Config.instance().validation_enabled('html5'):
|
266 |
validate_html(html_or_response)
|
267 |
validate_html(html_or_response)
|
267 |
if Config.instance().validation_enabled('js'):
|
268 |
if Config.instance().validation_enabled('inlinejs'):
|
268 |
validate_js(html_or_response)
|
269 |
validate_js(html_or_response)
|
269 |
|
270 |
|
270 |
|
271 |
|
271 |
class AntiSpamTestApp(TestApp):
|
272 |
class AntiSpamTestApp(TestApp):
|
272 |
|
273 |
|