Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package python-pyotp for openSUSE:Factory 
checked in at 2026-11-27 19:44:35
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-pyotp (Old)
 and      /work/SRC/openSUSE:Factory/.python-pyotp.new.1340718 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python-pyotp"

Fri Nov 27 19:44:35 2026 rev:12 rq:1401126 version:2.12.2

Changes:
--------
--- /work/SRC/openSUSE:Factory/python-pyotp/python-pyotp.changes        
2026-11-19 16:58:30.534414597 +0100
+++ /work/SRC/openSUSE:Factory/.python-pyotp.new.1340718/python-pyotp.changes   
2026-11-27 19:48:42.667235257 +0100
@@ -1,0 +2,8 @@
+Fri Nov 27 12:22:15 UTC 2026 - Martin Hauke <[email protected]>
+
+- Update to version 2.12.2
+  * Restore positional provisioning names and add URI factories.
+- Update to version 2.12.1
+  * Allow subclasses to override minimum secret length (#208).
+
+-------------------------------------------------------------------

Old:
----
  pyotp-2.12.0.tar.gz

New:
----
  pyotp-2.12.2.tar.gz

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

Other differences:
------------------
++++++ python-pyotp.spec ++++++
--- /var/tmp/diff_new_pack.yEXl81/_old  2026-11-27 19:48:43.658277139 +0100
+++ /var/tmp/diff_new_pack.yEXl81/_new  2026-11-27 19:48:43.659277181 +0100
@@ -18,7 +18,7 @@
 
 %{?sle15_python_module_pythons}
 Name:           python-pyotp
-Version:        2.12.0
+Version:        2.12.2
 Release:        0
 Summary:        Python One Time Password Library
 License:        MIT

++++++ pyotp-2.12.0.tar.gz -> pyotp-2.12.2.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pyotp-2.12.0/Changes.rst new/pyotp-2.12.2/Changes.rst
--- old/pyotp-2.12.0/Changes.rst        2020-02-02 01:00:00.000000000 +0100
+++ new/pyotp-2.12.2/Changes.rst        2020-02-02 01:00:00.000000000 +0100
@@ -1,3 +1,13 @@
+Changes for v2.12.2 (2026-11-26)
+================================
+
+- Restore positional provisioning names and add URI factories (#210)
+
+Changes for v2.12.1 (2026-11-18)
+================================
+
+-  Allow subclasses to override minimum secret length (#208)
+
 Changes for v2.12.0 (2026-11-15)
 ================================
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pyotp-2.12.0/PKG-INFO new/pyotp-2.12.2/PKG-INFO
--- old/pyotp-2.12.0/PKG-INFO   2020-02-02 01:00:00.000000000 +0100
+++ new/pyotp-2.12.2/PKG-INFO   2020-02-02 01:00:00.000000000 +0100
@@ -1,6 +1,6 @@
 Metadata-Version: 2.5
 Name: PyOTP
-Version: 2.12.0
+Version: 2.12.2
 Summary: Python One Time Password Library
 Project-URL: Homepage, https://github.com/pyauth/pyotp
 Project-URL: Documentation, https://github.com/pyauth/pyotp
@@ -170,8 +170,8 @@
     hotp.at(1401) # => '666948'
 
     # OTP verified with a counter
-    hotp.verify('666948', 1401) # => True
-    hotp.verify('666948', 1402) # => False
+    hotp.verify('666948', counter=1401) # => True
+    hotp.verify('666948', counter=1402) # => False
 
 Generating a Secret Key
 ~~~~~~~~~~~~~~~~~~~~~~~
@@ -234,6 +234,35 @@
     totp = pyotp.TOTP("JBSWY3DPEHPK3PXPJBSWY3DP")
     print("Current OTP:", totp.now())
 
+Adjusting the minimum seed length
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+`RFC 4226, section 4 <https://www.rfc-editor.org/rfc/rfc4226#section-4>`_ 
requires a minimum seed length of 128 bits
+and recommends 160 bits. `NIST SP 800-63B-4, section 3.1.4.1
+<https://pages.nist.gov/800-63-4/sp800-63b/authenticators/#sf-otp>`_ requires 
the secret key and its algorithm to
+provide at least 112 bits of security strength. By default, PyOTP checks that 
secret inputs are at least 112 bits
+long after Base32 decoding. To specify a different minimum seed length, 
subclass ``pyotp.TOTP`` or ``pyotp.HOTP``
+and adjust the ``min_secret_length_bits`` class variable inherited from 
``pyotp.OTP``:
+
+.. code:: python
+
+    import pyotp
+
+    class TOTP128(pyotp.TOTP):
+        min_secret_length_bits = 128
+
+    class HOTP128(pyotp.HOTP):
+        min_secret_length_bits = 128
+
+    secret = pyotp.random_base32()
+    totp = TOTP128(secret)
+    hotp = HOTP128(secret)
+
+The minimum applies when constructing an instance and whenever its secret is 
decoded to generate or verify an OTP.
+
+When importing a provisioning URI, pass your subclass to ``pyotp.parse_uri()`` 
as the corresponding factory,
+for example ``pyotp.parse_uri(uri, totp_factory=TOTP128, 
hotp_factory=HOTP128)``.
+
 Third-party contributions
 ~~~~~~~~~~~~~~~~~~~~~~~~~
 The following third-party contributions are not described by a standard, not 
officially supported, and provided for
@@ -263,17 +292,6 @@
 Versioning
 ~~~~~~~~~~
 This package follows the `Semantic Versioning 2.0.0 <http://semver.org/>`_ 
standard. To control changes, it is
-recommended that application developers pin the package version and manage it 
using `pip-tools
-<https://github.com/jazzband/pip-tools>`_ or similar. For library developers, 
pinning the major version is
+recommended that application developers pin the package version and manage it 
using `uv
+<https://github.com/astral-sh/uv>`_ or similar. For library developers, 
pinning the major version is
 recommended.
-
-.. image:: https://github.com/pyauth/pyotp/workflows/Python%20package/badge.svg
-        :target: https://github.com/pyauth/pyotp/actions
-.. image:: https://img.shields.io/codecov/c/github/pyauth/pyotp/master.svg
-        :target: https://codecov.io/github/pyauth/pyotp?branch=master
-.. image:: https://img.shields.io/pypi/v/pyotp.svg
-        :target: https://pypi.python.org/pypi/pyotp
-.. image:: https://img.shields.io/pypi/l/pyotp.svg
-        :target: https://pypi.python.org/pypi/pyotp
-.. image:: https://readthedocs.org/projects/pyotp/badge/?version=latest
-        :target: https://pyotp.readthedocs.io/
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pyotp-2.12.0/README.rst new/pyotp-2.12.2/README.rst
--- old/pyotp-2.12.0/README.rst 2020-02-02 01:00:00.000000000 +0100
+++ new/pyotp-2.12.2/README.rst 2020-02-02 01:00:00.000000000 +0100
@@ -131,8 +131,8 @@
     hotp.at(1401) # => '666948'
 
     # OTP verified with a counter
-    hotp.verify('666948', 1401) # => True
-    hotp.verify('666948', 1402) # => False
+    hotp.verify('666948', counter=1401) # => True
+    hotp.verify('666948', counter=1402) # => False
 
 Generating a Secret Key
 ~~~~~~~~~~~~~~~~~~~~~~~
@@ -195,6 +195,35 @@
     totp = pyotp.TOTP("JBSWY3DPEHPK3PXPJBSWY3DP")
     print("Current OTP:", totp.now())
 
+Adjusting the minimum seed length
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+`RFC 4226, section 4 <https://www.rfc-editor.org/rfc/rfc4226#section-4>`_ 
requires a minimum seed length of 128 bits
+and recommends 160 bits. `NIST SP 800-63B-4, section 3.1.4.1
+<https://pages.nist.gov/800-63-4/sp800-63b/authenticators/#sf-otp>`_ requires 
the secret key and its algorithm to
+provide at least 112 bits of security strength. By default, PyOTP checks that 
secret inputs are at least 112 bits
+long after Base32 decoding. To specify a different minimum seed length, 
subclass ``pyotp.TOTP`` or ``pyotp.HOTP``
+and adjust the ``min_secret_length_bits`` class variable inherited from 
``pyotp.OTP``:
+
+.. code:: python
+
+    import pyotp
+
+    class TOTP128(pyotp.TOTP):
+        min_secret_length_bits = 128
+
+    class HOTP128(pyotp.HOTP):
+        min_secret_length_bits = 128
+
+    secret = pyotp.random_base32()
+    totp = TOTP128(secret)
+    hotp = HOTP128(secret)
+
+The minimum applies when constructing an instance and whenever its secret is 
decoded to generate or verify an OTP.
+
+When importing a provisioning URI, pass your subclass to ``pyotp.parse_uri()`` 
as the corresponding factory,
+for example ``pyotp.parse_uri(uri, totp_factory=TOTP128, 
hotp_factory=HOTP128)``.
+
 Third-party contributions
 ~~~~~~~~~~~~~~~~~~~~~~~~~
 The following third-party contributions are not described by a standard, not 
officially supported, and provided for
@@ -224,17 +253,6 @@
 Versioning
 ~~~~~~~~~~
 This package follows the `Semantic Versioning 2.0.0 <http://semver.org/>`_ 
standard. To control changes, it is
-recommended that application developers pin the package version and manage it 
using `pip-tools
-<https://github.com/jazzband/pip-tools>`_ or similar. For library developers, 
pinning the major version is
+recommended that application developers pin the package version and manage it 
using `uv
+<https://github.com/astral-sh/uv>`_ or similar. For library developers, 
pinning the major version is
 recommended.
-
-.. image:: https://github.com/pyauth/pyotp/workflows/Python%20package/badge.svg
-        :target: https://github.com/pyauth/pyotp/actions
-.. image:: https://img.shields.io/codecov/c/github/pyauth/pyotp/master.svg
-        :target: https://codecov.io/github/pyauth/pyotp?branch=master
-.. image:: https://img.shields.io/pypi/v/pyotp.svg
-        :target: https://pypi.python.org/pypi/pyotp
-.. image:: https://img.shields.io/pypi/l/pyotp.svg
-        :target: https://pypi.python.org/pypi/pyotp
-.. image:: https://readthedocs.org/projects/pyotp/badge/?version=latest
-        :target: https://pyotp.readthedocs.io/
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pyotp-2.12.0/src/pyotp/__init__.py 
new/pyotp-2.12.2/src/pyotp/__init__.py
--- old/pyotp-2.12.0/src/pyotp/__init__.py      2020-02-02 01:00:00.000000000 
+0100
+++ new/pyotp-2.12.2/src/pyotp/__init__.py      2020-02-02 01:00:00.000000000 
+0100
@@ -2,7 +2,7 @@
 from __future__ import annotations
 
 import hashlib
-from collections.abc import Sequence
+from collections.abc import Callable, Sequence
 from re import split
 from typing import Any
 from urllib.parse import parse_qsl, unquote, urlparse
@@ -31,7 +31,7 @@
     return random_base32(length=length, chars=chars)
 
 
-def parse_uri(uri: str) -> OTP:
+def parse_uri(uri: str, *, hotp_factory: Callable[..., HOTP] = HOTP, 
totp_factory: Callable[..., TOTP] = TOTP) -> OTP:
     """
     Parses the provisioning URI for the OTP; works for either TOTP or HOTP.
 
@@ -39,6 +39,8 @@
         https://github.com/google/google-authenticator/wiki/Key-Uri-Format
 
     :param uri: the hotp/totp URI to parse
+    :param hotp_factory: factory for HOTP URIs, defaults to 
:class:`~pyotp.hotp.HOTP`
+    :param totp_factory: factory for TOTP URIs, defaults to 
:class:`~pyotp.totp.TOTP`
     :returns: OTP object
     """
 
@@ -120,8 +122,8 @@
     if encoder == "steam":
         return contrib.Steam(secret, **otp_data)
     if parsed_uri.netloc == "totp":
-        return TOTP(secret, **otp_data)
+        return totp_factory(secret, **otp_data)
     elif parsed_uri.netloc == "hotp":
-        return HOTP(secret, **otp_data)
+        return hotp_factory(secret, **otp_data)
 
     raise ValueError("Not a supported OTP type")
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pyotp-2.12.0/src/pyotp/hotp.py 
new/pyotp-2.12.2/src/pyotp/hotp.py
--- old/pyotp-2.12.0/src/pyotp/hotp.py  2020-02-02 01:00:00.000000000 +0100
+++ new/pyotp-2.12.2/src/pyotp/hotp.py  2020-02-02 01:00:00.000000000 +0100
@@ -47,7 +47,7 @@
         """
         return self.generate_otp(self.initial_count + count)
 
-    def verify(self, otp: str, counter: int) -> bool:
+    def verify(self, otp: str, *, counter: int) -> bool:
         """
         Verifies the OTP passed in against the current counter OTP.
 
@@ -58,8 +58,8 @@
 
     def provisioning_uri(
         self,
-        *,
         name: str | None = None,
+        *,
         initial_count: int | None = None,
         issuer_name: str | None = None,
         **kwargs: Any,
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pyotp-2.12.0/src/pyotp/otp.py 
new/pyotp-2.12.2/src/pyotp/otp.py
--- old/pyotp-2.12.0/src/pyotp/otp.py   2020-02-02 01:00:00.000000000 +0100
+++ new/pyotp-2.12.2/src/pyotp/otp.py   2020-02-02 01:00:00.000000000 +0100
@@ -3,7 +3,7 @@
 import base64
 import hashlib
 import hmac
-from typing import Any
+from typing import Any, ClassVar
 
 
 class OTP:
@@ -11,8 +11,11 @@
     Base class for OTP handlers.
 
     The Base32 secret and its decoded length are validated at construction.
+    Subclasses can override ``min_secret_length_bits`` to adjust the minimum 
decoded secret length.
     """
 
+    min_secret_length_bits: ClassVar[int] = 112
+
     def __init__(
         self,
         s: str,
@@ -56,7 +59,7 @@
         return str_code[-self.digits :]
 
     def byte_secret(self) -> bytes:
-        """Decode the secret and enforce a minimum key length of 112 bits.
+        """Decode the secret and enforce ``min_secret_length_bits`` (112 bits 
by default).
 
         See NIST SP 800-63B-4, sections 3.1.4.1 and 3.1.4.2:
         https://pages.nist.gov/800-63-4/sp800-63b.html
@@ -66,8 +69,8 @@
         if missing_padding != 0:
             secret += "=" * (8 - missing_padding)
         decoded = base64.b32decode(secret, casefold=True)
-        if len(decoded) < 14:
-            raise ValueError("Secrets must be at least 112 bits after 
decoding")
+        if len(decoded) * 8 < self.min_secret_length_bits:
+            raise ValueError(f"Secrets must be at least 
{self.min_secret_length_bits} bits after decoding")
         return decoded
 
     @staticmethod
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pyotp-2.12.0/src/pyotp/totp.py 
new/pyotp-2.12.2/src/pyotp/totp.py
--- old/pyotp-2.12.0/src/pyotp/totp.py  2020-02-02 01:00:00.000000000 +0100
+++ new/pyotp-2.12.2/src/pyotp/totp.py  2020-02-02 01:00:00.000000000 +0100
@@ -150,7 +150,7 @@
                 return timecode + i
         raise OTPVerificationError("OTP verification failed")
 
-    def provisioning_uri(self, *, name: str | None = None, issuer_name: str | 
None = None, **kwargs: Any) -> str:
+    def provisioning_uri(self, name: str | None = None, *, issuer_name: str | 
None = None, **kwargs: Any) -> str:
         """
         Returns the provisioning URI for the OTP.  This can then be
         encoded in a QR Code and used to provision an OTP app like
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pyotp-2.12.0/test.py new/pyotp-2.12.2/test.py
--- old/pyotp-2.12.0/test.py    2020-02-02 01:00:00.000000000 +0100
+++ new/pyotp-2.12.2/test.py    2020-02-02 01:00:00.000000000 +0100
@@ -17,6 +17,16 @@
 
 
 class OTPConfigurationTest(unittest.TestCase):
+    def test_provisioning_uri_accepts_only_first_positional_argument(self):
+        secret = "GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ"
+        for otp_type in (pyotp.TOTP, pyotp.HOTP):
+            with self.subTest(otp_type=otp_type):
+                otp = otp_type(secret)
+                uri = otp.provisioning_uri("Name", issuer_name="Issuer")
+                self.assertEqual(urlparse(uri).path, "/Issuer:Name")
+                with self.assertRaises(TypeError):
+                    otp.provisioning_uri("Name", 0 if otp_type is pyotp.HOTP 
else "Issuer")
+
     def test_decoded_seed_length(self):
         for otp_type in (pyotp.OTP, pyotp.HOTP, pyotp.TOTP, 
pyotp.contrib.Steam):
             for length in (0, 1, 5, 10, 13, 14, 15, 20):
@@ -32,6 +42,50 @@
                             self.assertEqual(otp.byte_secret(), raw)
                             self.assertEqual(len(otp.generate_otp(0)), 5 if 
otp_type is pyotp.contrib.Steam else 6)
 
+    def test_subclass_minimum_seed_length(self):
+        for otp_type in (pyotp.OTP, pyotp.HOTP, pyotp.TOTP, 
pyotp.contrib.Steam):
+            for minimum_bits in (80, 113, 128, 160):
+
+                class CustomOTP(otp_type):
+                    min_secret_length_bits: ClassVar[int] = minimum_bits
+
+                minimum_bytes = (minimum_bits + 7) // 8
+                for length in (minimum_bytes - 1, minimum_bytes, minimum_bytes 
+ 1):
+                    raw = bytes(range(length))
+                    encoded = base64.b32encode(raw).decode("ascii")
+                    for seed in (encoded, encoded.rstrip("="), 
encoded.lower()):
+                        with self.subTest(otp_type=otp_type, 
minimum_bits=minimum_bits, length=length, seed=seed):
+                            if length < minimum_bytes:
+                                with self.assertRaisesRegex(ValueError, f"at 
least {minimum_bits} bits after decoding"):
+                                    CustomOTP(seed)
+                            else:
+                                otp = CustomOTP(seed)
+                                self.assertEqual(otp.byte_secret(), raw)
+                                self.assertEqual(len(otp.generate_otp(0)), 5 
if otp_type is pyotp.contrib.Steam else 6)
+                self.assertEqual(otp_type.min_secret_length_bits, 112)
+
+    def test_subclass_minimum_seed_length_after_secret_change(self):
+        for otp_type in (pyotp.OTP, pyotp.HOTP, pyotp.TOTP, 
pyotp.contrib.Steam):
+
+            class CustomOTP(otp_type):
+                min_secret_length_bits: ClassVar[int] = 128
+
+            with self.subTest(otp_type=otp_type):
+                otp = 
CustomOTP(base64.b32encode(bytes(range(16))).decode("ascii"))
+                otp.secret = base64.b32encode(bytes(range(15))).decode("ascii")
+                with self.assertRaisesRegex(ValueError, "at least 128 bits 
after decoding"):
+                    otp.generate_otp(0)
+                self.assertEqual(len(otp_type(otp.secret).byte_secret()), 15)
+
+    def test_lower_minimum_seed_length_preserves_base32_validation(self):
+        class CustomOTP(pyotp.OTP):
+            min_secret_length_bits: ClassVar[int] = 8
+
+        for secret in ("SOME_SECRET", "abc", "!" * 32):
+            with self.subTest(secret=secret):
+                with self.assertRaises(ValueError):
+                    CustomOTP(secret)
+
     def test_invalid_base32_is_rejected_at_construction(self):
         for otp_type in (pyotp.OTP, pyotp.HOTP, pyotp.TOTP, 
pyotp.contrib.Steam):
             for secret in ("SOME_SECRET", "abc", "!" * 32):
@@ -47,7 +101,7 @@
                 hotp = pyotp.HOTP(valid_secret)
                 hotp.secret = secret
                 with self.assertRaisesRegex(ValueError, "at least 112 bits 
after decoding"):
-                    hotp.verify("123456", 0)
+                    hotp.verify("123456", counter=0)
                 for otp_type in (pyotp.TOTP, pyotp.contrib.Steam):
                     otp = otp_type(valid_secret)
                     otp.secret = secret
@@ -140,10 +194,15 @@
 
     def test_verify_otp_reuse(self):
         hotp = pyotp.HOTP("GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ")
-        self.assertTrue(hotp.verify("520489", 9))
-        self.assertTrue(hotp.verify("520489", 9))
-        self.assertFalse(hotp.verify("520489", 10))
-        self.assertFalse(hotp.verify("520489", 10))
+        self.assertTrue(hotp.verify("520489", counter=9))
+        self.assertTrue(hotp.verify("520489", counter=9))
+        self.assertFalse(hotp.verify("520489", counter=10))
+        self.assertFalse(hotp.verify("520489", counter=10))
+
+    def test_verify_counter_is_keyword_only(self):
+        hotp = pyotp.HOTP("GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ")
+        with self.assertRaises(TypeError):
+            hotp.verify("520489", 9)
 
     def test_provisioning_uri(self):
         hotp = pyotp.HOTP("wrn3pqx5uqxqvnqrwrn3pqx5uqxqvnqr", 
name="mark@percival")
@@ -679,7 +738,7 @@
         oversized = "\u0301\u0323" * 32768
         hotp = pyotp.HOTP("ABCDEFGHABCDEFGHABCDEFGH")
         with patch("pyotp.utils.unicodedata.normalize") as normalize:
-            self.assertFalse(hotp.verify(oversized, 6))
+            self.assertFalse(hotp.verify(oversized, counter=6))
             for otp_type in (pyotp.TOTP, pyotp.contrib.Steam):
                 totp = otp_type("ABCDEFGHABCDEFGHABCDEFGH")
                 for valid_window in (0, 1):
@@ -697,7 +756,7 @@
         for digits in (6, 8, 10):
             with self.subTest(digits=digits):
                 hotp = pyotp.HOTP("ABCDEFGHABCDEFGHABCDEFGH", digits=digits)
-                self.assertTrue(hotp.verify(hotp.at(6).translate(fullwidth), 
6))
+                self.assertTrue(hotp.verify(hotp.at(6).translate(fullwidth), 
counter=6))
                 totp = pyotp.TOTP("ABCDEFGHABCDEFGHABCDEFGH", digits=digits)
                 code = totp.at(200).translate(fullwidth)
                 self.assertTrue(totp.verify(code, for_time=200))
@@ -789,6 +848,35 @@
                     with self.assertRaises(ValueError):
                         pyotp.parse_uri(f"otpauth://{otp_type}/Example?" + 
urlencode(query))
 
+    def test_hotp_factory_can_override_minimum_secret_length(self):
+        class LegacyHOTP(pyotp.HOTP):
+            min_secret_length_bits: ClassVar[int] = 80
+
+        uri = 
"otpauth://hotp/Issuer:Name?secret=GEZDGNBVGY3TQOJQ&issuer=Issuer&counter=7"
+        with self.assertRaisesRegex(ValueError, "at least 112 bits after 
decoding"):
+            pyotp.parse_uri(uri)
+        otp = pyotp.parse_uri(uri, hotp_factory=LegacyHOTP)
+        self.assertIs(type(otp), LegacyHOTP)
+        self.assertEqual(otp.byte_secret(), b"1234567890")
+        self.assertEqual((otp.issuer, otp.name, otp.initial_count), ("Issuer", 
"Name", 7))
+
+    def test_totp_factory_can_override_minimum_secret_length(self):
+        class LegacyTOTP(pyotp.TOTP):
+            min_secret_length_bits: ClassVar[int] = 80
+
+        uri = 
"otpauth://totp/Issuer:Name?secret=GEZDGNBVGY3TQOJQ&digits=8&period=60"
+        with self.assertRaisesRegex(ValueError, "at least 112 bits after 
decoding"):
+            pyotp.parse_uri(uri)
+        otp = pyotp.parse_uri(uri, totp_factory=LegacyTOTP)
+        self.assertIs(type(otp), LegacyTOTP)
+        self.assertEqual(otp.byte_secret(), b"1234567890")
+        self.assertEqual((otp.issuer, otp.name, otp.digits, otp.interval), 
("Issuer", "Name", 8, 60))
+
+    def test_factories_are_keyword_only(self):
+        uri = "otpauth://totp/Example?secret=GEZDGNBVGY3TQOJQGEZDGNBV"
+        with self.assertRaises(TypeError):
+            pyotp.parse_uri(uri, pyotp.HOTP, pyotp.TOTP)
+
     def test_duplicate_security_parameters(self):
         seed = "GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ"
         parameters = {

Reply via email to