Commit 8e51c69a by Matt Drayer Committed by Uman Shahzad

Log additional context for SuccessFactors errors.

parent 2605bf99
......@@ -307,15 +307,19 @@ class SapSuccessFactorsIdentityProvider(EdXSAMLIdentityProvider):
response = response.json()
except requests.RequestException as err:
# If there was an HTTP level error, log the error and return the details from the SAML assertion.
log.warning(
'Unable to retrieve user details with username %s from SAPSuccessFactors for company ID %s '
'with url "%s" and error message: %s',
username,
self.odata_company_id,
odata_api_url,
err.message,
exc_info=True,
sys_msg = err.response.json() if err.response else "Not available"
log_msg_template = (
'Unable to retrieve user details with username {username} from SAPSuccessFactors for company ' +
'ID {company} with url "{url}". Error message: {err_msg}. System message: {sys_msg}.'
)
log_msg = log_msg_template.format(
username=username,
company=self.odata_company_id,
url=odata_api_url,
err_msg=err.message,
sys_msg=sys_msg
)
log.warning(log_msg, exc_info=True)
return details
return self.get_registration_fields(response)
......
......@@ -517,8 +517,9 @@ class SuccessFactorsIntegrationTest(SamlIntegrationTestUtilities, IntegrationTes
with LogCapture(level=logging.WARNING) as log_capture:
super(SuccessFactorsIntegrationTest, self).test_register()
expected_message = 'Unable to retrieve user details with username {username} from SAPSuccessFactors ' \
'for company ID {company_id} with url "{odata_api_url}" and error message: ' \
'500 Server Error: Internal Server Error for url: {odata_api_url}'.format(
'for company ID {company_id} with url "{odata_api_url}". Error message: ' \
'500 Server Error: Internal Server Error for url: {odata_api_url}. System message: ' \
'Not available.'.format(
username=self.USER_USERNAME,
company_id=odata_company_id,
odata_api_url=mocked_odata_ai_url,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment