Ejemplo n.º 1
0
    def test_username_characters(self):
        """Verify usernames can have digits/symbols, but nothing too
        insane.

        """
        email = "*****@*****.**"
        username = "******"
        d = dict(assertion=self.fake_assertion)
        with browserid_mock.mock_browserid(email):
            self.client.post(reverse("browserid_login"), d, follow=True)

        d = dict(email=email, username=username, full_name="Akaaaaaaash Desaaaaaaai", country="pl", optin=True)
        with browserid_mock.mock_browserid(email):
            r = self.client.post(reverse("register"), d)
        eq_(r.status_code, 302, ("Registration flow should finish with a redirect."))
        u = User.objects.get(email=d["email"])
        eq_(u.username, username, 'Username should be set to "%s".' % username)

        r = self.mozillian_client.get(reverse("profile", args=[username]), follow=True)
        eq_(r.status_code, 200)
        eq_(r.context["profile"].user_id, u.id)

        # Now test a username with even weirder characters that we don't allow.
        bad_user_email = "*****@*****.**"
        bad_username = "******"
        d = dict(assertion=self.fake_assertion)
        with browserid_mock.mock_browserid(email):
            self.client.post(reverse("browserid_login"), d, follow=True)

        d = dict(email=bad_user_email, username=bad_username, full_name="Akaaaaaaash Desaaaaaaai", optin=True)
        with browserid_mock.mock_browserid(email):
            r = self.client.post(reverse("register"), d)
        eq_(r.status_code, 302, ("Registration flow should fail; username is bad."))
        assert not User.objects.filter(email=d["email"]), "User shouldn't exist; username was bad."
Ejemplo n.º 2
0
    def test_repeat_username(self):
        """Verify one cannot repeat email adresses."""
        register = dict(username="******", full_name="Akaaaaaaash Desaaaaaaai", country="pl", optin=True)

        # Create first user
        email1 = "*****@*****.**"
        register.update(email=email1)
        d = dict(assertion=self.fake_assertion)
        with browserid_mock.mock_browserid(email1):
            self.client.post(reverse("browserid_login"), d, follow=True)

        with browserid_mock.mock_browserid(email1):
            self.client.post(reverse("register"), register, follow=True)

        self.client.logout()
        # Create a different user
        email2 = "*****@*****.**"
        register.update(email=email2)
        with browserid_mock.mock_browserid(email2):
            self.client.post(reverse("browserid_login"), d, follow=True)

        with browserid_mock.mock_browserid(email2):
            r = self.client.post(reverse("register"), register, follow=True)

        # Make sure we can't use the same username twice
        assert r.context["user_form"].errors, "Form should throw errors."
Ejemplo n.º 3
0
    def redeem_invite(self, invite, email):
        """Given an invite_url go to it and redeem an invite."""
        # Lets make sure we have a clean slate
        self.client.logout()
        assert not User.objects.filter(email=email), (
            "User shouldn't be in database.")

        # We need to store the invite code in the session
        self.client.get(invite.get_url(), follow=True)

        # BrowserID needs an assertion not to be whiney
        d = dict(assertion=self.fake_assertion)
        with mock_browserid(email):
            self.client.post(reverse('browserid_verify'), d, follow=True)

        # Now let's register
        d = dict(first_name='Akaaaaaaash',
                 last_name='Desaaaaaaai',
                 username='******',
                 optin=True)
        with mock_browserid(email):
            self.client.post(reverse('register'), d, follow=True)

        # Return the New Users Profile
        invited_user_profile = User.objects.get(email=email).get_profile()
        return invited_user_profile
Ejemplo n.º 4
0
    def redeem_invite(self, invite, email):
        """Given an invite_url go to it and redeem an invite."""
        # Lets make sure we have a clean slate
        self.client.logout()
        assert not User.objects.filter(email=email), (
            "User shouldn't be in database.")

        # We need to store the invite code in the session
        self.client.get(invite.get_url(), follow=True)

        # BrowserID needs an assertion not to be whiney
        d = dict(assertion=self.fake_assertion)
        with mock_browserid(email):
            self.client.post(reverse('browserid_verify'), d, follow=True)

        # Now let's register
        d = dict(full_name='Desaaaaaaai',
                 username='******',
                 optin=True)
        with mock_browserid(email):
            self.client.post(reverse('register'), d, follow=True)

        # Return the New Users Profile
        invited_user_profile = User.objects.get(email=email).get_profile()
        return invited_user_profile
