Commit Graph

45686 Commits

Author SHA1 Message Date
Steve Howell 302ef32c5b export tests: Extract verify_realm_logo_and_icon. 2021-12-13 12:25:19 -08:00
Steve Howell b4c089d3b8 export tests: Improve how we check avatars.
We avoid code duplication, and we iterate
over all records to see if files exist.
2021-12-13 12:25:19 -08:00
Steve Howell 0c02d89bf3 export tests: Avoid passing back path_id from setup. 2021-12-13 12:25:19 -08:00
Steve Howell d3ea369057 export tests: Clean up emoji checks. 2021-12-13 12:25:19 -08:00
Steve Howell fd94ba1579 tests: Avoid returning original_avatar_path_id.
The way we check for avatars is kind of clumsy for
realms.  Ideally we would just check all users
in the realm.
2021-12-13 12:25:19 -08:00
Steve Howell dbf1ae989d tests: Avoid relying on setup data (test_image).
It is better for the verifying code to just explicitly
ensure that the exported file bytes match the bytes
in the test image.  This introduces a tiny bit more
of I/O.
2021-12-13 12:25:19 -08:00
Steve Howell 53ffb8152f tests: Use read_test_image_file helper. 2021-12-13 12:25:19 -08:00
Steve Howell 186c446458 tests: Create export files for specific user.
We no longer hackily look for the first message ever
sent within the realm.
2021-12-13 12:25:19 -08:00
Steve Howell 2debb5e5e6 tests: Add assertions for upload path_ids. 2021-12-13 12:25:19 -08:00
Steve Howell 035c90df68 export tests: Avoid full_data concept.
It's easier to read the code without the intermediate
full_data dictionary that obscures where the files live.

We also avoid some unnecessary file i/o in the tests.
2021-12-13 12:25:19 -08:00
Steve Howell 275653ad2a tests: Move helpers to module level.
(This is a pure code move apart from removing "self"
in a few places.)
2021-12-13 12:25:19 -08:00
Steve Howell 6e3e3a7bff export tests: Remove unnecessary setUp method.
I cargo-culted this in a recent commit.
2021-12-13 12:25:11 -08:00
Steve Howell 08376da7af tests: Remove dead testing code for 2nd message batch. 2021-12-13 12:25:05 -08:00
Alya Abbott 64aa278249 portico: Update designer job description. 2021-12-13 12:00:38 -08:00
Steve Howell d63e12c233 tests: Check more tables for user exports.
We do a sanity check for every table
that gets written to user.json as part of
the single-user export.

If we add more tables to the single-user export,
the test that I modified here will now ask
the author to add a new checker function, which
means we should always have at least a basic
sanity check for every exported table as long
as we stay in this new paradigm.

We also remove a little bit of old code that
became redundant.
2021-12-12 11:16:12 -08:00
Mateusz Mandera 323f5dbba2 lint: Enforce consistent style of using transaction.atomic decorator.
When decorating a function, @transaction.atomic and
@transaction.atomic() are equivalent. We can add a linting rule to
enforce consistency.
2021-12-12 11:15:33 -08:00
YashRE42 bc3d03730f message_controls: Inherit visibility from `.message_failed`.
Previously, there was a bug where a failed message would only show the
`.message_failed` icons on hover, the intent was for them to always be
visible if a message failed to send.

The cause of the above bug was that in
e7b1de8ace we modified the html
structure of the icons such that each icon was inside its own div,
which possessed the `message_control_button` class, and both such divs
were inside a `.message_failed` div. The unintended consequence of this
change was that the rule `.message_controls .message_control_button`
would apply `visibility: hidden` to the icons.

