def test_google_user_changing_emails_doesnt_clobber_others(self):
        # An existing Google user
        user1 = fake_user.google_user(123, "*****@*****.**")

        # An existing Facebook user - say they logged in after we started
        # collecting e-mails from FB users, so we have their email.
        user2 = fake_user.fb_user(123, "*****@*****.**")

        # Now, pretend the Google user logs in, but their e-mail has changed
        # to match the FB user's!
        self.fake_google_login(123, "*****@*****.**")

        # Unfortunately, we can't "merge" accounts, and it would suck to
        # clobber that other FB account and not make it accessible. So until
        # we can properly merge, we can't update the e-mail of that Google
        # user .
        current = _cur_user()
        self.assertEquals(2, _user_counts())
        self.assertEquals(
            user1.key(),
            current.key(),
            msg="Google user should still have access to old account")

        retrieved_by_email = \
            user_models.UserData.get_from_user_input_email("*****@*****.**")
        self.assertEquals(user2.key(),
                          retrieved_by_email.key(),
                          msg="The FB user should still own the new e-mail")
Beispiel #2
0
    def test_google_user_changing_emails_doesnt_clobber_others(self):
        # An existing Google user
        user1 = fake_user.google_user(123, "*****@*****.**")

        # An existing Facebook user - say they logged in after we started
        # collecting e-mails from FB users, so we have their email.
        user2 = fake_user.fb_user(123, "*****@*****.**")

        # Now, pretend the Google user logs in, but their e-mail has changed
        # to match the FB user's!
        self.fake_google_login(123, "*****@*****.**")

        # Unfortunately, we can't "merge" accounts, and it would suck to
        # clobber that other FB account and not make it accessible. So until
        # we can properly merge, we can't update the e-mail of that Google
        # user .
        current = _cur_user()
        self.assertEquals(2, _user_counts())
        self.assertEquals(
            user1.key(), current.key(),
            msg="Google user should still have access to old account")

        retrieved_by_email = \
            user_models.UserData.get_from_user_input_email("*****@*****.**")
        self.assertEquals(
            user2.key(), retrieved_by_email.key(),
            msg="The FB user should still own the new e-mail")
    def test_old_fb_user_with_clashing_email_doesnt_clobber_others(self):
        email = "*****@*****.**"

        # An existing google user with [email protected]
        user1 = fake_user.google_user(123, email)

        # An existing facebook user in our system - we don't know
        # their email yet, because historically we didn't ask.
        user2 = fake_user.fb_user(123)
        self.assertFalse(user2.has_sendable_email())

        # Now, pretend the FB user logs in and we now get their e-mail
        self.fake_fb_login(123, "*****@*****.**")

        current = _cur_user()

        self.assertEquals(
            2,
            _user_counts(),
            msg="New user shouldn't be created on FB email change")

        self.assertNotEquals(user1.key(),
                             current.key(),
                             msg="Shouldn't have logged in as the Google user")

        self.assertEquals(user2.key(),
                          current.key(),
                          msg="Should have logged in as the FB user")

        self.assertFalse(current.has_sendable_email(),
                         msg="FB email should not have been updated since it "
                         "conflicts with a different user's")
Beispiel #4
0
    def test_old_fb_user_with_clashing_email_doesnt_clobber_others(self):
        email = "*****@*****.**"

        # An existing google user with [email protected]
        user1 = fake_user.google_user(123, email)

        # An existing facebook user in our system - we don't know
        # their email yet, because historically we didn't ask.
        user2 = fake_user.fb_user(123)
        self.assertFalse(user2.has_sendable_email())

        # Now, pretend the FB user logs in and we now get their e-mail
        self.fake_fb_login(123, "*****@*****.**")

        current = _cur_user()

        self.assertEquals(
            2, _user_counts(),
            msg="New user shouldn't be created on FB email change")

        self.assertNotEquals(
            user1.key(), current.key(),
            msg="Shouldn't have logged in as the Google user")

        self.assertEquals(
            user2.key(), current.key(),
            msg="Should have logged in as the FB user")

        self.assertFalse(
            current.has_sendable_email(),
            msg="FB email should not have been updated since it "
                "conflicts with a different user's")