示例#1
0
 def test_successful_invite_user_with_name_and_normal_one(self):
     # type: () -> None
     """
     A call to /json/invite_users with valid parameters causes an invitation
     email to be sent.
     """
     self.login("*****@*****.**")
     email = "*****@*****.**"
     email2 = "*****@*****.**"
     invitee = "Alice Test <{}>, {}".format(email, email2)
     self.assert_json_success(self.invite(invitee, ["Denmark"]))
     self.assertTrue(find_key_by_email(email))
     self.assertTrue(find_key_by_email(email2))
     self.check_sent_emails([email, email2])
示例#2
0
    def submit_reg_form_for_user(self,
                                 email,
                                 password,
                                 realm_name="Zulip Test",
                                 realm_subdomain="zuliptest",
                                 realm_org_type=Realm.COMMUNITY,
                                 from_confirmation='',
                                 full_name=None,
                                 timezone=u'',
                                 **kwargs):
        # type: (Text, Text, Optional[Text], Optional[Text], int, Optional[Text], Optional[Text], Optional[Text], **Any) -> HttpResponse
        """
        Stage two of the two-step registration process.

        If things are working correctly the account should be fully
        registered after this call.

        You can pass the HTTP_HOST variable for subdomains via kwargs.
        """
        if full_name is None:
            full_name = email.replace("@", "_")
        return self.client_post(
            '/accounts/register/', {
                'full_name': full_name,
                'password': password,
                'realm_name': realm_name,
                'realm_subdomain': realm_subdomain,
                'key': find_key_by_email(email),
                'realm_org_type': realm_org_type,
                'timezone': timezone,
                'terms': True,
                'from_confirmation': from_confirmation
            }, **kwargs)
示例#3
0
    def submit_reg_form_for_user(self, email, password, realm_name="Zulip Test",
                                 realm_subdomain="zuliptest", realm_org_type=Realm.COMMUNITY,
                                 from_confirmation='', full_name=None, timezone=u'', **kwargs):
        # type: (Text, Text, Optional[Text], Optional[Text], int, Optional[Text], Optional[Text], Optional[Text], **Any) -> HttpResponse
        """
        Stage two of the two-step registration process.

        If things are working correctly the account should be fully
        registered after this call.

        You can pass the HTTP_HOST variable for subdomains via kwargs.
        """
        if full_name is None:
            full_name = email.replace("@", "_")
        return self.client_post('/accounts/register/',
                                {'full_name': full_name,
                                 'password': password,
                                 'realm_name': realm_name,
                                 'realm_subdomain': realm_subdomain,
                                 'key': find_key_by_email(email),
                                 'realm_org_type': realm_org_type,
                                 'timezone': timezone,
                                 'terms': True,
                                 'from_confirmation': from_confirmation},
                                **kwargs)
示例#4
0
    def submit_reg_form_for_user(
            self, email: str, password: str,
            realm_name: Optional[str]="Zulip Test",
            realm_subdomain: Optional[str]="zuliptest",
            from_confirmation: Optional[str]='', full_name: Optional[str]=None,
            timezone: Optional[str]='', realm_in_root_domain: Optional[str]=None,
            default_stream_groups: Optional[List[str]]=[],
            source_realm: Optional[str]='', **kwargs: Any) -> HttpResponse:
        """
        Stage two of the two-step registration process.

        If things are working correctly the account should be fully
        registered after this call.

        You can pass the HTTP_HOST variable for subdomains via kwargs.
        """
        if full_name is None:
            full_name = email.replace("@", "_")

        payload = {
            'full_name': full_name,
            'password': password,
            'realm_name': realm_name,
            'realm_subdomain': realm_subdomain,
            'key': find_key_by_email(email),
            'timezone': timezone,
            'terms': True,
            'from_confirmation': from_confirmation,
            'default_stream_group': default_stream_groups,
            'source_realm': source_realm,
        }
        if realm_in_root_domain is not None:
            payload['realm_in_root_domain'] = realm_in_root_domain
        return self.client_post('/accounts/register/', payload, **kwargs)
