Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package python-scitokens for 
openSUSE:Factory checked in at 2022-05-02 16:25:31
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-scitokens (Old)
 and      /work/SRC/openSUSE:Factory/.python-scitokens.new.1538 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python-scitokens"

Mon May  2 16:25:31 2022 rev:2 rq:974277 version:1.7.0

Changes:
--------
--- /work/SRC/openSUSE:Factory/python-scitokens/python-scitokens.changes        
2022-02-07 23:40:08.505602278 +0100
+++ 
/work/SRC/openSUSE:Factory/.python-scitokens.new.1538/python-scitokens.changes  
    2022-05-02 16:25:36.648840959 +0200
@@ -1,0 +2,32 @@
+Sun May  1 22:27:16 UTC 2022 - Atri Bhattacharya <[email protected]>
+
+- Update to version 1.7.0:
+  * Reference test files using relative paths
+    [gh#citokens/scitokens#128].
+  * Use shutil.move instead of os.rename
+    [gh#citokens/scitokens#136].
+  * Add error message for when SciToken.discover doesn't find a
+    token [gh#citokens/scitokens#138].
+  * SciToken.serialize: fix str/bytes mismatch
+    [gh#citokens/scitokens#137].
+  * Add rpmbuild github actions workflow
+    [gh#citokens/scitokens#134].
+  * Update the bogus url used in the tests
+    [gh#citokens/scitokens#140].
+  * Fix bug decoding a token with no audience
+    [gh#citokens/scitokens#141].
+  * Use unittest.mock to check UnableToCreateCache
+    [gh#citokens/scitokens#139].
+  * Add obsoletes for smoother Yum updates on EL7
+    [gh#citokens/scitokens#127].
+  * Update algorithm used to test UnsupportedKeyException
+    [gh#citokens/scitokens#142].
+  * Run test suite using pytest during rpmbuild
+    [gh#citokens/scitokens#135].
+  * Update pyjwt version in requirements.txt
+    [gh#citokens/scitokens#131].
+  * Typo fix in readme [gh#citokens/scitokens#144].
+  * Default cached public keys set to 4 days
+    [gh#citokens/scitokens#145].
+
+-------------------------------------------------------------------

Old:
----
  scitokens-1.6.2.tar.gz

New:
----
  scitokens-1.7.0.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ python-scitokens.spec ++++++
--- /var/tmp/diff_new_pack.udE8EE/_old  2022-05-02 16:25:37.184841555 +0200
+++ /var/tmp/diff_new_pack.udE8EE/_new  2022-05-02 16:25:37.192841564 +0200
@@ -21,12 +21,12 @@
 %{?!python_module:%define python_module() python-%{**} python3-%{**}}
 
 Name:           python-scitokens
-Version:        1.6.2
+Version:        1.7.0
 Release:        0
 Summary:        SciToken reference implementation library
 License:        Apache-2.0
 URL:            https://scitokens.org
-Source:         
https://github.com/scitokens/scitokens/archive/refs/tags/v1.6.2.tar.gz#/%{bname}-%{version}.tar.gz
+Source:         
https://github.com/scitokens/scitokens/archive/refs/tags/v%{version}.tar.gz#/%{bname}-%{version}.tar.gz
 BuildRequires:  %{python_module PyJWT}
 BuildRequires:  %{python_module pytest}
 BuildRequires:  %{python_module setuptools}

++++++ scitokens-1.6.2.tar.gz -> scitokens-1.7.0.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/scitokens-1.6.2/.github/workflows/packaging.yml 
new/scitokens-1.7.0/.github/workflows/packaging.yml
--- old/scitokens-1.6.2/.github/workflows/packaging.yml 1970-01-01 
01:00:00.000000000 +0100
+++ new/scitokens-1.7.0/.github/workflows/packaging.yml 2022-02-18 
19:56:16.000000000 +0100
@@ -0,0 +1,265 @@
+# ---------------------------
+#
+# Prepare distributions of this project
+# for various platforms
+#
+# ---------------------------
+
+name: Packaging
+
+on:
+  push:
+    branches:
+      - main
+      - master
+  pull_request:
+    branches:
+      - main
+      - master
+
+jobs:
+  tarball:
+    name: Tarball
+
+    runs-on: ubuntu-latest
+
+    steps:
+      - name: Get source code
+        uses: actions/checkout@v2
+
+      - name: Set up Python ${{ matrix.python-version }}
+        uses: actions/setup-python@v2
+        with:
+          python-version: '3.x'
+
+      - name: Install build requirements
+        run: python -m pip install build
+
+      - name: Create distributions
+        run: python -m build . --sdist --wheel --outdir .
+
+      - uses: actions/upload-artifact@v2
+        with:
+          name: tarball
+          path: scitokens-*.tar.*
+          if-no-files-found: error
+
+      - uses: actions/upload-artifact@v2
+        with:
+          name: wheel
+          path: scitokens*.whl
+          if-no-files-found: error
+
+  # -- RHEL -----------------
+
+  rhel-source:
+    name: ${{ matrix.name }} ${{ matrix.version }} source package
+    needs:
+      - tarball
+    strategy:
+      fail-fast: false
+      matrix:
+        include:
+          - dist: centos
+            name: CentOS
+            version: 7
+            container: centos:7
+          - dist: centos
+            name: CentOS
+            version: 8
+            container: quay.io/centos/centos:stream8
+          - dist: fedora
+            name: Fedora
+            version: latest
+            container: fedora:latest
+    runs-on: ubuntu-latest
+    container: ${{ matrix.container }}
+    env:
+      TARBALL: "scitokens-*.tar.*"
+    steps:
+      - name: Download tarball
+        uses: actions/download-artifact@v2
+        with:
+          name: tarball
+
+      - name: Configure DNF
+        if: matrix.dist == 'centos' && matrix.version < 8
+        run: ln -s /usr/bin/yum /usr/bin/dnf
+
+      - name: Configure EPEL
+        if: matrix.dist != 'fedora'
+        run: |
+          dnf -y install epel-release
+          dnf -y install epel-rpm-macros
+
+      - name: Configure rpmbuild
+        run: |
+          dnf -y install \
+              python-srpm-macros \
+              rpm-build \
+          ;
+
+      - name: Create source package
+        run: rpmbuild -ts --define "_srcrpmdir $(pwd)" ${TARBALL}
+
+      - name: Source package info
+        run: "rpm -qp *.src.rpm --info"
+
+      - uses: actions/upload-artifact@v2
+        with:
+          name: srpm-${{ matrix.dist }}-${{ matrix.version }}
+          path: "*.src.rpm"
+          if-no-files-found: error
+
+  rhel-binary:
+    name: ${{ matrix.name }} ${{ matrix.version }} binary package
+    needs:
+      - rhel-source
+    strategy:
+      fail-fast: false
+      matrix:
+        include:
+          - dist: centos
+            name: CentOS
+            version: 7
+            container: centos:7
+          - dist: centos
+            name: CentOS
+            version: 8
+            container: quay.io/centos/centos:stream8
+          - dist: fedora
+            name: Fedora
+            version: latest
+            container: fedora:latest
+    runs-on: ubuntu-latest
+    container: ${{ matrix.container }}
+    env:
+      SRPM: "python-scitokens-*.src.rpm"
+    steps:
+      - name: Download SRPM
+        uses: actions/download-artifact@v2
+        with:
+          name: srpm-${{ matrix.dist }}-${{ matrix.version }}
+
+      - name: Configure DNF
+        if: matrix.dist == 'centos' && matrix.version < 8
+        run: ln -s /usr/bin/yum /usr/bin/dnf
+
+      - name: Configure EPEL
+        if: matrix.dist != 'fedora'
+        run: |
+          dnf -y install epel-release
+          dnf -y install epel-rpm-macros
+
+      - name: Install build tools (yum)
+        if: matrix.dist == 'centos' && matrix.version < 8
+        run: |
+          dnf -y -q install \
+              rpm-build \
+              yum-utils \
+          ;
+
+      - name: Install build dependencies (yum)
+        if: matrix.dist == 'centos' && matrix.version < 8
+        run: yum-builddep -y ${SRPM}
+
+      - name: Install build tools (dnf)
+        if: matrix.dist != 'centos' || matrix.version > 7
+        run: |
+          dnf -y -q install \
+              rpm-build \
+              "dnf-command(builddep)" \
+          ;
+
+      - name: Install build dependencies (dnf)
+        if: matrix.dist != 'centos' || matrix.version > 7
+        run: dnf builddep -y ${SRPM}
+
+      - name: Build binary packages
+        run: |
+          rpmbuild --rebuild --define "_rpmdir $(pwd)" ${SRPM}
+          rm -f ${SRPM}
+          mv */*.rpm .
+
+      - name: Print package info
+        run: |
+          # print contents of packages
+          for rpmf in *.rpm; do
+              echo "===== ${rpmf}"
+              rpm -qp "${rpmf}" --info
+              echo "Files:"
+              rpm -qp "${rpmf}" --list
+              echo "Provides:"
+              rpm -qp "${rpmf}" --provides
+              echo "Requires:"
+              rpm -qp "${rpmf}" --requires
+          done
+
+      - uses: actions/upload-artifact@v2
+        with:
+          name: rpm-${{ matrix.dist }}-${{ matrix.version }}
+          path: "*.rpm"
+          if-no-files-found: error
+
+  rhel-install:
+    name: ${{ matrix.name }} ${{ matrix.version }} install test
+    needs:
+      - rhel-binary
+    strategy:
+      fail-fast: false
+      matrix:
+        include:
+          - dist: centos
+            name: CentOS
+            version: 7
+            container: centos:7
+            yum: true
+          - dist: centos
+            name: CentOS
+            version: 8
+            container: quay.io/centos/centos:stream8
+          - dist: fedora
+            name: Fedora
+            version: latest
+            container: fedora:latest
+    runs-on: ubuntu-latest
+    container: ${{ matrix.container }}
+    steps:
+      - name: Download RPMs
+        uses: actions/download-artifact@v2
+        with:
+          name: rpm-${{ matrix.dist }}-${{ matrix.version }}
+
+      - name: Configure DNF
+        if: matrix.dist == 'centos' && matrix.version < 8
+        run: ln -s /usr/bin/yum /usr/bin/dnf
+
+      - name: Configure EPEL
+        if: matrix.dist != 'fedora'
+        run: |
+          dnf -y install epel-release
+          dnf -y install epel-rpm-macros
+
+      - name: Install RPMs
+        run: dnf -y install *.rpm
+
+  lint-rhel:
+    name: Lint RPMs
+    runs-on: ubuntu-latest
+    container: quay.io/centos/centos:stream8
+    needs:
+      - rhel-binary
+    steps:
+      - name: Download RPM
+        uses: actions/download-artifact@v2
+        with:
+          name: rpm-centos-8
+
+      - name: Install rpmlint
+        run: |
+          dnf -y -q install \
+              rpmlint \
+          ;
+
+      - name: Lint
+        run: rpmlint --info *.rpm
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/scitokens-1.6.2/MANIFEST.in 
new/scitokens-1.7.0/MANIFEST.in
--- old/scitokens-1.6.2/MANIFEST.in     2021-11-04 19:40:16.000000000 +0100
+++ new/scitokens-1.7.0/MANIFEST.in     2022-02-18 19:56:16.000000000 +0100
@@ -1,2 +1,3 @@
 include LICENSE README.rst
+recursive-include configs *.spec
 recursive-include tests *.py *.pem *.ini
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/scitokens-1.6.2/README.rst 
new/scitokens-1.7.0/README.rst
--- old/scitokens-1.6.2/README.rst      2021-11-04 19:40:16.000000000 +0100
+++ new/scitokens-1.7.0/README.rst      2022-02-18 19:56:16.000000000 +0100
@@ -103,7 +103,7 @@
 -----------------
 
 In SciTokens, we try to distinguish between *validating* and *verifying*
-tokings. Here, verification refers to determining the integrity and
+tokens. Here, verification refers to determining the integrity and
 authenticity of the token: can we validate the token came from a known
 source without tampering? Can we validate the chain of trust? Validation
 is determining whether the claims of the token are satisfied in a given
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/scitokens-1.6.2/configs/python-scitokens.spec 
new/scitokens-1.7.0/configs/python-scitokens.spec
--- old/scitokens-1.6.2/configs/python-scitokens.spec   2021-11-04 
19:40:16.000000000 +0100
+++ new/scitokens-1.7.0/configs/python-scitokens.spec   2022-02-18 
19:56:16.000000000 +0100
@@ -10,10 +10,15 @@
 URL:            https://scitokens.org
 Source0:        
https://files.pythonhosted.org/packages/source/s/%{pypi_name}/%{pypi_name}-%{version}.tar.gz
 BuildArch:      noarch
- 
+
+# build requirements
 BuildRequires:  python3-devel
 BuildRequires:  python%{python3_pkgversion}-setuptools
 
+# test requirements
+BuildRequires:  python%{python3_pkgversion}-cryptography
+BuildRequires:  python%{python3_pkgversion}-pytest
+BuildRequires:  python%{python3_pkgversion}-jwt >= 1.6.1
 
 %description
 SciToken reference implementation library
@@ -21,6 +26,7 @@
 %package -n     python%{python3_pkgversion}-%{pypi_name}
 Requires:       python%{python3_pkgversion}-jwt >= 1.6.1
 Requires:       python%{python3_pkgversion}-cryptography
+Obsoletes:      python3-scitokens < 1.6.2-2
 Summary:        %{summary}
 %{?python_provide:%python_provide python%{python3_pkgversion}-%{pypi_name}}
 
@@ -40,10 +46,14 @@
 # overwritten with every setup.py install.
 %py3_install
 
+%check
+export PYTHONPATH="%{buildroot}%{python3_sitelib}"
+(cd tests/ && %{__python3} -m pytest --verbose -ra .)
+
 %files -n python%{python3_pkgversion}-%{pypi_name}
 %license LICENSE
 %{python3_sitelib}/%{pypi_name}
-%{python3_sitelib}/%{pypi_name}-%{version}-py?.?.egg-info
+%{python3_sitelib}/%{pypi_name}-%{version}-py*.egg-info
 %doc README.rst
 %{_bindir}/scitokens-admin-create-key
 %{_bindir}/scitokens-admin-create-token
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/scitokens-1.6.2/requirements.txt 
new/scitokens-1.7.0/requirements.txt
--- old/scitokens-1.6.2/requirements.txt        2021-11-04 19:40:16.000000000 
+0100
+++ new/scitokens-1.7.0/requirements.txt        2022-02-18 19:56:16.000000000 
+0100
@@ -1,3 +1,3 @@
 cryptography
-PyJWT>=2.0.0
+PyJWT>=1.6.1
 six
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/scitokens-1.6.2/src/scitokens/__init__.py 
new/scitokens-1.7.0/src/scitokens/__init__.py
--- old/scitokens-1.6.2/src/scitokens/__init__.py       2021-11-04 
19:40:16.000000000 +0100
+++ new/scitokens-1.7.0/src/scitokens/__init__.py       2022-02-18 
19:56:16.000000000 +0100
@@ -6,4 +6,4 @@
 from .scitokens import SciToken, Validator, Enforcer, MissingClaims
 from .utils.config import set_config
 
-__version__ = "1.6.2"
+__version__ = "1.7.0"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/scitokens-1.6.2/src/scitokens/scitokens.py 
new/scitokens-1.7.0/src/scitokens/scitokens.py
--- old/scitokens-1.6.2/src/scitokens/scitokens.py      2021-11-04 
19:40:16.000000000 +0100
+++ new/scitokens-1.7.0/src/scitokens/scitokens.py      2022-02-18 
19:56:16.000000000 +0100
@@ -123,7 +123,7 @@
         :param str issuer: A string indicating the issuer for the token.  It 
should be an HTTPS address,
                            as specified in 
https://tools.ietf.org/html/draft-ietf-oauth-discovery-07
         :param int lifetime: Number of seconds that the token should be valid
-        :return str: base64 encoded token
+        :return bytes: base64 encoded token
         """
 
         if include_key is not False:
@@ -164,6 +164,8 @@
             encoded = jwt.encode(payload, self._key, algorithm = 
self._key_alg, headers={'kid': self._key_id})
         else:
             encoded = jwt.encode(payload, self._key, algorithm = self._key_alg)
+        if isinstance(encoded, bytes):  # pyjwt < 2 returns bytes
+            encoded = encoded.decode("utf-8")
         self._serialized_token = encoded
 
         # Move claims over to verified claims
@@ -175,9 +177,7 @@
 
         # Encode the returned string for backwards compatibility.
         # Previous versions of PyJWT returned bytes
-        if not isinstance(encoded, bytes):
-            encoded = str.encode(encoded)
-        return encoded
+        return str.encode(encoded, encoding="utf-8")
 
     def update_claims(self, claims):
         """
@@ -287,6 +287,7 @@
 
         unverified_headers = jwt.get_unverified_header(serialized_jwt)
         unverified_payload = jwt.decode(serialized_jwt, algorithms=['RS256', 
'ES256'],
+                                        audience=audience,
                                         options={"verify_signature": False})
         
         # Get the public key from the issuer
@@ -347,7 +348,9 @@
                 return SciToken.deserialize(token_data,
                                             audience, require_key, insecure, 
public_key)
 
-        raise IOError
+        raise OSError(
+            "failed to identify a valid bearer token",
+        )
 
 
 class ValidationFailure(Exception):
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/scitokens-1.6.2/src/scitokens/utils/config.py 
new/scitokens-1.7.0/src/scitokens/utils/config.py
--- old/scitokens-1.6.2/src/scitokens/utils/config.py   2021-11-04 
19:40:16.000000000 +0100
+++ new/scitokens-1.7.0/src/scitokens/utils/config.py   2022-02-18 
19:56:16.000000000 +0100
@@ -10,10 +10,11 @@
 import logging
 import logging.handlers
 
+# Set the default cache lifetime fo 4 days
 CONFIG_DEFAULTS = {
     'log_file': "",
     'log_level': "INFO",
-    'cache_lifetime': "3600",
+    'cache_lifetime': "345600",
     'cache_location': "",
     'default_alg': "RS256"
 }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/scitokens-1.6.2/tests/test_admin_create_key.py 
new/scitokens-1.7.0/tests/test_admin_create_key.py
--- old/scitokens-1.6.2/tests/test_admin_create_key.py  2021-11-04 
19:40:16.000000000 +0100
+++ new/scitokens-1.7.0/tests/test_admin_create_key.py  2022-02-18 
19:56:16.000000000 +0100
@@ -5,6 +5,7 @@
 import os
 import sys
 import unittest
+from pathlib import Path
 
 # Codacy has issues with subprocess, but this is only in the tests!
 import subprocess # nosec
@@ -22,6 +23,9 @@
 
 from scitokens.utils import long_from_bytes
 
+TESTS_DIR = Path(__file__).parent
+
+
 class TestKeyCreate(unittest.TestCase):
     """
     Test the admin-create-key tool
@@ -186,25 +190,41 @@
         """
         Test reading in the private key
         """
-        command = "{} {} --private-key=tests/simple_private_key.pem 
--pem-private".format(sys.executable, self.tool)
+        command = "{} {} --private-key={}/simple_private_key.pem 
--pem-private".format(
+            sys.executable,
+            self.tool,
+            TESTS_DIR,
+        )
         output = self._run_command(command)
         private_key = self._test_private(output)
         self.assertIsNotNone(private_key)
 
         # Test public key
-        command = "{} {} --private-key=tests/simple_private_key.pem 
--pem-public".format(sys.executable, self.tool)
+        command = "{} {} --private-key={}/simple_private_key.pem 
--pem-public".format(
+            sys.executable,
+            self.tool,
+            TESTS_DIR,
+        )
         output = self._run_command(command)
         public_key = self._test_public(output)
         self.assertIsNotNone(public_key)
 
         # Test public key
-        command = "{} {} --private-key=tests/simple_private_key.pem 
--jwks-private".format(sys.executable, self.tool)
+        command = "{} {} --private-key={}/simple_private_key.pem 
--jwks-private".format(
+            sys.executable,
+            self.tool,
+            TESTS_DIR,
+        )
         output = self._run_command(command)
         private_key = self._test_private_jwk(output)
         self.assertIsNotNone(public_key)
 
         # Test public key
-        command = "{} {} --private-key=tests/simple_private_key.pem 
--jwks-public".format(sys.executable, self.tool)
+        command = "{} {} --private-key={}/simple_private_key.pem 
--jwks-public".format(
+            sys.executable,
+            self.tool,
+            TESTS_DIR,
+        )
         output = self._run_command(command)
         public_key = self._test_public_jwk(output)
         self.assertIsNotNone(public_key)
@@ -213,25 +233,41 @@
         """
         Test reading in the private key
         """
-        command = "{} {} --ec --private-key=tests/simple_ec_private_key.pem 
--pem-private".format(sys.executable, self.tool)
+        command = "{} {} --ec --private-key={}/simple_ec_private_key.pem 
--pem-private".format(
+            sys.executable,
+            self.tool,
+            TESTS_DIR,
+        )
         output = self._run_command(command)
         private_key = self._test_private(output)
         self.assertIsNotNone(private_key)
 
         # Test public key
-        command = "{} {} --ec --private-key=tests/simple_ec_private_key.pem 
--pem-public".format(sys.executable, self.tool)
+        command = "{} {} --ec --private-key={}/simple_ec_private_key.pem 
--pem-public".format(
+            sys.executable,
+            self.tool,
+            TESTS_DIR,
+        )
         output = self._run_command(command)
         public_key = self._test_public(output)
         self.assertIsNotNone(public_key)
 
         # Test public key
-        command = "{} {} --ec --private-key=tests/simple_ec_private_key.pem 
--jwks-private".format(sys.executable, self.tool)
+        command = "{} {} --ec --private-key={}/simple_ec_private_key.pem 
--jwks-private".format(
+            sys.executable,
+            self.tool,
+            TESTS_DIR,
+        )
         output = self._run_command(command)
         private_key = self._test_ec_private_jwk(output)
         self.assertIsNotNone(public_key)
 
         # Test public key
-        command = "{} {} --ec --private-key=tests/simple_ec_private_key.pem 
--jwks-public".format(sys.executable, self.tool)
+        command = "{} {} --ec --private-key={}/simple_ec_private_key.pem 
--jwks-public".format(
+            sys.executable,
+            self.tool,
+            TESTS_DIR,
+        )
         output = self._run_command(command)
         public_key = self._test_ec_public_jwk(output)
         self.assertIsNotNone(public_key)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/scitokens-1.6.2/tests/test_create_scitoken.py 
new/scitokens-1.7.0/tests/test_create_scitoken.py
--- old/scitokens-1.6.2/tests/test_create_scitoken.py   2021-11-04 
19:40:16.000000000 +0100
+++ new/scitokens-1.7.0/tests/test_create_scitoken.py   2022-02-18 
19:56:16.000000000 +0100
@@ -288,7 +288,7 @@
 
         # Test when we give an unsupported algorithm
         unsupported_private_key = ec.generate_private_key(
-            ec.SECP192R1(), default_backend()
+            ec.SECP521R1(), default_backend()
         )
         with self.assertRaises(scitokens.scitokens.UnsupportedKeyException):
             token = scitokens.SciToken(key = unsupported_private_key)
@@ -324,7 +324,7 @@
         (bt_fd, bt_tmp) = tempfile.mkstemp()
         os.close(bt_fd)
         if os.path.isfile(bt_path):
-            os.rename(bt_path, bt_tmp)
+            shutil.move(bt_path, bt_tmp)
 
         # check that the function fails properly
         with self.assertRaises(IOError):
@@ -399,7 +399,7 @@
         os.remove(bearer_token_file)
         os.remove(bt_path)
         if os.path.isfile(bt_tmp):
-            os.rename(bt_tmp, bt_path)
+            shutil.move(bt_tmp, bt_path)
 
 
 if __name__ == '__main__':
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/scitokens-1.6.2/tests/test_keycache.py 
new/scitokens-1.7.0/tests/test_keycache.py
--- old/scitokens-1.6.2/tests/test_keycache.py  2021-11-04 19:40:16.000000000 
+0100
+++ new/scitokens-1.7.0/tests/test_keycache.py  2022-02-18 19:56:16.000000000 
+0100
@@ -6,6 +6,7 @@
 import tempfile
 import shutil
 import unittest
+from unittest import mock
 from scitokens.utils.keycache import KeyCache
 from scitokens.utils.errors import UnableToCreateCache
 from cryptography.hazmat.primitives.asymmetric.rsa import generate_private_key
@@ -46,16 +47,12 @@
         if self.old_xdg:
             os.environ['XDG_CACHE_HOME'] = self.old_xdg
 
-    @unittest.skipIf(
-        os.name == "nt",
-        "makedirs('/does/not/exists') dosen't fail on windows",
-    )
-    def test_cannot_make_cache(self):
+    @mock.patch("os.makedirs", side_effect=OSError)
+    @mock.patch.dict("os.environ")
+    def test_cannot_make_cache(self, _):
         """
         Test when the keycache shouldn't be able to make the cache
         """
-        # A directory that shouldn't exist
-        old_xdg = os.environ.get('XDG_CACHE_HOME', None)
         os.environ['XDG_CACHE_HOME'] = "/does/not/exists"
 
         # Make sure it raises an unable to create cache exception
@@ -63,9 +60,6 @@
             keycache = KeyCache()
             del keycache
 
-        if old_xdg:
-            os.environ['XDG_CACHE_HOME'] = old_xdg
-
     def test_empty(self):
         """
         Test when the keycache should be empty
@@ -116,10 +110,10 @@
             format=serialization.PublicFormat.SubjectPublicKeyInfo
         )
 
-        self.keycache.addkeyinfo("https://doesnotexists.com/";, "blahstuff", 
public_key, cache_timer=60)
+        self.keycache.addkeyinfo("https://doesnotexists.edu/";, "blahstuff", 
public_key, cache_timer=60)
 
         # Now extract the just inserted key
-        pubkey = self.keycache.getkeyinfo("https://doesnotexists.com/";, 
"blahstuff")
+        pubkey = self.keycache.getkeyinfo("https://doesnotexists.edu/";, 
"blahstuff")
 
         public_pem2 = pubkey.public_bytes(
             encoding=serialization.Encoding.PEM,
@@ -130,7 +124,7 @@
 
         # Make sure it errors with urlerror when it should not exist
         with self.assertRaises(URLError):
-            self.keycache.getkeyinfo("https://doesnotexists.com/";, "asdf")
+            self.keycache.getkeyinfo("https://doesnotexists.edu/";, "asdf")
 
 
     def test_cache_timer(self):
@@ -151,7 +145,7 @@
                                             key_id=test_id,
                                             insecure=True)
 
-        self.assertEqual(cache_timer, 3600)
+        self.assertEqual(cache_timer, 345600)
         create_webserver.shutdown_server()
 
     def test_cache_update_time(self):
@@ -170,12 +164,12 @@
             format=serialization.PublicFormat.SubjectPublicKeyInfo
         )
 
-        self.keycache.addkeyinfo("https://doesnotexists.com/";, "blahstuff", 
public_key, cache_timer=60, next_update=-1)
+        self.keycache.addkeyinfo("https://doesnotexists.edu/";, "blahstuff", 
public_key, cache_timer=60, next_update=-1)
 
         # Even though the cache is still valid, the next update is triggered
         # We should still get the key, even though the next update fails
         # (invalid url)
-        pubkey = self.keycache.getkeyinfo("https://doesnotexists.com/";, 
"blahstuff")
+        pubkey = self.keycache.getkeyinfo("https://doesnotexists.edu/";, 
"blahstuff")
 
         public_pem2 = pubkey.public_bytes(
             encoding=serialization.Encoding.PEM,
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/scitokens-1.6.2/tests/test_with_http.py 
new/scitokens-1.7.0/tests/test_with_http.py
--- old/scitokens-1.6.2/tests/test_with_http.py 2021-11-04 19:40:16.000000000 
+0100
+++ new/scitokens-1.7.0/tests/test_with_http.py 2022-02-18 19:56:16.000000000 
+0100
@@ -5,6 +5,7 @@
 import os
 import sys
 import unittest
+from pathlib import Path
 
 # Allow unittests to be run from within the project base.
 if os.path.exists("src"):
@@ -19,13 +20,16 @@
 from cryptography.hazmat.primitives import serialization
 from create_webserver import start_server
 
+TESTS_DIR = Path(__file__).parent
+
+
 class TestDeserialization(unittest.TestCase):
     """
     Test the deserialization of a SciToken
     """
 
     def setUp(self):
-        with open('tests/simple_private_key.pem', 'rb') as key_file:
+        with open(TESTS_DIR / 'simple_private_key.pem', 'rb') as key_file:
             self.private_key = serialization.load_pem_private_key(
                 key_file.read(),
                 password=None,
@@ -34,7 +38,7 @@
         self.test_id = "stuffblah"
         self.public_numbers = self.private_key.public_key().public_numbers()
 
-        with open('tests/simple_ec_private_key.pem', 'rb') as key_file:
+        with open(TESTS_DIR / 'simple_ec_private_key.pem', 'rb') as key_file:
             self.ec_private_key = serialization.load_pem_private_key(
                 key_file.read(),
                 password=None,

Reply via email to