remove six transitional dependency
This commit is contained in:
parent
0025a3772b
commit
7ce1979e90
13 changed files with 37 additions and 60 deletions
|
@ -15,4 +15,3 @@ exclude_lines =
|
||||||
def __str__
|
def __str__
|
||||||
raise AssertionError
|
raise AssertionError
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
if six.PY3:
|
|
||||||
|
|
|
@ -33,7 +33,6 @@ Dependencies
|
||||||
* requests >= 2.4
|
* requests >= 2.4
|
||||||
* requests_futures >= 0.9.5
|
* requests_futures >= 0.9.5
|
||||||
* lxml >= 3.4
|
* lxml >= 3.4
|
||||||
* six >= 1.8
|
|
||||||
|
|
||||||
Minimal version of package dependencies are just indicative and means that ``django-cas-server`` has
|
Minimal version of package dependencies are just indicative and means that ``django-cas-server`` has
|
||||||
been tested with it. Previous versions of dependencies may or may not work.
|
been tested with it. Previous versions of dependencies may or may not work.
|
||||||
|
@ -51,7 +50,6 @@ them on debian like systems and centos like systems.
|
||||||
You should try as much as possible to use system packages as they are automatically updated when
|
You should try as much as possible to use system packages as they are automatically updated when
|
||||||
you update your system. You can then install Not Available (N/A)
|
you update your system. You can then install Not Available (N/A)
|
||||||
packages on your system using pip3 inside a virtualenv as described in the `Installation`_ section.
|
packages on your system using pip3 inside a virtualenv as described in the `Installation`_ section.
|
||||||
For use with python2, just replace python3(6) in the table by python.
|
|
||||||
|
|
||||||
+------------------+--------------------------+---------------------+
|
+------------------+--------------------------+---------------------+
|
||||||
| python package | debian like systems | centos like systems |
|
| python package | debian like systems | centos like systems |
|
||||||
|
@ -64,8 +62,6 @@ For use with python2, just replace python3(6) in the table by python.
|
||||||
+------------------+--------------------------+---------------------+
|
+------------------+--------------------------+---------------------+
|
||||||
| lxml | python3-lxml | python36-lxml |
|
| lxml | python3-lxml | python36-lxml |
|
||||||
+------------------+--------------------------+---------------------+
|
+------------------+--------------------------+---------------------+
|
||||||
| six | python3-six | python36-six |
|
|
||||||
+------------------+--------------------------+---------------------+
|
|
||||||
| ldap3 | python3-ldap3 | python36-ldap3 |
|
| ldap3 | python3-ldap3 | python36-ldap3 |
|
||||||
+------------------+--------------------------+---------------------+
|
+------------------+--------------------------+---------------------+
|
||||||
| psycopg2 | python3-psycopg2 | python36-psycopg2 |
|
| psycopg2 | python3-psycopg2 | python36-psycopg2 |
|
||||||
|
@ -84,14 +80,14 @@ The recommended installation mode is to use a virtualenv with ``--system-site-pa
|
||||||
|
|
||||||
On debian like systems::
|
On debian like systems::
|
||||||
|
|
||||||
$ sudo apt-get install python3-django python3-requests python3-six python3-lxml python3-requests-futures
|
$ sudo apt-get install python3-django python3-requests python3-lxml python3-requests-futures
|
||||||
|
|
||||||
On debian jessie, you can use the version of python-django available in the
|
On debian jessie, you can use the version of python-django available in the
|
||||||
`backports <https://backports.debian.org/Instructions/>`_.
|
`backports <https://backports.debian.org/Instructions/>`_.
|
||||||
|
|
||||||
On centos like systems with epel enabled::
|
On centos like systems with epel enabled::
|
||||||
|
|
||||||
$ sudo yum install python36-django python36-requests python36-six python36-lxml
|
$ sudo yum install python36-django python36-requests python36-lxml
|
||||||
|
|
||||||
3. Create a virtualenv::
|
3. Create a virtualenv::
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,6 @@ from django.db import connections, DatabaseError
|
||||||
|
|
||||||
import warnings
|
import warnings
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
from six.moves import range
|
|
||||||
try: # pragma: no cover
|
try: # pragma: no cover
|
||||||
import MySQLdb
|
import MySQLdb
|
||||||
import MySQLdb.cursors
|
import MySQLdb.cursors
|
||||||
|
|
|
@ -22,10 +22,9 @@
|
||||||
# at commit ec1f2d4779625229398547b9234d0e9e874a2c9a
|
# at commit ec1f2d4779625229398547b9234d0e9e874a2c9a
|
||||||
# some modifications have been made to be unicode coherent between python2 and python2
|
# some modifications have been made to be unicode coherent between python2 and python2
|
||||||
|
|
||||||
import six
|
import urllib.parse as urllib_parse
|
||||||
from six.moves.urllib import parse as urllib_parse
|
import urllib.request as urllib_request
|
||||||
from six.moves.urllib import request as urllib_request
|
from urllib.request import Request
|
||||||
from six.moves.urllib.request import Request
|
|
||||||
from uuid import uuid4
|
from uuid import uuid4
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
|
@ -37,7 +36,7 @@ class CASError(ValueError):
|
||||||
class ReturnUnicode(object):
|
class ReturnUnicode(object):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def u(string, charset):
|
def u(string, charset):
|
||||||
if not isinstance(string, six.text_type):
|
if not isinstance(string, str):
|
||||||
return string.decode(charset)
|
return string.decode(charset)
|
||||||
else:
|
else:
|
||||||
return string
|
return string
|
||||||
|
|
|
@ -17,7 +17,7 @@ from .cas import CASClient
|
||||||
from .models import FederatedUser, FederateSLO, User
|
from .models import FederatedUser, FederateSLO, User
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
from six.moves import urllib
|
import urllib
|
||||||
|
|
||||||
#: logger facility
|
#: logger facility
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
|
@ -10,6 +10,8 @@
|
||||||
#
|
#
|
||||||
# (c) 2016 Valentin Samir
|
# (c) 2016 Valentin Samir
|
||||||
"""tests for the CAS federate mode"""
|
"""tests for the CAS federate mode"""
|
||||||
|
import importlib
|
||||||
|
|
||||||
from cas_server import default_settings
|
from cas_server import default_settings
|
||||||
from cas_server.default_settings import settings
|
from cas_server.default_settings import settings
|
||||||
|
|
||||||
|
@ -17,8 +19,6 @@ import django
|
||||||
from django.test import TestCase, Client
|
from django.test import TestCase, Client
|
||||||
from django.test.utils import override_settings
|
from django.test.utils import override_settings
|
||||||
|
|
||||||
from six.moves import reload_module
|
|
||||||
|
|
||||||
from cas_server import utils, models
|
from cas_server import utils, models
|
||||||
from cas_server.tests.mixin import BaseServicePattern, CanLogin, FederatedIendityProviderModel
|
from cas_server.tests.mixin import BaseServicePattern, CanLogin, FederatedIendityProviderModel
|
||||||
from cas_server.tests import utils as tests_utils
|
from cas_server.tests import utils as tests_utils
|
||||||
|
@ -49,7 +49,7 @@ class FederateAuthLoginLogoutTestCase(
|
||||||
def test_default_settings(self):
|
def test_default_settings(self):
|
||||||
"""default settings should populated some default variable then CAS_FEDERATE is True"""
|
"""default settings should populated some default variable then CAS_FEDERATE is True"""
|
||||||
del settings.CAS_AUTH_CLASS
|
del settings.CAS_AUTH_CLASS
|
||||||
reload_module(default_settings)
|
importlib.reload(default_settings)
|
||||||
self.assertEqual(settings.CAS_AUTH_CLASS, "cas_server.auth.CASFederateAuth")
|
self.assertEqual(settings.CAS_AUTH_CLASS, "cas_server.auth.CASFederateAuth")
|
||||||
|
|
||||||
def test_login_get_provider(self):
|
def test_login_get_provider(self):
|
||||||
|
|
|
@ -14,7 +14,6 @@ import django
|
||||||
from django.test import TestCase, RequestFactory
|
from django.test import TestCase, RequestFactory
|
||||||
from django.db import connection
|
from django.db import connection
|
||||||
|
|
||||||
import six
|
|
||||||
import warnings
|
import warnings
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
|
@ -66,15 +65,12 @@ class CheckPasswordCase(TestCase):
|
||||||
salts = ["$6$UVVAQvrMyXMF3FF3", "aa"]
|
salts = ["$6$UVVAQvrMyXMF3FF3", "aa"]
|
||||||
hashed_password1 = []
|
hashed_password1 = []
|
||||||
for salt in salts:
|
for salt in salts:
|
||||||
if six.PY3:
|
hashed_password1.append(
|
||||||
hashed_password1.append(
|
utils.crypt.crypt(
|
||||||
utils.crypt.crypt(
|
self.password1.decode("utf8"),
|
||||||
self.password1.decode("utf8"),
|
salt
|
||||||
salt
|
).encode("utf8")
|
||||||
).encode("utf8")
|
)
|
||||||
)
|
|
||||||
else:
|
|
||||||
hashed_password1.append(utils.crypt.crypt(self.password1, salt))
|
|
||||||
|
|
||||||
for hp1 in hashed_password1:
|
for hp1 in hashed_password1:
|
||||||
self.assertTrue(utils.check_password("crypt", self.password1, hp1, "utf8"))
|
self.assertTrue(utils.check_password("crypt", self.password1, hp1, "utf8"))
|
||||||
|
@ -240,7 +236,7 @@ class UtilsTestCase(TestCase):
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
version = utils.last_version()
|
version = utils.last_version()
|
||||||
self.assertIsInstance(version, six.text_type)
|
self.assertIsInstance(version, str)
|
||||||
self.assertEqual(len(version.split('.')), 3)
|
self.assertEqual(len(version.split('.')), 3)
|
||||||
|
|
||||||
# version is cached 24h so calling it a second time should return the save value
|
# version is cached 24h so calling it a second time should return the save value
|
||||||
|
|
|
@ -22,7 +22,6 @@ import random
|
||||||
import json
|
import json
|
||||||
import mock
|
import mock
|
||||||
from lxml import etree
|
from lxml import etree
|
||||||
from six.moves import range
|
|
||||||
|
|
||||||
from cas_server import models
|
from cas_server import models
|
||||||
from cas_server import utils
|
from cas_server import utils
|
||||||
|
|
|
@ -18,11 +18,10 @@ from django.template import loader
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
|
|
||||||
import cgi
|
import cgi
|
||||||
import six
|
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
from lxml import etree
|
from lxml import etree
|
||||||
from six.moves import BaseHTTPServer
|
import http.server as BaseHTTPServer
|
||||||
from six.moves.urllib.parse import urlparse, parse_qsl, parse_qs
|
from urllib.parse import urlparse, parse_qsl, parse_qs
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
|
||||||
from cas_server import models
|
from cas_server import models
|
||||||
|
@ -43,7 +42,7 @@ else:
|
||||||
|
|
||||||
def return_unicode(string, charset):
|
def return_unicode(string, charset):
|
||||||
"""make `string` a unicode if `string` is a unicode or bytes encoded with `charset`"""
|
"""make `string` a unicode if `string` is a unicode or bytes encoded with `charset`"""
|
||||||
if not isinstance(string, six.text_type):
|
if not isinstance(string, str):
|
||||||
return string.decode(charset)
|
return string.decode(charset)
|
||||||
else:
|
else:
|
||||||
return string
|
return string
|
||||||
|
@ -54,7 +53,7 @@ def return_bytes(string, charset):
|
||||||
make `string` a bytes encoded with `charset` if `string` is a unicode
|
make `string` a bytes encoded with `charset` if `string` is a unicode
|
||||||
or bytes encoded with `charset`
|
or bytes encoded with `charset`
|
||||||
"""
|
"""
|
||||||
if isinstance(string, six.text_type):
|
if isinstance(string, str):
|
||||||
return string.encode(charset)
|
return string.encode(charset)
|
||||||
else:
|
else:
|
||||||
return string
|
return string
|
||||||
|
|
|
@ -32,7 +32,6 @@ import json
|
||||||
import hashlib
|
import hashlib
|
||||||
import crypt
|
import crypt
|
||||||
import base64
|
import base64
|
||||||
import six
|
|
||||||
import requests
|
import requests
|
||||||
import time
|
import time
|
||||||
import logging
|
import logging
|
||||||
|
@ -40,7 +39,7 @@ import binascii
|
||||||
|
|
||||||
from importlib import import_module
|
from importlib import import_module
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from six.moves.urllib.parse import urlparse, urlunparse, parse_qsl, urlencode
|
from urllib.parse import urlparse, urlunparse, parse_qsl, urlencode
|
||||||
|
|
||||||
from . import VERSION
|
from . import VERSION
|
||||||
|
|
||||||
|
@ -53,7 +52,7 @@ def json_encode(obj):
|
||||||
try:
|
try:
|
||||||
return json_encode.encoder.encode(obj)
|
return json_encode.encoder.encode(obj)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
json_encode.encoder = DjangoJSONEncoder(default=six.text_type)
|
json_encode.encoder = DjangoJSONEncoder(default=str)
|
||||||
return json_encode(obj)
|
return json_encode(obj)
|
||||||
|
|
||||||
|
|
||||||
|
@ -92,7 +91,7 @@ def context(params):
|
||||||
# make box discardable by default
|
# make box discardable by default
|
||||||
msg["discardable"] = msg.get("discardable", True)
|
msg["discardable"] = msg.get("discardable", True)
|
||||||
msg_hash = (
|
msg_hash = (
|
||||||
six.text_type(msg["message"]).encode("utf-8") +
|
str(msg["message"]).encode("utf-8") +
|
||||||
msg["type"].encode("utf-8")
|
msg["type"].encode("utf-8")
|
||||||
)
|
)
|
||||||
# hash depend of the rendering language
|
# hash depend of the rendering language
|
||||||
|
@ -125,10 +124,10 @@ def import_attr(path):
|
||||||
:return: The python object pointed by the dotted path or the python object unchanged
|
:return: The python object pointed by the dotted path or the python object unchanged
|
||||||
"""
|
"""
|
||||||
# if we got a str, decode it to unicode (normally it should only contain ascii)
|
# if we got a str, decode it to unicode (normally it should only contain ascii)
|
||||||
if isinstance(path, six.binary_type):
|
if isinstance(path, bytes):
|
||||||
path = path.decode("utf-8")
|
path = path.decode("utf-8")
|
||||||
# if path is not an unicode, return it unchanged (may be it is already the attribute to import)
|
# if path is not an unicode, return it unchanged (may be it is already the attribute to import)
|
||||||
if not isinstance(path, six.text_type):
|
if not isinstance(path, str):
|
||||||
return path
|
return path
|
||||||
if u"." not in path:
|
if u"." not in path:
|
||||||
ValueError("%r should be of the form `module.attr` and we just got `attr`" % path)
|
ValueError("%r should be of the form `module.attr` and we just got `attr`" % path)
|
||||||
|
@ -261,12 +260,8 @@ def update_url(url, params):
|
||||||
else:
|
else:
|
||||||
return data
|
return data
|
||||||
|
|
||||||
if six.PY3:
|
url = to_unicode(url)
|
||||||
url = to_unicode(url)
|
params = {to_unicode(key): to_unicode(value) for (key, value) in params.items()}
|
||||||
params = {to_unicode(key): to_unicode(value) for (key, value) in params.items()}
|
|
||||||
else:
|
|
||||||
url = to_bytes(url)
|
|
||||||
params = {to_bytes(key): to_bytes(value) for (key, value) in params.items()}
|
|
||||||
|
|
||||||
url_parts = list(urlparse(url))
|
url_parts = list(urlparse(url))
|
||||||
query = dict(parse_qsl(url_parts[4], keep_blank_values=True))
|
query = dict(parse_qsl(url_parts[4], keep_blank_values=True))
|
||||||
|
@ -567,14 +562,12 @@ class LdapHashUserPassword(object):
|
||||||
cls._schemes_to_hash[scheme](password + salt).digest() + salt
|
cls._schemes_to_hash[scheme](password + salt).digest() + salt
|
||||||
)
|
)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
if six.PY3:
|
password = password.decode(charset)
|
||||||
password = password.decode(charset)
|
salt = salt.decode(charset)
|
||||||
salt = salt.decode(charset)
|
|
||||||
if not crypt_salt_is_valid(salt):
|
if not crypt_salt_is_valid(salt):
|
||||||
raise cls.BadSalt("System crypt implementation do not support the salt %r" % salt)
|
raise cls.BadSalt("System crypt implementation do not support the salt %r" % salt)
|
||||||
hashed_password = crypt.crypt(password, salt)
|
hashed_password = crypt.crypt(password, salt)
|
||||||
if six.PY3:
|
hashed_password = hashed_password.encode(charset)
|
||||||
hashed_password = hashed_password.encode(charset)
|
|
||||||
return scheme + hashed_password
|
return scheme + hashed_password
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@ -639,9 +632,9 @@ def check_password(method, password, hashed_password, charset):
|
||||||
``False`` otherwise
|
``False`` otherwise
|
||||||
:rtype: bool
|
:rtype: bool
|
||||||
"""
|
"""
|
||||||
if not isinstance(password, six.binary_type):
|
if not isinstance(password, bytes):
|
||||||
password = password.encode(charset)
|
password = password.encode(charset)
|
||||||
if not isinstance(hashed_password, six.binary_type):
|
if not isinstance(hashed_password, bytes):
|
||||||
hashed_password = hashed_password.encode(charset)
|
hashed_password = hashed_password.encode(charset)
|
||||||
if method == "plain":
|
if method == "plain":
|
||||||
return password == hashed_password
|
return password == hashed_password
|
||||||
|
@ -652,10 +645,9 @@ def check_password(method, password, hashed_password, charset):
|
||||||
salt = hashed_password[:9]
|
salt = hashed_password[:9]
|
||||||
else:
|
else:
|
||||||
salt = hashed_password[:2]
|
salt = hashed_password[:2]
|
||||||
if six.PY3:
|
password = password.decode(charset)
|
||||||
password = password.decode(charset)
|
salt = salt.decode(charset)
|
||||||
salt = salt.decode(charset)
|
hashed_password = hashed_password.decode(charset)
|
||||||
hashed_password = hashed_password.decode(charset)
|
|
||||||
if not crypt_salt_is_valid(salt):
|
if not crypt_salt_is_valid(salt):
|
||||||
raise ValueError("System crypt implementation do not support the salt %r" % salt)
|
raise ValueError("System crypt implementation do not support the salt %r" % salt)
|
||||||
crypted_password = crypt.crypt(password, salt)
|
crypted_password = crypt.crypt(password, salt)
|
||||||
|
|
|
@ -2,7 +2,6 @@ setuptools>=5.5
|
||||||
requests>=2.4
|
requests>=2.4
|
||||||
requests_futures>=0.9.5
|
requests_futures>=0.9.5
|
||||||
lxml>=3.4
|
lxml>=3.4
|
||||||
six>=1.8
|
|
||||||
tox>=1.8.1
|
tox>=1.8.1
|
||||||
pytest>=7
|
pytest>=7
|
||||||
pytest-django>=2.8.0
|
pytest-django>=2.8.0
|
||||||
|
|
|
@ -3,4 +3,3 @@ setuptools>=5.5
|
||||||
requests>=2.4
|
requests>=2.4
|
||||||
requests_futures>=0.9.5
|
requests_futures>=0.9.5
|
||||||
lxml>=3.4
|
lxml>=3.4
|
||||||
six>=1.8
|
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -62,7 +62,7 @@ if __name__ == '__main__':
|
||||||
keywords=['django', 'cas', 'cas3', 'server', 'sso', 'single sign-on', 'authentication', 'auth'],
|
keywords=['django', 'cas', 'cas3', 'server', 'sso', 'single sign-on', 'authentication', 'auth'],
|
||||||
install_requires=[
|
install_requires=[
|
||||||
'Django >= 1.11,<4.2', 'requests >= 2.4', 'requests_futures >= 0.9.5',
|
'Django >= 1.11,<4.2', 'requests >= 2.4', 'requests_futures >= 0.9.5',
|
||||||
'lxml >= 3.4', 'six >= 1'
|
'lxml >= 3.4'
|
||||||
],
|
],
|
||||||
url="https://github.com/nitmir/django-cas-server",
|
url="https://github.com/nitmir/django-cas-server",
|
||||||
download_url="https://github.com/nitmir/django-cas-server/releases/latest",
|
download_url="https://github.com/nitmir/django-cas-server/releases/latest",
|
||||||
|
|
Loading…
Add table
Reference in a new issue