Hence, this commit explicitly sets the visibility of
`.message_failed .message_control_button` to `inherit`.
2021-12-12 11:14:46 -08:00
Steve Howell 1db74fcf2f test-all: Call documentation tests again.
I accidentally checked in a change where I commented
out the test.
2021-12-11 12:46:44 -08:00
Mateusz Mandera 74f4e3e914 do_change_realm_subdomain: Use transaction.atomic. 2021-12-11 10:39:07 -08:00
Mateusz Mandera 1692b2e81b do_reactivate_realm: Use transaction.atomic. 2021-12-11 10:39:07 -08:00
Mateusz Mandera 466e0bcdb3 do_set_realm_signup_notifications_stream: Use transaction.atomic. 2021-12-11 10:39:07 -08:00
Mateusz Mandera cddfd2cc92 do_set_realm_notifications_stream: Use transaction.atomic. 2021-12-11 10:39:07 -08:00
Mateusz Mandera 4999f68ba9 do_set_realm_message_editing: Use transaction.atomic. 2021-12-11 10:39:07 -08:00
Mateusz Mandera dc9aac9253 do_set_realm_authentication_methods: Use transaction.atomic. 2021-12-11 10:38:14 -08:00
Steve Howell 21ab5e3a55 tests: Register checkers for user export test. 2021-12-11 13:06:41 -05:00
Steve Howell 7df86f3614 tests: Tweak assertion for streams. 2021-12-11 13:06:41 -05:00
Steve Howell 6be3fbde1d tests: Split out single-user tests.
I dropped a minor assertion that was kind of redundant.
2021-12-11 13:06:41 -05:00
Steve Howell b2d83a8300 tests: Split out SingleUserExportTest.
This is mostly moving code, plus I now just
call shutil.rmtree directly.
2021-12-11 13:06:41 -05:00
Alya Abbott 0836b51738 policies: Update Kandra Labs policies pages. 2021-12-10 17:56:12 -08:00
Tim Abbott ee77c6365a portico: Use /help/ style pages for displaying policies.
This replaces the TERMS_OF_SERVICE and PRIVACY_POLICY settings with
just a POLICIES_DIRECTORY setting, in order to support settings (like
Zulip Cloud) where there's more policies than just those two.

With minor changes by Eeshan Garg.
2021-12-10 17:56:12 -08:00
Tim Abbott 95854d9d94 terms: Rename and tweak FIRST_TIME_TERMS_OF_SERVICE_TEMPLATE.
We do s/TOS/TERMS_OF_SERVICE/ on the name, and while we're at it,
remove the assumed zerver/ namespace for the template, which isn't
correct -- Zulip Cloud related content should be in the corporate/
directory.
2021-12-10 17:56:12 -08:00
Tim Abbott 509ed9ebf4 terms: Remove old development environment ToS file. 2021-12-10 17:56:12 -08:00
Alex Vandiver f6520a97cd setup-certbot: Reinstate nginx reload after installation.
If nginx was already installed, and we're using the webroot method of
initializing certbot, nginx needs to be reloaded.  Hooks in
`/etc/letsencrypt/renewal-hooks/deploy/` do not run during initial
`certbot certonly`, so an explicit reload is required.
2021-12-10 16:43:53 -08:00
Alex Vandiver e4b23daad7 puppet: Upgrade to Grafana 8.3.2, for CVE-2021-43813. 2021-12-10 14:00:11 -08:00
Tim Abbott 31842e1377 export: Fix empty realm_icons directory in single-user exports. 2021-12-10 12:05:34 -08:00
Tim Abbott 7dd543bee5 export_single_user: Fix extra leading tmp/ in tarball. 2021-12-10 12:05:34 -08:00
Steve Howell 2902f8b931 tests: Ensure stream senders get a UserMessage row.
We now complain if a test author sends a stream message
that does not result in the sender getting a
UserMessage row for the message.

This is basically 100% equivalent to complaining that
the author failed to subscribe the sender to the stream
as part of the test setup, as far as I can tell, so the
AssertionError instructs the author to subscribe the
sender to the stream.

We exempt bots from this check, although it is
plausible we should only exempt the system bots like
the notification bot.

I considered auto-subscribing the sender to the stream,
but that can be a little more expensive than the
current check, and we generally want test setup to be
explicit.

If there is some legitimate way than a subscribed human
sender can't get a UserMessage, then we probably want
an explicit test for that, or we may want to change the
backend to just write a UserMessage row in that
hypothetical situation.

For most tests, including almost all the ones fixed
here, the author just wants their test setup to
realistically reflect normal operation, and often devs
may not realize that Cordelia is not subscribed to
Denmark or not realize that Hamlet is not subscribed to
Scotland.

Some of us don't remember our Shakespeare from high
school, and our stream subscriptions don't even
necessarily reflect which countries the Bard placed his
characters in.

