Example #1
0
 def test_new_security_bug(self):
     # Structural subscribers are not notified of security bugs.
     maintainer = self.factory.makePerson(name='maintainer')
     project = self.factory.makeProduct(name='fnord', owner=maintainer)
     subscriber = self.factory.makePerson(name='subscriber')
     with person_logged_in(subscriber):
         project.addBugSubscription(subscriber, subscriber)
     transaction.commit()
     handler = MaloneHandler()
     with person_logged_in(project.owner):
         msg = self.factory.makeSignedMessage(
             body='bad thing\n security yes\n affects fnord',
             subject='security issue',
             to_address='*****@*****.**')
         handler.process(msg, msg['To'])
     notification = self.getLatestBugNotification()
     bug = notification.bug
     self.assertEqual('security issue', bug.title)
     self.assertTrue(bug.security_related)
     self.assertEqual(1, len(bug.bugtasks))
     self.assertEqual(project, bug.bugtasks[0].target)
     recipients = set()
     for notification in BugNotification.select():
         for recipient in notification.recipients:
             recipients.add(recipient.person)
     self.assertContentEqual([maintainer], recipients)
 def test_new_security_bug(self):
     # Structural subscribers are not notified of security bugs.
     maintainer = self.factory.makePerson(name='maintainer')
     project = self.factory.makeProduct(name='fnord', owner=maintainer)
     subscriber = self.factory.makePerson(name='subscriber')
     with person_logged_in(subscriber):
         project.addBugSubscription(subscriber, subscriber)
     transaction.commit()
     handler = MaloneHandler()
     with person_logged_in(project.owner):
         msg = self.factory.makeSignedMessage(
             body='bad thing\n security yes\n affects fnord',
             subject='security issue',
             to_address='*****@*****.**')
         handler.process(msg, msg['To'])
     notification = self.getLatestBugNotification()
     bug = notification.bug
     self.assertEqual('security issue', bug.title)
     self.assertTrue(bug.security_related)
     self.assertEqual(1, len(bug.bugtasks))
     self.assertEqual(project, bug.bugtasks[0].target)
     recipients = set()
     for notification in BugNotification.select():
         for recipient in notification.recipients:
             recipients.add(recipient.person)
     self.assertContentEqual([maintainer], recipients)
Example #3
0
 def test_duplicate_edit_notifications(self):
     # Bug edits for a duplicate are sent to duplicate subscribers only.
     with notify_modified(self.dupe_bug, ['description'],
                          user=self.dupe_bug.owner):
         self.dupe_bug.description = 'A changed description'
     latest_notification = BugNotification.selectFirst(orderBy='-id')
     recipients = set(recipient.person
                      for recipient in latest_notification.recipients)
     self.assertEqual(self.dupe_subscribers, recipients)
 def test_comment_notifications(self):
     # New comments are only sent to subscribers of the duplicate
     # bug, not to subscribers of the master bug.
     self.dupe_bug.newMessage(self.dupe_bug.owner,
                              subject='subject',
                              content='content')
     latest_notification = BugNotification.selectFirst(orderBy='-id')
     recipients = set(recipient.person
                      for recipient in latest_notification.recipients)
     self.assertEqual(self.dupe_subscribers, recipients)
 def addNotification(self, person):
     # Add a notification along with recipient data.
     # This is generally done with BugTaskSet.addNotification()
     # but that requires a more complex set-up.
     message = self.factory.makeMessage()
     notification = BugNotification(
         message=message, activity=None, bug=self.bug,
         is_comment=False, date_emailed=None)
     self.addNotificationRecipient(notification, person)
     return notification
 def test_for_bug_modifier_header(self):
     """Test X-Launchpad-Bug-Modifier appears when a bug is modified."""
     self.bug_task.transitionToStatus(BugTaskStatus.CONFIRMED, self.user)
     notify(ObjectModifiedEvent(self.bug_task, self.bug_task_before_modification, ["status"], user=self.user))
     transaction.commit()
     latest_notification = BugNotification.selectFirst(orderBy="-id")
     notifications, omitted, messages = construct_email_notifications([latest_notification])
     self.assertEqual(len(notifications), 1, "email notification not created")
     headers = [msg["X-Launchpad-Bug-Modifier"] for msg in messages]
     self.assertEqual(len(headers), len(messages))
 def test_comment_notifications(self):
     # New comments are only sent to subscribers of the duplicate
     # bug, not to subscribers of the master bug.
     self.dupe_bug.newMessage(
         self.dupe_bug.owner, subject='subject', content='content')
     latest_notification = BugNotification.selectFirst(orderBy='-id')
     recipients = set(
         recipient.person
         for recipient in latest_notification.recipients)
     self.assertEqual(self.dupe_subscribers, recipients)
 def test_for_bug_modifier_header(self):
     """Test X-Launchpad-Bug-Modifier appears when a bugtask is deleted."""
     self.bug_task.delete(self.user)
     transaction.commit()
     latest_notification = BugNotification.selectFirst(orderBy='-id')
     notifications, omitted, messages = construct_email_notifications(
         [latest_notification])
     self.assertEqual(len(notifications), 1,
                      'email notification not created')
     headers = [msg['X-Launchpad-Bug-Modifier'] for msg in messages]
     self.assertEqual(len(headers), len(messages))