示例#5
0
    def submit_reg_form_for_user(
            self, email: str, password: str,
            realm_name: Optional[str]="Zulip Test",
            realm_subdomain: Optional[str]="zuliptest",
            from_confirmation: Optional[str]='', full_name: Optional[str]=None,
            timezone: Optional[str]='', realm_in_root_domain: Optional[str]=None,
            default_stream_groups: Optional[List[str]]=[],
            source_realm: Optional[str]='', **kwargs: Any) -> HttpResponse:
        """
        Stage two of the two-step registration process.

        If things are working correctly the account should be fully
        registered after this call.

        You can pass the HTTP_HOST variable for subdomains via kwargs.
        """
        if full_name is None:
            full_name = email.replace("@", "_")
        payload = {
            'full_name': full_name,
            'password': password,
            'realm_name': realm_name,
            'realm_subdomain': realm_subdomain,
            'key': find_key_by_email(email),
            'timezone': timezone,
            'terms': True,
            'from_confirmation': from_confirmation,
            'default_stream_group': default_stream_groups,
            'source_realm': source_realm,
        }
        if realm_in_root_domain is not None:
            payload['realm_in_root_domain'] = realm_in_root_domain
        return self.client_post('/accounts/register/', payload, **kwargs)
示例#6
0
    def test_invite_user_signup_initial_history(self):
        # type: () -> None
        """
        Test that a new user invited to a stream receives some initial
        history but only from public streams.
        """
        self.login("*****@*****.**")
        user_profile = get_user_profile_by_email("*****@*****.**")
        private_stream_name = "Secret"
        (stream, _) = create_stream_if_needed(user_profile.realm, private_stream_name, invite_only=True)
        do_add_subscription(user_profile, stream)
        public_msg_id = self.send_message("*****@*****.**", "Denmark", Recipient.STREAM,
                                          "Public topic", "Public message")
        secret_msg_id = self.send_message("*****@*****.**", private_stream_name, Recipient.STREAM,
                                          "Secret topic", "Secret message")
        invitee = "*****@*****.**"
        self.assert_json_success(self.invite(invitee, [private_stream_name, "Denmark"]))
        self.assertTrue(find_key_by_email(invitee))

        self.submit_reg_form_for_user("alice-test", "password")
        invitee_profile = get_user_profile_by_email(invitee)
        invitee_msg_ids = [um.message_id for um in
                           UserMessage.objects.filter(user_profile=invitee_profile)]
        self.assertTrue(public_msg_id in invitee_msg_ids)
        self.assertFalse(secret_msg_id in invitee_msg_ids)
示例#7
0
    def test_invite_user_signup_initial_history(self):
        """
        Test that a new user invited to a stream receives some initial
        history but only from public streams.
        """
        self.login("*****@*****.**")
        user_profile = get_user_profile_by_email("*****@*****.**")
        private_stream_name = "Secret"
        (stream, _) = create_stream_if_needed(user_profile.realm,
                                              private_stream_name,
                                              invite_only=True)
        do_add_subscription(user_profile, stream)
        public_msg_id = self.send_message("*****@*****.**", "Denmark",
                                          Recipient.STREAM, "Public topic",
                                          "Public message")
        secret_msg_id = self.send_message("*****@*****.**",
                                          private_stream_name,
                                          Recipient.STREAM, "Secret topic",
                                          "Secret message")
        invitee = "*****@*****.**"
        self.assert_json_success(
            self.invite(invitee, [private_stream_name, "Denmark"]))
        self.assertTrue(find_key_by_email(invitee))

        self.submit_reg_form_for_user("alice-test", "password")
        invitee_profile = get_user_profile_by_email(invitee)
        invitee_msg_ids = [
            um.message_id
            for um in UserMessage.objects.filter(user_profile=invitee_profile)
        ]
        self.assertTrue(public_msg_id in invitee_msg_ids)
        self.assertFalse(secret_msg_id in invitee_msg_ids)
示例#8
0
    def submit_reg_form_for_user(self,
                                 username,
                                 password,
                                 domain="zulip.com",
                                 realm_name="Zulip Test",
                                 realm_subdomain="zuliptest",
                                 realm_org_type=Realm.COMMUNITY,
                                 from_confirmation='',
                                 **kwargs):
        # type: (text_type, text_type, text_type, Optional[text_type], Optional[text_type], int, Optional[text_type], **Any) -> HttpResponse
        """
        Stage two of the two-step registration process.

        If things are working correctly the account should be fully
        registered after this call.

        You can pass the HTTP_HOST variable for subdomains via kwargs.
        """
        return self.client_post(
            '/accounts/register/', {
                'full_name': username,
                'password': password,
                'realm_name': realm_name,
                'realm_subdomain': realm_subdomain,
                'key': find_key_by_email(username + '@' + domain),
                'realm_org_type': realm_org_type,
                'terms': True,
                'from_confirmation': from_confirmation
            }, **kwargs)