There may also be some legitimate use case where an
author wants to simulate sending a message to an
unsubscribed stream, but for those edge cases, they can
always set allow_unsubscribed_sender to True.
2021-12-10 09:40:04 -08:00
Aman Agrawal 7fc191d816 yarn: Add package which allows creating css mixins. 2021-12-09 18:15:18 -08:00
Tim Abbott 1c180a9f57 documentation: Avoid potential unused variable code path.
These variables can be unset if the `os.path.exists` check fails.

That should be rare, since we've previously checked the files do
exist before getting here.
2021-12-09 17:51:52 -08:00
Tim Abbott 3319893545 help: Apply heading CSS beyond just h1 headings.
This makes it possible to use non-H1 headings in the sidebars.
2021-12-09 17:51:52 -08:00
Tim Abbott 5701174a26 urls: Move developer-community redirect code. 2021-12-09 17:51:51 -08:00
Tim Abbott 4cb189fc63 settings: Rename TOS_VERSION to TERMS_OF_SERVICE_VERSION.
The previous version was appropriate in a setting where it was only
used for Zulip Cloud, but it's definitely clearer to spell it out.
2021-12-09 17:51:16 -08:00
odunybrad 90aa45a316 emoji: Add database-level uniqueness constraint for RealmEmoji.
While races here are unlikely, it is most correct to enforce this
invariant at the database layer, and having a database-level
constraint makes the models file a bit more readable.
2021-12-09 17:48:53 -08:00
Steve Howell 9a39ca217f user export: Show less info for recipients.
For PM and huddles, show full names but no
emails or other crufty fields.
2021-12-09 17:20:01 -08:00
Steve Howell 6a5c407b05 user export: Be more selective about exported messages. 2021-12-09 17:20:01 -08:00
Steve Howell fa654fd7a0 user export: Ignore realm icon and logo.
These are not considered to be "personal"
info, even if you upload them, so we
don't export them.

Generally the only folks who upload
these are admins, who can easily get
them in other ways. In fact, anybody
can get these via the app.
2021-12-09 17:20:01 -08:00
Eeshan Garg 5aaeb1a432 use_cases: Rename /for/companies to /for/business. 2021-12-09 17:16:52 -08:00
Alex Vandiver 01e8f752a8 puppet: Use certbot package timer, not our own cron job.
The certbot package installs its own systemd timer (and cron job,
which disabled itself if systemd is enabled) which updates
certificates.  This process races with the cron job which Zulip
installs -- the only difference being that Zulip respects the
`certbot.auto_renew` setting, and that it passes the deploy hook.
This means that occasionally nginx would not be reloaded, when the
systemd timer caught the expiration first.

Remove the custom cron job and `certbot-maybe-renew` script, and
reconfigure certbot to always reload nginx after deploying, using
certbot directory hooks.

Since `certbot.auto_renew` can't have an effect, remove the setting.
In turn, this removes the need for `--no-zulip-conf` to
`setup-certbot`.  `--deploy-hook` is similarly removed, as running
deploy hooks to restart nginx is now the default; pass
`--no-directory-hooks` in standalone mode to not attempt to reload
nginx.  The other property of `--deploy-hook`, of skipping symlinking
into place, is given its own flog.
2021-12-09 13:47:33 -08:00
Tim Abbott 9aa2e0ad45 upgrade-zulip-from-git: Improve webpack failure error handling.
We've had a number of unhappy reports of upgrades failing due to
webpack requiring too much memory.  While the previous commit will
likely fix this issue for everyone, it's worth improving the error
message for failures here.

We avoid doing the stop+retry ourselves, because that could cause an
outage in a production system if webpack fails for another reason.

Fixes #20105.
2021-12-09 12:26:34 -08:00
Tim Abbott 72b381d749 upgrade-zulip-from-git: Require more memory to run webpack.
Since the upgrade to Webpack 5, we've been seeing occasional reports
that servers with roughly 4GiB of RAM were getting OOM kills while
running webpack.

Since we can't readily optimize the memory requirements for webpack
itself, we should raise the RAM requirements for doing the
lower-downtime upgrade strategy.

Fixes #20231.
2021-12-09 12:23:25 -08:00