diff --git a/pyvulnerabilitylookup/api.py b/pyvulnerabilitylookup/api.py index d7b7a43..580fd2b 100644 --- a/pyvulnerabilitylookup/api.py +++ b/pyvulnerabilitylookup/api.py @@ -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() diff --git a/tests/test_web.py b/tests/test_web.py index 4161b03..e82e090 100644 --- a/tests/test_web.py +++ b/tests/test_web.py @@ -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