Fix responses context when no response (#1754)
This commit is contained in:
parent
de6e8d1226
commit
4f26ea3a68
2 changed files with 15 additions and 1 deletions
|
|
@ -274,4 +274,5 @@ class WebhookResponse(models.Model):
|
|||
content = models.TextField(null=True, default=None)
|
||||
|
||||
def json(self):
|
||||
return json.loads(self.content)
|
||||
if self.content:
|
||||
return json.loads(self.content)
|
||||
|
|
|
|||
|
|
@ -297,6 +297,7 @@ def test_execute_webhook_using_responses_data(
|
|||
public_primary_key="response-1",
|
||||
),
|
||||
trigger_type=Webhook.TRIGGER_FIRING,
|
||||
status_code=200,
|
||||
content=json.dumps({"id": "third-party-id"}),
|
||||
)
|
||||
make_webhook_response(
|
||||
|
|
@ -306,8 +307,20 @@ def test_execute_webhook_using_responses_data(
|
|||
public_primary_key="response-2",
|
||||
),
|
||||
trigger_type=Webhook.TRIGGER_ACKNOWLEDGE,
|
||||
status_code=200,
|
||||
content=json.dumps({"id": "third-party-id", "status": "updated"}),
|
||||
)
|
||||
# webhook wasn't executed because of some error, there is no content or status_code
|
||||
make_webhook_response(
|
||||
alert_group=alert_group,
|
||||
webhook=make_custom_webhook(
|
||||
organization=organization,
|
||||
public_primary_key="response-3",
|
||||
),
|
||||
trigger_type=Webhook.TRIGGER_SILENCE,
|
||||
content=None,
|
||||
status_code=None,
|
||||
)
|
||||
|
||||
mock_response = MockResponse()
|
||||
with patch("apps.webhooks.utils.socket.gethostbyname") as mock_gethostbyname:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue