diff --git a/flask_rebar/swagger_generation/generator_utils.py b/flask_rebar/swagger_generation/generator_utils.py index eb4b1367..9e474a46 100644 --- a/flask_rebar/swagger_generation/generator_utils.py +++ b/flask_rebar/swagger_generation/generator_utils.py @@ -186,7 +186,7 @@ def format_path_for_swagger(path): return subbed_path, args -@deprecated(eol_version="2,0") +@deprecated(eol_version="2.0") def convert_header_api_key_authenticator(authenticator): """ Converts a HeaderApiKeyAuthenticator object to a Swagger definition. diff --git a/tests/swagger_generation/test_generator_utils.py b/tests/swagger_generation/test_generator_utils.py index 2e484cf0..32181aa0 100644 --- a/tests/swagger_generation/test_generator_utils.py +++ b/tests/swagger_generation/test_generator_utils.py @@ -8,6 +8,7 @@ :license: MIT, see LICENSE for details. """ import unittest +import warnings from flask_rebar.swagger_generation.generator_utils import PathArgument from flask_rebar.swagger_generation.generator_utils import flatten @@ -197,30 +198,33 @@ class TestAuthenticatorConverter(unittest.TestCase): def test_legacy_behaviour(self): """Check that the AuthenticatorConverter maintains backward compatibility with functions as the converters """ - - converter = AuthenticatorConverter( - {HeaderApiKeyAuthenticator: convert_header_api_key_authenticator} - ) - converter.register(MyCustomAuthenticator, convert_my_customer_authenticator) - - auth_1 = HeaderApiKeyAuthenticator("X-Test-Header") - auth_2 = MyCustomAuthenticator() - - registry = HandlerRegistry(default_authenticators=[auth_1, auth_2]) - - self.assertEqual( - converter.get_security_requirement(auth_1), [{"sharedSecret": []}] - ) - self.assertEqual(converter.get_security_requirement(auth_2), [{"myAuth": []}]) - - self.assertEqual( - converter.get_security_schemes(registry), - { - "sharedSecret": { - "type": "apiKey", - "in": "header", - "name": "X-Test-Header", + with warnings.catch_warnings(record=True) as caught_warnings: + converter = AuthenticatorConverter( + {HeaderApiKeyAuthenticator: convert_header_api_key_authenticator} + ) + converter.register(MyCustomAuthenticator, convert_my_customer_authenticator) + + auth_1 = HeaderApiKeyAuthenticator("X-Test-Header") + auth_2 = MyCustomAuthenticator() + + registry = HandlerRegistry(default_authenticators=[auth_1, auth_2]) + + self.assertEqual( + converter.get_security_requirement(auth_1), [{"sharedSecret": []}] + ) + self.assertEqual( + converter.get_security_requirement(auth_2), [{"myAuth": []}] + ) + + self.assertEqual( + converter.get_security_schemes(registry), + { + "sharedSecret": { + "type": "apiKey", + "in": "header", + "name": "X-Test-Header", + }, + "myAuth": {"type": "basic"}, }, - "myAuth": {"type": "basic"}, - }, - ) + ) + self.assertTrue(caught_warnings)