Commit graph

707 commits

Author SHA1 Message Date
Aleksi Häkli
d5261f6a7f
Update Travis matrix to allow failures on Django master
Signed-off-by: Aleksi Häkli <aleksi.hakli@iki.fi>
2019-02-23 21:09:07 +02:00
Aleksi Häkli
c1ac9de894
Merge pull request #404 from jazzband/pytest
Use pytest for test runner
2019-02-22 08:56:01 +02:00
Aleksi Häkli
7152cf482d
Run coverage with pytest
Signed-off-by: Aleksi Häkli <aleksi.hakli@iki.fi>
2019-02-22 08:30:11 +02:00
Aleksi Häkli
5a78d41828
Fix buggy test case and improve test speed
- Cool off time was overly long on a number of test
- Cool off time on test was fetched with the wrong method
  resulting in bugs on non-integer second cool off values

Signed-off-by: Aleksi Häkli <aleksi.hakli@iki.fi>
2019-02-22 07:58:28 +02:00
Aleksi Häkli
c17db16253
Use pytest for test runner
Signed-off-by: Aleksi Häkli <aleksi.hakli@iki.fi>
2019-02-20 23:05:21 +02:00
Aleksi Häkli
11e02c8dfc
Merge pull request #403 from jazzband/pyup-scheduled-update-2019-02-18
Scheduled weekly dependency update for week 07
2019-02-18 23:07:49 +02:00
pyup-bot
cc1954209d Update sphinx_rtd_theme from 0.4.2 to 0.4.3 2019-02-18 18:23:05 +02:00
Camilo Nova
ad2ed23ced
Merge pull request #400 from jazzband/development
Refactor attempt and handler implementations
2019-02-14 17:49:02 -05:00
Aleksi Häkli
6d83901031
Refactor attempt and handler implementations
Signed-off-by: Aleksi Häkli <aleksi.hakli@iki.fi>
2019-02-13 20:39:44 +02:00
Aleksi Häkli
820ecca236
Add missing test case for disabled lockouts
Signed-off-by: Aleksi Häkli <aleksi.hakli@iki.fi>
2019-02-13 20:22:16 +02:00
Aleksi Häkli
09fe330957
Fix test compatibility on Python 3.5
Signed-off-by: Aleksi Häkli <aleksi.hakli@iki.fi>
2019-02-13 19:02:10 +02:00
Aleksi Häkli
cd56631865
Refactor attempts and add NEVER_LOCKOUT_GET flag
- Move cache and cool off utility functions to the axes.utils module
- Clean up axes.attempts duplicate code in attempt and cache calculations
- Add stable implementation for AccessAttempt attribute calculation
  in the axes.attempts.get_filter_kwargs function

Fixes #398

Signed-off-by: Aleksi Häkli <aleksi.hakli@iki.fi>
2019-02-13 18:20:04 +02:00
Aleksi Häkli
77103c42fe
Add type annotations to utils module 2019-02-13 14:06:55 +02:00
Aleksi Häkli
42fe9c15fa
Unify import styling to use from ... imports 2019-02-13 14:05:24 +02:00
Aleksi Häkli
8c73eed726
Introduce gradual typing with mypy 2019-02-13 01:14:26 +02:00
Aleksi Häkli
911de8f347
Refactor is_user_lockable
Signed-off-by: Aleksi Häkli <aleksi.hakli@iki.fi>
2019-02-13 00:58:17 +02:00
Aleksi Häkli
c3e471a211
Improve handler tests 2019-02-13 00:04:50 +02:00
Aleksi Häkli
6240b20793
Clean up utils tests for get_client_username 2019-02-12 23:44:35 +02:00
Aleksi Häkli
df83adb059
Run more comprehensive prospector checks
Signed-off-by: Aleksi Häkli <aleksi.hakli@iki.fi>
2019-02-12 23:33:18 +02:00
Aleksi Häkli
40a0eae647
Improve tests
Signed-off-by: Aleksi Häkli <aleksi.hakli@iki.fi>
2019-02-12 23:22:52 +02:00
Aleksi Häkli
a926e74f5d
Add check for empty tuple in get_client_str
Signed-off-by: Aleksi Häkli <aleksi.hakli@iki.fi>
2019-02-12 23:11:37 +02:00
Aleksi Häkli
1b1771d164
Rename CommonAccess to better name
Signed-off-by: Aleksi Häkli <aleksi.hakli@iki.fi>
2019-02-12 23:11:18 +02:00
Aleksi Häkli
19f84c5daa
Clean up and unify imports
- Use consistent alphabetical import ordering across files
- Use axes.conf.settings for internally loading settings

