Skip to content

Commit

Permalink
[#4825] Log prefill retrieve empty only for the used authentication flow
Browse files Browse the repository at this point in the history
This is a fix which is meant for backporting. The 'proper' fix will be
implemented in a different PR, out of the scope of the v3.0.
  • Loading branch information
vaszig committed Dec 20, 2024
1 parent 260a985 commit e900c0b
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/openforms/prefill/sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,12 @@ def invoke_plugin(
if values:
logevent.prefill_retrieve_success(submission, plugin, fields)
else:
logevent.prefill_retrieve_empty(submission, plugin, fields)
if (
plugin.requires_auth is None
or (auth_info := getattr(submission, "auth_info", None))
and auth_info.attribute == plugin.requires_auth
):
logevent.prefill_retrieve_empty(submission, plugin, fields)
return fields, values

invoke_plugin_args = []
Expand Down
30 changes: 30 additions & 0 deletions src/openforms/prefill/tests/test_prefill_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
from ..base import BasePlugin
from ..constants import IdentifierRoles
from ..contrib.demo.plugin import DemoPrefill
from ..contrib.haalcentraal_brp.plugin import (
PLUGIN_IDENTIFIER as HAAL_CENTRAAL_PLUGIN_IDENTIFIER,
HaalCentraalPrefill,
)
from ..registry import Registry, register as prefill_register
from ..service import inject_prefill, prefill_variables
from .utils import get_test_register
Expand Down Expand Up @@ -626,3 +630,29 @@ class TestPlugin(BasePlugin):
result = plugin.get_identifier_value(submission, IdentifierRoles.main)

self.assertEqual("123123123", result)

def test_prefill_logging_with_mismatching_login_method(self):
components = [
{
"key": "mainPersonName",
"type": "textfield",
"prefill": {
"plugin": HAAL_CENTRAAL_PLUGIN_IDENTIFIER,
"attribute": "naam.voornamen",
"identifierRole": IdentifierRoles.main,
},
},
]
submission = SubmissionFactory.from_components(
components_list=components, kvk="69599084"
)
register = Registry()
register(HAAL_CENTRAAL_PLUGIN_IDENTIFIER)(HaalCentraalPrefill)

apply_prefill(
configuration={"components": components},
submission=submission,
register=register,
)

self.assertFalse(TimelineLogProxy.objects.exists())

0 comments on commit e900c0b

Please sign in to comment.