(
url: str, secret: str | None, webhook_type: WebhookType
)
| 313 | |
| 314 | |
| 315 | def send_test_request_to_webhook( |
| 316 | url: str, secret: str | None, webhook_type: WebhookType |
| 317 | ) -> requests.models.Response: |
| 318 | test_data = ( |
| 319 | generate_environment_sample_webhook_data() |
| 320 | if webhook_type == WebhookType.ENVIRONMENT |
| 321 | else generate_organisation_sample_webhook_data() |
| 322 | ) |
| 323 | |
| 324 | json_data = json.dumps( |
| 325 | test_data, |
| 326 | sort_keys=True, |
| 327 | cls=DjangoJSONEncoder, |
| 328 | ) |
| 329 | headers = {"content-type": "application/json"} |
| 330 | if secret: |
| 331 | signed_payload = sign_payload(json_data, secret) |
| 332 | headers.update({FLAGSMITH_SIGNATURE_HEADER: signed_payload}) |
| 333 | res = requests.post( |
| 334 | url, data=json_data, headers=headers, timeout=10, allow_redirects=False |
| 335 | ) |
| 336 | return res |
| 337 | |
| 338 | |
| 339 | def generate_environment_sample_webhook_data() -> dict[str, Any]: |
no test coverage detected
searching dependent graphs…