Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revise python/django versions that are tested and documented as supported #10

Merged
merged 8 commits into from
Aug 26, 2020
13 changes: 10 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,22 @@ python:
- "3.5"
- "3.6"
- "3.7"
- "3.8"

env:
- DJANGO=1.8
- DJANGO=1.9
- DJANGO=1.10
- DJANGO=1.11
- DJANGO=2.0
- DJANGO=2.1
- DJANGO=2.2
- DJANGO=3.0
- DJANGO=3.1

matrix:
exclude:
- python: "3.5"
env: DJANGO=3.0
- python: "3.5"
env: DJANGO=3.1

before_install:
- pip install --upgrade pytest
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ CHANGELOG
0.7
----
* Drop support for Python 2.7
* No longer tested against Django 1.8-1.10; now tested against 3.0 and 3.1
* Add testing for Python 3.8
* Default branch name for current release is now **main**

0.6
-----
Expand Down
9 changes: 4 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ support for prepopulating user account data based on an LDAP search.
.. _Django: https://www.djangoproject.com/
.. _django-cas-ng: https://github.com/mingchen/django-cas-ng

**django-pucas** is tested under:
**django-pucas** is tested against:

* Django ``1.8-2.2``
* Python ``3.5-3.7``
* Django ``1.11-3.1``
* Python ``3.5-3.8``

**django-pucas** requires **django-cas-ng** 3.6 or greater.

Expand Down Expand Up @@ -129,8 +129,7 @@ An example of a login template with local branding is provided at
``pucas/templates/pucas/sample-pu-login.html`` using re-usable template
snippets that can be adapted or re-used as appropriate.

For Django 1.8, you will need to override ``admin/login.html`` as a whole, as
extending the login template with itself causes a recursion error.
Note that login templates have not yet been updated for Django 3.x.

Usage
-----
Expand Down
16 changes: 4 additions & 12 deletions pucas/management/commands/createcasuser.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,11 @@ def handle(self, *args, **options):
user.save()

self.stdout.write(
self.style_success("%s user '%s'" \
self.style.SUCCESS(
"%s user '%s'"
% ('Created' if created else 'Updated', netid)))

except LDAPSearchException:
self.stderr.write(
self.style.ERROR("LDAP information for '%s' not found" \
% netid))

def style_success(self, msg):
# workaround to support django 1.8 - style.SUCCESS
# only added in django 1.9
if hasattr(self.style, 'SUCCESS'):
return self.style.SUCCESS(msg)
else:
return msg

self.style.ERROR("LDAP information for '%s' not found"
% netid))
9 changes: 6 additions & 3 deletions pucas/tests.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,31 @@
from io import StringIO
from unittest import mock

from django.conf import settings
from django.core.management import call_command
from django.test import TestCase, override_settings
from django.utils.six import StringIO
from ldap3.core.exceptions import LDAPException, LDAPCursorError
from ldap3.core.exceptions import LDAPCursorError, LDAPException
import pytest

from pucas.ldap import LDAPSearch, LDAPSearchException, \
user_info_from_ldap
from pucas.management.commands import createcasuser, ldapsearch
from pucas.signals import cas_login
from pucas.management.commands import ldapsearch, createcasuser


class MockLDAPInfo(object):
'''Simulate ldap result object with ldap3 specific behavior for getattr'''
def __init__(self, **kwargs):
for k, v in kwargs.items():
setattr(self, k, v)

def __getattr__(self, attr):
# __getattr__ only gets called when the default attribute access
# falls through, so in this case, we always want that to raise the
# cursor error
raise LDAPCursorError


class TestMockLDAPInfo(TestCase):

def test_init(self):
Expand Down
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,12 @@
classifiers=[
'Environment :: Web Environment',
'Framework :: Django',
'Framework :: Django :: 1.8',
'Framework :: Django :: 1.9',
'Framework :: Django :: 1.10',
'Framework :: Django :: 1.11',
'Framework :: Django :: 2.0',
'Framework :: Django :: 2.1',
'Framework :: Django :: 2.2',
'Framework :: Django :: 3.0',
'Framework :: Django :: 3.1',
'Intended Audience :: Developers',
'License :: OSI Approved :: Apache Software License',
'Operating System :: OS Independent',
Expand All @@ -50,6 +49,7 @@
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3 :: Only',
'Topic :: Internet :: WWW/HTTP',
'Topic :: System :: Systems Administration :: Authentication/Directory',
Expand Down