Ejemplo n.º 5
0
    def test_username(self):
        """Test that we can submit a perfectly cromulent username.

        We verify that /:username then works as well.

        """
        email = '*****@*****.**'
        d = dict(assertion=self.fake_assertion)
        with browserid_mock.mock_browserid(email):
            self.client.post(reverse('browserid_verify'), d, follow=True)
        d = dict(email=email,
                 username='******',
                 full_name='Akaaaaaaash Desaaaaaaai',
                 country='pl',
                 optin=True)
        with browserid_mock.mock_browserid(email):
            r = self.client.post(reverse('register'), d)
        eq_(r.status_code, 302, "Problems if we didn't redirect...")
        u = User.objects.filter(email=d['email'])[0]
        eq_(u.username, 'mrfusion', "Username didn't get set.")

        r = self.mozillian_client.get(reverse('profile', args=['mrfusion']),
                                      follow=True)
        eq_(r.status_code, 200)
        eq_(r.context['profile'].user_id, u.id)
Ejemplo n.º 6
0
    def test_username(self):
        """Test that we can submit a perfectly cromulent username.

        We verify that /:username then works as well.

        """
        email = '*****@*****.**'
        d = dict(assertion=self.fake_assertion)
        with browserid_mock.mock_browserid(email):
            self.client.post(reverse('browserid_verify'), d, follow=True)
        d = dict(email=email,
                 username='******',
                 full_name='Akaaaaaaash Desaaaaaaai',
                 country='pl',
                 optin=True)
        with browserid_mock.mock_browserid(email):
            r = self.client.post(reverse('register'), d)
        eq_(r.status_code, 302, "Problems if we didn't redirect...")
        u = User.objects.filter(email=d['email'])[0]
        eq_(u.username, 'mrfusion', "Username didn't get set.")

        r = self.mozillian_client.get(reverse('profile', args=['mrfusion']),
                                              follow=True)
        eq_(r.status_code, 200)
        eq_(r.context['profile'].user_id, u.id)
Ejemplo n.º 7
0
    def test_bad_username(self):
        """'about' is a terrible username, as are its silly friends.

        Let's make some stop words *and* analyze the routing system,
        whenever someone sets their username and verify that they can't
        be 'about' or 'help' or anything that is in use.
        """
        email = '*****@*****.**'
        badnames = UsernameBlacklist.objects.all().values_list('value',
                                                               flat=True)
        # BrowserID needs an assertion not to be whiney
        d = dict(assertion=self.fake_assertion)
        with browserid_mock.mock_browserid(email):
            self.client.post(reverse('browserid_verify'), d, follow=True)

        for name in badnames:
            d = dict(email=email,
                     username=name,
                     full_name='Akaaaaaaash Desaaaaaaai',
                     optin=True)
            with browserid_mock.mock_browserid(email):
                r = self.client.post(reverse('register'), d)

            eq_(r.status_code, 200,
                'This form should fail for "%s", and say so.' % name)
            assert r.context['user_form'].errors, (
                "Didn't raise errors for %s" % name)
Ejemplo n.º 8
0
    def test_repeat_username(self):
        """Verify one cannot repeat email adresses."""
        register = dict(username='******',
                        full_name='Akaaaaaaash Desaaaaaaai',
                        optin=True)

        # Create first user
        email1 = '*****@*****.**'
        register.update(email=email1)
        d = dict(assertion=self.fake_assertion)
        with browserid_mock.mock_browserid(email1):
            self.client.post(reverse('browserid_verify'), d, follow=True)

        with browserid_mock.mock_browserid(email1):
            self.client.post(reverse('register'), register, follow=True)

        self.client.logout()
        # Create a different user
        email2 = '*****@*****.**'
        register.update(email=email2)
        with browserid_mock.mock_browserid(email2):
            self.client.post(reverse('browserid_verify'), d, follow=True)

        with browserid_mock.mock_browserid(email2):
            r = self.client.post(reverse('register'), register, follow=True)

        # Make sure we can't use the same username twice
        assert r.context['user_form'].errors, "Form should throw errors."