Example #9
0
 def test_assignee_new_subscriber(self):
     """Build a list of people who will receive emails about the bug
     task changes and ensure the assignee is not one."""
     with notify_modified(self.bug_task, ['assignee'], user=self.user):
         self.bug_task.transitionToAssignee(self.person_assigned)
     latest_notification = BugNotification.selectFirst(orderBy='-id')
     notifications, omitted, messages = construct_email_notifications(
         [latest_notification])
     self.assertEqual(len(notifications), 1, 'email notication not created')
     receivers = [message['To'] for message in messages]
     self.assertFalse(self.person_assigned_email in receivers,
                      'Assignee was emailed about the bug task change')
 def test_branch_linked_notification(self):
     # Notices for branches linked to a duplicate are sent only
     # to subscribers of the duplicate.
     #
     # No one should really do this, but this case covers notices
     # provided by the Bug.addChange mechanism.
     branch = self.factory.makeBranch(owner=self.dupe_bug.owner)
     self.dupe_bug.linkBranch(branch, self.dupe_bug.owner)
     latest_notification = BugNotification.selectFirst(orderBy='-id')
     recipients = set(recipient.person
                      for recipient in latest_notification.recipients)
     self.assertEqual(self.dupe_subscribers, recipients)
 def test_for_bug_modifier_header(self):
     """Test X-Launchpad-Bug-Modifier appears when a bug is modified."""
     with notify_modified(self.bug_task, ['status'], user=self.user):
         self.bug_task.transitionToStatus(BugTaskStatus.CONFIRMED,
                                          self.user)
     transaction.commit()
     latest_notification = BugNotification.selectFirst(orderBy='-id')
     notifications, omitted, messages = construct_email_notifications(
         [latest_notification])
     self.assertEqual(len(notifications), 1,
                      'email notification not created')
     headers = [msg['X-Launchpad-Bug-Modifier'] for msg in messages]
     self.assertEqual(len(headers), len(messages))
 def test_branch_linked_notification(self):
     # Notices for branches linked to a duplicate are sent only
     # to subscribers of the duplicate.
     #
     # No one should really do this, but this case covers notices
     # provided by the Bug.addChange mechanism.
     branch = self.factory.makeBranch(owner=self.dupe_bug.owner)
     self.dupe_bug.linkBranch(branch, self.dupe_bug.owner)
     latest_notification = BugNotification.selectFirst(orderBy='-id')
     recipients = set(
         recipient.person
         for recipient in latest_notification.recipients)
     self.assertEqual(self.dupe_subscribers, recipients)
 def test_duplicate_edit_notifications(self):
     # Bug edits for a duplicate are sent to duplicate subscribers only.
     bug_before_modification = Snapshot(
         self.dupe_bug, providing=providedBy(self.dupe_bug))
     self.dupe_bug.description = 'A changed description'
     notify(ObjectModifiedEvent(
         self.dupe_bug, bug_before_modification, ['description'],
         user=self.dupe_bug.owner))
     latest_notification = BugNotification.selectFirst(orderBy='-id')
     recipients = set(
         recipient.person
         for recipient in latest_notification.recipients)
     self.assertEqual(self.dupe_subscribers, recipients)
 def test_duplicate_edit_notifications(self):
     # Bug edits for a duplicate are sent to duplicate subscribers only.
     bug_before_modification = Snapshot(self.dupe_bug,
                                        providing=providedBy(self.dupe_bug))
     self.dupe_bug.description = 'A changed description'
     notify(
         ObjectModifiedEvent(self.dupe_bug,
                             bug_before_modification, ['description'],
                             user=self.dupe_bug.owner))
     latest_notification = BugNotification.selectFirst(orderBy='-id')
     recipients = set(recipient.person
                      for recipient in latest_notification.recipients)
     self.assertEqual(self.dupe_subscribers, recipients)
 def test_dup_subscriber_change_notification_message(self):
     """Duplicate bug number in the reason (email footer) for
        duplicate subscribers when a master bug is modified."""
     with notify_modified(self.master_bug_task, ['status'], user=self.user):
         self.master_bug_task.transitionToStatus(
             BugTaskStatus.CONFIRMED, self.user)
     transaction.commit()
     latest_notification = BugNotification.selectFirst(orderBy='-id')
     notifications, omitted, messages = construct_email_notifications(
         [latest_notification])
     self.assertEqual(
         len(notifications), 1, 'email notification not created')
     rationale = 'duplicate bug report (%i)' % self.dup_bug.id
     self.assertIn(rationale, str(messages[-1]))
