Commit 8e51c69a by Matt Drayer Committed by Uman Shahzad

Log additional context for SuccessFactors errors.

parent 2605bf99
...@@ -307,15 +307,19 @@ class SapSuccessFactorsIdentityProvider(EdXSAMLIdentityProvider): ...@@ -307,15 +307,19 @@ class SapSuccessFactorsIdentityProvider(EdXSAMLIdentityProvider):
response = response.json() response = response.json()
except requests.RequestException as err: except requests.RequestException as err:
# If there was an HTTP level error, log the error and return the details from the SAML assertion. # If there was an HTTP level error, log the error and return the details from the SAML assertion.
log.warning( sys_msg = err.response.json() if err.response else "Not available"
'Unable to retrieve user details with username %s from SAPSuccessFactors for company ID %s ' log_msg_template = (
'with url "%s" and error message: %s', 'Unable to retrieve user details with username {username} from SAPSuccessFactors for company ' +
username, 'ID {company} with url "{url}". Error message: {err_msg}. System message: {sys_msg}.'
self.odata_company_id, )
odata_api_url, log_msg = log_msg_template.format(
err.message, username=username,
exc_info=True, 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 details
return self.get_registration_fields(response) return self.get_registration_fields(response)
......
...@@ -517,8 +517,9 @@ class SuccessFactorsIntegrationTest(SamlIntegrationTestUtilities, IntegrationTes ...@@ -517,8 +517,9 @@ class SuccessFactorsIntegrationTest(SamlIntegrationTestUtilities, IntegrationTes
with LogCapture(level=logging.WARNING) as log_capture: with LogCapture(level=logging.WARNING) as log_capture:
super(SuccessFactorsIntegrationTest, self).test_register() super(SuccessFactorsIntegrationTest, self).test_register()
expected_message = 'Unable to retrieve user details with username {username} from SAPSuccessFactors ' \ 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: ' \ 'for company ID {company_id} with url "{odata_api_url}". Error message: ' \
'500 Server Error: Internal Server Error for url: {odata_api_url}'.format( '500 Server Error: Internal Server Error for url: {odata_api_url}. System message: ' \
'Not available.'.format(
username=self.USER_USERNAME, username=self.USER_USERNAME,
company_id=odata_company_id, company_id=odata_company_id,
odata_api_url=mocked_odata_ai_url, 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