Signed-off-by: Aleksi Häkli <aleksi.hakli@iki.fi>
2019-02-10 22:06:04 +02:00
Aleksi Häkli
0b6d84762a
Remove deprecated Six usages
Signed-off-by: Aleksi Häkli <aleksi.hakli@iki.fi>
2019-02-10 21:47:02 +02:00
Aleksi Häkli
5c2fa348ba
Update and clean up setup.py
- Use Python 3 syntax for file reads
- Use simpler keywords formatting
- Add Aleksi Hakli to authors listing
- Update maintainer to Jazzband
- Add cleaner project_urls
- Add Python 3.5+ version requirement

Signed-off-by: Aleksi Häkli <aleksi.hakli@iki.fi>
2019-02-10 21:46:44 +02:00
Aleksi Häkli
fd963f38c1
Clean up Tox file formatting
Signed-off-by: Aleksi Häkli <aleksi.hakli@iki.fi>
2019-02-10 20:52:00 +02:00
Aleksi Häkli
502434bbcb
Clean up logging initialization
Signed-off-by: Aleksi Häkli <aleksi.hakli@iki.fi>
2019-02-10 20:51:38 +02:00
Aleksi Häkli
84ff56e8b1
Add Jazzband guidelines to README
Signed-off-by: Aleksi Häkli <aleksi.hakli@iki.fi>
2019-02-10 20:51:29 +02:00
Aleksi Häkli
e3e69006a4
Improve management test branch coverage
Signed-off-by: Aleksi Häkli <aleksi.hakli@iki.fi>
2019-02-10 20:05:02 +02:00
Aleksi Häkli
b8f417d485
Merge pull request #397 from jazzband/development
Version 5.0.0 draft
2019-02-10 19:53:41 +02:00
Aleksi Häkli
8859dde508
Modernize Django test setting types
Signed-off-by: Aleksi Häkli <aleksi.hakli@iki.fi>
2019-02-10 19:40:51 +02:00
Aleksi Häkli
40a9b76772
Use a faster password hasher for testing
Signed-off-by: Aleksi Häkli <aleksi.hakli@iki.fi>
2019-02-10 19:38:03 +02:00
Aleksi Häkli
6aa1ce1a8a
Raise minimum test coverage to 90%
As we aim for a stable production grade package
we should strive to have the code base tested
comprehensively to root out any bugs in the
implementations that are offered.

Signed-off-by: Aleksi Häkli <aleksi.hakli@iki.fi>
2019-02-10 19:22:13 +02:00
Aleksi Häkli
fa7f35dda5
Add tests for the new components
Use mocks and test new backends, handlers and middleware
on an API call level, aiming for a 100% coverage on behaviour.

Also add tests for old decorators which are not covered
after moving the default authentication checks from them
to the authentication backends, middleware and signal handlers.

Fixes #323

Signed-off-by: Aleksi Häkli <aleksi.hakli@iki.fi>
2019-02-10 19:22:13 +02:00
Aleksi Häkli
5fe339dce6
Rename management tests
Signed-off-by: Aleksi Häkli <aleksi.hakli@iki.fi>
2019-02-10 19:22:13 +02:00
Aleksi Häkli
07e7c675bd
Configure Codecov parameters
Signed-off-by: Aleksi Häkli <aleksi.hakli@iki.fi>
2019-02-08 00:05:31 +02:00
Aleksi Häkli
a9e9b0d984
Pluggable signal handler backend for lockouts
Implements a proxied API which enables overriding
a handler backend with a user supplied implementation.

Fixes #399

