Skip to content

Commit

Permalink
Update tests and remove default token strings
Browse files Browse the repository at this point in the history
  • Loading branch information
NeonDaniel committed Jan 19, 2024
1 parent 9ed7743 commit c1ccb6d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
4 changes: 2 additions & 2 deletions neon_hana/auth/client_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ def __init__(self, config: dict):
self._access_token_lifetime = config.get("access_token_ttl", 3600 * 24)
self._refresh_token_lifetime = config.get("refresh_token_ttl",
3600 * 24 * 7)
self._access_secret = config.get("access_token_secret") or "a800445648142061fc238d1f84e96200da87f4f9f784108ac90db8b4391b117b"
self._refresh_secret = config.get("refresh_token_secret") or "a800445648142061fc238d1f84e96200da87f4f9f784108ac90db8b4391b117b"
self._access_secret = config.get("access_token_secret")
self._refresh_secret = config.get("refresh_token_secret")
self._rpm = config.get("requests_per_minute", 60)
self._disable_auth = config.get("disable_auth")
self._jwt_algo = "HS256"
Expand Down
14 changes: 9 additions & 5 deletions tests/test_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@

class TestClientManager(unittest.TestCase):
from neon_hana.auth.client_manager import ClientManager
client_manager = ClientManager({})
client_manager = ClientManager({"access_token_secret": "a800445648142061fc238d1f84e96200da87f4f9f784108ac90db8b4391b117b",
"refresh_token_secret": "a800445648142061fc238d1f84e96200da87f4f9f784108ac90db8b4391b117b"})

def test_check_auth_request(self):
client_1 = str(uuid4())
Expand Down Expand Up @@ -63,9 +64,12 @@ def test_validate_auth(self):
valid_client = str(uuid4())
invalid_client = str(uuid4())
auth_response = self.client_manager.check_auth_request(
username="valid", client_id=valid_client)['jwt_token']
username="valid", client_id=valid_client)['access_token']

self.assertTrue(self.client_manager.validate_auth(auth_response))
self.assertFalse(self.client_manager.validate_auth(invalid_client))
self.assertTrue(self.client_manager.validate_auth(auth_response,
"127.0.0.1"))
self.assertFalse(self.client_manager.validate_auth(invalid_client,
"127.0.0.1"))
self.client_manager.authorized_clients.pop(valid_client)
self.assertFalse(self.client_manager.validate_auth(auth_response))
self.assertFalse(self.client_manager.validate_auth(auth_response,
"127.0.0.1"))

0 comments on commit c1ccb6d

Please sign in to comment.