-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_slack.py
More file actions
28 lines (25 loc) · 1.03 KB
/
Copy pathtest_slack.py
File metadata and controls
28 lines (25 loc) · 1.03 KB
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
# test_slack.py — Verify Slack webhook before the demo
# Location: ~/threat-demo/test_slack.py
# Run this FIRST to confirm alerts are working
import requests
from config import SLACK_WEBHOOK_URL
def test_slack():
message = {
'text': ':white_check_mark: *Threat Detection Demo — Test Alert*',
'blocks': [
{'type': 'header',
'text': {'type': 'plain_text',
'text': ':white_check_mark: Demo System Test — All Systems Ready'}},
{'type': 'section',
'text': {'type': 'mrkdwn',
'text': 'Threat Detection Pipeline is *online*.\n'
'Slack alerts are *working correctly*. :rocket:'}},
]
}
resp = requests.post(SLACK_WEBHOOK_URL, json=message, timeout=10)
if resp.status_code == 200:
print('SUCCESS: Test alert sent — check #threat-alerts in Slack')
else:
print(f'FAILED: HTTP {resp.status_code} — check your webhook URL')
if __name__ == '__main__':
test_slack()