Eeshan Garg
5069683cad
decorators: Refactor the webhook_logger code.
...
Just to make the code a bit cleaner and to be able to reuse the
same logging code in other decorator functions.
2018-03-02 11:56:20 -08:00
Umair Khan
0eca2e102d
cache: Add ignore_unhashable_lru_cache function.
...
This is a wrapper over lru_cache function. It adds following features on
top of lru_cache:
* It will not cache result of functions with unhashable arguments.
* It will clear cache whenever zerver.lib.cache.KEY_PREFIX changes.
2018-02-09 18:14:08 -08:00
Dennis Ludl
895a675f4c
decorators: Fix email check in access_user_by_api_key case insensitive.
...
In Zulip, email addresses should always be treated as
case-insensitive; this code path incorrectly assumed the email input
by the user had the correct case.
Discussed in:
https://chat.zulip.org/#narrow/stream/issues/subject/Mobile.20Apps.3A.20Sometimes.20don't.20load.20data/near/461062
Commit message tweaked by tabbott.
2018-01-23 10:04:03 -08:00
Alena Volkova
7c22045158
test_decorators: Replace the json/fetch_api_key endpoint in tests.
...
This endpoint is about to become an API-style route and have the legacy
decorator removed from its view. Other endpoints will be used in tests
instead of it.
2018-01-08 13:15:52 -05:00
Robert Hönig
3420ed1fcc
validator.py: Cover missing lines in check_dict().
2018-01-07 15:23:17 -05:00
Alena Volkova
26eb23afc7
tests: Replace api_auth usages with auth methods in zerver/tests.
2017-12-18 09:24:09 -05:00
rht
0260ba82ca
zerver/tests: Use python 3 syntax for typing (part 4).
2017-11-21 22:01:19 -08:00
Rishi Gupta
27babcf92b
portico: Update error message for deactivated user.
...
The installation admin is not the right person to get support requests from
deactivated users, regardless of the situation.
Also updates the wording to be a bit more concise.
2017-11-20 13:40:51 -08:00
rht
6c28c7e879
zerver/tests: Use python 3 syntax for typing.
2017-11-18 15:35:57 -08:00
Tim Abbott
8dc82f97c7
python: Wrap long def lines in test files.
...
We don't have our linter checking test files due to ultra-long strings
that are often present in test output that we verify. But it's worth
at least cleaning out all the ultra-long def lines.
2017-11-16 22:00:53 -08:00
rht
4f5b1c0a5a
zerver/tests: Use python 3 syntax for typing in most files.
2017-11-16 21:52:01 -08:00
Tim Abbott
a23378a304
check_short_string: Verify string before checking length.
...
While the previous implementation was correct, this should give better
error messages.
2017-11-10 16:37:43 -08:00
Steve Howell
5be13fb066
Add cachify decorator.
2017-11-07 10:36:02 -08:00
rht
c7fa1d4146
zerver/tests: Remove inheritance from object.
2017-11-06 08:53:48 -08:00
neiljp (Neil Pilgrim)
42f5eea61f
mypy: Improve typing of request.pyi (REQ).
...
This expands request.pyi to type-check the arguments passed into REQ.
Tweaked by tabbott to fix the report.py annotations.
2017-11-04 20:26:03 -07:00
neiljp (Neil Pilgrim)
055dff9038
mypy: Clarify parameter types in test_decorators.py.
2017-11-04 19:47:45 -07:00
Greg Price
68b0a419ec
decorator: Cut a bunch of dead imports of two view decorators.
...
Saw these when grepping for these two decorators; they're actually
more numerous than the surviving use sites are. Cut out the noise.
2017-11-04 19:27:00 -07:00
Tim Abbott
5467296f60
decorators: Use human_users_only more aggressively.
2017-10-27 15:16:13 -07:00
Tim Abbott
1cd017288d
views: Fix imports of REQ/has_request_variables from the wrong place.
...
These were never in zerver/decorator.py, and so it makes sense to
import them zerver/lib/request.py, mostly for ease of finding things.
2017-10-27 15:07:31 -07:00
Alena Volkova
0e653d198d
test_decorators: Replace the json/tutorial_status endpoint in tests.
...
This endpoint is about to become an API-style route and have the legacy
decorator removed from its view. The json/fetch_api_key endpoint will be
used in tests instead of it.
2017-10-09 15:13:33 -07:00
derAnfaenger
747c283180
lint: Replace `pk` with `id` where they are equivalent.
2017-10-06 12:52:12 -07:00
Tim Abbott
7581e0e1c5
settings: Remove remaining references to REALMS_HAVE_SUBDOMAINS.
2017-10-02 16:43:54 -07:00
Tim Abbott
edc10e8f51
test_decorators: de-inline REALMS_HAVE_SUBDOMAINS with statements.
...
This will significantly shrink the diff when we toggle
REALMS_HAVE_SUBDOMAINS soon.
2017-10-02 13:49:53 -07:00
Tim Abbott
5a27a4cf1c
decorator: Improve wrong-subdomain logging output.
...
Often, it's helpful to see both values in errors.
2017-10-02 13:31:20 -07:00
Tim Abbott
6327f30c76
test_decorators: Remove test_login_deactivated_realm.
...
This test was a duplicate of test_login_deactivated in LoginTest.
2017-10-02 11:42:15 -07:00
invinciblycool
5475c5cedb
tests: Replace test_user_agent_parsing with a normal test.
...
Previously, this was its own separate test script; now it's a normal
part of the test suite.
Tweaked by tabbott to use a proper test method.
Fixes #6327 .
2017-09-16 03:56:18 -07:00
Tim Abbott
4a22316d90
test_decorator: Add explicit subdomains in tests.
2017-08-28 22:51:57 -07:00
Tim Abbott
4229faf36e
tests: Remove old six.PY2 code paths.
2017-08-25 11:05:16 -07:00
Tim Abbott
7d08ff69f0
tests: Remove most references to get_api_key.
...
This test helper doesn't really have value.
2017-08-24 23:30:46 -07:00
Tim Abbott
5206dad373
decorator: Fix is_browser_view handling of e.g. mobile apps.
...
We may end up with some endpoints that could be the browser or the
mobile apps, and we want the right default to happen here.
2017-08-24 16:26:57 -07:00
Tim Abbott
7ffc107061
decorator: Rename is_json_view to is_browser_view.
...
This improves clarity, now that we're planning to start logging in the
login/registration pages, which aren't browser views.
2017-08-24 16:25:08 -07:00
Tim Abbott
58edf75962
api: Allow incoming webhook bots to use the send_message API.
2017-08-22 10:06:34 -07:00
Tim Abbott
5a63ea0170
decorator: Extract validate_account_and_subdomain and deduplicate.
...
This fixes the significant duplication of code between the
authenticate_log_and_execute_json code path and the `validate_api_key`
code path.
These's till a bit of duplication, in the form of `process_client` and
`request._email` interactions, but it is very minor at this point.
2017-08-15 10:54:23 -07:00
Tim Abbott
3c37795675
decorator: Add localhost/Tornado hack to access_user_by_api_key.
...
This should make it possible to share that code with other code paths.
2017-08-15 10:54:23 -07:00
Tim Abbott
fc0144f6e4
test_decorators: Annotate fake Request as HttpRequest.
2017-08-05 17:53:18 -07:00
Tim Abbott
1e5aee054b
settings: Migrate main settings-change code to API.
...
This was one of the few major remaining endpoints that were still on
the old-style legacy API.
2017-07-31 13:08:06 -07:00
Tim Abbott
9bf02fb913
custom_profile: Prevent bot users from accessing endpoint.
2017-07-31 13:08:06 -07:00
Tim Abbott
93261e14b7
hotspots: Prevent bot users from accessing endpoint.
2017-07-31 13:08:06 -07:00
Anna Liao
6a3c8ca2c5
push_notifications: Add human users only decorator.
...
This is part of #4517 .
2017-07-31 13:08:06 -07:00
Eeshan Garg
6fe3748826
decorator: Remove redundant tests for api_key_only_webhook_view.
...
We do not need to test the exception message being logged in every
test case where an exception is raised by a webhook function.
Testing it once should be enough; this makes the tests less
verbose.
2017-07-20 10:30:03 -07:00
Eeshan Garg
a24ea56c53
decorator: Handle invalid JSON in api_key_only_webhook_view.
...
Exception logging within api_key_only_webhook_view fails when
ValueError is raised if the request.body passed to ujson.loads
isn't valid JSON. In this case, we now just convert the payload
to a string and log that. This allows us to inspect JSON payloads
that aren't being decoded properly.
2017-07-19 10:42:35 -07:00
Umair Khan
638b32542d
auth: Don't show deactivation notice to mirror dummies.
2017-07-05 23:50:53 -07:00
Yago González
2f4091b38d
api: Fix caps in JSON validation error message.
2017-06-27 08:33:56 -04:00
Umair Khan
4f223c19d8
sign-in: Show proper error for deactivated user.
...
Show a clear error message when a user tries to sign in with
a deactivated account.
Fixes #4757
2017-06-20 11:38:58 -04:00
vaibhav
42af09663d
validators: Add check_url validator.
...
This just uses Django's existing validator, and reformats its
interface to work with has_request_variables.
2017-06-15 15:03:26 -07:00
Vishnu Ks
bb98e35aa0
Replace othello@zulip.com with example_email('othello').
2017-05-24 19:37:36 -07:00
Vishnu Ks
c4db3b7d1c
Replace cordelia@zulip.com with example_email('cordelia').
2017-05-24 19:37:36 -07:00
Vishnu Ks
5230eaef1c
Replace hamlet@zulip.com with example_email('hamlet').
2017-05-24 19:37:36 -07:00
Tim Abbott
6aaca44e17
tests: Fix str/Text mypy issues in various tests.
2017-05-24 15:19:38 -07:00
Andrew Archer
6c3f89af1c
tests: Remove get_user_profile_by_email from numerous tests.
2017-05-24 15:19:20 -07:00