Skip to content

Commit

Permalink
Updates - black formatting, GH actions versions, tox 4 (mpdavis#313)
Browse files Browse the repository at this point in the history
* Update GH actions, upgrade to tox 4

* reformat with the new version of black

* Remove python 3.6

* More GHA updates

* remove quotes
  • Loading branch information
asherf authored May 3, 2023
1 parent 96474ec commit b26c724
Show file tree
Hide file tree
Showing 16 changed files with 33 additions and 87 deletions.
47 changes: 23 additions & 24 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,67 +12,66 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10", "pypy3"]
python-version: ["3.7", "3.8", "3.9", "3.10", "pypy3.9"]
os: [ubuntu-latest, macos-latest, windows-latest]
exclude:
- os: macos-latest
python-version: "pypy3"
python-version: "pypy3.9"
- os: windows-latest
python-version: "pypy3"
python-version: "pypy3.9"
runs-on: ${{ matrix.os }}
name: "${{ matrix.os }} Python: ${{ matrix.python-version }}"
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
pip install -U "pip>=21.1"
pip install -U setuptools
pip install -U "tox>=3.23.0,<4" codecov tox-gh-actions coverage
pip install -U "pip>=23.1.2"
pip install -U "tox-gh-actions==3.1.0" coverage
- name: Log python & pip versions
run: |
python --version
pip --version
- name: Run unit tests
run: tox
- name: "Coverage report"
- name: Coverage report
run: coverage xml
- name: "Upload coverage to Codecov"
uses: "codecov/codecov-action@v1"
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
fail_ci_if_error: true
linting:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: 3.8
python-version: 3.9
- name: Install dependencies
run: |
pip install -U setuptools
pip install -U "tox>=3.23.0,<4"
pip install -U "tox>=4.5.1,<5"
- run: tox -e lint
package:
name: "Build & verify package"
name: Build & verify package
runs-on: "ubuntu-latest"
steps:
- uses: "actions/checkout@v2"
- uses: "actions/setup-python@v2"
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.8"
- name: "Install build, check-wheel-content, and twine"
python-version: "3.9"
- name: Install build, check-wheel-content, and twine
run: "python -m pip install build twine check-wheel-contents"
- name: "Build package"
- name: Build package
run: "python -m build --sdist --wheel ."
- name: "List result"
- name: List result
run: "ls -l dist"
- name: "Check wheel contents"
- name: Check wheel contents
run: "check-wheel-contents dist/*.whl"
- name: "Check long_description"
- name: Check long_description
run: "python -m twine check dist/*"
9 changes: 6 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog #

## 3.4.0 -- UNPUBLISHED ##

### News ###

* Remove support for python 3.6

## 3.3.0 -- 2021-06-04 ##

### News ###
Expand All @@ -17,7 +23,6 @@
* Updated Syntax to use Python 3.6+
* Upgrade to latest pytest, remove used dev requirements.


## 3.2.0 -- 2020-07-29 ##

### News ###
Expand All @@ -39,8 +44,6 @@

* Fixed some typos #160, #162, and #164



## 3.1.0 -- 2019-12-10 ##

This is a greatly overdue release.
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
# All configuration values have a default; values that are commented out
# serve to show the default.

import sys
import os
import sys

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
Expand Down
1 change: 0 additions & 1 deletion jose/backends/rsa_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,6 @@ def public_key(self):
return self.__class__(pyrsa.PublicKey(n=self._prepared_key.n, e=self._prepared_key.e), self._algorithm)

def to_pem(self, pem_format="PKCS8"):

if isinstance(self._prepared_key, pyrsa.PrivateKey):
der = self._prepared_key.save_pkcs1(format="DER")
if pem_format == "PKCS8":
Expand Down
2 changes: 0 additions & 2 deletions jose/jws.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@ def _sig_matches_keys(keys, signing_input, signature, alg):


def _get_keys(key):

if isinstance(key, Key):
return (key,)

Expand Down Expand Up @@ -248,7 +247,6 @@ def _get_keys(key):


def _verify_signature(signing_input, header, signature, key="", algorithms=None):

alg = header.get("alg")
if not alg:
raise JWSError("No algorithm was specified in the JWS header.")
Expand Down
2 changes: 0 additions & 2 deletions jose/jwt.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ def encode(claims, key, algorithm=ALGORITHMS.HS256, headers=None, access_token=N
"""

for time_claim in ["exp", "iat", "nbf"]:

# Convert datetime to a intDate value in known time-format claims
if isinstance(claims.get(time_claim), datetime):
claims[time_claim] = timegm(claims[time_claim].utctimetuple())
Expand Down Expand Up @@ -456,7 +455,6 @@ def _validate_at_hash(claims, access_token, algorithm):


def _validate_claims(claims, audience=None, issuer=None, subject=None, algorithm=None, access_token=None, options=None):

leeway = options.get("leeway", 0)

if isinstance(leeway, timedelta):
Expand Down
1 change: 0 additions & 1 deletion jose/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
def long_to_bytes(n, blocksize=0):
return _long_to_bytes(n, blocksize or None)


except ImportError:
from ecdsa.ecdsa import int_to_string as _long_to_bytes

Expand Down
1 change: 0 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ classifiers =
Programming Language :: Python
Programming Language :: Python :: 3
Programming Language :: Python :: 3 :: Only
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Expand Down
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python
from setuptools import setup


setup()
1 change: 0 additions & 1 deletion tests/algorithms/test_RSA.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,6 @@ def test_python_rsa_legacy_private_key_pkcs8_to_pkcs1_invalid(self):
None in (default_backend, pyca_rsa, CryptographyRSAKey), reason="Cryptography backend not available"
)
def test_cryptography_RSA_key_instance():

key = pyca_rsa.RSAPublicNumbers(
int(65537),
int(
Expand Down
7 changes: 0 additions & 7 deletions tests/rfc/test_rfc7520.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from jose.backends import RSAKey
from jose.jws import verify


expected_payload = b"It\xe2\x80\x99s a dangerous business, Frodo, going out your door. You step onto the road, and if you don't keep your feet, there\xe2\x80\x99s no knowing where you might be swept off to."


Expand Down Expand Up @@ -39,31 +38,25 @@


class TestFourOneThree:

token = "eyJhbGciOiJSUzI1NiIsImtpZCI6ImJpbGJvLmJhZ2dpbnNAaG9iYml0b24uZXhhbXBsZSJ9.SXTigJlzIGEgZGFuZ2Vyb3VzIGJ1c2luZXNzLCBGcm9kbywgZ29pbmcgb3V0IHlvdXIgZG9vci4gWW91IHN0ZXAgb250byB0aGUgcm9hZCwgYW5kIGlmIHlvdSBkb24ndCBrZWVwIHlvdXIgZmVldCwgdGhlcmXigJlzIG5vIGtub3dpbmcgd2hlcmUgeW91IG1pZ2h0IGJlIHN3ZXB0IG9mZiB0by4.MRjdkly7_-oTPTS3AXP41iQIGKa80A0ZmTuV5MEaHoxnW2e5CZ5NlKtainoFmKZopdHM1O2U4mwzJdQx996ivp83xuglII7PNDi84wnB-BDkoBwA78185hX-Es4JIwmDLJK3lfWRa-XtL0RnltuYv746iYTh_qHRD68BNt1uSNCrUCTJDt5aAE6x8wW1Kt9eRo4QPocSadnHXFxnt8Is9UzpERV0ePPQdLuW3IS_de3xyIrDaLGdjluPxUAhb6L2aXic1U12podGU0KLUQSE_oI-ZnmKJ3F4uOZDnd6QZWJushZ41Axf_fcIe8u9ipH84ogoree7vjbU5y18kDquDg"

@pytest.mark.skipif(RSAKey is None, reason="RSA is not available")
def test_signature(self):

payload = verify(self.token, rsa_public_jwk, "RS256")
assert payload == expected_payload


class TestFourThreeThree:

token = "eyJhbGciOiJFUzUxMiIsImtpZCI6ImJpbGJvLmJhZ2dpbnNAaG9iYml0b24uZXhhbXBsZSJ9.SXTigJlzIGEgZGFuZ2Vyb3VzIGJ1c2luZXNzLCBGcm9kbywgZ29pbmcgb3V0IHlvdXIgZG9vci4gWW91IHN0ZXAgb250byB0aGUgcm9hZCwgYW5kIGlmIHlvdSBkb24ndCBrZWVwIHlvdXIgZmVldCwgdGhlcmXigJlzIG5vIGtub3dpbmcgd2hlcmUgeW91IG1pZ2h0IGJlIHN3ZXB0IG9mZiB0by4.AE_R_YZCChjn4791jSQCrdPZCNYqHXCTZH0-JZGYNlaAjP2kqaluUIIUnC9qvbu9Plon7KRTzoNEuT4Va2cmL1eJAQy3mtPBu_u_sDDyYjnAMDxXPn7XrT0lw-kvAD890jl8e2puQens_IEKBpHABlsbEPX6sFY8OcGDqoRuBomu9xQ2"

def test_signature(self):

payload = verify(self.token, ec_public_key, "ES512")
assert payload == expected_payload


class TestFourFourThree:

token = "eyJhbGciOiJIUzI1NiIsImtpZCI6IjAxOGMwYWU1LTRkOWItNDcxYi1iZmQ2LWVlZjMxNGJjNzAzNyJ9.SXTigJlzIGEgZGFuZ2Vyb3VzIGJ1c2luZXNzLCBGcm9kbywgZ29pbmcgb3V0IHlvdXIgZG9vci4gWW91IHN0ZXAgb250byB0aGUgcm9hZCwgYW5kIGlmIHlvdSBkb24ndCBrZWVwIHlvdXIgZmVldCwgdGhlcmXigJlzIG5vIGtub3dpbmcgd2hlcmUgeW91IG1pZ2h0IGJlIHN3ZXB0IG9mZiB0by4.s0h6KThzkfBBBkLspW1h84VsJZFTsPPqMDA7g1Md7p0"

def test_signature(self):

payload = verify(self.token, hmac_key, "HS256")
assert payload == expected_payload
1 change: 0 additions & 1 deletion tests/test_jwe.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ def test_wrong_auth_tag_is_ignored(self):
@pytest.mark.skipif(AESKey is None, reason="Test requires AES Backend")
@pytest.mark.skipif(RSAKey is RSABackendRSAKey, reason="RSA Backend does not support all modes")
class TestDecrypt:

JWE_RSA_PACKAGES = (
pytest.param(
b"eyJhbGciOiJSU0ExXzUiLCJlbmMiOiJBMTI4Q0JDLUhTMjU2In0.qHxZy-MfqRjCDAieY5AoU75XRGS7S-Xx4NytHgNa5dmGh9R8q1riHyPw5Hec_D395fKqV75u1hKke5r-jgiDTaCicQjOuxM2cSaiFlUid7dk5zIucaKH84N8jMzq3PwBePmGftePM2NMCzs6RvWBFP5SnDHh95NU2Xd-rIUICA7zIBXTwNRsB2LM9c_TZv1qh59DYoiSHWy94WXJBNFqViuVLmjVz5250J6Q4uRiYKGJKEGkfLDUp18N97aw5RQ35jJF6QyO5JkeLFTA0L10QAEtM8RjBRrKYgJ6fJLCVbHHTf7EKdn6Z-4cIZKtYe2d7PPKa0ZWZvtYTuU1S6DgmA.gdSr6lSIci4GjzMsdLaK6g.4ynh6gGG4dzxpmNfZHo6o8Eqp1eXRhKzI2Tmde-IulU.cFUhLtodRUqZ1GfSO6e3pw",
Expand Down
5 changes: 0 additions & 5 deletions tests/test_jwk.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@

class TestJWK:
def test_interface(self):

key = jwk.Key("key", "ALG")

with pytest.raises(NotImplementedError):
Expand All @@ -55,7 +54,6 @@ def test_invalid_hash_alg(self):

@pytest.mark.skipif(RSAKey is None, reason="RSA is not available")
def test_invalid_jwk(self):

with pytest.raises(JWKError):
key = HMACKey(rsa_key, "HS256")

Expand All @@ -67,7 +65,6 @@ def test_invalid_jwk(self):

@pytest.mark.skipif(RSAKey is None, reason="RSA is not available")
def test_RSAKey_errors(self):

rsa_key = {
"kty": "RSA",
"kid": "[email protected]",
Expand All @@ -91,7 +88,6 @@ def test_RSAKey_errors(self):
key = RSAKey(rsa_key, "RS256") # noqa: F841

def test_construct_from_jwk(self):

hmac_key = {
"kty": "oct",
"kid": "018c0ae5-4d9b-471b-bfd6-eef314bc7037",
Expand All @@ -108,7 +104,6 @@ def test_construct_EC_from_jwk(self):
assert isinstance(key, jwk.Key)

def test_construct_from_jwk_missing_alg(self):

hmac_key = {
"kty": "oct",
"kid": "018c0ae5-4d9b-471b-bfd6-eef314bc7037",
Expand Down
1 change: 0 additions & 1 deletion tests/test_jws.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ def test_unsupported_alg(self, payload):
jws.sign(payload, "secret", algorithm="SOMETHING")

def test_add_headers(self, payload):

additional_headers = {"test": "header"}

expected_headers = {
Expand Down
Loading

0 comments on commit b26c724

Please sign in to comment.