Compare commits

...

2 Commits

Author SHA1 Message Date
Peter Pfeufer
5e42007088 Merge branch 'django-esi-min-version' into 'master'
[CHANGE] Django ESI min version

See merge request allianceauth/allianceauth!1734
2025-07-05 12:37:00 +00:00
Peter Pfeufer
9f81c7fa0e
[CHANGE] User agent generation 2025-07-05 14:36:48 +02:00
3 changed files with 18 additions and 5 deletions

View File

@ -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__}'

View File

@ -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

View File

@ -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})'
)