diff --git a/taiga/hooks/gitlab/api.py b/taiga/hooks/gitlab/api.py index 6dd2368d..8b3671d0 100644 --- a/taiga/hooks/gitlab/api.py +++ b/taiga/hooks/gitlab/api.py @@ -79,4 +79,4 @@ class GitLabViewSet(BaseWebhookApiViewSet): def _get_event_name(self, request): payload = json.loads(request.body.decode("utf-8")) - return payload.get('object_kind', 'push') + return payload.get('object_kind', 'push') if payload is not None else 'empty' diff --git a/tests/integration/test_hooks_gitlab.py b/tests/integration/test_hooks_gitlab.py index de53bff6..76e3c3be 100644 --- a/tests/integration/test_hooks_gitlab.py +++ b/tests/integration/test_hooks_gitlab.py @@ -60,6 +60,23 @@ def test_ok_signature(client): assert response.status_code == 204 +def test_ok_empty_payload(client): + project = f.ProjectFactory() + f.ProjectModulesConfigFactory(project=project, config={ + "gitlab": { + "secret": "tpnIwJDz4e", + "valid_origin_ips": ["111.111.111.111"], + } + }) + + url = reverse("gitlab-hook-list") + url = "{}?project={}&key={}".format(url, project.id, "tpnIwJDz4e") + data = {} + response = client.post(url,"null", content_type="application/json", REMOTE_ADDR="111.111.111.111") + + assert response.status_code == 204 + + def test_ok_signature_ip_in_network(client): project = f.ProjectFactory() f.ProjectModulesConfigFactory(project=project, config={