don't cache local metadata anymore (#13881)

This commit is contained in:
Frédéric Péters 2018-09-05 16:49:23 +02:00
parent d026ce40e1
commit a1fa7d36df
2 changed files with 10 additions and 17 deletions

View File

@ -18,18 +18,16 @@ from . import app_settings
def create_metadata(request):
entity_id = reverse('mellon_metadata')
cache = getattr(settings, '_MELLON_METADATA_CACHE', {})
if not entity_id in cache:
login_url = reverse(app_settings.LOGIN_URL)
logout_url = reverse(app_settings.LOGOUT_URL)
public_keys = []
for public_key in app_settings.PUBLIC_KEYS:
if public_key.startswith('/'):
# clean PEM file
public_key = ''.join(open(public_key).read().splitlines()[1:-1])
public_keys.append(public_key)
name_id_formats = app_settings.NAME_ID_FORMATS
cache[entity_id] = render_to_string('mellon/metadata.xml', {
login_url = reverse(app_settings.LOGIN_URL)
logout_url = reverse(app_settings.LOGOUT_URL)
public_keys = []
for public_key in app_settings.PUBLIC_KEYS:
if public_key.startswith('/'):
# clean PEM file
public_key = ''.join(open(public_key).read().splitlines()[1:-1])
public_keys.append(public_key)
name_id_formats = app_settings.NAME_ID_FORMATS
return render_to_string('mellon/metadata.xml', {
'entity_id': request.build_absolute_uri(entity_id),
'login_url': request.build_absolute_uri(login_url),
'logout_url': request.build_absolute_uri(logout_url),
@ -40,10 +38,6 @@ def create_metadata(request):
'contact_persons': app_settings.CONTACT_PERSONS,
'discovery_endpoint_url': request.build_absolute_uri(reverse('mellon_login')),
})
settings._MELLON_METADATA_CACHE = cache
return settings._MELLON_METADATA_CACHE[entity_id]
SERVERS = {}
def create_server(request):

View File

@ -153,7 +153,6 @@ def test_create_metadata(rf, private_settings, caplog):
('/ds:X509Certificate[text()=\'xxx\']', 1),
('/ds:X509Certificate[text()=\'yyy\']', 1)))),
namespaces=ns)
assert metadata is create_metadata(request)
def test_iso8601_to_datetime(private_settings):