Skip to content

Commit

Permalink
new: get user profile
Browse files Browse the repository at this point in the history
  • Loading branch information
Rafiot committed Jul 31, 2024
1 parent 6e50407 commit e4ed7ed
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pyvulnerabilitylookup/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,3 +211,8 @@ def list_users(self) -> dict[str, Any]:
'''List users'''
r = self.session.get(urljoin(self.root_url, str(PurePosixPath('api', 'user'))))
return r.json()

def get_user_information(self) -> dict[str, Any]:
'''Get user information'''
r = self.session.get(urljoin(self.root_url, str(PurePosixPath('api', 'user', 'me'))))
return r.json()
12 changes: 12 additions & 0 deletions tests/test_web.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,18 @@ def test_bundles_local(self) -> None:
self.assertTrue(len(comments["data"]) == 0)

# Test User
def test_users_info(self) -> None:
if not self.admin_token:
# this test is only working if the admin token is set
return None
# Makes sure the userkey is set to the right one
self.client.set_apikey(self.admin_token)
user_info = self.client.get_user_information()
self.assertTrue(isinstance(user_info, dict))
self.assertTrue('login' in user_info)
self.assertTrue('apikey' in user_info)
self.assertEqual(user_info['apikey'], self.admin_token)

def test_list_users(self) -> None:
if not self.admin_token:
# this test is only working if the admin token is set
Expand Down

0 comments on commit e4ed7ed

Please sign in to comment.