Skip to content

Commit

Permalink
Merge branch 'release/0.7' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
rlskoeser committed Aug 31, 2020
2 parents bacf2fc + 807f53f commit efd41a0
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 29 deletions.
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
19 changes: 12 additions & 7 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ django-pucas
:target: https://requires.io/github/Princeton-CDH/django-pucas/requirements/?branch=master
:alt: Requirements Status

.. image:: https://img.shields.io/pypi/pyversions/viapy
:alt: PyPI - Python Version

.. image:: https://img.shields.io/pypi/djversions/viapy
:alt: PyPI - Django Version

**django-pucas** is a reusable `Django`_ application to simplify logging
into a Django application with CAS using `django-cas-ng`_. Login and
creation of user accounts is handled by django-cas-ng; pucas adds
Expand All @@ -27,10 +33,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 +135,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 All @@ -151,7 +156,7 @@ Two manage commands are provided, for convenience.
Development instructions
------------------------

This git repository uses git flow branching conventions.
This git repository uses git flow branching conventions, with **main** as the current production release branch.

Initial setup and installation:

Expand All @@ -168,7 +173,7 @@ Initial setup and installation:
Unit Testing
^^^^^^^^^^^^^

Unit tests are written with [py.test](http://doc.pytest.org/) but use some
Unit tests are written with `py.test <http://doc.pytest.org/>`_ but use some
Django test classes for compatibility with django test suites. Running
the tests requires a minimal settings file for Django required configurations.

Expand Down
2 changes: 1 addition & 1 deletion pucas/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
default_app_config = 'pucas.apps.PucasConfig'

__version_info__ = (0, 7, 0)
__version_info__ = (0, 7, 0, None)

# Dot-connect all but the last. Last is dash-connected if not None.
__version__ = '.'.join([str(i) for i in __version_info__[:-1]])
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
7 changes: 4 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,8 @@
'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',
'Topic :: System :: Systems Administration :: Authentication/Directory :: LDAP',
Expand Down

0 comments on commit efd41a0

Please sign in to comment.