Page MenuHomeSoftware Heritage

Jenkins > .tox.py3.lib.python3.7.site-packages.swh.web.tests.api.test_apiresponse::Tests / Python tests / test_api_endpoints_have_cors_headers
Failed

TEST RESULT

Run At
May 7 2022, 7:43 PM
Details
client = <django.test.client.Client object at 0x7f869114ef28> content = {'blake2s256': '574bff42d27168b2ae7d6d62ce7b36a79b2c8514ca4d82271eb470c7b962ebe1', 'data': '/*\n** SGI FREE SOFTWARE L...Elements( TESStesselator *tess )\n{\n\treturn tess->elements;\n}\n', 'encoding': 'us-ascii', 'hljs_language': 'c', ...} directory = '476daad0ea1406747bce46ad1649f6a7438724a5' revision = 'f691a30f9751b8c300f445af1df9bdffcc5fd969' def test_api_endpoints_have_cors_headers(client, content, directory, revision): url = reverse("api-1-stat-counters") resp = check_http_get_response( client, url, status_code=200, http_origin="https://example.org" ) assert ACCESS_CONTROL_ALLOW_ORIGIN in resp swhids = [ gen_swhid(ObjectType.CONTENT, content["sha1_git"]), gen_swhid(ObjectType.DIRECTORY, directory), gen_swhid(ObjectType.REVISION, revision), ] url = reverse("api-1-known") ac_request_method = "POST" ac_request_headers = "Content-Type" resp = client.options( url, HTTP_ORIGIN="https://example.org", HTTP_ACCESS_CONTROL_REQUEST_METHOD=ac_request_method, HTTP_ACCESS_CONTROL_REQUEST_HEADERS=ac_request_headers, ) assert resp.status_code == 200 assert ACCESS_CONTROL_ALLOW_ORIGIN in resp assert ACCESS_CONTROL_ALLOW_METHODS in resp assert ac_request_method in resp[ACCESS_CONTROL_ALLOW_METHODS] assert ACCESS_CONTROL_ALLOW_HEADERS in resp assert ac_request_headers.lower() in resp[ACCESS_CONTROL_ALLOW_HEADERS] resp = resp = check_http_post_response( > client, url, data=swhids, status_code=200, http_origin="https://example.org" ) .tox/py3/lib/python3.7/site-packages/swh/web/tests/api/test_apiresponse.py:185: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ .tox/py3/lib/python3.7/site-packages/swh/web/tests/utils.py:103: in check_http_post_response content_type=content_type, _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ response = <Response status_code=500, "application/json">, status_code = 200 content_type = '*/*' def _assert_http_response( response: HttpResponse, status_code: int, content_type: str ) -> HttpResponse: if isinstance(response, Response): drf_response = cast(Response, response) error_context = ( drf_response.data.pop("traceback") if isinstance(drf_response.data, dict) and "traceback" in drf_response.data else drf_response.data ) elif isinstance(response, StreamingHttpResponse): error_context = getattr(response, "traceback", response.streaming_content) else: error_context = getattr(response, "traceback", response.content) > assert response.status_code == status_code, error_context E AssertionError: Traceback (most recent call last): E File "/var/lib/jenkins/workspace/DWAPPS/tests-on-diff@2/.tox/py3/lib/python3.7/site-packages/rest_framework/views.py", line 506, in dispatch E response = handler(request, *args, **kwargs) E File "/var/lib/jenkins/workspace/DWAPPS/tests-on-diff@2/.tox/py3/lib/python3.7/site-packages/rest_framework/decorators.py", line 50, in handler E return func(*args, **kwargs) E File "/var/lib/jenkins/workspace/DWAPPS/tests-on-diff@2/.tox/py3/lib/python3.7/site-packages/swh/web/api/apiurls.py", line 96, in api_view_f E response = f(request, **kwargs) E File "/var/lib/jenkins/workspace/DWAPPS/tests-on-diff@2/.tox/py3/lib/python3.7/site-packages/swh/web/api/apidoc.py", line 380, in documented_view E raise exc E File "/var/lib/jenkins/workspace/DWAPPS/tests-on-diff@2/.tox/py3/lib/python3.7/site-packages/swh/web/api/apidoc.py", line 377, in documented_view E return {"data": f(request, **kwargs), "doc_data": doc_data} E File "/var/lib/jenkins/workspace/DWAPPS/tests-on-diff@2/.tox/py3/lib/python3.7/site-packages/swh/web/api/views/identifiers.py", line 116, in api_swhid_known E for hash in missing_hashes.iter(): E AttributeError: 'set' object has no attribute 'iter' E E assert 500 == 200 E + where 500 = <Response status_code=500, "application/json">.status_code .tox/py3/lib/python3.7/site-packages/swh/web/tests/utils.py:34: AssertionError