mirror of
https://github.com/jazzband/django-defender.git
synced 2026-05-19 13:01:11 +00:00
added landscape.io and some fixes it found
This commit is contained in:
parent
7e32eacd97
commit
a7bc8c0d55
7 changed files with 30 additions and 5 deletions
|
|
@ -16,7 +16,7 @@ the goal is to do those things very well, and have full unit tests with docs.
|
|||
Build status
|
||||
------------
|
||||
|
||||
[](https://travis-ci.org/kencochrane/django-defender) [](https://coveralls.io/r/kencochrane/django-defender)
|
||||
[](https://travis-ci.org/kencochrane/django-defender) [](https://coveralls.io/r/kencochrane/django-defender)[](https://landscape.io/github/kencochrane/django-defender/master)
|
||||
|
||||
Goals for 0.1
|
||||
=============
|
||||
|
|
|
|||
7
defender/.landscape.yaml
Normal file
7
defender/.landscape.yaml
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
doc-warnings: yes
|
||||
test-warnings: no
|
||||
strictness: veryhigh
|
||||
max-line-length: 80
|
||||
uses:
|
||||
- django
|
||||
autodetect: yes
|
||||
|
|
@ -30,3 +30,9 @@ class AccessAttempt(models.Model):
|
|||
|
||||
class Meta:
|
||||
ordering = ['-attempt_time']
|
||||
|
||||
def __unicode__(self):
|
||||
""" unicode value for this model """
|
||||
return u"{0} @ {1} | {2}".format(self.username,
|
||||
self.attempt_time,
|
||||
self.login_valid)
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
import os
|
||||
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.sqlite3',
|
||||
|
|
@ -28,7 +30,7 @@ INSTALLED_APPS = [
|
|||
'defender',
|
||||
]
|
||||
|
||||
SECRET_KEY = 'too-secret-for-test'
|
||||
SECRET_KEY = os.environ.get('SECRET_KEY', 'too-secret-for-test')
|
||||
|
||||
LOGIN_REDIRECT_URL = '/admin'
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ from django.http import HttpRequest
|
|||
from .connection import parse_redis_url
|
||||
from . import utils
|
||||
from . import config
|
||||
from models import AccessAttempt
|
||||
|
||||
mocked_redis = mockredis.mock_strict_redis_client()
|
||||
|
||||
|
|
@ -287,6 +288,14 @@ class AccessAttemptTest(TestCase):
|
|||
response = self.client.get(ADMIN_LOGIN_URL)
|
||||
self.assertContains(response, self.PERMANENT_LOCKED_MESSAGE)
|
||||
|
||||
def test_login_attempt_model(self):
|
||||
""" test the login model"""
|
||||
|
||||
response = self._login()
|
||||
self.assertContains(response, LOGIN_FORM_KEY)
|
||||
self.assertEquals(AccessAttempt.objects.count(), 1)
|
||||
self.assertIsNotNone(AccessAttempt.objects.all()[0])
|
||||
|
||||
def test_is_valid_ip(self):
|
||||
""" Test the is_valid_ip() method
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import os
|
||||
|
||||
DATABASES = {
|
||||
'default': {
|
||||
|
|
@ -29,7 +30,7 @@ INSTALLED_APPS = [
|
|||
'defender',
|
||||
]
|
||||
|
||||
SECRET_KEY = 'too-secret-for-test'
|
||||
SECRET_KEY = os.environ.get('SECRET_KEY', 'too-secret-for-test')
|
||||
|
||||
LOGIN_REDIRECT_URL = '/admin'
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ def is_valid_ip(ip_address):
|
|||
valid = True
|
||||
try:
|
||||
socket.inet_aton(ip_address.strip())
|
||||
except:
|
||||
except (socket.error, AttributeError):
|
||||
valid = False
|
||||
return valid
|
||||
|
||||
|
|
@ -61,7 +61,7 @@ def get_ip_address_from_request(request):
|
|||
remote_addr):
|
||||
ip_address = remote_addr.strip()
|
||||
if not ip_address:
|
||||
ip_address = '127.0.0.1'
|
||||
ip_address = '127.0.0.1'
|
||||
return ip_address
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue