Beispiel #1
0
    def test_patch_submitter_expiry(self):
        # someone submits a patch...
        patch = create_patch()
        submitter = patch.submitter

        # ... then starts registration...
        date = ((datetime.datetime.now() - EmailConfirmation.validity) -
                datetime.timedelta(hours=1))
        user = create_user(link_person=False, email=submitter.email)
        user.is_active = False
        user.date_joined = user.last_login = date
        user.save()

        conf = EmailConfirmation(type='registration', user=user,
                                 email=user.email)
        conf.date = date
        conf.save()

        # ... which expires
        do_expiry()

        # we should see no matching user
        self.assertFalse(User.objects.filter(email=patch.submitter.email)
                         .exists())
        # but the patch and person should still be present
        self.assertTrue(Person.objects.filter(pk=submitter.pk).exists())
        self.assertTrue(Patch.objects.filter(pk=patch.pk).exists())
        # and there should be no user associated with the person
        self.assertEqual(Person.objects.get(pk=submitter.pk).user, None)
Beispiel #2
0
    def handle(self, *args, **kwargs):
        errors = send_notifications()
        for (recipient, error) in errors:
            self.stderr.write("Failed sending to %s: %s" %
                              (recipient.email, error))

        do_expiry()
Beispiel #3
0
    def testRecentRegistrationExpiry(self):
        date = ((datetime.datetime.now() - EmailConfirmation.validity) +
                datetime.timedelta(hours=1))
        (user, conf) = self.register(date)

        do_expiry()

        self.assertTrue(User.objects.filter(pk=user.pk).exists())
        self.assertTrue(EmailConfirmation.objects.filter(pk=conf.pk).exists())
    def testRecentRegistrationExpiry(self):
        date = ((datetime.datetime.now() - EmailConfirmation.validity) +
                datetime.timedelta(hours = 1))
        (user, conf) = self.register(date)

        do_expiry()

        self.assertTrue(User.objects.filter(pk = user.pk).exists())
        self.assertTrue(EmailConfirmation.objects.filter(pk = conf.pk)
                            .exists())
Beispiel #5
0
    def test_old_registration_expiry(self):
        date = ((datetime.datetime.now() - EmailConfirmation.validity) -
                datetime.timedelta(hours=1))
        user, conf = self.register(date)

        do_expiry()

        self.assertFalse(User.objects.filter(pk=user.pk).exists())
        self.assertFalse(
            EmailConfirmation.objects.filter(pk=conf.pk).exists())
Beispiel #6
0
    def testInactiveRegistrationExpiry(self):
        (user, conf) = self.register(datetime.datetime.now())

        # confirm registration
        conf.user.is_active = True
        conf.user.save()
        conf.deactivate()

        do_expiry()

        self.assertTrue(User.objects.filter(pk=user.pk).exists())
        self.assertFalse(EmailConfirmation.objects.filter(pk=conf.pk).exists())
    def testInactiveRegistrationExpiry(self):
        (user, conf) = self.register(datetime.datetime.now())

        # confirm registration
        conf.user.is_active = True
        conf.user.save()
        conf.deactivate()

        do_expiry()

        self.assertTrue(User.objects.filter(pk = user.pk).exists())
        self.assertFalse(EmailConfirmation.objects.filter(pk = conf.pk)
                            .exists())
Beispiel #8
0
    def testPatchSubmitterExpiry(self):
        defaults.project.save()
        defaults.patch_author_person.save()

        # someone submits a patch...
        patch = Patch(project=defaults.project,
                      msgid='*****@*****.**',
                      name='test patch',
                      submitter=defaults.patch_author_person,
                      content=defaults.patch)
        patch.save()

        # ... then starts registration...
        date = ((datetime.datetime.now() - EmailConfirmation.validity) -
                datetime.timedelta(hours=1))
        userid = 'test-user'
        user = User.objects.create_user(userid,
                                        defaults.patch_author_person.email,
                                        userid)
        user.is_active = False
        user.date_joined = user.last_login = date
        user.save()

        self.assertEqual(user.email, patch.submitter.email)

        conf = EmailConfirmation(type='registration',
                                 user=user,
                                 email=user.email)
        conf.date = date
        conf.save()

        # ... which expires
        do_expiry()

        # we should see no matching user
        self.assertFalse(
            User.objects.filter(email=patch.submitter.email).exists())
        # but the patch and person should still be present
        self.assertTrue(
            Person.objects.filter(pk=defaults.patch_author_person.pk).exists())
        self.assertTrue(Patch.objects.filter(pk=patch.pk).exists())

        # and there should be no user associated with the person
        self.assertEqual(
            Person.objects.get(pk=defaults.patch_author_person.pk).user, None)
Beispiel #9
0
    def testPatchSubmitterExpiry(self):
        defaults.project.save()
        defaults.patch_author_person.save()

        # someone submits a patch...
        patch = Patch(project=defaults.project,
                      msgid='*****@*****.**', name='test patch',
                      submitter=defaults.patch_author_person,
                      content=defaults.patch)
        patch.save()

        # ... then starts registration...
        date = ((datetime.datetime.now() - EmailConfirmation.validity) -
                datetime.timedelta(hours=1))
        userid = 'test-user'
        user = User.objects.create_user(
            userid,
            defaults.patch_author_person.email, userid)
        user.is_active = False
        user.date_joined = user.last_login = date
        user.save()

        self.assertEqual(user.email, patch.submitter.email)

        conf = EmailConfirmation(type='registration', user=user,
                                 email=user.email)
        conf.date = date
        conf.save()

        # ... which expires
        do_expiry()

        # we should see no matching user
        self.assertFalse(User.objects.filter(email=patch.submitter.email)
                         .exists())
        # but the patch and person should still be present
        self.assertTrue(Person.objects.filter(
            pk=defaults.patch_author_person.pk).exists())
        self.assertTrue(Patch.objects.filter(pk=patch.pk).exists())

        # and there should be no user associated with the person
        self.assertEqual(Person.objects.get(
            pk=defaults.patch_author_person.pk).user, None)
Beispiel #10
0
def main(args):
    errors = send_notifications()
    for (recipient, error) in errors:
        print "Failed sending to %s: %s" % (recipient.email, ex)

    do_expiry()