Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Add travis support #32

Merged
merged 7 commits into from

3 participants

@camilonova
Owner

Having travis support is great, currently the tests are broken, but the travis support is working.

I hope to have the tests fixed soon

@camilonova
Owner

Tests are fixed now so the travis page looks good:

https://travis-ci.org/camilonova/django-axes

@aclark4life aclark4life merged commit 95cd103 into from
@camilonova camilonova deleted the branch
@aclark4life
Owner

I think we'll need @codekoala to do the Travis-CI stuff, and anyone can send a pull request with the README changes… but I will do it if no one else does.

@camilonova
Owner

@codekoala Hey there, can you please enable travis on your account, otherwise the status badge will not work, just follow this: http://about.travis-ci.org/docs/user/getting-started/#Step-two%3A-Activate-GitHub-Service-Hook

@codekoala
@codekoala

Should be up and running now. Tests are passing!

Thanks for all of your hard work and attention to django-axes :)

@camilonova
Owner
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
10 .travis.yml
@@ -0,0 +1,10 @@
+language: python
+python:
+ - "2.7"
+env:
+ - PYTHONPATH=$PYTHONPATH:$PWD DJANGO_VERSION=1.4.5
+ - PYTHONPATH=$PYTHONPATH:$PWD DJANGO_VERSION=1.5
+install:
+ - pip install --use-mirrors Django==$DJANGO_VERSION
+script:
+ - django-admin.py test axes --settings=axes.test_settings
View
42 README.rst
@@ -15,33 +15,29 @@ Requirements
work around the Django admin and the regular ``django.contrib.auth``
login-powered pages.
+
Installation
============
-Download ``django-axes`` using **one** of the following methods:
-
-easy_install
-------------
+Download and install ``django-axes`` using **one** of the following methods:
-You can download the package from the `CheeseShop <http://pypi.python.org/pypi/django-axes/>`_ or use::
+PIP
+---
- easy_install django-axes
+You can install the latest stable package running this command::
-to download and install ``django-axes``.
+ $ pip install django-axes
-Package Download
-----------------
+Also you can install the development version running this command::
-Download the latest ``.tar.gz`` file from the downloads section and extract it
-somewhere you'll remember. Use ``python setup.py install`` to install it.
+ $ pip install -e git+http://github.com/codekoala/django-axes.git#egg=django_axes-dev
-Checkout from GitHub
---------------------
+Setuptools
+----------
-Execute the following command, and make sure you're checking ``django-axes``
-out somewhere on the ``PYTHONPATH``::
+You can install the latest stable package running::
- git clone git://github.com/codekoala/django-axes.git
+ $ easy_install django-axes
Verifying Installation
----------------------
@@ -55,6 +51,20 @@ If that command completes with some sort of version number, you're probably
good to go. If you see error output, you need to check your installation (I'd
start with your ``PYTHONPATH``).
+
+Development
+===========
+
+You can contribute to this project forking it from github and sending pull requests.
+
+Running tests
+-------------
+
+Tests can be run, after you clone the repository and having django installed, like::
+
+ $ PYTHONPATH=$PYTHONPATH:$PWD django-admin.py test axes --settings=axes.test_settings
+
+
Configuration
=============
View
2  axes/__init__.py
@@ -1,7 +1,7 @@
import logging
import os
-VERSION = (1, 2, 9)
+VERSION = (1, 3, 0)
def get_version():
View
52 axes/test_settings.py
@@ -0,0 +1,52 @@
+import os
+import django
+
+if django.VERSION[:2] >= (1, 3):
+ DATABASES = {
+ 'default': {
+ 'ENGINE': 'django.db.backends.sqlite3',
+ 'NAME': ':memory:',
+ }
+ }
+else:
+ DATABASE_ENGINE = 'sqlite3'
+
+SITE_ID = 1
+
+MIDDLEWARE_CLASSES = (
+ 'django.middleware.common.CommonMiddleware',
+ 'django.contrib.sessions.middleware.SessionMiddleware',
+ 'django.contrib.auth.middleware.AuthenticationMiddleware',
+ 'axes.middleware.FailedLoginMiddleware'
+)
+
+ROOT_URLCONF = 'axes.test_urls'
+
+INSTALLED_APPS = [
+ 'django.contrib.auth',
+ 'django.contrib.contenttypes',
+ 'django.contrib.sessions',
+ 'django.contrib.sites',
+ 'django.contrib.messages',
+ 'django.contrib.admin',
+
+ 'axes',
+]
+
+SECRET_KEY = 'too-secret-for-test'
+
+LOGGING = {
+ 'version': 1,
+ 'root': {
+ 'level': 'DEBUG',
+ 'handlers': ['console'],
+ },
+ 'handlers': {
+ 'console': {
+ 'level': 'DEBUG',
+ 'class': 'logging.StreamHandler',
+ },
+ }
+ }
+
+# AXES_LOGIN_FAILURE_LIMIT = 1
View
6 axes/test_urls.py
@@ -0,0 +1,6 @@
+from django.conf.urls import patterns, include
+from django.contrib import admin
+
+urlpatterns = patterns('',
+ (r'^admin/', include(admin.site.urls)),
+)
View
63 axes/tests.py
@@ -10,32 +10,19 @@
from django.core.urlresolvers import reverse
from django.test.utils import override_settings
+from axes.decorators import FAILURE_LIMIT
+from axes.decorators import LOGIN_FORM_KEY
-FAILURE_LIMIT = 3
-
-@override_settings(
- AXES_LOGIN_FAILURE_LIMIT=FAILURE_LIMIT,
- AXES_LOCKOUT_URL=None,
- AXES_USE_USER_AGENT=False,
- AXES_COOLOFF_TIME=None,
- AXES_LOCKOUT_TEMPLATE=None,
-)
class AccessAttemptTest(TestCase):
- """Test case using custom settings for testing"""
-
- def setUp(self):
- for i in range(0, random.randrange(10, 50)):
- username = "person%s" % i
- email = "%s@example.org" % username
- u = User.objects.create_user(email=email, username=username, password=username)
- u.is_staff = True
- u.save()
+ """Test case using custom settings for testing
+ """
+ LOCKED_MESSAGE = 'Account locked: too many login attempts.'
def _generate_random_string(self):
"""Generates a random string"""
- return ''.join(random.choice(string.ascii_uppercase + string.digits)
- for x in range(20))
+ chars = string.ascii_uppercase + string.digits
+ return ''.join(random.choice(chars) for x in range(20))
def _random_username(self, existing_username=False):
"""Returns a username, existing or not depending on params"""
@@ -44,40 +31,52 @@ def _random_username(self, existing_username=False):
return self._generate_random_string()
- def _attempt_login(self, existing_username=False):
+ def _login(self, existing_username=False):
response = self.client.post(reverse('admin:index'), {
'username': self._random_username(existing_username),
- 'password': self._generate_random_string()
+ 'password': self._generate_random_string(),
})
return response
+ def setUp(self):
+ for i in range(0, random.randrange(10, 50)):
+ username = "person%s" % i
+ email = "%s@example.org" % username
+ u = User.objects.create_user(
+ username=username,
+ password=username,
+ email=email,
+ )
+ u.is_staff = True
+ u.save()
+
def test_login_max(self, existing_username=False):
for i in range(0, FAILURE_LIMIT - 1):
- response = self._attempt_login(existing_username=existing_username)
+ response = self._login(existing_username=existing_username)
# Check if we are in the same login page
- self.assertIn('this_is_the_login_form', response.content)
+ self.assertContains(response, LOGIN_FORM_KEY)
# So, we shouldn't have gotten a lock-out yet.
# But we should get one now
- response = self._attempt_login()
- self.assertContains(response, 'Account locked')
+ response = self._login()
+ self.assertContains(response, self.LOCKED_MESSAGE)
def test_with_real_username_max(self):
self.test_login_max(existing_username=True)
def test_login_max_with_more_attempts(self, existing_username=False):
- for i in range(0, FAILURE_LIMIT - 1):
- response = self._attempt_login(existing_username=existing_username)
+ for i in range(0, FAILURE_LIMIT - 2):
+ response = self._login(existing_username=existing_username)
# Check if we are in the same login page
- self.assertIn('this_is_the_login_form', response.content)
+ self.assertContains(response, LOGIN_FORM_KEY)
# So, we shouldn't have gotten a lock-out yet.
# But we should get one now
for i in range(0, random.randrange(1, 100)):
# try to log in a bunch of times
- response = self._attempt_login()
- self.assertContains(response, 'Account locked')
+ response = self._login()
+ self.assertContains(response, self.LOCKED_MESSAGE)
def test_with_real_username_max_with_more(self):
self.test_login_max_with_more_attempts(existing_username=True)
@@ -88,4 +87,4 @@ def test_valid_login(self):
'username': valid_username,
'password': valid_username
})
- self.assertNotIn('authentication_form', response.context)
+ self.assertNotIn(LOGIN_FORM_KEY, response.context)
Something went wrong with that request. Please try again.