Skip to content

Commit 4a60521

Browse files
authored
0.4.0: Bump python support (#21)
2 parents 5cd8c9f + cd343f4 commit 4a60521

File tree

13 files changed

+121
-95
lines changed

13 files changed

+121
-95
lines changed

.github/workflows/tox.yaml

+82
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: Tox CI
2+
3+
on:
4+
push:
5+
branches: [ "master" ]
6+
pull_request:
7+
branches: [ "master" ]
8+
9+
jobs:
10+
lint:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout repo
14+
uses: actions/checkout@v4
15+
16+
- name: Setup Python
17+
uses: actions/setup-python@v5
18+
with:
19+
python-version: "3.8"
20+
21+
- name: Install tox
22+
run: pip install --user tox
23+
24+
- name: Lint
25+
run: tox -e lint
26+
27+
test:
28+
runs-on: ubuntu-latest
29+
strategy:
30+
matrix:
31+
python-version: ["3.8", "3.9", "3.10", "3.11"]
32+
steps:
33+
- name: Checkout repo
34+
uses: actions/checkout@v4
35+
36+
- name: Setup Python
37+
uses: actions/setup-python@v5
38+
with:
39+
python-version: ${{ matrix.python-version }}
40+
41+
- name: Install tox
42+
run: pip install --user tox
43+
44+
- name: Select tox env
45+
id: tox-env
46+
run: echo tox-env=py${{ matrix.python-version }} | tr -d '.' >> ${GITHUB_OUTPUT}
47+
48+
- name: Prepare Integration
49+
run: sudo -E ./scripts/prepare-integration.sh
50+
51+
- name: Test
52+
run: sudo -E -- $(which tox) -e ${{ steps.tox-env.outputs.tox-env }}
53+
54+
set_merge_ok:
55+
name: Set Merge OK
56+
if: always() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled')
57+
needs:
58+
- lint
59+
- test
60+
outputs:
61+
merge_ok: ${{ steps.set_merge_ok.outputs.merge_ok }}
62+
runs-on: ubuntu-latest
63+
steps:
64+
- id: set_merge_ok
65+
run: echo 'merge_ok=true' >> ${GITHUB_OUTPUT}
66+
67+
merge_ok:
68+
name: Merge OK
69+
if: always()
70+
needs:
71+
- set_merge_ok
72+
runs-on: ubuntu-latest
73+
steps:
74+
- run: |
75+
merge_ok="${{ needs.set_merge_ok.outputs.merge_ok }}"
76+
if [[ "${merge_ok}" == "true" ]]; then
77+
echo "Merge OK"
78+
exit 0
79+
else
80+
echo "Merge NOT OK"
81+
exit 1
82+
fi

.travis.yml

-27
This file was deleted.

README.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
# PAM authentication plugin for StackStorm Community and Enterprise edition
2-
3-
[![Build Status](https://travis-ci.org/StackStorm/st2-auth-backend-pam.svg?branch=master)](https://travis-ci.org/StackStorm/st2-auth-backend-pam) [![IRC](https://img.shields.io/irc/%23stackstorm.png)](http://webchat.freenode.net/?channels=stackstorm)
1+
# PAM authentication plugin for StackStorm
42

53
PAM authentication backend allows users to authenticate against the PAM (Pluggable Authentication
64
Modules) on the system where ``st2auth`` service is running.

lint-configs/python/.pylintrc

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,17 @@
11
[MESSAGES CONTROL]
22
# C0111 Missing docstring
33
# I0011 Warning locally suppressed using disable-msg
4-
# I0012 Warning locally suppressed using disable-msg
5-
# W0704 Except doesn't do anything Used when an except clause does nothing but "pass" and there is no "else" clause
6-
# W0142 Used * or * magic* Used when a function or method is called using *args or **kwargs to dispatch arguments.
74
# W0212 Access to a protected member %s of a client class
8-
# W0232 Class has no __init__ method Used when a class has no __init__ method, neither its parent classes.
95
# W0613 Unused argument %r Used when a function or method argument is not used.
106
# W0702 No exception's type specified Used when an except clause doesn't specify exceptions type to catch.
11-
# R0201 Method could be a function
127
# W0614 Unused import XYZ from wildcard import
138
# R0914 Too many local variables
149
# R0912 Too many branches
1510
# R0915 Too many statements
1611
# R0913 Too many arguments
1712
# R0904 Too many public methods
1813
# E0211: Method has no argument
19-
disable=C0103,C0111,I0011,I0012,W0704,W0142,W0212,W0232,W0613,W0702,R0201,W0614,R0914,R0912,R0915,R0913,R0904,R0801
14+
disable=C0103,C0111,I0011,W0212,W0613,W0702,W0614,R0914,R0912,R0915,R0913,R0904,R0801
2015

2116
[TYPECHECK]
2217
# Note: This modules are manipulated during the runtime so we can't detect all the properties during

requirements.txt

-1
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
six

scripts/travis/prepare-integration.sh scripts/prepare-integration.sh

+3-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ create_user() {
2121
}
2222

2323
# mkpasswd requires whois package
24-
apt-get update
25-
apt-get install -y whois
24+
apt-get install -y whois pamtester
2625

2726
create_user
27+
28+
echo ${TESTPASSWD} | pamtester -v login ${TESTUSER} authenticate

scripts/travis/build.sh

-22
This file was deleted.

setup.py

+9-3
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,15 @@
2727
version = parse_version_string(INIT_FILE)
2828
install_reqs, dep_links = fetch_requirements(REQUIREMENTS_FILE)
2929

30+
with open("README.md", "r") as fh:
31+
long_description = fh.read()
32+
3033
setup(
3134
name='st2-auth-backend-pam',
3235
version=version,
3336
description='PAM authentication plugin for StackStorm.',
37+
long_description=long_description,
38+
long_description_content_type="text/markdown",
3439
author='StackStorm, Inc.',
3540
author_email='[email protected]',
3641
url='https://github.com/StackStorm/st2-auth-backend-pam',
@@ -43,20 +48,21 @@
4348
'License :: OSI Approved :: Apache Software License',
4449
'Programming Language :: Python',
4550
'Programming Language :: Python :: 3',
46-
'Programming Language :: Python :: 3.6',
47-
'Programming Language :: Python :: 3.7',
4851
'Programming Language :: Python :: 3.8',
52+
'Programming Language :: Python :: 3.9',
53+
'Programming Language :: Python :: 3.10',
54+
'Programming Language :: Python :: 3.11',
4955
'Intended Audience :: Developers',
5056
'Environment :: Console',
5157
],
58+
python_requires='>=3.8',
5259
platforms=['Any'],
5360
scripts=[],
5461
provides=['st2auth_pam_backend'],
5562
packages=find_packages(),
5663
include_package_data=True,
5764
install_requires=install_reqs,
5865
dependency_links=dep_links,
59-
test_suite='tests',
6066
entry_points={
6167
'st2auth.backends.backend': [
6268
'pam = st2auth_pam_backend.pam_backend:PAMAuthenticationBackend',

st2auth_pam_backend/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@
2121
'PAMAuthenticationBackend'
2222
]
2323

24-
__version__ = '0.3.0'
24+
__version__ = '0.4.0'

st2auth_pam_backend/pam_ffi.py

-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@
2525
from ctypes import memmove
2626
from ctypes.util import find_library
2727

28-
from six.moves import range # pylint: disable=import-error,redefined-builtin
29-
3028
LIBPAM = CDLL(find_library('pam'))
3129
LIBC = CDLL(find_library('c'))
3230

test-requirements.txt

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
mock==3.0.5 ; python_version == '2.7'
2-
mock==4.0.3 ; python_version >= '3.6'
3-
nose>=1.3.7
1+
flake8==7.0.0
2+
mock==5.1.0
43
pep8==1.7.1
5-
pylint<2 ; python_version == '2.7'
6-
pylint==2.8.2 ; python_version >= '3.6'
7-
st2flake8==0.1.0
8-
unittest2
4+
pylint~=3.1.0
5+
pytest
6+
st2flake8

tests/integration/test_authenticate.py

+7-9
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,19 @@
1414
# limitations under the License.
1515

1616
import mock
17-
import unittest2
17+
import unittest
1818

1919
from st2auth_pam_backend import pam_backend
2020

2121

22-
class PAMBackendAuthenticationTest(unittest2.TestCase):
22+
class PAMBackendAuthenticationTest(unittest.TestCase):
2323
@mock.patch('os.geteuid')
2424
def test_non_root_user(self, mock_get_euid):
2525
# non root
2626
mock_get_euid.return_value = 100
2727

2828
expected_msg = 'st2auth process needs to run as "root"'
29-
self.assertRaisesRegexp(ValueError, expected_msg,
29+
self.assertRaisesRegex(ValueError, expected_msg,
3030
pam_backend.PAMAuthenticationBackend)
3131

3232
# non root, but check for root is disabled
@@ -37,16 +37,14 @@ def test_non_root_user(self, mock_get_euid):
3737
mock_get_euid.return_value = 0
3838
pam_backend.PAMAuthenticationBackend()
3939

40-
# See scrips/travis/prepare-integration.sh for right username + password.
40+
# See scrips/prepare-integration.sh for right username + password.
4141
@mock.patch('os.geteuid', mock.Mock(return_value=0))
4242
def test_good_password(self):
4343
pam = pam_backend.PAMAuthenticationBackend()
44-
self.assertEqual(pam.authenticate('pammer', 'spammer'), True,
45-
'Valid credentials should return True.')
44+
assert pam.authenticate('pammer', 'spammer'), 'Valid credentials should return True.'
4645

47-
# See scrips/travis/prepare-integration.sh for right username + password.
46+
# See scrips/prepare-integration.sh for right username + password.
4847
@mock.patch('os.geteuid', mock.Mock(return_value=0))
4948
def test_bad_password(self):
5049
pam = pam_backend.PAMAuthenticationBackend()
51-
self.assertEqual(pam.authenticate('pammer', 'oumpalumpa'), False,
52-
'Invalid credentials should return False.')
50+
assert not pam.authenticate('pammer', 'oumpalumpa'), 'Invalid credentials should return False.'

tox.ini

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
[tox]
2-
envlist = py27,py36,py38,lint
2+
envlist = py38,py39,py310,py311,lint
33

44
[testenv]
5-
deps = -r{toxinidir}/requirements.txt
6-
-r{toxinidir}/test-requirements.txt
7-
8-
[testenv:py27]
9-
basepython = python2.7
10-
commands = python setup.py test
11-
12-
[testenv:py36]
13-
basepython = python3.6
14-
commands = python setup.py test
5+
deps = -r{toxinidir}/test-requirements.txt
6+
commands = pytest -l --log-level=DEBUG --color=yes --show-capture=all
157

168
[testenv:py38]
179
basepython = python3.8
18-
commands = python setup.py test
10+
11+
[testenv:py39]
12+
basepython = python3.9
13+
14+
[testenv:py310]
15+
basepython = python3.10
16+
17+
[testenv:py311]
18+
basepython = python3.11
1919

2020
[testenv:lint]
2121
commands = flake8 --config ./lint-configs/python/.flake8 st2auth_pam_backend/

0 commit comments

Comments
 (0)