Skip to content

Commit

Permalink
added testcase for newline in api key
Browse files Browse the repository at this point in the history
  • Loading branch information
MKLepium committed Nov 21, 2023
1 parent aae195d commit 06fb27e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions python/hopsworks/client/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def __init__(self, token):
self._token = token

def __call__(self, r):
r.headers["Authorization"] = "Bearer " + self._token
r.headers["Authorization"] = "Bearer " + self._token.strip()
return r


Expand All @@ -35,5 +35,5 @@ def __init__(self, token):
self._token = token

def __call__(self, r):
r.headers["Authorization"] = "ApiKey " + self._token
r.headers["Authorization"] = "ApiKey " + self._token.strip()
return r
7 changes: 7 additions & 0 deletions python/tests/hopsworks/test_login.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,3 +225,10 @@ def test_login_api_key_as_environ(self):
raise e
finally:
del os.environ["HOPSWORKS_API_KEY"]

def test_login_newline_in_api_key(self):
try:
imaginaryApiKey = "ImaginaryApiKey\n"
project = hopsworks.login(api_key_value=imaginaryApiKey)
except Exception as e:
self.assertNotIn(imaginaryApiKey.strip(), str(e))

0 comments on commit 06fb27e

Please sign in to comment.