franceconnect: fix data_source endpoint with bad id in param (#71456)
This commit is contained in:
parent
9b889430d1
commit
d0bdb9b618
|
@ -222,11 +222,13 @@ class Resource(BaseResource):
|
|||
)
|
||||
def data_source(self, request, id=None, test=None, mode=None, **kwargs):
|
||||
if id:
|
||||
return {
|
||||
'data': [
|
||||
dict(self.retrieve(id), id=id),
|
||||
]
|
||||
}
|
||||
token = self.retrieve(id)
|
||||
if token:
|
||||
return {
|
||||
'data': [
|
||||
dict(token, id=id),
|
||||
]
|
||||
}
|
||||
url = request.build_absolute_uri(
|
||||
reverse(
|
||||
'generic-endpoint',
|
||||
|
@ -262,6 +264,10 @@ class Resource(BaseResource):
|
|||
return token.guid.hex
|
||||
|
||||
def retrieve(self, ref):
|
||||
try:
|
||||
ref = uuid.UUID(str(ref))
|
||||
except ValueError:
|
||||
return None
|
||||
token = Token.objects.filter(guid=ref).first()
|
||||
return token and token.content
|
||||
|
||||
|
|
|
@ -95,6 +95,8 @@ def test_callback(app, fc):
|
|||
'text': 'John Doe né le April 28, 2001',
|
||||
}
|
||||
|
||||
app.get('/franceconnect-data/test/data_source?id=bad') # no error
|
||||
|
||||
|
||||
@mock_response(
|
||||
['/api/v1/token', ''],
|
||||
|
|
Loading…
Reference in New Issue