-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1553 from maykinmedia/2959-sync-user-to-esuite-po…
…st-registration [#2959] Sync user to eSuite after completing registration
- Loading branch information
Showing
5 changed files
with
193 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -287,6 +287,7 @@ def test_notification_settings_with_cms_page_published(self, m): | |
necessary_form[ | ||
"case_notification_channel" | ||
] = NotificationChannelChoice.digital_only | ||
necessary_form["email"] = "[email protected]" | ||
necessary_form.submit() | ||
|
||
user = User.objects.get(bsn=data["auth_name"]) | ||
|
@@ -304,12 +305,13 @@ def test_notification_settings_with_cms_page_published(self, m): | |
self.assertEqual( | ||
klant_patch_data, | ||
{ | ||
"emailadres": "[email protected]", | ||
"toestemmingZaakNotificatiesAlleenDigitaal": True, | ||
}, | ||
) | ||
# only check logs for klant api update | ||
dump = self.getTimelineLogDump() | ||
msg = "patched klant from user profile edit with fields: toestemmingZaakNotificatiesAlleenDigitaal" | ||
msg = "patched klant from user profile edit with fields: emailadres, toestemmingZaakNotificatiesAlleenDigitaal" | ||
assert msg in dump | ||
|
||
@requests_mock.Mocker() | ||
|
@@ -507,6 +509,72 @@ def test_existing_user_digid_login_fails_brp_update_when_brp_http_404(self, m): | |
|
||
self.assertNotEqual(user.first_name, "UpdatedName") | ||
|
||
@requests_mock.Mocker() | ||
def test_user_without_klant_is_created_and_updated(self, m): | ||
""" | ||
Assert that if no klant exists during the filling of the necessary fields form, | ||
the klant is created and updated with the writable fields (though not with | ||
the toestemmingZaakNotificatiesAlleenDigitaal by default, which is tested | ||
above). | ||
""" | ||
MockAPIReadPatchData.setUpServices() | ||
mock_api_data = MockAPIReadPatchData().install_mocks(m) | ||
|
||
# reset noise from signals | ||
m.reset_mock() | ||
self.clearTimelineLogs() | ||
|
||
invite = InviteFactory() | ||
|
||
url = reverse("digid-mock:password") | ||
params = { | ||
"acs": reverse("acs"), | ||
"next": f"{reverse('profile:registration_necessary')}?invite={invite.key}", | ||
} | ||
url = f"{url}?{urlencode(params)}" | ||
|
||
data = { | ||
"auth_name": mock_api_data.user_without_klant.bsn, | ||
"auth_pass": "bar", | ||
} | ||
|
||
# post our password to the IDP | ||
response = self.app.post(url, data).follow().follow() | ||
|
||
necessary_form = response.forms["necessary-form"] | ||
|
||
self.assertNotIn("cases_notifications", necessary_form.fields) | ||
self.assertNotIn("messages_notifications", necessary_form.fields) | ||
|
||
necessary_form["email"] = "[email protected]" | ||
necessary_form.submit() | ||
|
||
# klant did not exist, so is created | ||
klant_post_data = mock_api_data.matchers[3].request_history[0].json() | ||
self.assertEqual( | ||
klant_post_data, | ||
{"subjectIdentificatie": {"inpBsn": "665155311"}}, | ||
) | ||
|
||
# klant is patched with email address | ||
klant_patch_data = mock_api_data.matchers[4].request_history[0].json() | ||
self.assertEqual( | ||
klant_patch_data, | ||
{ | ||
"emailadres": "[email protected]", | ||
# Not enabled | ||
# "toestemmingZaakNotificatiesAlleenDigitaal": True, | ||
}, | ||
) | ||
|
||
# ensure klant operations are logged | ||
dump = self.getTimelineLogDump() | ||
for msg in ( | ||
"created klant (87654321) for user", | ||
"patched klant from user profile edit with fields: emailadres", | ||
): | ||
assert msg in dump | ||
|
||
|
||
@override_settings(ROOT_URLCONF="open_inwoner.cms.tests.urls") | ||
class eHerkenningRegistrationTest(AssertRedirectsMixin, WebTest): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,6 +44,11 @@ def __init__(self): | |
email="[email protected]", | ||
phonenumber="0100000000", | ||
) | ||
self.user_without_klant = DigidUserFactory( | ||
email="[email protected]", | ||
phonenumber="0100000000", | ||
bsn="665155311", | ||
) | ||
self.eherkenning_user = eHerkenningUserFactory( | ||
email="[email protected]", | ||
kvk="12345678", | ||
|
@@ -75,6 +80,32 @@ def __init__(self): | |
telefoonnummer="0123456789", | ||
toestemmingZaakNotificatiesAlleenDigitaal=False, | ||
) | ||
self.created_klant_bsn = generate_oas_component_cached( | ||
"kc", | ||
"schemas/Klant", | ||
bronorganisatie="123456789", | ||
klantnummer="87654321", | ||
subjectIdentificatie={ | ||
"inpBsn": "665155311", | ||
}, | ||
url=f"{KLANTEN_ROOT}klant/bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb", | ||
emailadres="[email protected]", | ||
telefoonnummer="0199995544", | ||
toestemmingZaakNotificatiesAlleenDigitaal=False, | ||
) | ||
self.created_klant_bsn_updated = generate_oas_component_cached( | ||
"kc", | ||
"schemas/Klant", | ||
bronorganisatie="123456789", | ||
klantnummer="87654321", | ||
subjectIdentificatie={ | ||
"inpBsn": "665155311", | ||
}, | ||
url=f"{KLANTEN_ROOT}klant/bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb", | ||
emailadres="[email protected]", | ||
telefoonnummer="0199995544", | ||
toestemmingZaakNotificatiesAlleenDigitaal=False, | ||
) | ||
self.klant_eherkenning_old = generate_oas_component_cached( | ||
"kc", | ||
"schemas/Klant", | ||
|
@@ -109,6 +140,21 @@ def install_mocks(self, m) -> "MockAPIReadPatchData": | |
json=self.klant_bsn_updated, | ||
status_code=200, | ||
), | ||
# Create and update flow | ||
m.get( | ||
f"{KLANTEN_ROOT}klanten?subjectNatuurlijkPersoon__inpBsn={self.user_without_klant.bsn}", | ||
json=paginated_response([]), | ||
), | ||
m.post( | ||
f"{KLANTEN_ROOT}klanten", | ||
json=self.created_klant_bsn, | ||
status_code=201, | ||
), | ||
m.patch( | ||
f"{KLANTEN_ROOT}klant/bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb", | ||
json=self.created_klant_bsn_updated, | ||
status_code=200, | ||
), | ||
] | ||
return self | ||
|
||
|