Signed-off-by: Aleksi Häkli <aleksi.hakli@iki.fi>
2019-02-07 22:13:30 +02:00
Aleksi Häkli
fcef40748a
Deprecate old signature for AXES_USERNAME_CALLABLE and update documentation
Signed-off-by: Aleksi Häkli <aleksi.hakli@iki.fi>
2019-02-07 22:09:21 +02:00
Aleksi Häkli
715dedc069
Use PEP257 compliant docstrings
Unify docstring representations based on PEP 257

https://www.python.org/dev/peps/pep-0257/

Signed-off-by: Aleksi Häkli <aleksi.hakli@iki.fi>
2019-02-07 18:42:54 +02:00
Aleksi Häkli
30f90ad3bf
Clean up code layouting
Signed-off-by: Aleksi Häkli <aleksi.hakli@iki.fi>
2019-02-07 18:42:53 +02:00
Aleksi Häkli
3c2fb2b335
Improve line separator conventions
Signed-off-by: Aleksi Häkli <aleksi.hakli@iki.fi>
2019-02-07 18:42:53 +02:00
Aleksi Häkli
a8732a383d
Use decorator syntax for admin views
Signed-off-by: Aleksi Häkli <aleksi.hakli@iki.fi>
2019-02-07 18:42:53 +02:00
Aleksi Häkli
ae0c30af29
Remove deprecated JSON testing shims
Signed-off-by: Aleksi Häkli <aleksi.hakli@iki.fi>
2019-02-07 17:40:05 +02:00
Aleksi Häkli
030810df79
Drop Python 2.7 and Python 3.4 support
Fixes #395

Signed-off-by: Aleksi Häkli <aleksi.hakli@iki.fi>
2019-02-07 17:28:26 +02:00
Aleksi Häkli
ecadddbf5d
Improve management commands, docs, and tests
Fixes #362

Signed-off-by: Aleksi Häkli <aleksi.hakli@iki.fi>
2019-02-03 16:03:30 +02:00
Aleksi Häkli
99175dc57f
Use middleware, backends, and signals for lockouts
Fixes #389

Remove monkey-patching from the application loader phase
and use the Django authentication stack for lockout signals.

Utilize custom AUTHENTICATION_BACKENDS and MIDDLEWARE with signals
with backwards compatible implementation of features.

Update documentation, configuration and migration instructions
to match the new configuration and improve the code commentation.

Signed-off-by: Aleksi Häkli <aleksi.hakli@iki.fi>
2019-02-03 16:03:30 +02:00
Aleksi Häkli
d33a55b927
Use single quotes for strings
Signed-off-by: Aleksi Häkli <aleksi.hakli@iki.fi>
2019-02-03 16:03:30 +02:00
Aleksi Häkli
d215485a66
Remove broken JSON login test case
The test did not work correctly because the admin login view
does not accept JSON input, but instead produces an error on JSON POST.

It appeared to be functional and working because the
monkey-patched decorator returned a HTTP 403 when a user was accessing the view.

This did not actually result from a failed login,
but from a premature view permission checking that was not sane.

The HTTP 403 was produced by the login function decorator
before the user was ever accessing or using the actual view.

After modifying the view checking logic to run on a login attempt
instead of before attempt (ie when accessing the view)
the admin view error that resulted from missing form POST data
was discovered and since no easy fix was available without
writing a custom view the broken test case was removed altogether.

The correct fix for supporting JSON payloads and mimetypes
can be implemented by writing a login view that supports
JSON login via eg HTTP AJAX POST and produces the same errors.

Signed-off-by: Aleksi Häkli <aleksi.hakli@iki.fi>
2019-02-03 16:03:29 +02:00
Aleksi Häkli
15d2f98980
Clean up database test case imports
Signed-off-by: Aleksi Häkli <aleksi.hakli@iki.fi>
2019-02-03 16:03:29 +02:00
Aleksi Häkli
d293976e1c
Update test runner script and versions
- Use manage.py for running tests instead of a custom script
- Drop support for Python 3.5 for Django master for tox and Travis
- Run branch coverage tests in addition to line coverage

Signed-off-by: Aleksi Häkli <aleksi.hakli@iki.fi>
2019-02-03 16:03:29 +02:00