Skip to content

Commit

Permalink
Accept bytes as input to is_encrypted (like pw_validate does)
Browse files Browse the repository at this point in the history
And for good measure, add support for recent Pythons and drop 3.3
  • Loading branch information
davisagli committed Oct 30, 2018
1 parent e011dbd commit f4a5d3a
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 5 deletions.
7 changes: 6 additions & 1 deletion .travis.yml
Expand Up @@ -3,9 +3,14 @@ language: python
sudo: false
python:
- 2.7
- 3.3
- 3.4
- 3.5
- 3.6
matrix:
include:
- python: "3.7"
dist: xenial
sudo: true
install:
- python bootstrap.py
- bin/buildout
Expand Down
6 changes: 5 additions & 1 deletion CHANGES.txt
Expand Up @@ -4,11 +4,15 @@ Changelog
4.1.0 (unreleased)
------------------

- Drop Python 2.6 support.
- Drop Python 2.6 and 3.3 support.

- Add Python 3.6 and 3.7 support.

- Add ``BCRYPTHashingScheme``, optionally available if package is
installed with the `bcrypt` extra.

- Accept bytes as input to ``AuthEncoding.is_encrypted``.


4.0.0 (2015-09-30)
------------------
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Expand Up @@ -37,9 +37,10 @@
"Programming Language :: Python :: 2.6",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.3",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6,
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Topic :: System :: Systems Administration :: Authentication/Directory :: LDAP",
Expand Down
1 change: 1 addition & 0 deletions src/AuthEncoding/AuthEncoding.py
Expand Up @@ -266,6 +266,7 @@ def pw_validate(reference, attempt):


def is_encrypted(pw):
pw = b(pw)
for id, prefix, scheme in _schemes:
lp = len(prefix)
if pw[:lp] == b(prefix):
Expand Down
7 changes: 7 additions & 0 deletions src/AuthEncoding/tests/test_AuthEncoding.py
Expand Up @@ -99,3 +99,10 @@ def testEncryptWithNotSupportedScheme():
def testEncryptAcceptsTextAndBinaryEncodingNames():
assert (AuthEncoding.pw_encrypt(u'asdf', b'SHA') ==
AuthEncoding.pw_encrypt(u'asdf', u'SHA'))


def testIsEncryptedAcceptsTextAndBinary():
assert AuthEncoding.is_encrypted(b'{SHA}')
assert AuthEncoding.is_encrypted(u'{SHA}')
assert not AuthEncoding.is_encrypted(b'foo')
assert not AuthEncoding.is_encrypted(u'foo')
4 changes: 2 additions & 2 deletions tox.ini
@@ -1,10 +1,10 @@
[tox]
envlist = py27, pypy, py33, py34, py35
envlist = py27, pypy, py34, py35, py36, py37
minversion = 1.6

[testenv]
deps = pytest >= 2.9
pytest-cov
commands = py.test --cov=src --cov-report=html --junitxml=testreport.xml
install_command = pip install --egg {opts} {packages}
install_command = pip install {opts} {packages}
usedevelop = True

0 comments on commit f4a5d3a

Please sign in to comment.