zulip/zerver/tests
Mateusz Mandera 4102816240 upload: Pass the target realm to create_attachment.
The target realm was not being passed to create_attachment in
upload_message_file implementations. This was a bug in the edge-case of
cross-realm messages - in particular, causing a bug in the email
gateway:
When an email with an attachment is sent, the message is mirrored to
Zulip with Email Gateway Bot as the message sender and uploader of the
attachment. Due to the realm not being passed to create_attachment, the
Attachment would get created with .realm being the system bot realm,
making the attachment inaccessible under some conditions due to failing
the following condition check (that's expected to pass, provided that
the .realm is set correctly):
```
    if (
        attachment.is_realm_public
        and attachment.realm == user_profile.realm
        and user_profile.can_access_public_streams()
    ):
        # Any user in the realm can access realm-public files
        return True
```
2022-01-27 17:23:44 -08:00
..
fixtures markdown: Ensure all markdown fixtures have unique names. 2021-11-10 12:36:47 -08:00
images upload: Replace exif_rotate with Pillow exif_transpose. 2021-08-09 20:32:19 -07:00
__init__.py
test_alert_words.py tests: Consistently use assert_length helper. 2021-05-19 11:55:56 -07:00
test_attachments.py
test_audit_log.py refactor: Pass realm to bulk_remove_subscriptions. 2021-12-28 12:15:02 -08:00
test_auth_backends.py mypy: Add types-beautifulsoup4. 2022-01-23 23:39:40 -08:00
test_bots.py streams: Add notifications for permission policy changes. 2022-01-21 13:59:34 -08:00
test_cache.py bots: Pass realm to get_system_bot calls in test_cache.py. 2021-07-26 15:33:13 -07:00
test_compatibility.py compatibility: Shift functions to new module. 2021-06-05 07:33:25 -07:00
test_create_video_call.py integrations: Switch BigBlueButton over to SHA256. 2021-11-25 07:58:27 -08:00
test_custom_profile_data.py types: Fix declared type of custom profile field values. 2021-09-22 16:22:46 -07:00
test_data_types.py
test_decorators.py remote_server: Migrate RemoteZulipServer.uuid to be UUIDField. 2021-12-28 10:11:34 -08:00
test_digest.py tests: Ensure stream senders get a UserMessage row. 2021-12-10 09:40:04 -08:00
test_docs.py docs: Consistently hyphenate “self-host” and “self-service”. 2022-01-05 16:21:35 -08:00
test_drafts.py populate_db: Create some drafts in the initial database. 2021-07-30 10:41:52 -07:00
test_email_change.py confirmation: Use error status codes for confirmation link error pages. 2021-12-01 23:14:04 +00:00
test_email_log.py
test_email_mirror.py upload: Pass the target realm to create_attachment. 2022-01-27 17:23:44 -08:00
test_email_notifications.py send_custom_email: Add support for emailing remote server contacts. 2021-12-14 18:11:23 -08:00
test_embedded_bot_system.py tests: Ensure stream senders get a UserMessage row. 2021-12-10 09:40:04 -08:00
test_event_queue.py notifications: Don't enqueue notifications for bots. 2022-01-03 09:55:06 -08:00
test_event_system.py apply_event: Do not include new user settings in the top level. 2021-10-07 16:39:51 -07:00
test_events.py api: Update `update_message` event required fields. 2022-01-26 13:11:26 -08:00
test_example.py performance: Avoid Recipient lookup. 2021-12-28 12:15:02 -08:00
test_external.py remote_server: Migrate RemoteZulipServer.uuid to be UUIDField. 2021-12-28 10:11:34 -08:00
test_github.py downloads: Serve desktop downloads from desktop-download.zulip.com. 2021-08-28 23:08:45 -07:00
test_gitter_importer.py tests: Consistently use assert_length helper. 2021-05-19 11:55:56 -07:00
test_home.py portico: Use /help/ style pages for displaying policies. 2021-12-10 17:56:12 -08:00
test_hotspots.py hotspots: Remove intro_reply hotspot. 2021-12-07 21:55:59 -08:00
test_i18n.py invite: Extend invite api for handling expiration duration. 2021-09-10 16:53:03 -07:00
test_import_export.py mypy: Fix content types. 2021-12-16 20:35:56 -05:00
test_integrations.py tests: Add a test for fixtures for non-webhook integrations. 2021-04-28 08:16:51 -07:00
test_integrations_dev_panel.py exceptions: Add ResourceNotFoundError. 2021-07-05 11:02:12 -07:00
test_internet.py
test_legacy_subject.py
test_link_embed.py tests: Ensure stream senders get a UserMessage row. 2021-12-10 09:40:04 -08:00
test_logging_handlers.py typing: Fix function signatures with django-stubs. 2021-08-20 06:02:55 -07:00
test_management_commands.py export: Remove `--delete-after-upload` flag in realm export. 2021-11-03 11:14:02 -07:00
test_markdown.py refactor: Add MentionBackend. 2021-12-30 11:28:15 -08:00
test_mattermost_importer.py tests: Verify emoji codes. 2021-12-06 13:22:47 -08:00
test_message_dict.py tests: Ensure stream senders get a UserMessage row. 2021-12-10 09:40:04 -08:00
test_message_edit.py python: Replace string concatenations with f-strings. 2022-01-25 17:32:59 -08:00
test_message_edit_notifications.py notifications: Fix unnecessary wildcard mention notifications. 2021-08-13 09:48:18 -07:00
test_message_fetch.py upload: Pass the target realm to create_attachment. 2022-01-27 17:23:44 -08:00
test_message_flags.py streams: Add notifications for permission policy changes. 2022-01-21 13:59:34 -08:00
test_message_send.py string_validation: Loosen to allow some `Cn` unicode characters. 2022-01-11 15:17:53 -08:00
test_message_topics.py streams: Add notifications for permission policy changes. 2022-01-21 13:59:34 -08:00
test_messages.py notifications: Calculate PMs/mentions settings like other settings. 2021-07-28 13:55:25 -07:00
test_middleware.py mypy: Add types-beautifulsoup4. 2022-01-23 23:39:40 -08:00
test_migrations.py
test_mirror_users.py tests: Migrate mocked Request to HostMockRequest. 2021-07-14 12:01:07 -07:00
test_muting_topics.py test_classes: Type kwargs for client_get and friends. 2021-12-17 08:03:52 -08:00
test_muting_users.py tests: Ensure stream senders get a UserMessage row. 2021-12-10 09:40:04 -08:00
test_new_users.py settings: Remove do_change_notification_settings function. 2021-09-08 11:04:44 -07:00
test_notification_data.py notifications: Don't enqueue notifications for bots. 2022-01-03 09:55:06 -08:00
test_onboarding.py
test_openapi.py Remove Ubuntu 18.04 support. 2022-01-21 17:26:14 -08:00
test_outgoing_http.py python: Replace requests.packages.urllib3 alias with urllib3. 2022-01-23 22:14:17 -08:00
test_outgoing_webhook_interfaces.py outgoing webhooks: Fix inconsistencies with Slack's API. 2021-09-23 11:19:20 -07:00
test_outgoing_webhook_system.py tests: Consistently use assert_length helper. 2021-05-19 11:55:56 -07:00
test_populate_db.py
test_presence.py statistics: Remove unused seconds_usage_between function. 2021-08-19 01:51:37 -07:00
test_push_notifications.py python: Replace IOError with OSError. 2022-01-23 22:17:02 -08:00
test_queue.py test_queue_error_json: Acknowledge the received message. 2022-01-21 13:38:13 -08:00
test_queue_worker.py rate_limit: Fix logging string when rate limiting email gateway. 2021-11-22 10:28:56 -08:00
test_rate_limiter.py rate_limit: Implement IP-based rate limiting. 2021-07-08 15:46:52 -07:00
test_reactions.py streams: Add notifications for permission policy changes. 2022-01-21 13:59:34 -08:00
test_realm.py actions: Rename do_change_plan_type -> do change_realm_plan_type. 2021-12-06 16:18:53 -08:00
test_realm_domains.py tests: Clean up tests for realm_domain and update_streams endpoint. 2021-05-12 12:38:16 -07:00
test_realm_emoji.py emoji: Add database-level uniqueness constraint for RealmEmoji. 2021-12-09 17:48:53 -08:00
test_realm_export.py test_classes: Extract assert_streaming_content helper. 2022-01-21 13:37:26 -08:00
test_realm_linkifiers.py linkifiers: Support URL percent-encoded bytes. 2021-10-22 13:00:20 -07:00
test_realm_playgrounds.py models: Fix bug in unique_together condition on RealmPlayground. 2021-05-24 23:11:41 -07:00
test_redis_utils.py
test_report.py docs: Fix capitalization mistakes. 2021-05-10 09:57:26 -07:00
test_retention.py upload: Pass the target realm to create_attachment. 2022-01-27 17:23:44 -08:00
test_rocketchat_importer.py tests: Verify emoji codes. 2021-12-06 13:22:47 -08:00
test_scim.py test_scim: Placate mypy 0.930. 2021-12-28 09:31:55 -08:00
test_send_email.py email: Don't send overly-long "To" addresses. 2021-12-14 15:37:12 -08:00
test_service_bot_system.py tests: Consistently use assert_length helper. 2021-05-19 11:55:56 -07:00
test_sessions.py auth: Add login buttons for web public access. 2021-10-05 16:30:40 -07:00
test_settings.py lint: Fix typos found by codespell. 2021-10-19 16:51:13 -07:00
test_signup.py actions: Give do_get_user_invites a more specific name. 2022-01-12 13:53:34 -08:00
test_slack_importer.py tests: Use read_test_image_file. 2022-01-13 14:59:46 -08:00
test_slack_message_conversion.py tests: Consistently use assert_length helper. 2021-05-19 11:55:56 -07:00
test_soft_deactivation.py tests: Consistently use assert_length helper. 2021-05-19 11:55:56 -07:00
test_subdomains.py subdomains: Extend "static" to include resources hosted on S3. 2021-06-08 15:28:10 -07:00
test_submessage.py tests: Ensure stream senders get a UserMessage row. 2021-12-10 09:40:04 -08:00
test_subs.py streams: Add RealmAuditLog entries for permission changes. 2022-01-21 13:59:35 -08:00
test_templates.py markdown/tabbed_sections: Raise exception for missing tab name. 2021-10-01 16:25:17 -07:00
test_thumbnail.py requirements: Remove Thumbor. 2021-05-06 20:07:32 -07:00
test_timestamp.py
test_timezone.py test_timezone: Fix ambiguous_abbrevs type. 2021-12-28 09:31:55 -08:00
test_tornado.py tornado: Explicitly mark requests as varying by cookie. 2021-04-02 14:55:22 -07:00
test_transfer.py tests: Use read_test_image_file. 2022-01-13 14:59:46 -08:00
test_tutorial.py onboarding: Manage occurrence of 'help' command. 2021-12-06 11:32:00 -08:00
test_type_debug.py
test_typing.py typing_notifications: Make privacy settings functional. 2021-10-07 17:39:22 -07:00
test_upload.py upload: Pass the target realm to create_attachment. 2022-01-27 17:23:44 -08:00
test_urls.py test_urls: Fix get_callback_string logic. 2021-12-28 09:31:55 -08:00
test_user_groups.py tests: Use more selective query in user group tests. 2021-10-19 17:02:10 -07:00
test_user_status.py user_status: Add backend changes to support status emoji. 2021-07-27 17:57:15 -07:00
test_users.py do_deactivate_user: Revoke invitations generated by the user. 2022-01-12 13:53:34 -08:00
test_webhooks_common.py typing: Fix function signatures. 2021-08-20 05:54:19 -07:00
test_widgets.py widgets: Add range checks on backend for indexes. 2021-06-29 13:40:33 -07:00
test_zcommand.py zcommand: Replace "mode" with "theme" in the returned message. 2021-11-22 14:59:16 -08:00
test_zephyr.py docs: Add missing space to compound verbs “log in”, “set up”, etc. 2021-04-26 09:31:08 -07:00