toulouse-maelis: do not crash linking RL1 with no birth data (#80922)
gitea/passerelle/pipeline/head This commit looks good
Details
gitea/passerelle/pipeline/head This commit looks good
Details
This commit is contained in:
parent
40287181cc
commit
fd1c591ab3
|
@ -1116,6 +1116,11 @@ class ToulouseMaelis(BaseResource, HTTPResource):
|
|||
def link(self, request, NameID, post_data):
|
||||
family_id = post_data['family_id']
|
||||
response = self.call('Family', 'readFamily', dossierNumber=family_id)
|
||||
if not (
|
||||
response['RL1']['birth']
|
||||
and isinstance(response['RL1']['birth'].get('dateBirth'), datetime.datetime)
|
||||
):
|
||||
raise APIError("Maelis provides an invalid dateBirth for RL1 on '%s' family" % family_id)
|
||||
if not (
|
||||
response['RL1']['firstname'] == post_data['firstname'].upper()
|
||||
and response['RL1']['lastname'] == post_data['lastname'].upper()
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
|
||||
<soap:Body>
|
||||
<ns2:readFamilyResponse xmlns:ns2="family.ws.maelis.sigec.com">
|
||||
<familyResult>
|
||||
<number>1312</number>
|
||||
<category>BI</category>
|
||||
<situation>M</situation>
|
||||
<flagCom>true</flagCom>
|
||||
<nbChild>2</nbChild>
|
||||
<RL1>
|
||||
<num>613878</num>
|
||||
<lastname>DOE</lastname>
|
||||
<firstname>JHON</firstname>
|
||||
<quality>PERE</quality>
|
||||
<civility>M.</civility>
|
||||
<adresse>
|
||||
<idStreet>2317</idStreet>
|
||||
<num>170</num>
|
||||
<street1>RUE ACHILLE VIADIEU</street1>
|
||||
<town>Paris</town>
|
||||
<zipcode>75014</zipcode>
|
||||
</adresse>
|
||||
</RL1>
|
||||
</familyResult>
|
||||
</ns2:readFamilyResponse>
|
||||
</soap:Body>
|
||||
</soap:Envelope>
|
|
@ -672,6 +672,21 @@ def test_link_additional_properties_error(con, app):
|
|||
assert resp.json['err_desc'] == "Additional properties are not allowed ('plop' was unexpected)"
|
||||
|
||||
|
||||
def test_link_family_with_no_birth_error(family_service, con, app):
|
||||
family_service.add_soap_response('readFamily', get_xml_file('R_read_family_no_rl1_birth.xml'))
|
||||
url = get_endpoint('link')
|
||||
|
||||
params = {
|
||||
'family_id': '1312',
|
||||
'firstname': 'Jhon',
|
||||
'lastname': 'Doe',
|
||||
'dateBirth': '1938-07-26',
|
||||
}
|
||||
resp = app.post_json(url + '?NameID=local', params=params)
|
||||
assert resp.json['err'] == 1
|
||||
assert resp.json['err_desc'] == "Maelis provides an invalid dateBirth for RL1 on '1312' family"
|
||||
|
||||
|
||||
def test_unlink(con, app):
|
||||
url = get_endpoint('unlink')
|
||||
Link.objects.create(resource=con, family_id='1312', name_id='local')
|
||||
|
|
Loading…
Reference in New Issue