diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4e8ea27d..f77b40a8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -64,6 +64,21 @@ test-3.8-core: reports: cobertura: coverage.xml +test-3.9-core: + image: python:3.9-buster + script: + - tox -e py39-core + before_script: + - apt-get update && apt-get install redis-server -y + - redis-server --daemonize yes + - redis-cli ping + - python -V + - pip install wheel tox + artifacts: + when: always + reports: + cobertura: coverage.xml + test-3.6-all: image: python:3.6-buster script: @@ -109,9 +124,24 @@ test-3.8-all: reports: cobertura: coverage.xml +test-3.9-all: + image: python:3.9-buster + script: + - tox -e py39-all + before_script: + - apt-get update && apt-get install redis-server -y + - redis-server --daemonize yes + - redis-cli ping + - python -V + - pip install wheel tox + artifacts: + when: always + reports: + cobertura: coverage.xml + deploy_production: stage: deploy - image: python:3.8-buster + image: python:3.9-buster before_script: - pip install twine wheel diff --git a/allianceauth/services/modules/discourse/views.py b/allianceauth/services/modules/discourse/views.py index ed634975..ba822a2a 100644 --- a/allianceauth/services/modules/discourse/views.py +++ b/allianceauth/services/modules/discourse/views.py @@ -12,20 +12,12 @@ import base64 import hmac import hashlib -try: - from urllib import unquote, urlencode -except ImportError: #py3 - from urllib.parse import unquote, urlencode -try: - from urlparse import parse_qs -except ImportError: #py3 - from urllib.parse import parse_qs +from urllib.parse import unquote, urlencode, parse_qs import logging logger = logging.getLogger(__name__) - ACCESS_PERM = 'discourse.access_discourse' @@ -55,7 +47,7 @@ def discourse_sso(request): # Validate the payload try: payload = unquote(payload).encode('utf-8') - decoded = base64.decodestring(payload).decode('utf-8') + decoded = base64.decodebytes(payload).decode('utf-8') assert 'nonce' in decoded assert len(payload) > 0 except AssertionError: @@ -86,7 +78,7 @@ def discourse_sso(request): if main_char: params['avatar_url'] = main_char.portrait_url(256) - return_payload = base64.encodestring(urlencode(params).encode('utf-8')) + return_payload = base64.encodebytes(urlencode(params).encode('utf-8')) h = hmac.new(key, return_payload, digestmod=hashlib.sha256) query_string = urlencode({'sso': return_payload, 'sig': h.hexdigest()}) diff --git a/setup.py b/setup.py index a44aeb8e..dc3bc53d 100644 --- a/setup.py +++ b/setup.py @@ -76,10 +76,11 @@ setup( 'License :: OSI Approved :: GNU General Public License v2 (GPLv2)', 'Operating System :: POSIX :: Linux', 'Programming Language :: Python', - 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', 'Topic :: Internet :: WWW/HTTP', 'Topic :: Internet :: WWW/HTTP :: Dynamic Content', ], diff --git a/tox.ini b/tox.ini index 4b87addc..8d5f6355 100644 --- a/tox.ini +++ b/tox.ini @@ -1,7 +1,7 @@ [tox] skipsdist = true usedevelop = true -envlist = py{36,37,38}-{all} +envlist = py{36,37,38,39}-{all} [testenv] setenv = @@ -11,6 +11,7 @@ basepython = py36: python3.6 py37: python3.7 py38: python3.8 + py39: python3.9 deps= coverage install_command = pip install -e ".[testing]" -U {opts} {packages}