示例#9
0
 def test_successful_invite_user(self):
     """
     A call to /json/invite_users with valid parameters causes an invitation
     email to be sent.
     """
     self.login("*****@*****.**")
     invitee = "*****@*****.**"
     self.assert_json_success(self.invite(invitee, ["Denmark"]))
     self.assertTrue(find_key_by_email(invitee))
     self.check_sent_emails([invitee])
示例#10
0
 def test_successful_invite_user(self):
     """
     A call to /json/invite_users with valid parameters causes an invitation
     email to be sent.
     """
     self.login("*****@*****.**")
     invitee = "*****@*****.**"
     self.assert_json_success(self.invite(invitee, ["Denmark"]))
     self.assertTrue(find_key_by_email(invitee))
     self.check_sent_emails([invitee])
示例#11
0
    def test_multi_user_invite(self):
        """
        Invites multiple users with a variety of delimiters.
        """
        self.login("*****@*****.**")
        # Intentionally use a weird string.
        self.assert_json_success(self.invite(
"""[email protected],     [email protected],
[email protected]


[email protected]""", ["Denmark"]))
        for user in ("bob", "carol", "dave", "earl"):
            self.assertTrue(find_key_by_email("*****@*****.**" % (user,)))
        self.check_sent_emails(["*****@*****.**", "*****@*****.**",
                                "*****@*****.**", "*****@*****.**"])
示例#12
0
    def test_multi_user_invite(self):
        """
        Invites multiple users with a variety of delimiters.
        """
        self.login("*****@*****.**")
        # Intentionally use a weird string.
        self.assert_json_success(self.invite(
"""[email protected],     [email protected],
[email protected]


[email protected]""", ["Denmark"]))
        for user in ("bob", "carol", "dave", "earl"):
            self.assertTrue(find_key_by_email("*****@*****.**" % (user,)))
        self.check_sent_emails(["*****@*****.**", "*****@*****.**",
                                "*****@*****.**", "*****@*****.**"])
示例#13
0
    def submit_reg_form_for_user(
        self,
        email: str,
        password: str,
        realm_name: str = "Zulip Test",
        realm_subdomain: str = "zuliptest",
        from_confirmation: str = "",
        full_name: Optional[str] = None,
        timezone: str = "",
        realm_in_root_domain: Optional[str] = None,
        default_stream_groups: Sequence[str] = [],
        source_realm: str = "",
        key: Optional[str] = None,
        **kwargs: Any,
    ) -> HttpResponse:
        """
        Stage two of the two-step registration process.

        If things are working correctly the account should be fully
        registered after this call.

        You can pass the HTTP_HOST variable for subdomains via kwargs.
        """
        if full_name is None:
            full_name = email.replace("@", "_")
        payload = {
            "full_name": full_name,
            "password": password,
            "realm_name": realm_name,
            "realm_subdomain": realm_subdomain,
            "key": key if key is not None else find_key_by_email(email),
            "timezone": timezone,
            "terms": True,
            "from_confirmation": from_confirmation,
            "default_stream_group": default_stream_groups,
            "source_realm": source_realm,
        }
        if realm_in_root_domain is not None:
            payload["realm_in_root_domain"] = realm_in_root_domain
        return self.client_post("/accounts/register/", payload, **kwargs)
示例#14
0
    def submit_reg_form_for_user(self, username, password, domain="zulip.com",
                                 realm_name="Zulip Test", realm_subdomain="zuliptest",
                                 realm_org_type=Realm.COMMUNITY,
                                 from_confirmation='', **kwargs):
        # type: (text_type, text_type, text_type, Optional[text_type], Optional[text_type], int, Optional[text_type], **Any) -> HttpResponse
        """
        Stage two of the two-step registration process.

        If things are working correctly the account should be fully
        registered after this call.

        You can pass the HTTP_HOST variable for subdomains via kwargs.
        """
        return self.client_post('/accounts/register/',
                                {'full_name': username, 'password': password,
                                 'realm_name': realm_name,
                                 'realm_subdomain': realm_subdomain,
                                 'key': find_key_by_email(username + '@' + domain),
                                 'realm_org_type': realm_org_type,
                                 'terms': True,
                                 'from_confirmation': from_confirmation},
                                **kwargs)