mirror of https://github.com/zulip/zulip.git
create_confirmation_link: Turn some args into kwargs-only.
This commit is contained in:
parent
3205f680c1
commit
bea9205c4a
|
@ -84,9 +84,13 @@ def get_object_from_key(
|
|||
def create_confirmation_link(
|
||||
obj: Union[Realm, HasRealmObject, OptionalHasRealmObject],
|
||||
confirmation_type: int,
|
||||
*,
|
||||
validity_in_days: Optional[int] = None,
|
||||
url_args: Mapping[str, str] = {},
|
||||
) -> str:
|
||||
# validity_in_days is an override for the default values which are
|
||||
# determined by the confirmation_type - its main purpose is for use
|
||||
# in tests which may want to have control over the exact expiration time.
|
||||
key = generate_key()
|
||||
realm = None
|
||||
if isinstance(obj, Realm):
|
||||
|
|
|
@ -1521,7 +1521,9 @@ class SocialAuthBase(DesktopFlowTestingLib, ZulipTestCase):
|
|||
multiuse_obj = MultiuseInvite.objects.create(realm=realm, referred_by=referrer)
|
||||
multiuse_obj.streams.set(streams)
|
||||
validity_in_days = 2
|
||||
create_confirmation_link(multiuse_obj, Confirmation.MULTIUSE_INVITE, validity_in_days)
|
||||
create_confirmation_link(
|
||||
multiuse_obj, Confirmation.MULTIUSE_INVITE, validity_in_days=validity_in_days
|
||||
)
|
||||
multiuse_confirmation = Confirmation.objects.all().last()
|
||||
assert multiuse_confirmation is not None
|
||||
multiuse_object_key = multiuse_confirmation.confirmation_key
|
||||
|
@ -4053,7 +4055,9 @@ class GoogleAuthBackendTest(SocialAuthBase):
|
|||
multiuse_obj = MultiuseInvite.objects.create(realm=realm, referred_by=referrer)
|
||||
multiuse_obj.streams.set(streams)
|
||||
validity_in_days = 2
|
||||
create_confirmation_link(multiuse_obj, Confirmation.MULTIUSE_INVITE, validity_in_days)
|
||||
create_confirmation_link(
|
||||
multiuse_obj, Confirmation.MULTIUSE_INVITE, validity_in_days=validity_in_days
|
||||
)
|
||||
multiuse_confirmation = Confirmation.objects.all().last()
|
||||
assert multiuse_confirmation is not None
|
||||
multiuse_object_key = multiuse_confirmation.confirmation_key
|
||||
|
|
|
@ -1927,7 +1927,9 @@ so we didn't send them an invitation. We did send invitations to everyone else!"
|
|||
invitee = PreregistrationUser.objects.get(email=data["email"])
|
||||
referrer = self.example_user(referrer_name)
|
||||
validity_in_days = 2
|
||||
link = create_confirmation_link(invitee, Confirmation.INVITATION, validity_in_days)
|
||||
link = create_confirmation_link(
|
||||
invitee, Confirmation.INVITATION, validity_in_days=validity_in_days
|
||||
)
|
||||
context = common_context(referrer)
|
||||
context.update(
|
||||
activate_url=link,
|
||||
|
@ -2277,7 +2279,9 @@ class InvitationsTestCase(InviteUserBase):
|
|||
email="TestThree@zulip.com", referred_by=user_profile, status=active_value
|
||||
)
|
||||
prereg_user_three.save()
|
||||
create_confirmation_link(prereg_user_three, Confirmation.INVITATION, invite_expires_in_days)
|
||||
create_confirmation_link(
|
||||
prereg_user_three, Confirmation.INVITATION, validity_in_days=invite_expires_in_days
|
||||
)
|
||||
|
||||
do_create_multiuse_invite_link(
|
||||
hamlet, PreregistrationUser.INVITE_AS["MEMBER"], invite_expires_in_days
|
||||
|
@ -2396,7 +2400,9 @@ class InvitationsTestCase(InviteUserBase):
|
|||
referred_by=self.example_user("hamlet"), realm=zulip_realm
|
||||
)
|
||||
validity_in_days = 2
|
||||
create_confirmation_link(multiuse_invite, Confirmation.MULTIUSE_INVITE, validity_in_days)
|
||||
create_confirmation_link(
|
||||
multiuse_invite, Confirmation.MULTIUSE_INVITE, validity_in_days=validity_in_days
|
||||
)
|
||||
result = self.client_delete("/json/invites/multiuse/" + str(multiuse_invite.id))
|
||||
self.assertEqual(result.status_code, 200)
|
||||
self.assertIsNone(MultiuseInvite.objects.filter(id=multiuse_invite.id).first())
|
||||
|
@ -2411,7 +2417,9 @@ class InvitationsTestCase(InviteUserBase):
|
|||
invited_as=PreregistrationUser.INVITE_AS["REALM_OWNER"],
|
||||
)
|
||||
validity_in_days = 2
|
||||
create_confirmation_link(multiuse_invite, Confirmation.MULTIUSE_INVITE, validity_in_days)
|
||||
create_confirmation_link(
|
||||
multiuse_invite, Confirmation.MULTIUSE_INVITE, validity_in_days=validity_in_days
|
||||
)
|
||||
error_result = self.client_delete("/json/invites/multiuse/" + str(multiuse_invite.id))
|
||||
self.assert_json_error(error_result, "Must be an organization owner")
|
||||
|
||||
|
@ -2427,7 +2435,7 @@ class InvitationsTestCase(InviteUserBase):
|
|||
)
|
||||
validity_in_days = 2
|
||||
create_confirmation_link(
|
||||
multiuse_invite_in_mit, Confirmation.MULTIUSE_INVITE, validity_in_days
|
||||
multiuse_invite_in_mit, Confirmation.MULTIUSE_INVITE, validity_in_days=validity_in_days
|
||||
)
|
||||
error_result = self.client_delete(
|
||||
"/json/invites/multiuse/" + str(multiuse_invite_in_mit.id)
|
||||
|
@ -2669,7 +2677,9 @@ class MultiuseInviteTest(ZulipTestCase):
|
|||
date_sent = timezone_now()
|
||||
validity_in_days = 2
|
||||
with patch("confirmation.models.timezone_now", return_value=date_sent):
|
||||
return create_confirmation_link(invite, Confirmation.MULTIUSE_INVITE, validity_in_days)
|
||||
return create_confirmation_link(
|
||||
invite, Confirmation.MULTIUSE_INVITE, validity_in_days=validity_in_days
|
||||
)
|
||||
|
||||
def check_user_able_to_register(self, email: str, invite_link: str) -> None:
|
||||
password = "password"
|
||||
|
|
Loading…
Reference in New Issue