← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~trb143/openlp/bug-1421804 into lp:openlp

 

Tim Bentley has proposed merging lp:~trb143/openlp/bug-1421804 into lp:openlp.

Requested reviews:
  Raoul Snyman (raoul-snyman)
Related bugs:
  Bug #1421804 in OpenLP: "Remote password protection doesn't work with https off"
  https://bugs.launchpad.net/openlp/+bug/1421804

For more details, see:
https://code.launchpad.net/~trb143/openlp/bug-1421804/+merge/249886

Fixes the persistence of the userid and password.
Password needs to be re-entered after browser reset.

tested with android client as well.

lp:~trb143/openlp/bug-1416528a (revision 2492)
[SUCCESS] http://ci.openlp.org/job/Branch-01-Pull/946/
[SUCCESS] http://ci.openlp.org/job/Branch-02-Functional-Tests/872/
[FAILURE] http://ci.openlp.org/job/Branch-03-Interface-Tests/817/

Stopped a crosswalk bug
-- 
Your team OpenLP Core is subscribed to branch lp:openlp.
=== modified file 'openlp/core/lib/settingstab.py'
--- openlp/core/lib/settingstab.py	2015-01-18 13:39:21 +0000
+++ openlp/core/lib/settingstab.py	2015-02-16 20:58:35 +0000
@@ -51,6 +51,12 @@
         self.tab_visited = False
         if icon_path:
             self.icon_path = icon_path
+        self._setup()
+
+    def _setup(self):
+        """
+        Run some initial setup. This method is separate from __init__ in order to mock it out in tests.
+        """
         self.setupUi()
         self.retranslateUi()
         self.initialise()

=== modified file 'openlp/plugins/remotes/lib/httprouter.py'
--- openlp/plugins/remotes/lib/httprouter.py	2015-01-18 13:39:21 +0000
+++ openlp/plugins/remotes/lib/httprouter.py	2015-02-16 20:58:35 +0000
@@ -117,7 +117,7 @@
 from mako.template import Template
 from PyQt4 import QtCore
 
-from openlp.core.common import Registry, RegistryProperties, AppLocation, Settings, translate
+from openlp.core.common import RegistryProperties, AppLocation, Settings, translate, UiStrings
 from openlp.core.lib import PluginStatus, StringContent, image_to_byte, ItemCapabilities, create_thumb
 
 log = logging.getLogger(__name__)
@@ -232,12 +232,18 @@
                 return func, args
         return None, None
 
+    def set_cache_headers(self):
+        self.send_header("Cache-Control", "no-cache, no-store, must-revalidate")
+        self.send_header("Pragma", "no-cache")
+        self.send_header("Expires", "0")
+
     def do_http_success(self):
         """
         Create a success http header.
         """
         self.send_response(200)
         self.send_header('Content-type', 'text/html')
+        self.set_cache_headers()
         self.end_headers()
 
     def do_json_header(self):
@@ -246,6 +252,7 @@
         """
         self.send_response(200)
         self.send_header('Content-type', 'application/json')
+        self.set_cache_headers()
         self.end_headers()
 
     def do_http_error(self):
@@ -254,6 +261,7 @@
         """
         self.send_response(404)
         self.send_header('Content-type', 'text/html')
+        self.set_cache_headers()
         self.end_headers()
 
     def do_authorisation(self):
@@ -261,8 +269,10 @@
         Create a needs authorisation http header.
         """
         self.send_response(401)
-        self.send_header('WWW-Authenticate', 'Basic realm=\"Test\"')
+        header = 'Basic realm=\"{}\"'.format(UiStrings().OLPV2)
+        self.send_header('WWW-Authenticate', header)
         self.send_header('Content-type', 'text/html')
+        self.set_cache_headers()
         self.end_headers()
 
     def do_not_found(self):
@@ -271,6 +281,7 @@
         """
         self.send_response(404)
         self.send_header('Content-type', 'text/html')
+        self.set_cache_headers()
         self.end_headers()
         self.wfile.write(bytes('<html><body>Sorry, an error occurred </body></html>', 'UTF-8'))
 

=== modified file 'tests/functional/openlp_plugins/remotes/test_router.py'
--- tests/functional/openlp_plugins/remotes/test_router.py	2015-01-18 13:39:21 +0000
+++ tests/functional/openlp_plugins/remotes/test_router.py	2015-02-16 20:58:35 +0000
@@ -25,7 +25,6 @@
 import os
 import urllib.request
 from unittest import TestCase
-from PyQt4 import QtCore
 from openlp.core.common import Settings, Registry
 from openlp.core.ui import ServiceManager
 from openlp.plugins.remotes.lib.httpserver import HttpRouter
@@ -128,7 +127,7 @@
 
         # THEN: the function should have been called only once
         self.router.send_response.assert_called_once_with(401)
-        self.assertEqual(self.router.send_header.call_count, 2, 'The header should have been called twice.')
+        self.assertEqual(self.router.send_header.call_count, 5, 'The header should have been called five times.')
 
     def get_content_type_test(self):
         """
@@ -187,7 +186,6 @@
 
         # THEN: it should return a 404
         self.router.send_response.assert_called_once_with(404)
-        self.router.send_header.assert_called_once_with('Content-type', 'text/html')
         self.assertEqual(self.router.end_headers.call_count, 1, 'end_headers called once')
 
     def serve_file_with_valid_params_test(self):
@@ -217,14 +215,19 @@
         """
         Test the serve_thumbnail routine without params
         """
+        # GIVEN: mocked environment
         self.router.send_response = MagicMock()
         self.router.send_header = MagicMock()
         self.router.end_headers = MagicMock()
         self.router.wfile = MagicMock()
+
+        # WHEN: I request a thumbnail
         self.router.serve_thumbnail()
+
+        # THEN: The headers should be set correctly
         self.router.send_response.assert_called_once_with(404)
-        self.assertEqual(self.router.send_response.call_count, 1, 'Send response called once')
-        self.assertEqual(self.router.end_headers.call_count, 1, 'end_headers called once')
+        self.assertEqual(self.router.send_response.call_count, 1, 'Send response should be called once')
+        self.assertEqual(self.router.end_headers.call_count, 1, 'end_headers should be called once')
 
     def serve_thumbnail_with_invalid_params_test(self):
         """
@@ -240,7 +243,7 @@
         self.router.serve_thumbnail('badcontroller', 'tecnologia 1.pptx/slide1.png')
 
         # THEN: a 404 should be returned
-        self.assertEqual(len(self.router.send_header.mock_calls), 1, 'One header')
+        self.assertEqual(len(self.router.send_header.mock_calls), 4, 'header should be called 4 times')
         self.assertEqual(len(self.router.send_response.mock_calls), 1, 'One response')
         self.assertEqual(len(self.router.wfile.mock_calls), 1, 'Once call to write to the socket')
         self.router.send_response.assert_called_once_with(404)
@@ -284,7 +287,7 @@
             mocked_location.get_section_data_path.return_value = ''
 
             # WHEN: pass good controller and filename
-            result = self.router.serve_thumbnail('presentations', '{0}x{1}'.format(width, height), file_name)
+            self.router.serve_thumbnail('presentations', '{0}x{1}'.format(width, height), file_name)
 
             # THEN: a file should be returned
             self.assertEqual(self.router.send_header.call_count, 1, 'One header')


Follow ups