Skip to content

Commit

Permalink
Config with pure python template (#6)
Browse files Browse the repository at this point in the history
* Drop support for Python 2.7, 3.5, 3.6.
* Add support for Python 3.11.

Co-authored-by: Jens Vagelpohl <jens@netz.ooo>
  • Loading branch information
Michael Howitz and dataflake committed Feb 6, 2023
1 parent da1b0e9 commit dadb53c
Show file tree
Hide file tree
Showing 18 changed files with 208 additions and 212 deletions.
20 changes: 9 additions & 11 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,29 @@ jobs:
fail-fast: false
matrix:
os:
- ubuntu
- ["ubuntu", "ubuntu-20.04"]
config:
# [Python version, tox env]
- ["3.9", "lint"]
- ["2.7", "py27"]
- ["3.5", "py35"]
- ["3.6", "py36"]
- ["3.7", "py37"]
- ["3.8", "py38"]
- ["3.9", "py39"]
- ["3.10", "py310"]
- ["pypy2", "pypy"]
- ["pypy3", "pypy3"]
- ["3.11", "py311"]
- ["pypy-3.9", "pypy3"]
- ["3.9", "coverage"]

runs-on: ${{ matrix.os }}-latest
runs-on: ${{ matrix.os[1] }}
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
name: ${{ matrix.config[1] }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.config[0] }}
- name: Pip cache
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ matrix.config[0] }}-${{ hashFiles('setup.*', 'tox.ini') }}
Expand All @@ -57,7 +55,7 @@ jobs:
- name: Coverage
if: matrix.config[1] == 'coverage'
run: |
pip install coveralls coverage-python-version
pip install coveralls
coveralls --service=github
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ lib64
log/
parts/
pyvenv.cfg
testing.log
var/
4 changes: 2 additions & 2 deletions .meta.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
# https://github.com/zopefoundation/meta/tree/master/config/pure-python
[meta]
template = "pure-python"
commit-id = "fba6d957ba447b6fa369d872e803756bd5176391"
commit-id = "e5c611fb"

[python]
with-windows = false
with-pypy = true
with-future-python = false
with-legacy-python = true
with-sphinx-doctests = false
with-macos = false

[tox]
use-flake8 = true
Expand Down
8 changes: 5 additions & 3 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
CHANGES
=======

1.1.1 (unreleased)
------------------
2.0 (unreleased)
----------------

- Add support for Python 3.11.

- Nothing changed yet.
- Drop support for Python 2.7, 3.5, 3.6.


1.1.0 (2021-12-14)
Expand Down
23 changes: 23 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!--
Generated from:
https://github.com/zopefoundation/meta/tree/master/config/pure-python
-->
# Contributing to zopefoundation projects

The projects under the zopefoundation GitHub organization are open source and
welcome contributions in different forms:

* bug reports
* code improvements and bug fixes
* documentation improvements
* pull request reviews

For any changes in the repository besides trivial typo fixes you are required
to sign the contributor agreement. See
https://www.zope.dev/developer/becoming-a-committer.html for details.

