Language: Python
Label: safe
CWE: CWE-918 \u2014 Server-Side Request Forgery (SSRF)
The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.

Code:
def test_http_request_with_auth(fetch_auth, request):
    mock_fetch_auth = {"test_name": "test_auth_value"}
    fetch_auth.return_value = mock_fetch_auth
    auth = "test_auth_name"
    host_only = MlflowHostCreds("http://my-host", auth=auth)
    response = mock.MagicMock()
    response.status_code = 200
    request.return_value = response
    http_request(host_only, "/my/endpoint", "GET")

    fetch_auth.assert_called_with(auth)

    request.assert_called_with(
        "GET",
        "http://my-host/my/endpoint",
        allow_redirects=True,
        verify=mock.ANY,
        headers=mock.ANY,
        timeout=mock.ANY,
        auth=mock_fetch_auth,
    )