Ejemplo n.º 9
0
    def test_login(self):
        """Given an invite_url go to it and redeem an invite."""
        # Lettuce make sure we have a clean slate

        info = dict(full_name='Akaaaaaaash Desaaaaaaai', optin=True)
        self.client.logout()
        u = User.objects.create(username='******', email=self.email)
        p = u.get_profile()

        p.full_name = info['full_name']
        u.save()
        p.save()

        # BrowserID needs an assertion not to be whiney
        d = dict(assertion='tofu')
        with browserid_mock.mock_browserid(self.email):
            r = self.client.post(reverse('browserid_verify'), d, follow=True)

        eq_(r.status_code, 200)

        # Now let's register
        with browserid_mock.mock_browserid(self.email):
            r = self.client.post(reverse('register'), info, follow=True)

        eq_(r.status_code, 200)
Ejemplo n.º 10
0
    def test_bad_username(self):
        """'about' is a terrible username, as are its silly friends.

        Let's make some stop words *and* analyze the routing system,
        whenever someone sets their username and verify that they can't
        be 'about' or 'help' or anything that is in use.
        """
        email = '*****@*****.**'
        badnames = UsernameBlacklist.objects.all().values_list('value',
                                                               flat=True)
        # BrowserID needs an assertion not to be whiney
        d = dict(assertion=self.fake_assertion)
        with browserid_mock.mock_browserid(email):
            self.client.post(reverse('browserid_verify'), d, follow=True)

        for name in badnames:
            d = dict(email=email,
                     username=name,
                     full_name='Akaaaaaaash Desaaaaaaai',
                     optin=True)
            with browserid_mock.mock_browserid(email):
                r = self.client.post(reverse('register'), d)

            eq_(r.status_code, 200,
                'This form should fail for "%s", and say so.' % name)
            assert r.context['user_form'].errors, (
                "Didn't raise errors for %s" % name)
Ejemplo n.º 11
0
    def test_mozillacom_registration(self):
        """Verify @mozilla.com users are auto-vouched and marked "staff"."""

        d = dict(assertion=self.fake_assertion)
        with browserid_mock.mock_browserid('*****@*****.**'):
            self.client.post(reverse('browserid_login'), d, follow=True)

        d = self.data_privacy_fields.copy()
        d.update(dict(username='******',
                 email='*****@*****.**',
                 full_name='Akaaaaaaash Desaaaaaaai',
                 country='pl',
                 optin=True))
        with browserid_mock.mock_browserid('*****@*****.**'):
            r = self.client.post(reverse('profile.edit'), d, follow=True)

        doc = pq(r.content)

        assert r.context['user'].get_profile().is_vouched, (
                "Moz.com should be auto-vouched")

        assert not doc('#pending-approval'), (
                'Moz.com profile page should not having pending vouch div.')

        assert r.context['user'].get_profile().groups.filter(name='staff'), (
                'Moz.com should belong to the "staff" group.')
Ejemplo n.º 12
0
        def test_login(self):
            """Given an invite_url go to it and redeem an invite."""
            # Lettuce make sure we have a clean slate

            info = self.data_privacy_fields.copy()
            info.update(full_name='Akaaaaaaash Desaaaaaaai', country='pl',
                        username='******', optin=True)
            self.client.logout()
            u = User.objects.create(username='******', email=self.email)
            p = u.get_profile()

            p.full_name = info['full_name']
            u.save()
            p.save()

            # BrowserID needs an assertion not to be whiney
            d = dict(assertion='tofu')
            with browserid_mock.mock_browserid(self.email):
                r = self.client.post(reverse('browserid_login'),
                                     d, follow=True)

            eq_(r.status_code, 200)

            # Now let's register
            with browserid_mock.mock_browserid(self.email):
                r = self.client.post(reverse('profile.edit'), info, follow=True)

            eq_(r.status_code, 200)
