Skip to content

Commit

Permalink
Updated to account for new default in ujson - ultrajson/ultrajson#266
Browse files Browse the repository at this point in the history
  • Loading branch information
willnx committed Jun 3, 2020
1 parent b1b7436 commit 11848c5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions tests/test_generate_token.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ def test_basic_usage(self):
self.assertTrue(token is not None)

def test_return_type(self):
"""Return type for generate_token function is Bytes"""
"""Return type for generate_token function is String"""
token = generate_token.generate_token(username=self.username,
version=self.version,
memberOf=self.memberOf,
issued_at_timestamp=time.time())
self.assertTrue(isinstance(token, bytes))
self.assertTrue(isinstance(token, str))

def test_token_content_keys(self):
"""The JSON Web Token contains all expected data"""
Expand Down Expand Up @@ -72,13 +72,13 @@ def test_basic_usage(self):
self.assertTrue(token is not None)

def test_return_type(self):
"""Return type for generate_v2_token function is Bytes"""
"""Return type for generate_v2_token function is String"""
token = generate_token.generate_v2_token(username=self.username,
version=self.version,
client_ip='127.0.0.1',
issued_at_timestamp=time.time())

self.assertTrue(isinstance(token, bytes))
self.assertTrue(isinstance(token, str))

def test_token_content_keys(self):
"""The JSON Web Token contains all expected data"""
Expand Down
4 changes: 2 additions & 2 deletions vlab_auth_service/lib/generate_token.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def generate_token(username, version, memberOf, issued_at_timestamp):
'version' : version,
'memberOf' : memberOf,
}
return jwt.encode(claims, const.AUTH_TOKEN_SECRET, algorithm=const.AUTH_TOKEN_ALGORITHM)
return jwt.encode(claims, const.AUTH_TOKEN_SECRET, algorithm=const.AUTH_TOKEN_ALGORITHM).decode()


def generate_v2_token(username, version, client_ip, issued_at_timestamp):
Expand All @@ -52,4 +52,4 @@ def generate_v2_token(username, version, client_ip, issued_at_timestamp):
'version' : version,
'client_ip' : client_ip,
}
return jwt.encode(claims, const.AUTH_TOKEN_SECRET, algorithm=const.AUTH_TOKEN_ALGORITHM)
return jwt.encode(claims, const.AUTH_TOKEN_SECRET, algorithm=const.AUTH_TOKEN_ALGORITHM).decode()

0 comments on commit 11848c5

Please sign in to comment.