...
 
Commits (2)
...@@ -6,31 +6,15 @@ before_script: ...@@ -6,31 +6,15 @@ before_script:
- python3.6 -m venv $HOME/tox - python3.6 -m venv $HOME/tox
- $HOME/tox/bin/pip install tox - $HOME/tox/bin/pip install tox
py27-django18:
stage: test
script: $HOME/tox/bin/tox -e 'py27-django18'
py27-django110:
stage: test
script: $HOME/tox/bin/tox -e 'py27-django110'
py27-django111:
stage: test
script: $HOME/tox/bin/tox -e 'py27-django111'
py36-django18:
stage: test
script: $HOME/tox/bin/tox -e 'py36-django18'
py36-django110:
stage: test
script: $HOME/tox/bin/tox -e 'py36-django110'
py36-django111: py36-django111:
stage: test stage: test
script: $HOME/tox/bin/tox -e 'py36-django111' script: $HOME/tox/bin/tox -e 'py36-django111'
py36-django20: py36-django22:
stage: test
script: $HOME/tox/bin/tox -e 'py36-django22'
py36-django30:
stage: test stage: test
script: $HOME/tox/bin/tox -e 'py36-django20' script: $HOME/tox/bin/tox -e 'py36-django30'
...@@ -5,6 +5,7 @@ from django.contrib.auth import get_user_model ...@@ -5,6 +5,7 @@ from django.contrib.auth import get_user_model
from django.db.models.signals import pre_save from django.db.models.signals import pre_save
from .ldap import Ldap from .ldap import Ldap
def set_attributes_from_ldap(sender, instance, **kwargs): def set_attributes_from_ldap(sender, instance, **kwargs):
l = Ldap() l = Ldap()
username = getattr(instance, instance.USERNAME_FIELD) username = getattr(instance, instance.USERNAME_FIELD)
......
...@@ -3,7 +3,7 @@ from __future__ import unicode_literals ...@@ -3,7 +3,7 @@ from __future__ import unicode_literals
import getpass import getpass
from django.core.management.base import BaseCommand from django.core.management.base import BaseCommand
from django.contrib.auth import get_user_model from django.contrib.auth import get_user_model
from django.utils.six import moves
class Command(BaseCommand): class Command(BaseCommand):
help = "Used to create a superuser without a usable password." help = "Used to create a superuser without a usable password."
...@@ -23,7 +23,7 @@ class Command(BaseCommand): ...@@ -23,7 +23,7 @@ class Command(BaseCommand):
username = options.get('username') username = options.get('username')
if not username: if not username:
current_user = getpass.getuser() current_user = getpass.getuser()
input_user = moves.input('Username [{}]: '.format(current_user)) input_user = input('Username [{}]: '.format(current_user))
if not input_user: if not input_user:
username = current_user username = current_user
else: else:
......
...@@ -171,7 +171,7 @@ ...@@ -171,7 +171,7 @@
"top" "top"
], ],
"sn": [ "sn": [
"This User Has A Very Long Surname Which Exceeds The Maximum Allowed Length" "This User Has A Very Long Surname Which Exceeds The Maximum Allowed Length. This is only required for testing. This User Has A Very Long Surname Which Exceeds The Maximum Allowed Length. This is only required for testing."
], ],
"uid": [ "uid": [
"long" "long"
......
...@@ -26,7 +26,8 @@ INSTALLED_APPS = ( ...@@ -26,7 +26,8 @@ INSTALLED_APPS = (
'tests' 'tests'
) )
MIDDLEWARE = ( MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware', 'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware', 'django.middleware.csrf.CsrfViewMiddleware',
...@@ -34,10 +35,25 @@ MIDDLEWARE = ( ...@@ -34,10 +35,25 @@ MIDDLEWARE = (
'django.contrib.auth.middleware.RemoteUserMiddleware', 'django.contrib.auth.middleware.RemoteUserMiddleware',
'django.contrib.messages.middleware.MessageMiddleware', 'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware', ]
)
# compat for Django 1.8
MIDDLEWARE_CLASSES = MIDDLEWARE TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
ROOT_URLCONF = 'tests.urls' ROOT_URLCONF = 'tests.urls'
......
...@@ -13,6 +13,7 @@ from django.test.utils import override_settings ...@@ -13,6 +13,7 @@ from django.test.utils import override_settings
_CURRENT_DIRECTORY = os.path.dirname(os.path.realpath(__file__)) _CURRENT_DIRECTORY = os.path.dirname(os.path.realpath(__file__))
_LDAP_FAKE_DATA_LOCATION = os.path.join(_CURRENT_DIRECTORY, 'test_ldap_data.json') _LDAP_FAKE_DATA_LOCATION = os.path.join(_CURRENT_DIRECTORY, 'test_ldap_data.json')
@override_settings( @override_settings(
LDAP_SYNC_URI='ldap://localhost/ou=Users,dc=example,dc=org', LDAP_SYNC_URI='ldap://localhost/ou=Users,dc=example,dc=org',
LDAP_TESTING_FAKE_DATA=_LDAP_FAKE_DATA_LOCATION LDAP_TESTING_FAKE_DATA=_LDAP_FAKE_DATA_LOCATION
...@@ -37,7 +38,6 @@ class LdapTestCase(TestCase): ...@@ -37,7 +38,6 @@ class LdapTestCase(TestCase):
self.assertEquals(user.last_name, 'User') self.assertEquals(user.last_name, 'User')
self.assertEquals(user.email, 'test@example.org') self.assertEquals(user.email, 'test@example.org')
def test_autocreate(self): def test_autocreate(self):
response = self.client.get('/admin/') response = self.client.get('/admin/')
self.assertEquals(response.status_code, 302) self.assertEquals(response.status_code, 302)
...@@ -146,7 +146,7 @@ class LdapTestCase(TestCase): ...@@ -146,7 +146,7 @@ class LdapTestCase(TestCase):
the equivalent Django field, are cut off properly. the equivalent Django field, are cut off properly.
""" """
last_name_field = self.USER_MODEL._meta.get_field('last_name') last_name_field = self.USER_MODEL._meta.get_field('last_name')
if last_name_field.max_length >= 74: if last_name_field.max_length >= 200:
self.skipTest("The `max_length` of the `last_name` field is too large for this test.") self.skipTest("The `max_length` of the `last_name` field is too large for this test.")
user = self.USER_MODEL.objects.create(username='long') user = self.USER_MODEL.objects.create(username='long')
......
...@@ -5,8 +5,9 @@ ...@@ -5,8 +5,9 @@
[tox] [tox]
skipsdist = true skipsdist = true
envlist = py{27,36}-django{18,110,111}, skip_missing_interpreters = true
py{36}-django{20} envlist = py{36}-django{111,22,30},
py37-django{22,30}
[testenv] [testenv]
...@@ -20,10 +21,9 @@ deps = ...@@ -20,10 +21,9 @@ deps =
lxml lxml
python-dateutil python-dateutil
ldap3 ldap3
django18: Django >= 1.8, < 1.9 django111: Django==1.11.*
django110: Django >= 1.10, < 1.11 django22: Django==2.2.*
django111: Django >= 1.11, < 2 django30: Django==3.0.*
django20: Django >= 2, < 2.1
setenv = setenv =
DJANGO_LIVE_TEST_SERVER_ADDRESS=localhost:9000-9200 DJANGO_LIVE_TEST_SERVER_ADDRESS=localhost:9000-9200
......