Skip to content

Commit

Permalink
[AFX-5268] Use auth/user-info to get user account information #12
Browse files Browse the repository at this point in the history
  • Loading branch information
Pixel-Jack authored Apr 6, 2023
2 parents 98a957e + c251940 commit 193704b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
4 changes: 4 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All major changes in each released version of the archfx-cloud plugin are listed here.

## 0.15.0

- Use the endpoint `/auth/user-info/` to get account information in the `BaseMain` class.

## 0.14.0

- Add optional parameter to BaseMain constructor to give the config file path (.ini)
Expand Down
4 changes: 2 additions & 2 deletions archfx_cloud/utils/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ def login(self) -> bool:

if self.api.token:
try:
user = self.api.account.get()
LOG.info('Using token for {}'.format(user['results'][0]['email']))
user = getattr(self.api.auth, 'user-info').get()
LOG.info('Using token for {}'.format(user['email']))
return True
except HttpClientError as err:
LOG.debug(err)
Expand Down
6 changes: 3 additions & 3 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ def test_main_login_email_password_ok(
@mock.patch('archfx_cloud.utils.main.argparse.ArgumentParser.parse_args')
def test_main_login_token_file_ok(self, mock_request, mock_parse_args):
mock_request.get(
'https://test.archfx.io/api/v1/account/',
text=json.dumps({'results': [{'email': '[email protected]'}]}),
'https://test.archfx.io/api/v1/auth/user-info/',
text=json.dumps({'email': '[email protected]'}),
)
mock_request.post(
'https://test.archfx.io/api/v1/auth/logout/', status_code=204
Expand All @@ -75,7 +75,7 @@ def test_main_login_token_file_ok(self, mock_request, mock_parse_args):
self.assertEqual(len(mock_request.request_history), 2)
self.assertEqual(
mock_request.request_history[0].url,
'https://test.archfx.io/api/v1/account/',
'https://test.archfx.io/api/v1/auth/user-info/',
)
self.assertEqual(
mock_request.request_history[0].headers['Authorization'],
Expand Down
2 changes: 1 addition & 1 deletion version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version = '0.14.0'
version = '0.15.0'

0 comments on commit 193704b

Please sign in to comment.