diff --git a/allianceauth/__init__.py b/allianceauth/__init__.py index 1c6fab28..394625ed 100644 --- a/allianceauth/__init__.py +++ b/allianceauth/__init__.py @@ -7,5 +7,6 @@ manage online service access. __version__ = '4.8.0' __title__ = 'Alliance Auth' +__title_useragent__ = 'AllianceAuth' __url__ = 'https://gitlab.com/allianceauth/allianceauth' NAME = f'{__title__} v{__version__}' diff --git a/allianceauth/eveonline/providers.py b/allianceauth/eveonline/providers.py index d8c30604..14520048 100644 --- a/allianceauth/eveonline/providers.py +++ b/allianceauth/eveonline/providers.py @@ -7,7 +7,7 @@ from jsonschema.exceptions import RefResolutionError from django.conf import settings from esi.clients import esi_client_factory -from allianceauth import __version__ +from allianceauth import __version__, __title_useragent__, __url__ from allianceauth.utils.django import StartupCommand @@ -185,7 +185,9 @@ class EveSwaggerProvider(EveProvider): self._client = esi_client_factory( token=token, spec_file=SWAGGER_SPEC_PATH, - app_info_text=f"allianceauth v{__version__}" + ua_appname=__title_useragent__, + ua_version=__version__, + ua_url=__url__ ) except (HTTPError, RefResolutionError): logger.exception( @@ -202,7 +204,11 @@ class EveSwaggerProvider(EveProvider): def client(self): if self._client is None: self._client = esi_client_factory( - token=self._token, spec_file=SWAGGER_SPEC_PATH, app_info_text=("allianceauth v" + __version__) + token=self._token, + spec_file=SWAGGER_SPEC_PATH, + ua_appname=__title_useragent__, + ua_version=__version__, + ua_url=__url__ ) return self._client diff --git a/allianceauth/eveonline/tests/test_providers.py b/allianceauth/eveonline/tests/test_providers.py index e90b727b..d67d96ee 100644 --- a/allianceauth/eveonline/tests/test_providers.py +++ b/allianceauth/eveonline/tests/test_providers.py @@ -6,6 +6,12 @@ from jsonschema.exceptions import RefResolutionError from django.test import TestCase +from allianceauth import __url__ as aa_url +from allianceauth import __version__ as aa_version + +from esi import __url__ as esi_url +from esi import __version__ as esi_version + from . import set_logger from .esi_client_stub import EsiClientStub from ..providers import ( @@ -717,11 +723,11 @@ class TestEveSwaggerProvider(TestCase): self.assertIsNotNone(my_provider._client) self.assertEqual(my_client, 'my_client') - @patch(MODULE_PATH + '.__version__', '1.0.0') def test_user_agent_header(self): my_provider = EveSwaggerProvider() my_client = my_provider.client operation = my_client.Universe.get_universe_factions() self.assertEqual( - operation.future.request.headers['User-Agent'], 'allianceauth v1.0.0 dummy@example.net' + operation.future.request.headers['User-Agent'], + f'AllianceAuth/{aa_version} (dummy@example.net; +{aa_url}) Django-ESI/{esi_version} (+{esi_url})' )