diff options
Diffstat (limited to 'pecan/tests/test_secure.py')
-rw-r--r-- | pecan/tests/test_secure.py | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/pecan/tests/test_secure.py b/pecan/tests/test_secure.py index 1f48037..53a63ca 100644 --- a/pecan/tests/test_secure.py +++ b/pecan/tests/test_secure.py @@ -5,6 +5,7 @@ if sys.version_info < (2, 7): else: import unittest # noqa +from six import b as b_ from webtest import TestApp from pecan import expose, make_app @@ -59,11 +60,11 @@ class TestSecure(PecanTestCase): )) response = app.get('/') assert response.status_int == 200 - assert response.body == 'Hello, World!' + assert response.body == b_('Hello, World!') response = app.get('/unlocked') assert response.status_int == 200 - assert response.body == 'Sure thing' + assert response.body == b_('Sure thing') response = app.get('/locked', expect_errors=True) assert response.status_int == 401 @@ -73,7 +74,7 @@ class TestSecure(PecanTestCase): response = app.get('/secret/allowed') assert response.status_int == 200 - assert response.body == 'Allowed!' + assert response.body == b_('Allowed!') def test_unlocked_attribute(self): class AuthorizedSubController(object): @@ -121,11 +122,11 @@ class TestSecure(PecanTestCase): )) response = app.get('/') assert response.status_int == 200 - assert response.body == 'Hello, World!' + assert response.body == b_('Hello, World!') response = app.get('/unlocked') assert response.status_int == 200 - assert response.body == 'Sure thing' + assert response.body == b_('Sure thing') response = app.get('/locked', expect_errors=True) assert response.status_int == 401 @@ -135,15 +136,15 @@ class TestSecure(PecanTestCase): response = app.get('/secret/allowed') assert response.status_int == 200 - assert response.body == 'Allowed!' + assert response.body == b_('Allowed!') response = app.get('/secret/authorized/') assert response.status_int == 200 - assert response.body == 'Index' + assert response.body == b_('Index') response = app.get('/secret/authorized/allowed') assert response.status_int == 200 - assert response.body == 'Allowed!' + assert response.body == b_('Allowed!') def test_secure_attribute(self): authorized = False @@ -163,7 +164,7 @@ class TestSecure(PecanTestCase): app = TestApp(make_app(RootController())) response = app.get('/') assert response.status_int == 200 - assert response.body == 'Hello from root!' + assert response.body == b_('Hello from root!') response = app.get('/sub/', expect_errors=True) assert response.status_int == 401 @@ -171,7 +172,7 @@ class TestSecure(PecanTestCase): authorized = True response = app.get('/sub/') assert response.status_int == 200 - assert response.body == 'Hello from sub!' + assert response.body == b_('Hello from sub!') def test_state_attribute(self): from pecan.secure import Any, Protected @@ -288,7 +289,7 @@ class TestObjectPathSecurity(PecanTestCase): def test_sub_of_both_not_secret(self): response = self.app.get('/notsecret/hi/') assert response.status_int == 200 - assert response.body == 'Index hi' + assert response.body == b_('Index hi') def test_protected_lookup(self): response = self.app.get('/secret/hi/', expect_errors=True) @@ -297,7 +298,7 @@ class TestObjectPathSecurity(PecanTestCase): self.secret_cls.authorized = True response = self.app.get('/secret/hi/') assert response.status_int == 200 - assert response.body == 'Index hi' + assert response.body == b_('Index hi') assert 'secretcontroller' in self.permissions_checked def test_secured_notfound_lookup(self): @@ -324,7 +325,7 @@ class TestObjectPathSecurity(PecanTestCase): self.deepsecret_cls.authorized = True response = self.app.get('/secret/hi/deepsecret/') assert response.status_int == 200 - assert response.body == 'Deep Secret' + assert response.body == b_('Deep Secret') assert 'secretcontroller' in self.permissions_checked assert 'deepsecret' in self.permissions_checked @@ -333,14 +334,14 @@ class TestObjectPathSecurity(PecanTestCase): self.deepsecret_cls.authorized = True response = self.app.get('/secret/1/deepsecret/2/deepsecret/') assert response.status_int == 200 - assert response.body == 'Deep Secret' + assert response.body == b_('Deep Secret') assert 'secretcontroller' in self.permissions_checked assert 'deepsecret' in self.permissions_checked def test_unlocked_lookup(self): response = self.app.get('/notsecret/1/deepsecret/2/') assert response.status_int == 200 - assert response.body == 'Index 2' + assert response.body == b_('Index 2') assert 'deepsecret' not in self.permissions_checked response = self.app.get( @@ -368,7 +369,7 @@ class TestObjectPathSecurity(PecanTestCase): self.secret_cls.independent_authorization = True response = self.app.get('/secret/independent') assert response.status_int == 200 - assert response.body == 'Independent Security' + assert response.body == b_('Independent Security') assert len(self.permissions_checked) == 1 assert 'independent' in self.permissions_checked @@ -383,7 +384,7 @@ class TestObjectPathSecurity(PecanTestCase): self.secret_cls.independent_authorization = True response = self.app.get('/secret/wrapped/') assert response.status_int == 200 - assert response.body == 'Index wrapped' + assert response.body == b_('Index wrapped') assert len(self.permissions_checked) == 1 assert 'independent' in self.permissions_checked @@ -392,7 +393,7 @@ class TestObjectPathSecurity(PecanTestCase): self.secret_cls.independent_authorization = True response = self.app.get('/secret/lookup_wrapped/') assert response.status_int == 200 - assert response.body == 'Index wrapped' + assert response.body == b_('Index wrapped') assert len(self.permissions_checked) == 2 assert 'independent' in self.permissions_checked assert 'secretcontroller' in self.permissions_checked @@ -400,7 +401,7 @@ class TestObjectPathSecurity(PecanTestCase): def test_unlocked_attribute_in_insecure(self): response = self.app.get('/notsecret/unlocked/') assert response.status_int == 200 - assert response.body == 'Index unlocked' + assert response.body == b_('Index unlocked') class SecureControllerSharedPermissionsRegression(PecanTestCase): |