summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNavaL <ayoyo@thoughtworks.com>2016-02-22 17:49:27 +0100
committerNavaL <ayoyo@thoughtworks.com>2016-02-22 17:49:27 +0100
commit7c1affe11f7563911c34c9d439fe5ed1bf7c3a17 (patch)
treeae5f96f7c7b642276fe3d1462369633e81141c08
parent82d4432b977e0960746bba1c6f03077fb6322263 (diff)
Removes stacktrace errors from appearing on the login page.
For the case of wrong file path or file not existing Issue #214
-rw-r--r--service/pixelated/resources/login_resource.py2
-rw-r--r--service/test/unit/resources/test_login_resource.py17
2 files changed, 19 insertions, 0 deletions
diff --git a/service/pixelated/resources/login_resource.py b/service/pixelated/resources/login_resource.py
index 5f20a3c2..f1d9c1e3 100644
--- a/service/pixelated/resources/login_resource.py
+++ b/service/pixelated/resources/login_resource.py
@@ -70,6 +70,8 @@ class DisclaimerElement(Element):
return super(DisclaimerElement, self).render(request)
except SAXParseException:
return ["Invalid XML template format for %s." % self._banner_filename]
+ except IOError:
+ return ["Disclaimer banner file %s could not be read or does not exit." % self._banner_filename]
class LoginWebSite(Element):
diff --git a/service/test/unit/resources/test_login_resource.py b/service/test/unit/resources/test_login_resource.py
index d8194156..4076946a 100644
--- a/service/test/unit/resources/test_login_resource.py
+++ b/service/test/unit/resources/test_login_resource.py
@@ -122,6 +122,23 @@ class TestLoginResource(unittest.TestCase):
d.addCallback(tear_down)
return d
+ def test_wrong_banner_file_location_will_send_default_invalid_format_banner(self):
+ request = DummyRequest([''])
+
+ non_existing_banner_file = 'banner.txt'
+
+ self.resource._disclaimer_banner = non_existing_banner_file
+
+ d = self.web.get(request)
+
+ def assert_default_invalid_banner_disclaimer_rendered(_):
+ self.assertEqual(200, request.responseCode)
+ written_response = ''.join(request.written)
+ self.assertIn("Disclaimer banner file banner.txt could not be read or does not exit.", written_response)
+
+ d.addCallback(assert_default_invalid_banner_disclaimer_rendered)
+ return d
+
class TestLoginPOST(unittest.TestCase):
def setUp(self):