Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions config/run.py
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions shaman/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
)
Expand Down
2 changes: 1 addition & 1 deletion shaman/tests/controllers/test_bus.py
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down
2 changes: 1 addition & 1 deletion shaman/tests/controllers/test_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
3 changes: 1 addition & 2 deletions shaman/tests/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()