Exemplo n.º 1
0
    def test_keywords_conversion(self):
        yield self.perform_full_submission_actions()
        yield Delivery().run()

        data = {}
        data['type'] = 'tip'
        data['user'] = yield user.get_user(1, self.dummyReceiver_1['id'],
                                           u'en')
        data['context'] = yield admin.context.get_context(
            1, self.dummyContext['id'], u'en')
        data['notification'] = yield tw(admin.notification.db_get_notification,
                                        1, u'en')
        data['node'] = yield tw(admin.node.db_admin_serialize_node, 1, u'en')

        for tip in self.dummyRTips:
            if tip['receiver_id'] == self.dummyReceiver_1['id']:
                tip_id = tip['id']
                break

        data['tip'], _ = yield rtip.get_rtip(1, self.dummyReceiver_1['id'],
                                             tip_id, u'en')

        data['comments'] = data['tip']['comments']
        data['comment'] = data['comments'][0]

        data['messages'] = data['tip']['messages']
        data['message'] = data['messages'][0]

        files = yield rtip.receiver_get_rfile_list(data['tip']['id'])
        data['file'] = files[0]

        for key in ['tip', 'comment', 'message', 'file']:
            data['type'] = key
            template = ''.join(supported_template_types[key].keyword_list)
            Templating().format_template(template, data)
Exemplo n.º 2
0
    def setUp(self):
        yield helpers.TestHandlerWithPopulatedDB.setUp(self)

        yield self.perform_full_submission_actions()

        # populates alarms conditions
        self.pollute_events(10)

        # creates the receiver files
        yield Delivery().run()
Exemplo n.º 3
0
    def test_notification(self):
        yield self.test_model_count(models.Mail, 2)

        yield Delivery().run()

        notification = Notification()
        notification.skip_sleep = True
        yield notification.run()

        yield self.test_model_count(models.Mail, 0)
Exemplo n.º 4
0
    def test_get(self):
        yield self.perform_minimal_submission()
        yield Delivery().run()

        rtip_descs = yield self.get_rtips()
        for rtip_desc in rtip_descs:
            rfiles_desc = yield self.get_rfiles(rtip_desc['id'])
            for rfile_desc in rfiles_desc:
                handler = self.request(role='receiver', user_id=rtip_desc['receiver_id'])
                yield handler.get(rfile_desc['id'])
                self.assertNotEqual(handler.request.getResponseBody(), '')
Exemplo n.º 5
0
    def test_get(self):
        yield self.perform_full_submission_actions()

        self._handler = rtip.WhistleblowerFileHandler
        rtips_desc = yield self.get_rtips()
        for rtip_desc in rtips_desc:
            handler = self.request(role='receiver',
                                   user_id=rtip_desc['receiver_id'],
                                   attached_file=attachment)
            yield handler.post(rtip_desc['id'])

        yield Delivery().run()

        self._handler = wbtip.WBTipWBFileHandler
        wbtips_desc = yield self.get_wbtips()
        for wbtip_desc in wbtips_desc:
            wbfiles_desc = yield self.get_wbfiles(wbtip_desc['id'])
            for wbfile_desc in wbfiles_desc:
                handler = self.request(role='whistleblower',
                                       user_id=wbtip_desc['id'])
                yield handler.get(wbfile_desc['id'])
                self.assertEqual(handler.request.getResponseBody(), attachment)

        self._handler = rtip.RTipWBFileHandler
        rtips_desc = yield self.get_rtips()
        deleted_wbfiles_ids = []
        for rtip_desc in rtips_desc:
            for wbfile_desc in rtip_desc['wbfiles']:
                if wbfile_desc['id'] in deleted_wbfiles_ids:
                    continue

                self.assertEqual(wbfile_desc['description'], 'description')

                handler = self.request(role='receiver',
                                       user_id=rtip_desc['receiver_id'])
                yield handler.delete(wbfile_desc['id'])

                deleted_wbfiles_ids.append(wbfile_desc['id'])

                yield self.test_model_count(models.SecureFileDelete,
                                            len(deleted_wbfiles_ids))

        # check that the files are effectively gone from the db
        rtips_desc = yield self.get_rtips()
        for rtip_desc in rtips_desc:
            self.assertEqual(len(rtip_desc['wbfiles']), 0)
    def test_notification(self):
        yield self.test_model_count(models.User, 8)

        yield self.test_model_count(models.InternalTip, 0)
        yield self.test_model_count(models.ReceiverTip, 0)
        yield self.test_model_count(models.InternalFile, 0)
        yield self.test_model_count(models.WhistleblowerFile, 0)
        yield self.test_model_count(models.Comment, 0)
        yield self.test_model_count(models.Message, 0)
        yield self.test_model_count(models.Mail, 0)

        yield self.perform_full_submission_actions()

        yield self.test_model_count(models.InternalTip, 2)
        yield self.test_model_count(models.ReceiverTip, 4)
        yield self.test_model_count(models.InternalFile, 4)
        yield self.test_model_count(models.ReceiverFile, 0)
        yield self.test_model_count(models.WhistleblowerFile, 0)
        yield self.test_model_count(models.Comment, 6)
        yield self.test_model_count(models.Message, 8)
        yield self.test_model_count(models.Mail, 0)

        yield Delivery().run()

        yield self.test_model_count(models.InternalTip, 2)
        yield self.test_model_count(models.ReceiverTip, 4)
        yield self.test_model_count(models.InternalFile, 4)
        yield self.test_model_count(models.ReceiverFile, 8)
        yield self.test_model_count(models.WhistleblowerFile, 0)
        yield self.test_model_count(models.Comment, 6)
        yield self.test_model_count(models.Message, 8)
        yield self.test_model_count(models.Mail, 0)

        notification = Notification()
        notification.skip_sleep = True

        yield notification.generate_emails()

        yield self.test_model_count(models.Mail, 4)

        yield notification.spool_emails()

        yield self.test_model_count(models.Mail, 0)
    def test_notification_failure(self):
        yield self.test_model_count(models.Mail, 0)

        yield Delivery().run()

        notification = Notification()
        notification.skip_sleep = True

        def sendmail_failure(_):
            # simulate the failure just returning with no action
            return succeed(None)

        notification.sendmail = sendmail_failure

        for _ in range(10):
            yield notification.run()
            yield self.test_model_count(models.Mail, 24)

        yield notification.run()

        yield self.test_model_count(models.Mail, 0)
Exemplo n.º 8
0
 def setUp(self):
     yield helpers.TestHandlerWithPopulatedDB.setUp(self)
     yield self.perform_full_submission_actions()
     yield Delivery().run()