client = <django.test.client.Client object at 0x7f45de1780f0>
def test_oidc_get_bearer_token_anonymous_user(client):
"""
Anonymous user should be refused access with forbidden response.
"""
url = reverse("oidc-get-bearer-token")
> check_http_post_response(client, url, status_code=403)
.tox/py3/lib/python3.7/site-packages/swh/web/tests/auth/test_views.py:182:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
client = <django.test.client.Client object at 0x7f45de1780f0>
url = '/oidc/get-bearer-token/', status_code = 403, content_type = '*/*'
request_content_type = 'application/json', data = None, http_origin = None
def check_http_post_response(
client: Client,
url: str,
status_code: int,
content_type: str = "*/*",
request_content_type="application/json",
data: Optional[Dict[str, Any]] = None,
http_origin: Optional[str] = None,
) -> HttpResponse:
"""Helper function to check HTTP response for a POST request.
Args:
client: Django test client
url: URL to check response
status_code: expected HTTP status code
content_type: expected response content type
request_content_type: content type of request body
data: optional POST data
Returns:
The HTTP response
"""
actual_response = client.post(
url,
data=data,
content_type=request_content_type,
HTTP_ACCEPT=content_type,
HTTP_ORIGIN=http_origin,
)
> assert isinstance(actual_response, Response)
E assert False
E + where False = isinstance(<HttpResponseForbidden status_code=403, "text/html; charset=utf-8">, Response)
.tox/py3/lib/python3.7/site-packages/swh/web/tests/utils.py:103: AssertionError
TEST RESULT
TEST RESULT
- Run At
- May 25 2022, 4:46 PM