From c027f7446a8df10074da657f16d20648f9e241ac Mon Sep 17 00:00:00 2001 From: Jacob Floyd Date: Tue, 11 Jun 2024 11:56:06 -0500 Subject: [PATCH 01/14] 0.2.1: Require passlib[bcrypt] --- requirements.txt | 5 ++++- st2auth_flat_file_backend/__init__.py | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 7ac66c3..bd5e796 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,4 @@ -passlib>=1.7.1,<1.8.0 +# passlib can use several libs to provide bcrypt (which is required for htpasswd support), +# but passlib deprecated support for py-bcrypt, a bcrypt lib alternative. +# The [bcrypt] extra ensures we use bcrypt instead of some other lib. +passlib[bcrypt]>=1.7.1,<1.8.0 diff --git a/st2auth_flat_file_backend/__init__.py b/st2auth_flat_file_backend/__init__.py index 7c0f41b..3cd2c6d 100644 --- a/st2auth_flat_file_backend/__init__.py +++ b/st2auth_flat_file_backend/__init__.py @@ -21,4 +21,4 @@ 'FlatFileAuthenticationBackend' ] -__version__ = '0.2.0' +__version__ = '0.2.1' From a1e9bcb1ec2fa25b70d76390ce6e53ea77ccdf7b Mon Sep 17 00:00:00 2001 From: Jacob Floyd Date: Sat, 19 Oct 2024 12:22:08 -0500 Subject: [PATCH 02/14] sync test reqs w/ st2.git --- test-requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test-requirements.txt b/test-requirements.txt index 4cdc397..3ae305e 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,6 +1,6 @@ -mock==3.0.5 +mock==5.1.0 nose>=1.3.7 pep8==1.7.1 -pylint==1.9.4 +pylint~=3.1.0 st2flake8==0.1.0 unittest2 From a8e4aa734ce767c9ff828d525c1b3c7911f0dc60 Mon Sep 17 00:00:00 2001 From: Jacob Floyd Date: Sat, 19 Oct 2024 12:22:51 -0500 Subject: [PATCH 03/14] unpin st2flake8 to get update --- test-requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test-requirements.txt b/test-requirements.txt index 3ae305e..23e5574 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -2,5 +2,5 @@ mock==5.1.0 nose>=1.3.7 pep8==1.7.1 pylint~=3.1.0 -st2flake8==0.1.0 +st2flake8 unittest2 From 0a836eecb0c954bf064837d954dceaf77d894a8c Mon Sep 17 00:00:00 2001 From: Jacob Floyd Date: Sat, 19 Oct 2024 13:00:24 -0500 Subject: [PATCH 04/14] switch from travis to GHA --- .github/workflows/tox.yaml | 49 ++++++++++++++++++++++++++++++++++++++ .travis.yml | 29 ---------------------- tox.ini | 22 +++++++++++------ 3 files changed, 64 insertions(+), 36 deletions(-) create mode 100644 .github/workflows/tox.yaml delete mode 100644 .travis.yml diff --git a/.github/workflows/tox.yaml b/.github/workflows/tox.yaml new file mode 100644 index 0000000..7e21d1f --- /dev/null +++ b/.github/workflows/tox.yaml @@ -0,0 +1,49 @@ +name: Tox CI + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@v4 + + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: "3.8" + + - name: Install tox + run: pip install --user tox + + - name: Lint + run: tox -e lint + + build: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.8", "3.9", "3.10", "3.11"] + steps: + - name: Checkout repo + uses: actions/checkout@v4 + + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Install tox + run: pip install --user tox + + - name: Select tox env + id: tox-env + run: echo tox-env=py${{ matrix.python-version }} | tr . '' >> ${GITHUB_OUTPUT} + + - name: Test + run: tox -e ${{ steps.tox-env.outputs.tox-env }} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index c1225ce..0000000 --- a/.travis.yml +++ /dev/null @@ -1,29 +0,0 @@ -language: python -python: 2.7 -sudo: false - -env: - global: - - CACHE_NAME=JOB1 -matrix: - include: - - env: TOX_ENV=lint - python: 2.7 - - env: TOX_ENV=py27 - python: 2.7 - - env: TOX_ENV=py36 - python: 3.6 - -cache: - pip: true - directories: - - virtualenv/ - # NOTE: Caching .tox speeds up py3 build for 30-60 seconds, but causes issues when dependencies - # are updated so it's disabled - #- .tox/ - -install: - - pip install tox - -script: - - tox -e $TOX_ENV diff --git a/tox.ini b/tox.ini index ad597de..30f1724 100644 --- a/tox.ini +++ b/tox.ini @@ -1,16 +1,24 @@ [tox] -envlist = py27,py36,lint +envlist = py36,py38,py39,py310,py311,lint [testenv] deps = -r{toxinidir}/test-requirements.txt -[testenv:py27] -basepython = python2.7 -commands = python setup.py test +[testenv:py38] +basepython = python3.8 +commands = python3 setup.py test -[testenv:py36] -basepython = python3.6 -commands = python setup.py test +[testenv:py39] +basepython = python3.9 +commands = python3 setup.py test + +[testenv:py310] +basepython = python3.10 +commands = python3 setup.py test + +[testenv:py311] +basepython = python3.11 +commands = python3 setup.py test [testenv:lint] deps = -r{toxinidir}/test-requirements.txt From 67f42870fffa5d424d1f4686e2e76f5fb06e5331 Mon Sep 17 00:00:00 2001 From: Jacob Floyd Date: Sat, 19 Oct 2024 13:08:42 -0500 Subject: [PATCH 05/14] fix tr usage --- .github/workflows/tox.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tox.yaml b/.github/workflows/tox.yaml index 7e21d1f..3f26e0b 100644 --- a/.github/workflows/tox.yaml +++ b/.github/workflows/tox.yaml @@ -43,7 +43,7 @@ jobs: - name: Select tox env id: tox-env - run: echo tox-env=py${{ matrix.python-version }} | tr . '' >> ${GITHUB_OUTPUT} + run: echo tox-env=py${{ matrix.python-version }} | tr -d '.' >> ${GITHUB_OUTPUT} - name: Test run: tox -e ${{ steps.tox-env.outputs.tox-env }} From c2f621b3b48e95a3b923825678c81b940aec486b Mon Sep 17 00:00:00 2001 From: Jacob Floyd Date: Sat, 19 Oct 2024 13:12:34 -0500 Subject: [PATCH 06/14] use pytest --- setup.py | 1 - test-requirements.txt | 2 +- tox.ini | 8 ++++---- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/setup.py b/setup.py index c93ff63..02083c5 100644 --- a/setup.py +++ b/setup.py @@ -59,7 +59,6 @@ include_package_data=True, install_requires=install_reqs, dependency_links=dep_links, - test_suite='tests', entry_points={ 'st2auth.backends.backend': [ 'flat_file = st2auth_flat_file_backend.flat_file:FlatFileAuthenticationBackend', diff --git a/test-requirements.txt b/test-requirements.txt index 23e5574..503d397 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,6 +1,6 @@ mock==5.1.0 -nose>=1.3.7 pep8==1.7.1 pylint~=3.1.0 +pytest st2flake8 unittest2 diff --git a/tox.ini b/tox.ini index 30f1724..4daf46c 100644 --- a/tox.ini +++ b/tox.ini @@ -6,19 +6,19 @@ deps = -r{toxinidir}/test-requirements.txt [testenv:py38] basepython = python3.8 -commands = python3 setup.py test +commands = pytest [testenv:py39] basepython = python3.9 -commands = python3 setup.py test +commands = pytest [testenv:py310] basepython = python3.10 -commands = python3 setup.py test +commands = pytest [testenv:py311] basepython = python3.11 -commands = python3 setup.py test +commands = pytest [testenv:lint] deps = -r{toxinidir}/test-requirements.txt From 7a55402c2073a2766ae2def97b9085e28353f2e9 Mon Sep 17 00:00:00 2001 From: Jacob Floyd Date: Sat, 19 Oct 2024 13:42:29 -0500 Subject: [PATCH 07/14] drop unittest2 backport package --- test-requirements.txt | 1 - tests/unit/test_flat_file_backend.py | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/test-requirements.txt b/test-requirements.txt index 503d397..cc288f3 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -3,4 +3,3 @@ pep8==1.7.1 pylint~=3.1.0 pytest st2flake8 -unittest2 diff --git a/tests/unit/test_flat_file_backend.py b/tests/unit/test_flat_file_backend.py index 6b5ea34..4907481 100644 --- a/tests/unit/test_flat_file_backend.py +++ b/tests/unit/test_flat_file_backend.py @@ -16,14 +16,14 @@ import os import sys -import unittest2 +import unittest from st2auth_flat_file_backend.flat_file import FlatFileAuthenticationBackend BASE_DIR = os.path.dirname(os.path.abspath(__file__)) -class FlatFileAuthenticationBackendTestCase(unittest2.TestCase): +class FlatFileAuthenticationBackendTestCase(unittest.TestCase): def test_authenticate_httpasswd_file_without_comments(self): file_path = os.path.join(BASE_DIR, '../fixtures/htpasswd_test') backend = FlatFileAuthenticationBackend(file_path=file_path) @@ -69,4 +69,4 @@ def test_authenticate_httpasswd_file_doesnt_exist(self): self.assertRaises(IOError, backend.authenticate, username='doesntexist', password='bar') if __name__ == '__main__': - sys.exit(unittest2.main()) + sys.exit(unittest.main()) From 5f7cf90889fb8616ffddc0e3c7e0cdc9458f4295 Mon Sep 17 00:00:00 2001 From: Jacob Floyd Date: Sat, 19 Oct 2024 14:00:00 -0500 Subject: [PATCH 08/14] explicit test dep on flake8 --- test-requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/test-requirements.txt b/test-requirements.txt index cc288f3..79c982e 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,3 +1,4 @@ +flake8==7.0.0 mock==5.1.0 pep8==1.7.1 pylint~=3.1.0 From 9fda3b464c3e6d78f48ba3b3184f8117c63f7f8b Mon Sep 17 00:00:00 2001 From: Jacob Floyd Date: Sat, 19 Oct 2024 14:05:26 -0500 Subject: [PATCH 09/14] satisfy upgraded pylint --- lint-configs/python/.pylintrc | 7 +------ st2auth_flat_file_backend/flat_file.py | 4 +--- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/lint-configs/python/.pylintrc b/lint-configs/python/.pylintrc index 8e2d3c5..2ac0894 100644 --- a/lint-configs/python/.pylintrc +++ b/lint-configs/python/.pylintrc @@ -1,14 +1,9 @@ [MESSAGES CONTROL] # C0111 Missing docstring # I0011 Warning locally suppressed using disable-msg -# I0012 Warning locally suppressed using disable-msg -# W0704 Except doesn't do anything Used when an except clause does nothing but "pass" and there is no "else" clause -# W0142 Used * or * magic* Used when a function or method is called using *args or **kwargs to dispatch arguments. # W0212 Access to a protected member %s of a client class -# W0232 Class has no __init__ method Used when a class has no __init__ method, neither its parent classes. # W0613 Unused argument %r Used when a function or method argument is not used. # W0702 No exception's type specified Used when an except clause doesn't specify exceptions type to catch. -# R0201 Method could be a function # W0614 Unused import XYZ from wildcard import # R0914 Too many local variables # R0912 Too many branches @@ -16,7 +11,7 @@ # R0913 Too many arguments # R0904 Too many public methods # E0211: Method has no argument -disable=C0103,C0111,I0011,I0012,W0704,W0142,W0212,W0232,W0613,W0702,R0201,W0614,R0914,R0912,R0915,R0913,R0904,R0801 +disable=C0103,C0111,I0011,W0212,W0613,W0702,W0614,R0914,R0912,R0915,R0913,R0904,R0801 [TYPECHECK] # Note: This modules are manipulated during the runtime so we can't detect all the properties during diff --git a/st2auth_flat_file_backend/flat_file.py b/st2auth_flat_file_backend/flat_file.py index e689f4b..fd70735 100644 --- a/st2auth_flat_file_backend/flat_file.py +++ b/st2auth_flat_file_backend/flat_file.py @@ -33,14 +33,12 @@ class HttpasswdFileWithComments(HtpasswdFile): """ def _load_lines(self, lines): - result = super(HttpasswdFileWithComments, self)._load_lines(lines=lines) + super(HttpasswdFileWithComments, self)._load_lines(lines=lines) # Filter out comments self._records.pop(COMMENT_MARKER, None) assert COMMENT_MARKER not in self._records - return result - def _parse_record(self, record, lineno): if record.startswith(b'#'): # Comment, add special marker so we can filter it out later From e00b400fc25a98d70f3ae6f3321802fbd77629ce Mon Sep 17 00:00:00 2001 From: Jacob Floyd Date: Sat, 19 Oct 2024 14:07:55 -0500 Subject: [PATCH 10/14] 0.3.0: Require python 3.8 or newer --- setup.py | 6 ++++-- st2auth_flat_file_backend/__init__.py | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index 02083c5..8781de0 100644 --- a/setup.py +++ b/setup.py @@ -46,12 +46,14 @@ 'License :: OSI Approved :: Apache Software License', 'Programming Language :: Python', 'Programming Language :: Python :: 3', - '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', 'Intended Audience :: Developers', 'Environment :: Console', ], + python_requires='>=3.8', platforms=['Any'], scripts=[], provides=['st2auth_flat_file_backend'], diff --git a/st2auth_flat_file_backend/__init__.py b/st2auth_flat_file_backend/__init__.py index 3cd2c6d..a71c03c 100644 --- a/st2auth_flat_file_backend/__init__.py +++ b/st2auth_flat_file_backend/__init__.py @@ -21,4 +21,4 @@ 'FlatFileAuthenticationBackend' ] -__version__ = '0.2.1' +__version__ = '0.3.0' From 1e8457aa356902055bc39fc5a61b7f134fa48eb7 Mon Sep 17 00:00:00 2001 From: Jacob Floyd Date: Sat, 19 Oct 2024 14:38:53 -0500 Subject: [PATCH 11/14] add merge ok to GHA workflow to simplify branch rules --- .github/workflows/tox.yaml | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tox.yaml b/.github/workflows/tox.yaml index 3f26e0b..37ab1c4 100644 --- a/.github/workflows/tox.yaml +++ b/.github/workflows/tox.yaml @@ -24,7 +24,7 @@ jobs: - name: Lint run: tox -e lint - build: + test: runs-on: ubuntu-latest strategy: matrix: @@ -47,3 +47,33 @@ jobs: - name: Test run: tox -e ${{ steps.tox-env.outputs.tox-env }} + + set_merge_ok: + name: Set Merge OK + if: always() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') + needs: + - lint + - test + outputs: + merge_ok: ${{ steps.set_merge_ok.outputs.merge_ok }} + runs-on: ubuntu-latest + steps: + - id: set_merge_ok + run: echo 'merge_ok=true' >> ${GITHUB_OUTPUT} + + merge_ok: + name: Merge OK + if: always() + needs: + - set_merge_ok + runs-on: ubuntu-latest + steps: + - run: | + merge_ok="${{ needs.set_merge_ok.outputs.merge_ok }}" + if [[ "${merge_ok}" == "true" ]]; then + echo "Merge OK" + exit 0 + else + echo "Merge NOT OK" + exit 1 + fi From b26edf2fad45422d45ac2a119be646b5ad423034 Mon Sep 17 00:00:00 2001 From: Jacob Floyd Date: Sat, 19 Oct 2024 16:07:39 -0500 Subject: [PATCH 12/14] remove dup tox.ini line --- tox.ini | 1 - 1 file changed, 1 deletion(-) diff --git a/tox.ini b/tox.ini index 4daf46c..5f0b133 100644 --- a/tox.ini +++ b/tox.ini @@ -21,6 +21,5 @@ basepython = python3.11 commands = pytest [testenv:lint] -deps = -r{toxinidir}/test-requirements.txt commands = flake8 --config ./lint-configs/python/.flake8 st2auth_flat_file_backend/ pylint -E --rcfile=./lint-configs/python/.pylintrc st2auth_flat_file_backend/ From 3657e95169f0b41f00161e5ee2c0149236f2e29c Mon Sep 17 00:00:00 2001 From: Jacob Floyd Date: Sat, 19 Oct 2024 20:24:15 -0500 Subject: [PATCH 13/14] simplify tox config --- tox.ini | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/tox.ini b/tox.ini index 5f0b133..cabb9b6 100644 --- a/tox.ini +++ b/tox.ini @@ -1,24 +1,21 @@ [tox] -envlist = py36,py38,py39,py310,py311,lint +envlist = py38,py39,py310,py311,lint [testenv] deps = -r{toxinidir}/test-requirements.txt +commands = pytest [testenv:py38] basepython = python3.8 -commands = pytest [testenv:py39] basepython = python3.9 -commands = pytest [testenv:py310] basepython = python3.10 -commands = pytest [testenv:py311] basepython = python3.11 -commands = pytest [testenv:lint] commands = flake8 --config ./lint-configs/python/.flake8 st2auth_flat_file_backend/ From 6d92a5a3b82333f1e7e6bdd104cba85f7fbebd83 Mon Sep 17 00:00:00 2001 From: Jacob Floyd Date: Sat, 19 Oct 2024 20:24:40 -0500 Subject: [PATCH 14/14] add license to setup.py --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index 8781de0..ec59996 100644 --- a/setup.py +++ b/setup.py @@ -40,6 +40,7 @@ author='StackStorm, Inc.', author_email='info@stackstorm.com', url='https://github.com/StackStorm/st2-auth-backend-flat-file', + license='Apache License (2.0)', download_url='https://github.com/StackStorm/st2-auth-backend-flat-file/tarball/master', classifiers=[ 'Development Status :: 3 - Alpha',