Ejemplo n.º 13
0
    def test_repeat_username(self):
        """Verify one cannot repeat email adresses."""
        register = self.data_privacy_fields.copy()
        register.update(username='******',
                        full_name='Akaaaaaaash Desaaaaaaai',
                        country='pl',
                        optin=True)

        # Create first user
        email1 = '*****@*****.**'
        register.update(email=email1)
        d = dict(assertion=self.fake_assertion)
        with browserid_mock.mock_browserid(email1):
            self.client.post(reverse('browserid_login'), d, follow=True)

        with browserid_mock.mock_browserid(email1):
            self.client.post(reverse('profile.edit'), register, follow=True)

        self.client.logout()
        # Create a different user
        email2 = '*****@*****.**'
        register.update(email=email2)
        with browserid_mock.mock_browserid(email2):
            self.client.post(reverse('browserid_login'), d, follow=True)

        with browserid_mock.mock_browserid(email2):
            r = self.client.post(reverse('profile.edit'), register, follow=True)

        # Make sure we can't use the same username twice
        assert r.context['user_form'].errors, "Form should throw errors."
Ejemplo n.º 14
0
    def test_login(self):
        """Given an invite_url go to it and redeem an invite."""
        # Lettuce make sure we have a clean slate

        info = dict(full_name="Akaaaaaaash Desaaaaaaai", optin=True)
        self.client.logout()
        u = User.objects.create(username="******", email=self.email)
        p = u.get_profile()

        p.full_name = info["full_name"]
        u.save()
        p.save()

        # BrowserID needs an assertion not to be whiney
        d = dict(assertion="tofu")
        with browserid_mock.mock_browserid(self.email):
            r = self.client.post(reverse("browserid_login"), d, follow=True)

        eq_(r.status_code, 200)

        # Now let's register
        with browserid_mock.mock_browserid(self.email):
            r = self.client.post(reverse("register"), info, follow=True)

        eq_(r.status_code, 200)
Ejemplo n.º 15
0
    def test_plus_signs(self):
        email = "*****@*****.**"
        d = dict(assertion=self.fake_assertion)
        with browserid_mock.mock_browserid(email):
            self.client.post(reverse("browserid_login"), d, follow=True)

        d = dict(username="******", email=email, full_name="Akaaaaaaash Desaaaaaaai", optin=True)
        with browserid_mock.mock_browserid(email):
            self.client.post(reverse("register"), d, follow=True)

        assert User.objects.filter(email=d["email"])
Ejemplo n.º 16
0
    def test_plus_signs(self):
        email = '*****@*****.**'
        d = dict(assertion=self.fake_assertion)
        with browserid_mock.mock_browserid(email):
            self.client.post(reverse('browserid_verify'), d, follow=True)

        d = dict(username='******',
                 email=email,
                 full_name='Akaaaaaaash Desaaaaaaai',
                 optin=True)
        with browserid_mock.mock_browserid(email):
            self.client.post(reverse('register'), d, follow=True)

        assert User.objects.filter(email=d['email'])
Ejemplo n.º 17
0
    def test_plus_signs(self):
        email = '*****@*****.**'
        d = dict(assertion=self.fake_assertion)
        with browserid_mock.mock_browserid(email):
            self.client.post(reverse('browserid_verify'), d, follow=True)

        d = dict(username='******',
                 email=email,
                 full_name='Akaaaaaaash Desaaaaaaai',
                 optin=True)
        with browserid_mock.mock_browserid(email):
            self.client.post(reverse('register'), d, follow=True)

        assert User.objects.filter(email=d['email'])