Example #16
0
 def test_team_assigned_new_subscriber(self):
     """Assign a team, who is not subscribed to a bug, a bug task and
     ensure that team members do not receive an email about the bug
     task changes."""
     with notify_modified(self.bug_task, ['assignee'], user=self.user):
         self.bug_task.transitionToAssignee(self.team_assigned)
     latest_notification = BugNotification.selectFirst(orderBy='-id')
     notifications, omitted, messages = construct_email_notifications(
         [latest_notification])
     self.assertEqual(len(notifications), 1,
                      'email notification not created')
     receivers = [message['To'] for message in messages]
     self.assertFalse(self.team_member_email in receivers,
                      'Team member was emailed about the bug task change')
 def test_assignee_new_subscriber(self):
     """Build a list of people who will receive e-mails about the bug
     task changes and ensure the assignee is not one."""
     self.bug_task.transitionToAssignee(self.person_assigned)
     notify(ObjectModifiedEvent(
         self.bug_task, self.bug_task_before_modification,
         ['assignee'], user=self.user))
     latest_notification = BugNotification.selectFirst(orderBy='-id')
     notifications, omitted, messages = construct_email_notifications(
         [latest_notification])
     self.assertEqual(len(notifications), 1,
                      'email notication not created')
     receivers = [message['To'] for message in messages]
     self.assertFalse(self.person_assigned_email in receivers,
         'Assignee was emailed about the bug task change')
 def test_team_assigned_new_subscriber(self):
     """Assign a team, who is not subscribed to a bug, a bug task and
     ensure that team members do not receive an e-mail about the bug
     task changes."""
     self.bug_task.transitionToAssignee(self.team_assigned)
     notify(ObjectModifiedEvent(
         self.bug_task, self.bug_task_before_modification,
         ['assignee'], user=self.user))
     latest_notification = BugNotification.selectFirst(orderBy='-id')
     notifications, omitted, messages = construct_email_notifications(
         [latest_notification])
     self.assertEqual(len(notifications), 1,
                      'email notification not created')
     receivers = [message['To'] for message in messages]
     self.assertFalse(self.team_member_email in receivers,
         'Team member was emailed about the bug task change')
 def getLatestBugNotification():
     return BugNotification.selectFirst(orderBy='-id')
Example #20
0
 def assertNoPendingNotifications(self, bug):
     notifications = BugNotification.selectBy(bug=bug, date_emailed=None)
     count = notifications.count()
     self.assertEqual(
         count, 0,
         'Found %d pending notifications for bug %d' % (count, bug.id))
Example #21
0
 def getLatestBugNotification():
     return BugNotification.selectFirst(orderBy='-id')
 def assertNoPendingNotifications(self, bug):
     notifications = BugNotification.selectBy(bug=bug, date_emailed=None)
     count = notifications.count()
     self.assertEqual(count, 0,
                      'Found %d pending notifications for bug %d'
                      % (count, bug.id))