solis: force _links to use service_url scheme (#38039)
This commit is contained in:
parent
3a56b4c709
commit
2bc9d1d89a
|
@ -473,10 +473,15 @@ class Solis(BaseResource):
|
|||
for sublink in link:
|
||||
self.rsa_fill_with_link_content(sublink)
|
||||
return
|
||||
if (not isinstance(link, dict) or not link.get('href')
|
||||
or not link['href'].startswith(self.service_url)):
|
||||
if not isinstance(link, dict) or not link.get('href'):
|
||||
return
|
||||
endpoint = link['href'][len(self.service_url):]
|
||||
href = link['href']
|
||||
if href.startswith('http:') and self.service_url.startswith('https:'):
|
||||
# fix scheme (reverse-proxy bug, https://dev.entrouvert.org/issues/38039)
|
||||
href = 'https:' + href[5:]
|
||||
if not href.startswith(self.service_url):
|
||||
return
|
||||
endpoint = href[len(self.service_url):]
|
||||
try:
|
||||
value = self.request(endpoint)
|
||||
except APIError as e: # do not raise on linked informations
|
||||
|
|
|
@ -50,7 +50,7 @@ RSAALLOCATAIRES = '''{
|
|||
"href": "https://solis.example.net/solisapi/referentiels/civi/individu/4242/"
|
||||
},
|
||||
"conjoint": {
|
||||
"href": "https://solis.example.net/solisapi/referentiels/civi/individu/4273/"
|
||||
"href": "http://solis.example.net/solisapi/referentiels/civi/individu/4273/"
|
||||
}
|
||||
}
|
||||
}'''
|
||||
|
@ -61,7 +61,7 @@ RSA_3LINKS = '''{
|
|||
},
|
||||
"refOrientStructAcc": [
|
||||
{"href": "https://solis.example.net/solisapi/referentiels/civi/individu/4242/"},
|
||||
{"href": "https://solis.example.net/solisapi/referentiels/civi/individu/4242/"}
|
||||
{"href": "http://solis.example.net/solisapi/referentiels/civi/individu/4242/"}
|
||||
]
|
||||
}
|
||||
}'''
|
||||
|
@ -963,7 +963,7 @@ def test_solis_rsa_link_infos_unlink(app, solis):
|
|||
assert resp.json['data']['rsa_links']['conjoint']['content']['err'] == 1
|
||||
|
||||
# bad links, do nothing
|
||||
for content in (RSAALLOCATAIRES.replace('https:', 'http:'),
|
||||
for content in (RSAALLOCATAIRES.replace('solis.example.net', 'solis.example.org'),
|
||||
RSAALLOCATAIRES.replace('href', 'xxxx')):
|
||||
requests_post.reset_mock()
|
||||
requests_get.reset_mock()
|
||||
|
|
Loading…
Reference in New Issue