Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0.3.0: Bump python support #8

Merged
merged 8 commits into from
Oct 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions .github/workflows/tox.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
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

test:
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 -d '.' >> ${GITHUB_OUTPUT}

- 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
14 changes: 0 additions & 14 deletions .travis.yml

This file was deleted.

7 changes: 1 addition & 6 deletions lint-configs/python/.pylintrc
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
[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
# R0915 Too many statements
# 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
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
six
requests
12 changes: 9 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,15 @@
version = parse_version_string(INIT_FILE)
install_reqs, dep_links = fetch_requirements(REQUIREMENTS_FILE)

with open("README.md", "r") as fh:
long_description = fh.read()

setup(
name='st2-auth-backend-keystone',
version=version,
description='StackStorm authentication backend which reads credentials from an OpenStack Keystone instance.',
long_description=long_description,
long_description_content_type="text/markdown",
author='StackStorm, Inc.',
author_email='info@stackstorm.com',
url='https://github.com/StackStorm/st2-auth-backend-keystone',
Expand All @@ -42,20 +47,21 @@
'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_keystone_backend'],
packages=find_packages(),
include_package_data=True,
install_requires=install_reqs,
dependency_links=dep_links,
test_suite='tests',
entry_points={
'st2auth.backends.backend': [
'keystone = st2auth_keystone_backend.keystone:KeystoneAuthenticationBackend',
Expand Down
4 changes: 2 additions & 2 deletions st2auth_keystone_backend/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from keystone import KeystoneAuthenticationBackend
from .keystone import KeystoneAuthenticationBackend

__all__ = [
'KeystoneAuthenticationBackend'
]

__version__ = '0.2.0'
__version__ = '0.3.0'
7 changes: 3 additions & 4 deletions st2auth_keystone_backend/keystone.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@
# limitations under the License.

import logging
import httplib
import http.client

import requests

from six.moves.urllib.parse import urlparse
from six.moves.urllib.parse import urljoin
from urllib.parse import urljoin, urlparse

__all__ = [
'KeystoneAuthenticationBackend'
Expand Down Expand Up @@ -66,7 +65,7 @@ def authenticate(self, username, password):
LOG.debug('Authentication for user "{}" failed: {}'.format(username, str(e)))
return False

if login.status_code in [httplib.OK, httplib.CREATED]:
if login.status_code in [http.client.OK, http.client.CREATED]:
LOG.debug('Authentication for user "{}" successful'.format(username))
return True
else:
Expand Down
10 changes: 5 additions & 5 deletions test-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
mock==3.0.5
nose>=1.3.7
flake8==7.0.0
mock==5.1.0
pep8==1.7.1
pylint==1.9.4
st2flake8==0.1.0
unittest2
pylint~=3.1.0
pytest
st2flake8
14 changes: 7 additions & 7 deletions tests/unit/test_keystone_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,21 @@
# limitations under the License.

import sys
import httplib
import http.client

import unittest2
import unittest
import mock
from requests.models import Response

from st2auth_keystone_backend.keystone import KeystoneAuthenticationBackend


class KeystoneAuthenticationBackendTestCase(unittest2.TestCase):
class KeystoneAuthenticationBackendTestCase(unittest.TestCase):
def _mock_keystone(self, *args, **kwargs):
return_codes = {
'goodv2': httplib.OK,
'goodv3': httplib.CREATED,
'bad': httplib.UNAUTHORIZED
'goodv2': http.client.OK,
'goodv3': http.client.CREATED,
'bad': http.client.UNAUTHORIZED
}
json = kwargs.get('json')
res = Response()
Expand Down Expand Up @@ -70,4 +70,4 @@ def test_get_v3_creds(self):
self.assertEqual('password', creds['auth']['identity']['password']['user']['password'])

if __name__ == '__main__':
sys.exit(unittest2.main())
sys.exit(unittest.main())
17 changes: 14 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
[tox]
envlist = py27,lint
envlist = py36,py38,py39,py310,py311,lint

[testenv]
deps = -r{toxinidir}/test-requirements.txt
commands = python setup.py test
commands = pytest

[testenv:py38]
basepython = python3.8

[testenv:py39]
basepython = python3.9

[testenv:py310]
basepython = python3.10

[testenv:py311]
basepython = python3.11

[testenv:lint]
deps = -r{toxinidir}/test-requirements.txt
commands = flake8 --config ./lint-configs/python/.flake8 st2auth_keystone_backend/
pylint -E --rcfile=./lint-configs/python/.pylintrc st2auth_keystone_backend/