forked from openlp/openlp
More updates
This commit is contained in:
parent
bed1ca2d57
commit
401f5ac2be
@ -1080,7 +1080,6 @@ class SlideController(DisplayController):
|
||||
"""
|
||||
Go to the next slide.
|
||||
"""
|
||||
print "next"
|
||||
if not self.service_item:
|
||||
return
|
||||
Registry().execute(u'%s_next' % self.service_item.name.lower(), [self.service_item, self.is_live])
|
||||
@ -1108,7 +1107,6 @@ class SlideController(DisplayController):
|
||||
"""
|
||||
Go to the previous slide.
|
||||
"""
|
||||
print "prev"
|
||||
if not self.service_item:
|
||||
return
|
||||
Registry().execute(u'%s_previous' % self.service_item.name.lower(), [self.service_item, self.is_live])
|
||||
|
@ -36,7 +36,6 @@
|
||||
<link rel="stylesheet" href="/files/login.css" />
|
||||
<link rel="shortcut icon" type="image/x-icon" href="/files/images/favicon.ico">
|
||||
<script type="text/javascript" src="/files/jquery.js"></script>
|
||||
<script type="text/javascript" src="/files/openlp.js"></script>
|
||||
<script type="text/javascript" src="/files/jquery.mobile.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
@ -48,4 +47,4 @@
|
||||
<strong>Password: </strong><input type="password" name="password" /><br />
|
||||
<input type="submit" value="Log in" />
|
||||
</form>
|
||||
</body></html>
|
||||
</body></html>
|
||||
|
@ -59,11 +59,10 @@ def check_credentials(user_name, password):
|
||||
return translate('RemotePlugin.Mobile', 'Incorrect username or password.')
|
||||
|
||||
|
||||
def check_auth(*args, **kwargs):
|
||||
def check_authentication(*args, **kwargs):
|
||||
"""
|
||||
A tool that looks in config for 'auth.require'. If found and it
|
||||
is not None, a login is required and the entry is evaluated as a list of
|
||||
conditions that the user must fulfill
|
||||
A tool that looks in config for 'auth.require'. If found and it is not None, a login is required and the entry is
|
||||
evaluated as a list of conditions that the user must fulfill
|
||||
"""
|
||||
conditions = cherrypy.request.config.get('auth.require', None)
|
||||
if not Settings().value(u'remotes/authentication enabled'):
|
||||
@ -79,7 +78,7 @@ def check_auth(*args, **kwargs):
|
||||
else:
|
||||
raise cherrypy.HTTPRedirect("/auth/login")
|
||||
|
||||
cherrypy.tools.auth = cherrypy.Tool('before_handler', check_auth)
|
||||
cherrypy.tools.auth = cherrypy.Tool('before_handler', check_authentication)
|
||||
|
||||
|
||||
def require_auth(*conditions):
|
||||
@ -136,6 +135,7 @@ class AuthController(object):
|
||||
"""
|
||||
Provides the actual login control
|
||||
"""
|
||||
print "login", from_page
|
||||
if username is None or password is None:
|
||||
return self.get_login_form("", from_page=from_page)
|
||||
error_msg = check_credentials(username, password)
|
||||
|
@ -43,7 +43,7 @@ the remotes.
|
||||
``/files/{filename}``
|
||||
Serve a static file.
|
||||
|
||||
``/api/poll``
|
||||
``/stage/api/poll``
|
||||
Poll to see if there are any changes. Returns a JSON-encoded dict of
|
||||
any changes that occurred::
|
||||
|
||||
@ -227,30 +227,24 @@ class HttpConnection(object):
|
||||
"""
|
||||
Handles the requests for the main url. This is secure depending on settings in config.
|
||||
"""
|
||||
#url = urlparse.urlparse(cherrypy.url())
|
||||
#self.url_params = urlparse.parse_qs(url.query)
|
||||
print "default"
|
||||
self.request_data = None
|
||||
if isinstance(kwargs, dict):
|
||||
self.request_data = kwargs.get(u'data', None)
|
||||
# Loop through the routes we set up earlier and execute them
|
||||
return self._process_http_request(args, kwargs)
|
||||
|
||||
@cherrypy.expose
|
||||
def stage(self, *args, **kwargs):
|
||||
"""
|
||||
Handles the requests for the stage url. This is not secure.
|
||||
Handles the requests for the /stage url. This is not secure.
|
||||
"""
|
||||
#url = urlparse.urlparse(cherrypy.url())
|
||||
#self.url_params = urlparse.parse_qs(url.query)
|
||||
return self._process_http_request(args, kwargs)
|
||||
|
||||
@cherrypy.expose
|
||||
def files(self, *args, **kwargs):
|
||||
"""
|
||||
Handles the requests for the files url. This is not secure.
|
||||
Handles the requests for the /files url. This is not secure.
|
||||
"""
|
||||
#url = urlparse.urlparse(cherrypy.url())
|
||||
#self.url_params = urlparse.parse_qs(url.query)
|
||||
return self._process_http_request(args, kwargs)
|
||||
|
||||
def _process_http_request(self, args, kwargs):
|
||||
|
@ -4,10 +4,11 @@ This module contains tests for the lib submodule of the Remotes plugin.
|
||||
import os
|
||||
from unittest import TestCase
|
||||
from tempfile import mkstemp
|
||||
from mock import patch
|
||||
from mock import patch, MagicMock
|
||||
import cherrypy
|
||||
|
||||
from openlp.core.lib import Settings
|
||||
from openlp.plugins.remotes.lib.httpauth import check_credentials
|
||||
from openlp.plugins.remotes.lib.httpauth import check_credentials, check_authentication
|
||||
from PyQt4 import QtGui
|
||||
|
||||
__default_settings__ = {
|
||||
@ -21,6 +22,8 @@ __default_settings__ = {
|
||||
u'remotes/ip address': u'0.0.0.0'
|
||||
}
|
||||
|
||||
SESSION_KEY = '_cp_openlp'
|
||||
|
||||
|
||||
class TestLib(TestCase):
|
||||
"""
|
||||
@ -34,6 +37,10 @@ class TestLib(TestCase):
|
||||
Settings().set_filename(self.ini_file)
|
||||
self.application = QtGui.QApplication.instance()
|
||||
Settings().extend_default_settings(__default_settings__)
|
||||
cherrypy.config.update({'environment': "test_suite"})
|
||||
# prevent the HTTP server from ever starting
|
||||
cherrypy.server.unsubscribe()
|
||||
cherrypy.engine.start()
|
||||
|
||||
def tearDown(self):
|
||||
"""
|
||||
@ -42,24 +49,39 @@ class TestLib(TestCase):
|
||||
del self.application
|
||||
os.unlink(self.ini_file)
|
||||
os.unlink(Settings().fileName())
|
||||
cherrypy.engine.exit()
|
||||
|
||||
def check_credentials_test(self):
|
||||
"""
|
||||
Test the clean_string() function
|
||||
Test the Authentication check routine.
|
||||
"""
|
||||
# GIVEN: A user and password
|
||||
# GIVEN: A user and password in settings
|
||||
Settings().setValue(u'remotes/user id', u'twinkle')
|
||||
Settings().setValue(u'remotes/password', u'mongoose')
|
||||
|
||||
# WHEN: We run the string through the function
|
||||
# WHEN: We run the function with no input
|
||||
authenticated = check_credentials(u'', u'')
|
||||
|
||||
# THEN: The string should be cleaned up and lower-cased
|
||||
# THEN: The authentication will fail with an error message
|
||||
self.assertEqual(authenticated, u'Incorrect username or password.',
|
||||
u'The return should be a error message string')
|
||||
|
||||
# WHEN: We run the string through the function
|
||||
# WHEN: We run the function with the correct input
|
||||
authenticated = check_credentials(u'twinkle', u'mongoose')
|
||||
|
||||
# THEN: The string should be cleaned up and lower-cased
|
||||
# THEN: The authentication will pass.
|
||||
self.assertEqual(authenticated, None, u'The return should be a None string')
|
||||
|
||||
def check_auth_inactive_test(self):
|
||||
"""
|
||||
Test the Authentication check routine.
|
||||
"""
|
||||
# GIVEN: A access which is secure
|
||||
Settings().setValue(u'remotes/authentication enabled', False)
|
||||
|
||||
# WHEN: We run the function with no input
|
||||
with patch(u'cherrypy.request.config'):
|
||||
authenticated = check_authentication(None, None)
|
||||
|
||||
# THEN: The authentication will fail with an error message
|
||||
self.assertEqual(authenticated, None, u'The authentication should return None as not required')
|
||||
|
Loading…
Reference in New Issue
Block a user