Skip to content

Commit

Permalink
OpTestUtils: Handle successful login response format difference
Browse files Browse the repository at this point in the history
Depending on code level running on BMC/eBMC, expected format
for a response on successful login operation may differ.

Expected: status': 'ok'
Actual: "token":"<token>"

This patch adds code to handle this valid response.

before FIx:

Traceback (most recent call last):
  File "/home/shirisha_g/Desktop/Reinstall-202132021432/OPTEST-SETUP/op-test/common/OpTestUtil.py", line 2576, in login
    .format(r.status_code, json_data['status'],
KeyError: 'status'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/shirisha_g/Desktop/Reinstall-202132021432/OPTEST-SETUP/op-test/OpTestConfiguration.py", line 939, in objs
    password=self.args.bmc_password)
  File "/home/shirisha_g/Desktop/Reinstall-202132021432/OPTEST-SETUP/op-test/common/OpTestEBMC.py", line 55, in __init__
    r = self.conf.util_bmc_server.login()
  File "/home/shirisha_g/Desktop/Reinstall-202132021432/OPTEST-SETUP/op-test/common/OpTestUtil.py", line 2599, in login
    .format(self._url(uri), username, password, e))
common.Exceptions.HTTPCheck: Something happened with the HTTP Server.  Review the following for more details
Message="Requests post problem, check that your credentials are properly

Signed-off-by: Praveen K Pandey <[email protected]>
  • Loading branch information
PraveenPenguin committed Sep 2, 2024
1 parent e197972 commit a832140
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions common/OpTestUtil.py
Original file line number Diff line number Diff line change
Expand Up @@ -2571,6 +2571,12 @@ def login(self, username=None, password=None):
self.xAuthHeader['X-Auth-Token'] = match.group(1)
self.jsonHeader.update(self.xAuthHeader)
json_data = json.loads(r.text)
if json_data.get('token'):
json_data={
"data": "User '%s' logged in" %username,
"message": "200 OK",
"status": "ok"
}
log.debug("r.status_code={} json_data['status']={}"
" r.text={} r.headers={} r.request.headers={}"
.format(r.status_code, json_data['status'],
Expand Down

0 comments on commit a832140

Please sign in to comment.