Fixing gitlab requests with empty payloads
parent
800d4d398a
commit
a206d41ba1
|
@ -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'
|
||||
|
|
|
@ -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={
|
||||
|
|
Loading…
Reference in New Issue