diff --git a/allianceauth/eveonline/providers.py b/allianceauth/eveonline/providers.py index 3cff9567..dc25ba35 100644 --- a/allianceauth/eveonline/providers.py +++ b/allianceauth/eveonline/providers.py @@ -7,6 +7,8 @@ from jsonschema.exceptions import RefResolutionError from django.conf import settings from esi.clients import esi_client_factory +from allianceauth import __version__ + SWAGGER_SPEC_PATH = os.path.join(os.path.dirname( os.path.abspath(__file__)), 'swagger.json' @@ -166,7 +168,7 @@ class EveSwaggerProvider(EveProvider): else: try: self._client = esi_client_factory( - token=token, spec_file=SWAGGER_SPEC_PATH + token=token, spec_file=SWAGGER_SPEC_PATH, app_info_text=("allianceauth v" + __version__) ) except (HTTPError, RefResolutionError): logger.exception( @@ -182,7 +184,7 @@ class EveSwaggerProvider(EveProvider): def client(self): if self._client is None: self._client = esi_client_factory( - token=self._token, spec_file=SWAGGER_SPEC_PATH + token=self._token, spec_file=SWAGGER_SPEC_PATH, app_info_text=("allianceauth v" + __version__) ) return self._client diff --git a/allianceauth/eveonline/tests/test_providers.py b/allianceauth/eveonline/tests/test_providers.py index fa09c36a..48697168 100644 --- a/allianceauth/eveonline/tests/test_providers.py +++ b/allianceauth/eveonline/tests/test_providers.py @@ -592,3 +592,12 @@ class TestEveSwaggerProvider(TestCase): self.assertTrue(mock_esi_client_factory.called) 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.Status.get_status() + self.assertEqual( + operation.future.request.headers['User-Agent'], 'allianceauth v1.0.0' + )