Please visit our [Developer
Guidelines](https://www.zope.dev/developer/guidelines.html) if you'd like to
contribute code changes and our [guidelines for reporting
bugs](https://www.zope.dev/developer/reporting-bugs.html) if you want to file a
bug report.
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Generated from:
# https://github.com/zopefoundation/meta/tree/master/config/pure-python
include *.md
include *.rst
include *.txt
include buildout.cfg
Expand Down
13 changes: 12 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Generated from:
# https://github.com/zopefoundation/meta/tree/master/config/pure-python
[bdist_wheel]
universal = 1
universal = 0

[flake8]
doctests = 1
Expand All @@ -12,3 +12,14 @@ ignore =
.meta.toml
ignore-bad-ideas =
src/z3c/password/locales/*/LC_MESSAGES/z3c.password.mo

[isort]
force_single_line = True
combine_as_imports = True
sections = FUTURE,STDLIB,THIRDPARTY,ZOPE,FIRSTPARTY,LOCALFOLDER
known_third_party = six, docutils, pkg_resources, pytz
known_zope =
known_first_party =
default_section = ZOPE
line_length = 79
lines_after_imports = 2
19 changes: 10 additions & 9 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
"""Setup
"""
import os
from setuptools import setup, find_packages

from setuptools import find_packages
from setuptools import setup


def read(*rnames):
Expand All @@ -23,9 +25,9 @@ def read(*rnames):

setup(
name='z3c.password',
version='1.1.1.dev0',
version='2.0.dev0',
author="Stephan Richter, Roger Ineichen and the Zope Community",
author_email="zope3-dev@zope.org",
author_email="zope-dev@zope.dev",
description="Password generation and verification utility for Zope3",
long_description=(
read('README.rst')
Expand All @@ -40,26 +42,25 @@ def read(*rnames):
'Intended Audience :: Developers',
'License :: OSI Approved :: Zope Public License',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: Implementation :: CPython',
"Programming Language :: Python :: Implementation :: PyPy",
'Programming Language :: Python :: Implementation :: PyPy',
'Natural Language :: English',
'Operating System :: OS Independent',
'Topic :: Internet :: WWW/HTTP',
'Framework :: Zope :: 3'],
'Framework :: Zope :: 3',
],
url='http://pypi.org/project/z3c.password',
packages=find_packages('src'),
include_package_data=True,
package_dir={'': 'src'},
namespace_packages=['z3c'],
python_requires='>=3.7',
extras_require=dict(
test=[
'z3c.coverage',
Expand Down
8 changes: 1 addition & 7 deletions src/z3c/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1 @@
# this is a namespace package
try:
import pkg_resources
pkg_resources.declare_namespace(__name__)
except ImportError:
import pkgutil
__path__ = pkgutil.extend_path(__path__, __name__)
__import__('pkg_resources').declare_namespace(__name__) # pragma: no cover
47 changes: 23 additions & 24 deletions src/z3c/password/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,7 @@ letters, digits, punctuation, other), and the maximum similarity score.
...
TooManyGroupCharacters: Password contains too many characters of one group (should have at most 6).

>>> from z3c.password._compat import unichr
>>> pwd.verify(unichr(0x0e1)*8)
>>> pwd.verify(chr(0x0e1)*8)
Traceback (most recent call last):
...
TooManyGroupCharacters: Password contains too many characters of one group (should have at most 6).
Expand Down Expand Up @@ -256,17 +255,17 @@ We want to have at least 5 others in the password:
>>> pwd = password.HighSecurityPasswordUtility(seed=8)
>>> pwd.minOthers = 5

>>> pwd.verify('foobar'+unichr(0x0c3)+unichr(0x0c4))
>>> pwd.verify('foobar'+chr(0x0c3)+chr(0x0c4))
Traceback (most recent call last):
...
TooFewGroupCharactersOthers: Password does not contain enough characters of other characters (should have at least 5).

>>> pwd.verify('foobar'+unichr(0x0c3)+unichr(0x0c4)+unichr(0x0e1))
>>> pwd.verify('foobar'+chr(0x0c3)+chr(0x0c4)+chr(0x0e1))
Traceback (most recent call last):
...
TooFewGroupCharactersOthers: Password does not contain enough characters of other characters (should have at least 5).

>>> pwd.verify('fOO'+unichr(0x0e1)*5)
>>> pwd.verify('fOO'+chr(0x0e1)*5)


Generating passwords with others not yet supported
Expand Down Expand Up @@ -339,13 +338,13 @@ Let's now create the field:

>>> pwdField = field.Password(
... __name__='password',
... title=u'Password',
... title='Password',
... checker=pwd)

Let's validate a value:

>>> pwdField.validate(u'fooBar12')
>>> pwdField.validate(u'fooBar')
>>> pwdField.validate('fooBar12')
>>> pwdField.validate('fooBar')
Traceback (most recent call last):
...
TooShortPassword: Password is too short (minimum length: 8).
Expand All @@ -361,29 +360,29 @@ Let's now create a principal:
... principalfolder.InternalPrincipal):
... pass

>>> user = MyPrincipal('srichter', '123123', u'Stephan Richter')
>>> user = MyPrincipal('srichter', '123123', 'Stephan Richter')

Bind the field:

>>> bound = pwdField.bind(user)

>>> bound.validate(u'fooBar12')
>>> bound.validate(u'fooBar')
>>> bound.validate('fooBar12')
>>> bound.validate('fooBar')
Traceback (most recent call last):
...
TooShortPassword: Password is too short (minimum length: 8).

Let's create a principal without the PrincipalMixIn:

>>> user = principalfolder.InternalPrincipal('srichter', '123123',
... u'Stephan Richter')
... 'Stephan Richter')

Bind the field:

>>> bound = pwdField.bind(user)

>>> bound.validate(u'fooBar12')
>>> bound.validate(u'fooBar')
>>> bound.validate('fooBar12')
>>> bound.validate('fooBar')
Traceback (most recent call last):
...
TooShortPassword: Password is too short (minimum length: 8).
Expand All @@ -398,13 +397,13 @@ Recreate the field:

>>> pwdField = field.Password(
... __name__='password',
... title=u'Password',
... title='Password',
... checker='my password checker')

Let's validate a value:

>>> pwdField.validate(u'fooBar12')
>>> pwdField.validate(u'fooBar')
>>> pwdField.validate('fooBar12')
>>> pwdField.validate('fooBar')
Traceback (most recent call last):
...
TooShortPassword: Password is too short (minimum length: 8).
Expand All @@ -416,23 +415,23 @@ No checker specified.

>>> pwdField = field.Password(
... __name__='password',
... title=u'Password')
... title='Password')

Validation silently succeeds with a checker:

>>> pwdField.validate(u'fooBar12')
>>> pwdField.validate(u'fooBar')
>>> pwdField.validate('fooBar12')
>>> pwdField.validate('fooBar')

Bad utility name.

>>> pwdField = field.Password(
... __name__='password',
... title=u'Password',
... title='Password',
... checker='foobar password checker')

Burps on the utility lookup as expected:

>>> pwdField.validate(u'fooBar12')
>>> pwdField.validate('fooBar12')
Traceback (most recent call last):
...
ComponentLookupError:...
Expand All @@ -441,11 +440,11 @@ Bound object does not have the property:

>>> pwdField = field.Password(
... __name__='foobar',
... title=u'Password',
... title='Password',
... checker=pwd)

>>> bound = pwdField.bind(user)

Validation silently succeeds:

>>> bound.validate(u'fooBar12')
>>> bound.validate('fooBar12')
2 changes: 2 additions & 0 deletions src/z3c/password/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Make a package.

import zope.i18nmessageid


MessageFactory = zope.i18nmessageid.MessageFactory('z3c.password')
27 changes: 0 additions & 27 deletions src/z3c/password/_compat.py

This file was deleted.

Loading

0 comments on commit dadb53c

Please sign in to comment.