Repository navigation
Commit 41f9e5a
test(integrations): Mock Slack, Discord, Jira, and Sentry App calls in tests (#127946)
The outbound network guard in report mode (#127944) found 14 integration
tests that make real requests to `slack.com`, `discord.com`,
`example.atlassian.net`, or `example.com`. Some of them only pass
because of what the real service sends back. For example,
`test_post_message_failure_sdk` asserts the `ok=False, status=200`
metric that Slack's real `invalid_auth` reply produces.
Each test now uses a mock pattern that already exists in the same file:
- **Slack SDK** (it sends with urllib, so `responses` never matches):
- `tasks/test_tasks.py::test_post_message_failure_sdk` and
`service/test_slack_service.py::test_send_notification_to_slack_channel_error`
patch `_perform_urllib_http_request` to return the `invalid_auth` reply
the tests depended on, like their success-path neighbors do.
- `test_notify_action.py::test_invalid_channel_selected` had `responses`
mocks that could never match. It now uses the file's own
`mock_msg_schedule_response("channel_not_found")` and
`mock_list("users", ...)` helpers, which return the same data.
- `utils/test_channel.py::test_invalid_channel_selected_sdk_client` also
patches `users_list` with an empty member list.
- `webhooks/events/test_app_mention.py`: an autouse `set_thread_status`
patch, the same one `test_direct_message.py` uses.
`test_app_mention_only_mentions_halts` also patches
`send_threaded_ephemeral_message`, like its sibling halt tests.
- **Discord** `test_issue_alert.py::test_no_channel_id`: `responses`
returns a 400 for `GET /channels/`, and the test now asserts that the
mocked call happened.
- **Jira** `test_integration.py::JiraApiPipelineTest::test_install`:
when the install response serializes the org config, it fetches the
project list. `responses` now returns a 401 for that request, which
leads to the `ApiError` handling the real request hit.
- **Sentry Apps**
`test_disabled_sentry_app.py::test_delete_installation_of_disabled_app_allowed`:
the uninstall webhook is mocked the way
`test_organization_sentry_app_installation_details.py::test_delete_install`
does it.
No assertions were removed or weakened. This PR only changes tests and
doesn't depend on #127944. I ran every touched file locally with
`SENTRY_NETWORK_GUARD=strict`: they pass, and the guard records no
outbound attempts.
<!-- junior-request-attribution:start -->
via @joshuarli.
<!-- junior-request-attribution:end -->
<!-- junior-session-footer:start -->
<!-- junior-conversation-id:agent%3A35c0cbe32045897a494787cce713d692 -->
--
[View Junior
Session](https://junior-prod.sentry.dev/conversations/agent%3A35c0cbe32045897a494787cce713d692)
[[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3A35c0cbe32045897a494787cce713d692/?project=4510944073809921)
<!-- junior-session-footer:end -->
Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: Joshua Li <14209781+joshuarli@users.noreply.github.com>1 parent ee03089 commit 41f9e5a
8 files changed
Lines changed: 50 additions & 26 deletions
File tree
- tests/sentry
- integrations
- discord
- jira
- slack
- service
- tasks
- utils
- webhooks/events
- sentry_apps/api/bases
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| |||
328 | 328 | | |
329 | 329 | | |
330 | 330 | | |
| 331 | + | |
331 | 332 | | |
332 | 333 | | |
333 | 334 | | |
334 | 335 | | |
335 | 336 | | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
336 | 342 | | |
337 | 343 | | |
338 | 344 | | |
| 345 | + | |
339 | 346 | | |
340 | 347 | | |
341 | 348 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2456 | 2456 | | |
2457 | 2457 | | |
2458 | 2458 | | |
| 2459 | + | |
2459 | 2460 | | |
| 2461 | + | |
| 2462 | + | |
2460 | 2463 | | |
2461 | 2464 | | |
2462 | 2465 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
538 | 538 | | |
539 | 539 | | |
540 | 540 | | |
541 | | - | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
542 | 548 | | |
543 | 549 | | |
544 | 550 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
| 63 | + | |
63 | 64 | | |
64 | | - | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
65 | 74 | | |
66 | 75 | | |
67 | 76 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
243 | 243 | | |
244 | 244 | | |
245 | 245 | | |
246 | | - | |
247 | 246 | | |
248 | 247 | | |
249 | 248 | | |
250 | 249 | | |
251 | 250 | | |
252 | | - | |
253 | | - | |
254 | | - | |
255 | | - | |
256 | | - | |
257 | | - | |
258 | | - | |
259 | | - | |
260 | | - | |
261 | | - | |
262 | | - | |
263 | | - | |
264 | | - | |
265 | | - | |
266 | | - | |
267 | | - | |
268 | | - | |
| 251 | + | |
269 | 252 | | |
270 | | - | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
271 | 256 | | |
272 | | - | |
273 | | - | |
| 257 | + | |
| 258 | + | |
274 | 259 | | |
275 | 260 | | |
276 | 261 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
170 | 170 | | |
171 | 171 | | |
172 | 172 | | |
173 | | - | |
| 173 | + | |
174 | 174 | | |
175 | 175 | | |
176 | 176 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
| 4 | + | |
3 | 5 | | |
4 | 6 | | |
5 | 7 | | |
| |||
23 | 25 | | |
24 | 26 | | |
25 | 27 | | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
26 | 35 | | |
27 | 36 | | |
28 | 37 | | |
| |||
137 | 146 | | |
138 | 147 | | |
139 | 148 | | |
| 149 | + | |
140 | 150 | | |
141 | 151 | | |
142 | | - | |
| 152 | + | |
143 | 153 | | |
144 | 154 | | |
145 | 155 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
1 | 3 | | |
2 | 4 | | |
3 | 5 | | |
| |||
61 | 63 | | |
62 | 64 | | |
63 | 65 | | |
| 66 | + | |
64 | 67 | | |
65 | 68 | | |
| 69 | + | |
66 | 70 | | |
67 | 71 | | |
68 | 72 | | |
| |||
0 commit comments