diff --git a/config/run.py b/config/run.py index 0bf2ddd..c363e31 100644 --- a/config/run.py +++ b/config/run.py @@ -1,11 +1,12 @@ import os from os.path import dirname import cherrypy -from cherrypy import wsgiserver +from cheroot.wsgi import Server as CherryPyWSGIServer +from cheroot.wsgi import PathInfoDispatcher as WSGIPathInfoDispatcher from pecan.deploy import deploy -simpleapp_wsgi_app = deploy('dev.py') +simpleapp_wsgi_app = deploy('config/dev.py') current_dir = os.path.abspath(dirname(__file__)) base_dir = dirname(current_dir) @@ -35,13 +36,13 @@ def make_static_config(static_dir_name): # Assuming your app has media on different paths, like 'css', and 'images' -application = wsgiserver.WSGIPathInfoDispatcher({ +application = WSGIPathInfoDispatcher({ '/': simpleapp_wsgi_app, '/static': make_static_config('static') } ) -server = wsgiserver.CherryPyWSGIServer(('0.0.0.0', 8080), application, server_name='simpleapp') +server = CherryPyWSGIServer(('0.0.0.0', 8080), application, server_name='simpleapp') try: server.start() diff --git a/shaman/auth.py b/shaman/auth.py index f08f9db..dce1406 100644 --- a/shaman/auth.py +++ b/shaman/auth.py @@ -9,7 +9,7 @@ def basic_auth(): try: auth = request.headers.get('Authorization') assert auth - decoded = base64.b64decode(auth.split(' ')[1]) + decoded = base64.b64decode(auth.split(' ')[1]).decode() username, password = decoded.split(':') assert username == conf.api_user @@ -27,7 +27,7 @@ def github_basic_auth(): # if this isn't github try basic_auth return basic_auth() - github_secret = conf.github_secret + github_secret = conf.github_secret.encode() signature = "sha1={}".format( hmac.new(github_secret, request.body, sha1).hexdigest() ) diff --git a/shaman/tests/controllers/test_bus.py b/shaman/tests/controllers/test_bus.py index 1793db2..3b279dc 100644 --- a/shaman/tests/controllers/test_bus.py +++ b/shaman/tests/controllers/test_bus.py @@ -18,7 +18,7 @@ def test_post_index_github_auth_fails(self, session): assert result.status_int == 401 def test_post_index_github_auth_succeeds(self, session): - signature = "sha1={}".format(hmac.new('secret', '{}', sha1).hexdigest()) + signature = "sha1={}".format(hmac.new('secret'.encode(), '{}'.encode(), sha1).hexdigest()) result = session.app.post_json( '/api/bus/ceph/test', headers={'X-Hub-Signature': signature}, diff --git a/shaman/tests/controllers/test_nodes.py b/shaman/tests/controllers/test_nodes.py index 21c83ea..d1ed644 100644 --- a/shaman/tests/controllers/test_nodes.py +++ b/shaman/tests/controllers/test_nodes.py @@ -89,7 +89,7 @@ def _get_next_node(): monkeypatch.setattr(nodes, "get_next_node", _get_next_node) result = session.app.get("/api/nodes/next/") - assert result.body == "https://chacra.ceph.com/" + assert result.body.decode() == "https://chacra.ceph.com/" def test_get_next_node_fails(self, session, monkeypatch): monkeypatch.setattr(nodes, "check_node_health", mock_check_node_health(True)) diff --git a/shaman/tests/util.py b/shaman/tests/util.py index bea33ec..e6eb0e4 100644 --- a/shaman/tests/util.py +++ b/shaman/tests/util.py @@ -9,5 +9,4 @@ def make_credentials(correct=True, username=None, secret=None): creds = "%s:%s" % (username, secret) else: creds = 'you:wrong' - return 'Basic %s' % base64.b64encode(creds) - + return 'Basic %s' % base64.b64encode(creds.encode()).decode()