Ejemplo n.º 18
0
    def test_username_characters(self):
        """Verify usernames can have digits/symbols, but nothing too
        insane.

        """
        email = '*****@*****.**'
        username = '******'
        d = dict(assertion=self.fake_assertion)
        with browserid_mock.mock_browserid(email):
            self.client.post(reverse('browserid_login'), d, follow=True)

        d = self.data_privacy_fields.copy()
        d.update(email=email,
                 username=username,
                 full_name='Akaaaaaaash Desaaaaaaai',
                 country='pl',
                 optin=True)
        with browserid_mock.mock_browserid(email):
            r = self.client.post(reverse('profile.edit'), d)
        eq_(r.status_code, 302, (
                'Registration flow should finish with a redirect.'))
        u = User.objects.get(email=d['email'])
        eq_(u.username, username, 'Username should be set to "%s".' % username)

        r = self.mozillian_client.get(reverse('profile', args=[username]),
                                              follow=True)
        eq_(r.status_code, 200)
        eq_(r.context['profile'].user_id, u.id)

        # Now test a username with even weirder characters that we don't allow.
        bad_user_email = '*****@*****.**'
        bad_username = '******'
        d = dict(assertion=self.fake_assertion)
        with browserid_mock.mock_browserid(email):
            self.client.post(reverse('browserid_login'), d, follow=True)

        d = self.data_privacy_fields.copy()
        d.update(email=bad_user_email,
                 username=bad_username,
                 country='pl',
                 full_name='Akaaaaaaash Desaaaaaaai',
                 optin=True)
        with browserid_mock.mock_browserid(email):
            r = self.client.post(reverse('profile.edit'), d, follow=True)
        eq_(r.status_code, 400, (
                'Registration flow should fail; username is bad.'))
        assert not User.objects.filter(email=d['email']), (
                "User shouldn't exist; username was bad.")
Ejemplo n.º 19
0
    def invite_without_message(self, email):
        """
        Make sure we can send an invite without the optional personal
        message and that the template doesn't use Personal message:
        when there's no personal message.
        """
        #login as fake user.
        d = dict(assertion=self.fake_assertion)
        with mock_browserid(self.fake_email3):
            self.client.post(reverse('browserid_verify'), d, follow=True)

        # Send an invite without a personal message.
        url = reverse('invite')
        d = dict(recipient=email)
        r = self.mozillian_client.post(url, d, follow=True)
        eq_(r.status_code, 200)
        assert ('%s has been invited to Mozillians.' % email
                in pq(r.content)('div.alert-success').text())

        # See that the email was sent.
        eq_(len(mail.outbox), 2)

        # Note it's mail.outbox[1] here because we're sending another
        # message in a previous test.
        assert not ("Personal message" in mail.outbox[1].body)
Ejemplo n.º 20
0
    def test_plus_signs(self):
        email = '*****@*****.**'
        d = dict(assertion=self.fake_assertion)
        with browserid_mock.mock_browserid(email):
            self.client.post(reverse('browserid_login'), d, follow=True)

        d = self.data_privacy_fields.copy()
        d.update(dict(username='******',
                 email=email,
                 full_name='Akaaaaaaash Desaaaaaaai',
                 country='pl',
                 optin=True))
        with browserid_mock.mock_browserid(email):
            self.client.post(reverse('profile.edit'), d, follow=True)

        assert User.objects.filter(email=d['email'])
Ejemplo n.º 21
0
    def invite_without_message(self, email):
        """
        Make sure we can send an invite without the optional personal
        message and that the template doesn't use Personal message:
        when there's no personal message.
        """
        #login as fake user.
        d = dict(assertion=self.fake_assertion)
        with mock_browserid(self.fake_email3):
            self.client.post(reverse('browserid_verify'), d, follow=True)

        # Send an invite without a personal message.
        url = reverse('invite')
        d = dict(recipient=email)
        r = self.mozillian_client.post(url, d, follow=True)
        eq_(r.status_code, 200)
        assert ('%s has been invited to Mozillians.' % email in
                pq(r.content)('div.alert-success').text())

        # See that the email was sent.
        eq_(len(mail.outbox), 2)

        # Note it's mail.outbox[1] here because we're sending another
        # message in a previous test.
        assert not ("Personal message" in mail.outbox[1].body)
Ejemplo n.º 22
0
    def invite_someone(self, email, invite_message):
        """This method will invite a user.

        This will verify that an email with link has been sent.
        """
        # login as fake user.
        d = dict(assertion=self.fake_assertion)
        with mock_browserid(self.fake_email3):
            self.client.post(reverse('browserid_login'), d, follow=True)

        # Send an invite.
        url = reverse('invite')
        d = dict(recipient=email, message=invite_message)
        r = self.mozillian_client.post(url, d, follow=True)
        eq_(r.status_code, 200)
        assert ('%s has been invited to Mozillians.' % email in r.content)

        # See that the email was sent.
        eq_(len(mail.outbox), 1)

        i = Invite.objects.get()
        invite_url = i.get_url()

        assert settings.FROM_NOREPLY in mail.outbox[0].from_email
        assert invite_url in mail.outbox[0].body, "No link in email."
        return i
