-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_local.py
More file actions
35 lines (30 loc) · 855 Bytes
/
Copy pathtest_local.py
File metadata and controls
35 lines (30 loc) · 855 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import requests
import json
import uuid
import hmac
import hashlib
import os
secret = os.getenv("LINEAR_WEBHOOK_SECRET", "dummy_secret_for_tests")
url = "http://localhost:5005/webhooks/linear"
payload = {
"action": "create",
"type": "Issue",
"data": {
"id": str(uuid.uuid4()),
"title": "Local Test Issue",
"state": {"type": "started", "name": "In Progress"}
}
}
payload_bytes = json.dumps(payload).encode('utf-8')
signature = hmac.new(secret.encode('utf-8'), payload_bytes, hashlib.sha256).hexdigest()
headers = {
"Content-Type": "application/json",
"X-Linear-Signature": signature
}
print(f"POSTing to {url}...")
try:
r = requests.post(url, data=payload_bytes, headers=headers)
print(f"Status: {r.status_code}")
print(f"Response: {r.text}")
except Exception as e:
print(f"Error: {e}")