new: get user profile
Some checks failed
Python application - MyPy / Python 3.10 sample (push) Has been cancelled
Python application - MyPy / Python 3.11 sample (push) Has been cancelled
Python application - MyPy / Python 3.12 sample (push) Has been cancelled
Python application - MyPy / Python 3.8 sample (push) Has been cancelled
Python application - MyPy / Python 3.9 sample (push) Has been cancelled
Python application - Test Public Interface / Python 3.10 sample (push) Has been cancelled
Python application - Test Public Interface / Python 3.11 sample (push) Has been cancelled
Python application - Test Public Interface / Python 3.12 sample (push) Has been cancelled
Python application - Test Public Interface / Python 3.8 sample (push) Has been cancelled
Python application - Test Public Interface / Python 3.9 sample (push) Has been cancelled

This commit is contained in:
Raphaël Vinot 2024-07-31 16:29:34 +02:00
parent 6e504075a1
commit e4ed7ed1f6
2 changed files with 17 additions and 0 deletions

View file

@ -211,3 +211,8 @@ class PyVulnerabilityLookup():
'''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()

View file

@ -253,6 +253,18 @@ class TestPublic(unittest.TestCase):
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