author | David Douard <david.douard@logilab.fr> |
Fri, 03 Jul 2015 13:43:40 +0200 | |
changeset 10504 | 3755cd64fff8 |
parent 10071 | 4bc099f2a089 |
child 10907 | 9ae707db5265 |
permissions | -rw-r--r-- |
9326
9d145b4c4e53
[web] make sign_text unicode aware, avoid crash with non-ascii chars. Closes #3289774
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7791
diff
changeset
|
1 |
# -*- coding: utf-8 -*- |
9d145b4c4e53
[web] make sign_text unicode aware, avoid crash with non-ascii chars. Closes #3289774
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7791
diff
changeset
|
2 |
# copyright 2003-2013 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
3 |
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
4 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
5 |
# This file is part of CubicWeb. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
6 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
7 |
# CubicWeb is free software: you can redistribute it and/or modify it under the |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
8 |
# terms of the GNU Lesser General Public License as published by the Free |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
9 |
# Software Foundation, either version 2.1 of the License, or (at your option) |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
10 |
# any later version. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
11 |
# |
5424
8ecbcbff9777
replace logilab-common by CubicWeb in disclaimer
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5421
diff
changeset
|
12 |
# CubicWeb is distributed in the hope that it will be useful, but WITHOUT |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
13 |
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
14 |
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
15 |
# details. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
16 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
17 |
# You should have received a copy of the GNU Lesser General Public License along |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
18 |
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
9326
9d145b4c4e53
[web] make sign_text unicode aware, avoid crash with non-ascii chars. Closes #3289774
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7791
diff
changeset
|
19 |
"""cubicweb.web.webconfig unit tests""" |
1977
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1802
diff
changeset
|
20 |
|
0 | 21 |
import os |
22 |
||
23 |
from logilab.common.testlib import TestCase, unittest_main |
|
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
24 |
from cubicweb.devtools import ApptestConfiguration, fake |
0 | 25 |
|
26 |
class WebconfigTC(TestCase): |
|
27 |
def setUp(self): |
|
10071
4bc099f2a089
[test] make unittest_webconfig independant of CWD
David Douard <david.douard@logilab.fr>
parents:
9677
diff
changeset
|
28 |
# need explicit None if dirname(__file__) is empty, see |
4bc099f2a089
[test] make unittest_webconfig independant of CWD
David Douard <david.douard@logilab.fr>
parents:
9677
diff
changeset
|
29 |
# ApptestConfiguration.__init__ |
4bc099f2a089
[test] make unittest_webconfig independant of CWD
David Douard <david.douard@logilab.fr>
parents:
9677
diff
changeset
|
30 |
self.config = ApptestConfiguration('data', apphome=os.path.dirname(__file__) or None) |
16
a70ece4d9d1a
fix tests in web/test
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
31 |
self.config._cubes = ['file'] |
0 | 32 |
self.config.load_configuration() |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
16
diff
changeset
|
33 |
|
0 | 34 |
def test_nonregr_print_css_as_list(self): |
35 |
"""make sure PRINT_CSS *must* is a list""" |
|
36 |
config = self.config |
|
5444
f7fdb5dd82f6
[webconfig] introduce property sheets. Use them to replace external_resources
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
37 |
print_css = config.uiprops['STYLESHEETS_PRINT'] |
7791
31bb51ea5485
[deprecation] fix unittest pending deprecation warnings on failIf/failUnless methods family
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5907
diff
changeset
|
38 |
self.assertTrue(isinstance(print_css, list)) |
5444
f7fdb5dd82f6
[webconfig] introduce property sheets. Use them to replace external_resources
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
39 |
ie_css = config.uiprops['STYLESHEETS_IE'] |
7791
31bb51ea5485
[deprecation] fix unittest pending deprecation warnings on failIf/failUnless methods family
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5907
diff
changeset
|
40 |
self.assertTrue(isinstance(ie_css, list)) |
0 | 41 |
|
42 |
def test_locate_resource(self): |
|
9674
96549de9dd70
[test] use assertIn where appropriate
Julien Cristau <julien.cristau@logilab.fr>
parents:
9326
diff
changeset
|
43 |
self.assertIn('FILE_ICON', self.config.uiprops) |
5444
f7fdb5dd82f6
[webconfig] introduce property sheets. Use them to replace external_resources
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
44 |
rname = self.config.uiprops['FILE_ICON'].replace(self.config.datadir_url, '') |
9674
96549de9dd70
[test] use assertIn where appropriate
Julien Cristau <julien.cristau@logilab.fr>
parents:
9326
diff
changeset
|
45 |
self.assertIn('file', self.config.locate_resource(rname)[0].split(os.sep)) |
5907
5eba1248e12b
[web config] fix old css compat code: we have to modify locate_resource prototype so it return (potentially hacked) file name as well. Should only impact the file cube which has to be released anyway.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5444
diff
changeset
|
46 |
cubicwebcsspath = self.config.locate_resource('cubicweb.css')[0].split(os.sep) |
10071
4bc099f2a089
[test] make unittest_webconfig independant of CWD
David Douard <david.douard@logilab.fr>
parents:
9677
diff
changeset
|
47 |
|
4bc099f2a089
[test] make unittest_webconfig independant of CWD
David Douard <david.douard@logilab.fr>
parents:
9677
diff
changeset
|
48 |
# 'shared' if tests under apycot |
4bc099f2a089
[test] make unittest_webconfig independant of CWD
David Douard <david.douard@logilab.fr>
parents:
9677
diff
changeset
|
49 |
self.assertTrue('web' in cubicwebcsspath or 'shared' in cubicwebcsspath, |
4bc099f2a089
[test] make unittest_webconfig independant of CWD
David Douard <david.douard@logilab.fr>
parents:
9677
diff
changeset
|
50 |
'neither "web" nor "shared" found in cubicwebcsspath (%s)' |
4bc099f2a089
[test] make unittest_webconfig independant of CWD
David Douard <david.douard@logilab.fr>
parents:
9677
diff
changeset
|
51 |
% cubicwebcsspath) |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
16
diff
changeset
|
52 |
|
9326
9d145b4c4e53
[web] make sign_text unicode aware, avoid crash with non-ascii chars. Closes #3289774
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7791
diff
changeset
|
53 |
def test_sign_text(self): |
9d145b4c4e53
[web] make sign_text unicode aware, avoid crash with non-ascii chars. Closes #3289774
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7791
diff
changeset
|
54 |
signature = self.config.sign_text(u'hôp') |
9d145b4c4e53
[web] make sign_text unicode aware, avoid crash with non-ascii chars. Closes #3289774
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7791
diff
changeset
|
55 |
self.assertTrue(self.config.check_text_sign(u'hôp', signature)) |
9d145b4c4e53
[web] make sign_text unicode aware, avoid crash with non-ascii chars. Closes #3289774
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7791
diff
changeset
|
56 |
|
0 | 57 |
if __name__ == '__main__': |
58 |
unittest_main() |
|
59 |
||
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
16
diff
changeset
|
60 |