(
username, password, cloud_audience_urn, endpoint_address, soap_action, http_client,
**kwargs)
| 35 | logger = logging.getLogger(__name__) |
| 36 | |
| 37 | def send_request( |
| 38 | username, password, cloud_audience_urn, endpoint_address, soap_action, http_client, |
| 39 | **kwargs): |
| 40 | if not endpoint_address: |
| 41 | raise ValueError("WsTrust endpoint address can not be empty") |
| 42 | if soap_action is None: |
| 43 | if '/trust/2005/usernamemixed' in endpoint_address: |
| 44 | soap_action = Mex.ACTION_2005 |
| 45 | elif '/trust/13/usernamemixed' in endpoint_address: |
| 46 | soap_action = Mex.ACTION_13 |
| 47 | if soap_action not in (Mex.ACTION_13, Mex.ACTION_2005): |
| 48 | raise ValueError("Unsupported soap action: %s. " |
| 49 | "Contact your administrator to check your ADFS's MEX settings." % soap_action) |
| 50 | data = _build_rst( |
| 51 | username, password, cloud_audience_urn, endpoint_address, soap_action) |
| 52 | resp = http_client.post(endpoint_address, data=data, headers={ |
| 53 | 'Content-type':'application/soap+xml; charset=utf-8', |
| 54 | 'SOAPAction': soap_action, |
| 55 | }, **kwargs) |
| 56 | if resp.status_code >= 400: |
| 57 | logger.debug("Unsuccessful WsTrust request receives: %s", resp.text) |
| 58 | # It turns out ADFS uses 5xx status code even with client-side incorrect password error |
| 59 | # resp.raise_for_status() |
| 60 | return parse_response(resp.text) |
| 61 | |
| 62 | |
| 63 | def escape_xml(s): |
nothing calls this directly
no test coverage detected