create_preregistration_user: Add additional hardening assertion.

TestMaybeSendToRegistration needs tweaking here, because it wasn't
setting the subdomain for the dummy request, so
maybe_send_to_registration was actually running with realm=None, which
is not right for these tests.

Also, test_sso_only_when_preregistration_user_exists was creating
PreregistrationUser without setting the realm, which was also incorrect.
This commit is contained in:
Mateusz Mandera
2022-01-27 23:32:49 +01:00
committed by Alex Vandiver
parent 7b795b6338
commit 3c5ea830a9
2 changed files with 6 additions and 3 deletions

View File

@@ -121,6 +121,7 @@ def create_preregistration_user(
full_name_validated: bool = False,
) -> PreregistrationUser:
assert not (realm_creation and realm is not None)
assert not (realm is None and not realm_creation)
return PreregistrationUser.objects.create(
email=email,