Ejemplo n.º 23
0
    def invite_someone(self, email, invite_message):
        """This method will invite a user.

        This will verify that an email with link has been sent.
        """
        # login as fake user.
        d = dict(assertion=self.fake_assertion)
        with mock_browserid(self.fake_email3):
            self.client.post(reverse('browserid_login'), d, follow=True)

        # Send an invite.
        url = reverse('invite')
        d = dict(recipient=email, message=invite_message)
        r = self.mozillian_client.post(url, d, follow=True)
        eq_(r.status_code, 200)
        assert ('%s has been invited to Mozillians.' % email in r.content)

        # See that the email was sent.
        eq_(len(mail.outbox), 1)

        i = Invite.objects.get()
        invite_url = i.get_url()

        assert settings.FROM_NOREPLY in mail.outbox[0].from_email
        assert invite_url in mail.outbox[0].body, "No link in email."
        return i
Ejemplo n.º 24
0
    def test_username_characters(self):
        """Verify usernames can have digits/symbols, but nothing too
        insane.

        """
        email = '*****@*****.**'
        username = '******'
        d = dict(assertion=self.fake_assertion)
        with browserid_mock.mock_browserid(email):
            self.client.post(reverse('browserid_verify'), d, follow=True)

        d = dict(email=email,
                 username=username,
                 full_name='Akaaaaaaash Desaaaaaaai',
                 country='pl',
                 optin=True)
        with browserid_mock.mock_browserid(email):
            r = self.client.post(reverse('register'), d)
        eq_(r.status_code, 302,
            ('Registration flow should finish with a redirect.'))
        u = User.objects.get(email=d['email'])
        eq_(u.username, username, 'Username should be set to "%s".' % username)

        r = self.mozillian_client.get(reverse('profile', args=[username]),
                                      follow=True)
        eq_(r.status_code, 200)
        eq_(r.context['profile'].user_id, u.id)

        # Now test a username with even weirder characters that we don't allow.
        bad_user_email = '*****@*****.**'
        bad_username = '******'
        d = dict(assertion=self.fake_assertion)
        with browserid_mock.mock_browserid(email):
            self.client.post(reverse('browserid_verify'), d, follow=True)

        d = dict(email=bad_user_email,
                 username=bad_username,
                 full_name='Akaaaaaaash Desaaaaaaai',
                 optin=True)
        with browserid_mock.mock_browserid(email):
            r = self.client.post(reverse('register'), d)
        eq_(r.status_code, 302,
            ('Registration flow should fail; username is bad.'))
        assert not User.objects.filter(email=d['email']), (
            "User shouldn't exist; username was bad.")
Ejemplo n.º 25
0
    def test_username(self):
        """Test that we can submit a perfectly cromulent username.

        We verify that /:username then works as well.

        """
        email = "*****@*****.**"
        d = dict(assertion=self.fake_assertion)
        with browserid_mock.mock_browserid(email):
            self.client.post(reverse("browserid_login"), d, follow=True)
        d = dict(email=email, username="******", full_name="Akaaaaaaash Desaaaaaaai", country="pl", optin=True)
        with browserid_mock.mock_browserid(email):
            r = self.client.post(reverse("register"), d)
        eq_(r.status_code, 302, "Problems if we didn't redirect...")
        u = User.objects.filter(email=d["email"])[0]
        eq_(u.username, "mrfusion", "Username didn't get set.")

        r = self.mozillian_client.get(reverse("profile", args=["mrfusion"]), follow=True)
        eq_(r.status_code, 200)
        eq_(r.context["profile"].user_id, u.id)
Ejemplo n.º 26
0
    def test_mozillacom_registration(self):
        """Verify @mozilla.com users are auto-vouched and marked "staff"."""

        d = dict(assertion=self.fake_assertion)
        with browserid_mock.mock_browserid("*****@*****.**"):
            self.client.post(reverse("browserid_login"), d, follow=True)

        d = dict(username="******", email="*****@*****.**", full_name="Akaaaaaaash Desaaaaaaai", optin=True)
        with browserid_mock.mock_browserid("*****@*****.**"):
            r = self.client.post(reverse("register"), d, follow=True)

        doc = pq(r.content)

        assert r.context["user"].get_profile().is_vouched, "Moz.com should be auto-vouched"

        assert not doc("#pending-approval"), "Moz.com profile page should not having pending vouch div."

        assert (
            r.context["user"].get_profile().groups.filter(name="staff")
        ), 'Moz.com should belong to the "staff" group.'
