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 6 2022, 5:36 PM
Details
client = <django.test.client.Client object at 0x7fe21bcd9748> content = {'blake2s256': '833ec71111b41a49f0b96ec129b41dfe7ee3c38a50d54c20f5969d89128c885c', 'data': "// jshint multistr:true\n\...gs[n] : m;\n });\n }\n\n}(window, document));\n", 'encoding': 'us-ascii', 'hljs_language': 'javascript', ...} directory = '139f4a175f1af016a151dc4f1e4fd0886a512f44' revision = 'd87aa59fc671b0c3bbeb3a8e3a40d9c02b926d33' 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@3/.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@3/.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@3/.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@3/.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@3/.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@3/.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: 'generator' 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