Skip to content

Commit

Permalink
Fix codystyle warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Olek Golovatyi committed Aug 14, 2020
1 parent cf0d2ff commit 4bc8e8a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
12 changes: 6 additions & 6 deletions tabpy/tabpy_server/handlers/base_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ def handle_authentication(self, api_version):
Returns
-------
String
String
None if authentication is not required and username and password are None.
None if authentication is required and valid credentials provided.
NotAuthorized if authenication is required and credentials are incorrect.
Expand All @@ -387,19 +387,19 @@ def handle_authentication(self, api_version):
if method == "":
if not self._get_basic_auth_credentials():
self.logger.log(logging.DEBUG,
"authentication not required, username and password are none")
"authentication not required, username and password are none")
return AuthErrorStates.NONE
else:
self.logger.log(logging.DEBUG,
"authentication not required, username and password are not none")
"authentication not required, username and password are not none")
return AuthErrorStates.NotRequired

if not self._get_credentials(method):
return AuthErrorStates.NotAuthorized

if not self._validate_credentials(method):
return AuthErrorStates.NotAuthorized

return AuthErrorStates.NONE

def should_fail_with_auth_error(self):
Expand All @@ -412,9 +412,9 @@ def should_fail_with_auth_error(self):
-------
bool
False if authentication is not required and username
and password is None or isrequired and validation
and password is None or isrequired and validation
for credentials passes.
True if validation for credentials failed or
True if validation for credentials failed or
if authentication is not required and username and password
fields are not empty.
"""
Expand Down
2 changes: 2 additions & 0 deletions tabpy/tabpy_server/handlers/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
from hashlib import pbkdf2_hmac
from enum import Enum, auto


class AuthErrorStates(Enum):
NONE = auto()
NotAuthorized = auto()
NotRequired = auto()


def hash_password(username, pwd):
"""
Hashes password using PKDBF2 method:
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/server_tests/test_endpoint_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ def test_valid_creds_unknown_endpoint_fails(self):
)
self.assertEqual(404, response.code)


class TestEndpointHandlerWithoutAuth(AsyncHTTPTestCase):
@classmethod
def setUpClass(cls):
Expand Down Expand Up @@ -161,4 +162,4 @@ def test_creds_no_auth_fails(self):
},
)
self.assertEqual(400, response.code)

2 changes: 1 addition & 1 deletion tests/unit/server_tests/test_evaluation_plane_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,4 +286,4 @@ def test_creds_no_auth_fails(self):
},
)
self.assertEqual(400, response.code)

0 comments on commit 4bc8e8a

Please sign in to comment.