Ejemplo n.º 27
0
    def test_blank_ircname(self):
        username = "******"
        email = "*****@*****.**"
        register = dict(username=username, full_name="David Teststhings", optin=True)
        d = {"assertion": "rarrr"}

        with browserid_mock.mock_browserid(email):
            self.client.post(reverse("browserid_login"), d, follow=True)
            self.client.post(reverse("register"), register, follow=True)

        u = User.objects.filter(email=email)[0]
        p = u.get_profile()
        p.ircname = ""
        eq_(p.ircname, "", "We need to allow IRCname to be blank")
Ejemplo n.º 28
0
    def test_mozillacom_registration(self):
        """Verify @mozilla.com users are auto-vouched and marked "staff"."""

        d = dict(assertion=self.fake_assertion)
        with browserid_mock.mock_browserid('*****@*****.**'):
            self.client.post(reverse('browserid_verify'), d, follow=True)

        d = dict(username='******',
                 email='*****@*****.**',
                 full_name='Akaaaaaaash Desaaaaaaai',
                 optin=True)
        with browserid_mock.mock_browserid('*****@*****.**'):
            r = self.client.post(reverse('register'), d, follow=True)

        doc = pq(r.content)

        assert r.context['user'].get_profile().is_vouched, (
            "Moz.com should be auto-vouched")

        assert not doc('#pending-approval'), (
            'Moz.com profile page should not having pending vouch div.')

        assert r.context['user'].get_profile().groups.filter(
            name='staff'), ('Moz.com should belong to the "staff" group.')
Ejemplo n.º 29
0
    def test_blank_ircname(self):
        username = '******'
        email = '*****@*****.**'
        register = dict(username=username,
                        full_name='David Teststhings',
                        optin=True)
        d = {'assertion': 'rarrr'}

        with browserid_mock.mock_browserid(email):
            self.client.post(reverse('browserid_verify'), d, follow=True)
            self.client.post(reverse('register'), register, follow=True)

        u = User.objects.filter(email=email)[0]
        p = u.get_profile()
        p.ircname = ''
        eq_(p.ircname, '', 'We need to allow IRCname to be blank')
Ejemplo n.º 30
0
    def test_userprofile(self):
        u = user()

        UserProfile.objects.all().delete()

        # Somehow the User lacks a UserProfile
        # Note that u.get_profile() caches in memory.
        self.assertRaises(UserProfile.DoesNotExist, lambda: u.userprofile)

        # Sign in
        with browserid_mock.mock_browserid(u.email):
            d = dict(assertion='qwer')
            self.client.post(reverse('browserid_verify'), d, follow=True)

        # Good to go
        assert u.get_profile()
Ejemplo n.º 31
0
    def test_blank_ircname(self):
        username = '******'
        email = '*****@*****.**'
        register = dict(username=username,
                        full_name='David Teststhings',
                        optin=True)
        d = {'assertion': 'rarrr'}

        with browserid_mock.mock_browserid(email):
            self.client.post(reverse('browserid_verify'), d, follow=True)
            self.client.post(reverse('register'), register, follow=True)

        u = User.objects.filter(email=email)[0]
        p = u.get_profile()
        p.ircname = ''
        eq_(p.ircname, '', 'We need to allow IRCname to be blank')
Ejemplo n.º 32
0
    def test_userprofile(self):
        u = user()

        UserProfile.objects.all().delete()

        # Somehow the User lacks a UserProfile
        # Note that u.get_profile() caches in memory.
        self.assertRaises(UserProfile.DoesNotExist, lambda: u.userprofile)

        # Sign in
        with browserid_mock.mock_browserid(u.email):
            d = dict(assertion="qwer")
            self.client.post(reverse("browserid_login"), d, follow=True)

        # Good to go
        assert u.get_profile()