Ejemplo n.º 1
0
    def setup_tip_environment(self):
        self.context_desc = yield admin.create_context(self.dummyContext, 'en')

        self.dummyReceiver_1['contexts'] = self.dummyReceiver_2['contexts'] = [self.context_desc['id']]
        self.dummyReceiver_1['can_postpone_expiration'] = False
        self.dummyReceiver_2['can_postpone_expiration'] = True
        self.dummyReceiver_1['can_delete_submission'] = True
        self.dummyReceiver_2['can_delete_submission'] = False

        self.receiver1_desc = yield admin.create_receiver(self.dummyReceiver_1, 'en')
        self.receiver2_desc = yield admin.create_receiver(self.dummyReceiver_2, 'en')

        self.assertEqual(self.receiver1_desc['contexts'], [ self.context_desc['id']])
        self.assertEqual(self.receiver2_desc['contexts'], [ self.context_desc['id']])

        dummySubmissionDict = yield self.get_dummy_submission(self.context_desc['id'])

        token = Token(token_kind='submission')

        self.submission_desc = yield submission.create_submission(token.id, dummySubmissionDict, False, 'en')

        self.assertEqual(self.submission_desc['answers'], dummySubmissionDict['answers'])

        tips_receiver_1 = yield receiver.get_receivertip_list(self.receiver1_desc['id'], 'en')
        tips_receiver_2 = yield receiver.get_receivertip_list(self.receiver2_desc['id'], 'en')

        self.rtip1_id = tips_receiver_1[0]['id']
        self.rtip2_id = tips_receiver_2[0]['id']
        self.rtip1_questionnaire_hash = tips_receiver_1[0]['questionnaire_hash']
        self.rtip1_questionnaire_hash = tips_receiver_2[0]['questionnaire_hash']
Ejemplo n.º 2
0
    def test_001_setup_submission_environment(self):
        helpers.TestGL.setUp(self)

        basehandler = MockHandler()

        stuff = u"AAA :P ³²¼½¬¼³²"

        for attrname in Context.localized_strings:
            SubmissionTest.aContext1[attrname] = stuff

        basehandler.validate_jmessage(SubmissionTest.aContext1,
                                      adminContextDesc)
        SubmissionTest.context_used = yield admin.create_context(
            SubmissionTest.aContext1)

        # Correctly, TTip.tipContext has not selectable receiver, and we want test it in the 2nd test
        SubmissionTest.context_used['selectable_receiver'] = True

        for attrname in Context.localized_strings:
            SubmissionTest.context_used[attrname] = stuff

        SubmissionTest.context_used = yield admin.update_context(
            SubmissionTest.context_used['id'], SubmissionTest.context_used)

        basehandler.validate_jmessage(SubmissionTest.aContext2,
                                      adminContextDesc)
        SubmissionTest.context_unused = yield admin.create_context(
            SubmissionTest.aContext2)

        self.assertTrue(len(SubmissionTest.context_used['id']) > 1)
        self.assertTrue(len(SubmissionTest.context_unused['id']) > 1)

        SubmissionTest.aReceiver1['contexts'] = [
            SubmissionTest.context_used['id']
        ]

        for attrname in Receiver.localized_strings:
            SubmissionTest.aReceiver1[attrname] = stuff * 2
            SubmissionTest.aReceiver2[attrname] = stuff * 4

        basehandler.validate_jmessage(SubmissionTest.aReceiver1,
                                      adminReceiverDesc)
        SubmissionTest.receiver_used = yield admin.create_receiver(
            SubmissionTest.aReceiver1)

        SubmissionTest.aReceiver2['contexts'] = [
            SubmissionTest.context_unused['id']
        ]
        basehandler.validate_jmessage(SubmissionTest.aReceiver2,
                                      adminReceiverDesc)
        SubmissionTest.receiver_unused = yield admin.create_receiver(
            SubmissionTest.aReceiver2)

        self.assertTrue(SubmissionTest.receiver_used['name'] ==
                        SubmissionTest.aReceiver1['name'])
        self.assertTrue(SubmissionTest.receiver_unused['name'] ==
                        SubmissionTest.aReceiver2['name'])

        self.assertTrue(len(SubmissionTest.receiver_used['contexts']), 1)
        self.assertTrue(len(SubmissionTest.receiver_unused['contexts']), 1)
Ejemplo n.º 3
0
    def setup_tip_environment(self):

        basehandler = MockHandler()

        stuff = u'⅛⅛⅛£"$"$¼³²¼²³¼²³“““““ð'
        for attrname in models.Context.localized_strings:
            self.tipContext[attrname] = stuff

        basehandler.validate_jmessage(self.tipContext, requests.adminContextDesc)

        self.context_desc = yield admin.create_context(self.tipContext)

        self.tipReceiver1['contexts'] = self.tipReceiver2['contexts'] = [ self.context_desc['id'] ]

        for attrname in models.Receiver.localized_strings:
            self.tipReceiver1[attrname] = stuff
            self.tipReceiver2[attrname] = stuff

        basehandler.validate_jmessage( self.tipReceiver1, requests.adminReceiverDesc )
        basehandler.validate_jmessage( self.tipReceiver2, requests.adminReceiverDesc )

        self.receiver1_desc = yield admin.create_receiver(self.tipReceiver1)
        self.receiver2_desc = yield admin.create_receiver(self.tipReceiver2)

        self.assertEqual(self.receiver1_desc['contexts'], [ self.context_desc['id']])

        dummySubmissionDict = self.get_dummy_submission(
            self.context_desc['id'], self.context_desc['fields'])
        basehandler.validate_jmessage(dummySubmissionDict, requests.wbSubmissionDesc)

        self.submission_desc = yield submission.create_submission(dummySubmissionDict, finalize=True)

        self.assertEqual(self.submission_desc['wb_fields'], dummySubmissionDict['wb_fields'])
        self.assertEqual(self.submission_desc['mark'], models.InternalTip._marker[1])
Ejemplo n.º 4
0
    def do_setup_tip_environment(self):

        basehandler = MockHandler()

        for attrname in models.Context.localized_strings:
            self.tipContext[attrname] = u'⅛¡⅜⅛’ŊÑŦŊŊ’‘ª‘ª’‘ÐŊ'

        basehandler.validate_jmessage(self.tipContext, requests.adminContextDesc)
        self.context_desc = yield admin.create_context(self.tipContext)

        self.tipReceiver1['contexts'] = self.tipReceiver2['contexts'] = [ self.context_desc['id'] ]

        for attrname in models.Receiver.localized_strings:
            self.tipReceiver2[attrname] = u'222222’‘ª‘ª’‘ÐŊ'
            self.tipReceiver1[attrname] = u'⅛¡⅜⅛’ŊÑŦŊ1111111’‘ª‘ª’‘ÐŊ'

        basehandler.validate_jmessage( self.tipReceiver1, requests.adminReceiverDesc )
        basehandler.validate_jmessage( self.tipReceiver2, requests.adminReceiverDesc )

        try:
            self.receiver1_desc = yield admin.create_receiver(self.tipReceiver1)
            self.receiver2_desc = yield admin.create_receiver(self.tipReceiver2)
        except Exception as exxxx:
            self.assertTrue(False)

        self.assertEqual(self.receiver1_desc['contexts'], [ self.context_desc['id']])
        self.assertEqual(self.receiver2_desc['contexts'], [ self.context_desc['id']])

        dummySubmission = self.get_dummy_submission(self.context_desc['id'], self.context_desc['fields'])
        basehandler.validate_jmessage( dummySubmission, requests.wbSubmissionDesc)

        self.submission_desc = yield submission.create_submission(dummySubmission, finalize=False)

        self.assertEqual(self.submission_desc['wb_fields'], dummySubmission['wb_fields'])
        self.assertEqual(self.submission_desc['mark'], models.InternalTip._marker[0])
Ejemplo n.º 5
0
    def setup_tip_environment(self):
        self.context_desc = yield admin.create_context(self.dummyContext, 'en')

        self.dummyReceiver_1['contexts'] = self.dummyReceiver_2['contexts'] = [self.context_desc['id']]
        self.dummyReceiver_1['can_postpone_expiration'] = False
        self.dummyReceiver_2['can_postpone_expiration'] = True
        self.dummyReceiver_1['can_delete_submission'] = True
        self.dummyReceiver_2['can_delete_submission'] = False

        self.receiver1_desc = yield admin.create_receiver(self.dummyReceiver_1, 'en')
        self.receiver2_desc = yield admin.create_receiver(self.dummyReceiver_2, 'en')

        self.assertEqual(self.receiver1_desc['contexts'], [ self.context_desc['id']])
        self.assertEqual(self.receiver2_desc['contexts'], [ self.context_desc['id']])

        dummySubmissionDict = yield self.get_dummy_submission(self.context_desc['id'])

        token = Token(token_kind='submission',
                      context_id=self.context_desc['id'])

        self.submission_desc = yield submission.create_submission(token, dummySubmissionDict, 'en')

        self.assertEqual(self.submission_desc['wb_steps'], dummySubmissionDict['wb_steps'])

        tips_receiver_1 = yield receiver.get_receivertip_list(self.receiver1_desc['id'], 'en')
        tips_receiver_2 = yield receiver.get_receivertip_list(self.receiver2_desc['id'], 'en')

        self.rtip1_id = tips_receiver_1[0]['id']
        self.rtip2_id = tips_receiver_2[0]['id']
Ejemplo n.º 6
0
    def test_001_setup_submission_environment(self):
        helpers.TestGL.setUp(self)
        
        basehandler = MockHandler()

        stuff = u"AAA :P ³²¼½¬¼³²"

        for attrname in Context.localized_strings:
            SubmissionTest.aContext1[attrname] = stuff

        basehandler.validate_jmessage(SubmissionTest.aContext1, adminContextDesc)

        # the test context need fields to be present
        from globaleaks.handlers.admin.field import create_field
        for idx, field in enumerate(self.dummyFields):
            f = yield create_field(field, 'en')
            self.dummyFields[idx]['id'] = f['id']

        SubmissionTest.aContext1['steps'][0]['children'] = [
            self.dummyFields[0], # Field 1
            self.dummyFields[1], # Field 2
            self.dummyFields[4]  # Generalities
        ]

        SubmissionTest.context_used = yield admin.create_context(SubmissionTest.aContext1)

        # Correctly, TTip.tipContext has not selectable receiver, and we want test it in the 2nd test
        SubmissionTest.context_used['selectable_receiver'] = True

        for attrname in Context.localized_strings:
            SubmissionTest.context_used[attrname] = stuff

        SubmissionTest.context_used = yield admin.update_context(SubmissionTest.context_used['id'],
            SubmissionTest.context_used)

        basehandler.validate_jmessage( SubmissionTest.aContext2, adminContextDesc)
        SubmissionTest.context_unused = yield admin.create_context(SubmissionTest.aContext2)

        self.assertTrue(len(SubmissionTest.context_used['id']) > 1)
        self.assertTrue(len(SubmissionTest.context_unused['id']) > 1)

        SubmissionTest.aReceiver1['contexts'] = [ SubmissionTest.context_used['id'] ]

        for attrname in Receiver.localized_strings:
            SubmissionTest.aReceiver1[attrname] = stuff * 2
            SubmissionTest.aReceiver2[attrname] = stuff * 4

        basehandler.validate_jmessage( SubmissionTest.aReceiver1, adminReceiverDesc )
        SubmissionTest.receiver_used = yield admin.create_receiver(SubmissionTest.aReceiver1)

        SubmissionTest.aReceiver2['contexts'] = [ SubmissionTest.context_unused['id'] ]
        basehandler.validate_jmessage( SubmissionTest.aReceiver2, adminReceiverDesc )
        SubmissionTest.receiver_unused = yield admin.create_receiver(SubmissionTest.aReceiver2)

        self.assertTrue(SubmissionTest.receiver_used['name'] == SubmissionTest.aReceiver1['name'])
        self.assertTrue(SubmissionTest.receiver_unused['name'] == SubmissionTest.aReceiver2['name'])

        self.assertTrue(len(SubmissionTest.receiver_used['contexts']), 1)
        self.assertTrue(len(SubmissionTest.receiver_unused['contexts']), 1)
Ejemplo n.º 7
0
    def test_submission_file_delivery_pgp(self):

        new_fields = MockDict().dummyFields
        new_context = MockDict().dummyContext

        new_context['steps'][0]['children'] = []

        new_context['name'] = "this uniqueness is no more checked due to the lang"
        new_context_output = yield create_context(new_context, 'en')
        self.context_assertions(new_context, new_context_output)

        doubletest = yield get_context_list('en')
        self.assertEqual(len(doubletest), 2)

        yanr = dict(MockDict().dummyReceiver)
        yanr['name'] = yanr['mail_address'] = u"*****@*****.**"
        yanr['pgp_key_public'] = unicode(VALID_PGP_KEY1)
        yanr['contexts'] = [ new_context_output['id']]
        yanr_output = yield create_receiver(yanr, 'en')
        self.receiver_assertions(yanr, yanr_output)

        asdr = dict(MockDict().dummyReceiver)
        asdr['name'] = asdr['mail_address'] = u"*****@*****.**"
        asdr['pgp_key_public'] = unicode(VALID_PGP_KEY1)
        asdr['contexts'] = [ new_context_output['id']]
        asdr_output = yield create_receiver(asdr, 'en')
        self.receiver_assertions(asdr, asdr_output)

        new_subm = dict(MockDict().dummySubmission)

        new_subm['finalize'] = False

        new_subm['context_id'] = new_context_output['id']
        new_subm['receivers'] = [ asdr_output['id'],
                                  yanr_output['id'] ]
        new_subm['wb_steps'] = yield self.fill_random_fields(new_context_output['id'])

        token = Token('submission', new_context_output['id'])
        yield self.emulate_file_upload(token, 3)

        new_subm_output = yield submission.create_submission(token, new_subm, 'en')

        yield DeliverySchedule().operation()

        # now get a lots of receivertips/receiverfiles and check!
        ifilist = yield get_files_by_itip(new_subm_output['id'])

        self.assertTrue(isinstance(ifilist, list))
        self.assertEqual(len(ifilist), 3)

        rfilist = yield get_receiverfile_by_itip(new_subm_output['id'])

        self.assertTrue(isinstance(ifilist, list))
        self.assertEqual(len(rfilist), 6)

        for i in range(0, 3):
            self.assertLess(ifilist[0]['size'], rfilist[i]['size'])

        self.assertEqual(rfilist[0]['status'], u"encrypted" )
Ejemplo n.º 8
0
    def test_submission_file_delivery_pgp(self):
        new_fields = MockDict().dummyFields
        new_context = MockDict().dummyContext

        new_context['name'] = "this uniqueness is no more checked due to the lang"
        new_context_output = yield create_context(new_context, 'en')
        self.context_assertions(new_context, new_context_output)

        doubletest = yield get_context_list('en')
        self.assertEqual(len(doubletest), 2)

        yanr = dict(MockDict().dummyReceiver)
        yanr['name'] = u"Receiver1"
        yanr['pgp_key_public'] = unicode(VALID_PGP_KEY1)
        yanr['contexts'] = [ new_context_output['id']]
        yanr_output = yield create_receiver(yanr, 'en')
        self.receiver_assertions(yanr, yanr_output)

        asdr = dict(MockDict().dummyReceiver)
        asdr['name'] = u"Receiver2"
        asdr['pgp_key_public'] = unicode(VALID_PGP_KEY1)
        asdr['contexts'] = [ new_context_output['id']]
        asdr_output = yield create_receiver(asdr, 'en')
        self.receiver_assertions(asdr, asdr_output)

        new_subm = dict(MockDict().dummySubmission)

        new_subm['finalize'] = False

        new_subm['context_id'] = new_context_output['id']
        new_subm['receivers'] = [ asdr_output['id'],
                                  yanr_output['id'] ]
        new_subm['wb_steps'] = yield self.fill_random_answers(new_context_output['id'])

        token = Token('submission')
        yield self.emulate_file_upload(token, 3)

        new_subm_output = yield submission.create_submission(token.id, new_subm, False, 'en')

        yield DeliverySchedule().operation()

        # now get a lots of receivertips/receiverfiles and check!
        ifilist = yield get_files_by_itip(new_subm_output['id'])

        self.assertTrue(isinstance(ifilist, list))
        self.assertEqual(len(ifilist), 3)

        rfilist = yield get_receiverfile_by_itip(new_subm_output['id'])

        self.assertTrue(isinstance(ifilist, list))
        self.assertEqual(len(rfilist), 6)

        for i in range(0, 3):
            self.assertLess(ifilist[0]['size'], rfilist[i]['size'])

        self.assertEqual(rfilist[0]['status'], u"encrypted" )
Ejemplo n.º 9
0
    def _initialize(self):

        self.mockContext = MockDict().dummyContext
        self.mockReceiver = MockDict().dummyReceiver
        self.mockNode = MockDict().dummyNode

        try:
            self.createdContext = yield admin.create_context(self.mockContext)
            self.assertTrue(self.createdContext.has_key('context_gus'))
        except Exception as excep:
            self.assertFalse(True)
            raise excep

        try:
            self.mockReceiver['contexts'] = [ self.createdContext['context_gus'] ]
            self.createdReceiver = yield admin.create_receiver(self.mockReceiver)
            self.assertTrue(self.createdReceiver.has_key('receiver_gus'))
        except Exception as excep:
            self.assertFalse(True)
            raise excep

        try:
            self.createdNode = yield admin.update_node(self.mockNode)
            self.assertTrue(self.createdNode.has_key('version'))
        except Exception as excep:
            self.assertFalse(True)
            raise excep
Ejemplo n.º 10
0
    def test_submission_with_receiver_selection(self):

        yield create_receiver(self.get_new_receiver_desc("second"))
        yield create_receiver(self.get_new_receiver_desc("third"))
        yield create_receiver(self.get_new_receiver_desc("fourth"))

        # for some reason, the first receiver is no more with the same ID
        self.receivers = yield get_receiver_list()

        self.assertEqual(len(self.receivers), 4)

        self.dummyContext["receivers"] = [
            self.receivers[0]["receiver_gus"],
            self.receivers[1]["receiver_gus"],
            self.receivers[2]["receiver_gus"],
            self.receivers[3]["receiver_gus"],
        ]
        self.dummyContext["selectable_receiver"] = True
        self.dummyContext["escalation_threshold"] = 0

        context_status = yield update_context(self.dummyContext["context_gus"], self.dummyContext)

        # Create a new request with selected three of the four receivers
        submission_request = dict(self.dummySubmission)
        # submission_request['context_gus'] = context_status['context_gus']
        submission_request["submission_gus"] = submission_request["id"] = ""
        submission_request["finalize"] = False
        submission_request["receivers"] = [
            self.receivers[0]["receiver_gus"],
            self.receivers[1]["receiver_gus"],
            self.receivers[2]["receiver_gus"],
        ]

        status = yield submission.create_submission(submission_request, finalize=False)
        just_empty_eventually_internaltip = yield delivery_sched.tip_creation()

        # Checks, the submission need to be the same now
        self.assertEqual(len(submission_request["receivers"]), len(status["receivers"]))

        status["finalize"] = True
        submission_request["context_gus"] = context_status["context_gus"]  # reused
        status["receivers"] = [self.receivers[0]["receiver_gus"], self.receivers[3]["receiver_gus"]]

        status = yield submission.update_submission(status["submission_gus"], status, finalize=True)

        receiver_tips = yield delivery_sched.tip_creation()
        self.assertEqual(len(receiver_tips), len(status["receivers"]))
Ejemplo n.º 11
0
    def test_tor2web_absence(self):
        """
        This test checks:
        https://github.com/globaleaks/GlobaLeaks/issues/268
        """

        ### INITIALIZE BLOCK
        self.mockContext = helpers.MockDict().dummyContext
        self.mockReceiver = helpers.MockDict().dummyReceiver
        self.mockNode = helpers.MockDict().dummyNode

        self.createdContext = yield admin.create_context(self.mockContext)
        self.assertTrue(self.createdContext.has_key('id'))

        self.mockReceiver['contexts'] = [self.createdContext['id']]

        self.createdReceiver = yield admin.create_receiver(self.mockReceiver)
        self.assertTrue(self.createdReceiver.has_key('id'))

        self.createdNode = yield admin.update_node(self.mockNode)
        self.assertTrue(self.createdNode.has_key('version'))
        ### END OF THE INITIALIZE BLOCK

        # be sure of Tor2Web capability
        for attrname in Node.localized_strings:
            self.mockNode[attrname] = self.mockNode[attrname]['en']
        self.createdNode = yield admin.update_node(self.mockNode)
        yield admin.import_memory_variables()

        self._load_defaults()

        self.mockSubmission = helpers.MockDict().dummySubmission
        self.mockSubmission['finalize'] = True
        self.mockSubmission['context_id'] = self.createdReceiver['contexts'][0]
        self.mockSubmission['receivers'] = [self.createdReceiver['id']]
        self.mockSubmission['wb_fields'] = helpers.fill_random_fields(
            self.createdContext)
        self.createdSubmission = yield submission.create_submission(
            self.mockSubmission, finalize=True)

        created_rtip = yield delivery_sched.tip_creation()
        self.assertEqual(len(created_rtip), 1)

        yield self._fill_event(u'encrypted_tip', 'Tip', created_rtip[0])

        # adding funny configured variables
        self.templates['default_ETNT.txt'][
            'en'] += " %OttimoDireiOOOttimoDirei%"

        # with the event, we can finally call the format checks
        gentext = Templating().format_template(
            self.templates['default_ETNT.txt'], self.event)

        self.assertSubstring(self.createdContext['name'], gentext)
        self.assertSubstring(created_rtip[0], gentext)
        self.assertNotSubstring("%TipT2WURL%", gentext)

        # test against funny configured variables
        self.assertSubstring("%OttimoDireiOOOttimoDirei%", gentext)
Ejemplo n.º 12
0
    def do_setup_tip_environment(self):

        basehandler = MockHandler()

        basehandler.validate_jmessage(self.tipContext, requests.adminContextDesc)
        self.context_desc = yield admin.create_context(self.tipContext)

        self.tipReceiver1['contexts'] = self.tipReceiver2['contexts'] = [ self.context_desc['context_gus'] ]
        basehandler.validate_jmessage( self.tipReceiver1, requests.adminReceiverDesc )
        basehandler.validate_jmessage( self.tipReceiver2, requests.adminReceiverDesc )

        try:
            self.receiver1_desc = yield admin.create_receiver(self.tipReceiver1)
            self.receiver2_desc = yield admin.create_receiver(self.tipReceiver2)
        except Exception, e:
            print e
            self.assertTrue(False)
    def test_001_setup_submission_environment(self):
        helpers.TestGL.setUp(self)
        
        basehandler = MockHandler()

        stuff = u"AAA :P ³²¼½¬¼³²"

        for attrname in Context.localized_strings:
            SubmissionTest.aContext1[attrname] = stuff

        basehandler.validate_jmessage( SubmissionTest.aContext1, adminContextDesc)
        SubmissionTest.context_used = yield admin.create_context(SubmissionTest.aContext1)

        # Correctly, TTip.tipContext has not selectable receiver, and we want test it in the 2nd test
        SubmissionTest.context_used['selectable_receiver'] = True

        for attrname in Context.localized_strings:
            SubmissionTest.context_used[attrname] = stuff

        SubmissionTest.context_used = yield admin.update_context(SubmissionTest.context_used['id'],
            SubmissionTest.context_used)

        basehandler.validate_jmessage( SubmissionTest.aContext2, adminContextDesc)
        SubmissionTest.context_unused = yield admin.create_context(SubmissionTest.aContext2)

        self.assertTrue(len(SubmissionTest.context_used['id']) > 1)
        self.assertTrue(len(SubmissionTest.context_unused['id']) > 1)

        SubmissionTest.aReceiver1['contexts'] = [ SubmissionTest.context_used['id'] ]

        for attrname in Receiver.localized_strings:
            SubmissionTest.aReceiver1[attrname] = stuff * 2
            SubmissionTest.aReceiver2[attrname] = stuff * 4

        basehandler.validate_jmessage( SubmissionTest.aReceiver1, adminReceiverDesc )
        SubmissionTest.receiver_used = yield admin.create_receiver(SubmissionTest.aReceiver1)

        SubmissionTest.aReceiver2['contexts'] = [ SubmissionTest.context_unused['id'] ]
        basehandler.validate_jmessage( SubmissionTest.aReceiver2, adminReceiverDesc )
        SubmissionTest.receiver_unused = yield admin.create_receiver(SubmissionTest.aReceiver2)

        self.assertTrue(SubmissionTest.receiver_used['name'] == SubmissionTest.aReceiver1['name'])
        self.assertTrue(SubmissionTest.receiver_unused['name'] == SubmissionTest.aReceiver2['name'])

        self.assertTrue(len(SubmissionTest.receiver_used['contexts']), 1)
        self.assertTrue(len(SubmissionTest.receiver_unused['contexts']), 1)
Ejemplo n.º 14
0
 def test_create_submission_with_wrong_receiver(self):
     disassociated_receiver = yield create_receiver(
         self.get_dummy_receiver('dumb'), 'en')
     self.submission_desc = yield self.get_dummy_submission(
         self.dummyContext['id'])
     self.submission_desc['receivers'].append(disassociated_receiver['id'])
     yield self.assertFailure(self.create_submission(self.submission_desc),
                              errors.InvalidInputFormat)
Ejemplo n.º 15
0
    def setup_tip_environment(self):

        basehandler = MockHandler()

        stuff = u'⅛⅛⅛£"$"$¼³²¼²³¼²³“““““ð'
        for attrname in models.Context.localized_strings:
            self.tipContext[attrname] = stuff

        basehandler.validate_jmessage(self.tipContext, requests.adminContextDesc)

        # the test context need fields to be present
        from globaleaks.handlers.admin.field import create_field
        for idx, field in enumerate(self.dummyFields):
            f = yield create_field(field, 'en')
            self.dummyFields[idx]['id'] = f['id']

        self.tipContext['steps'][0]['children'] = [
            self.dummyFields[0], # Field 1
            self.dummyFields[1], # Field 2
            self.dummyFields[4]  # Generalities
        ]

        self.context_desc = yield admin.create_context(self.tipContext)

        self.tipReceiver1['contexts'] = self.tipReceiver2['contexts'] = [ self.context_desc['id'] ]

        for attrname in models.Receiver.localized_strings:
            self.tipReceiver1[attrname] = stuff
            self.tipReceiver2[attrname] = stuff

        basehandler.validate_jmessage( self.tipReceiver1, requests.adminReceiverDesc )
        basehandler.validate_jmessage( self.tipReceiver2, requests.adminReceiverDesc )

        self.receiver1_desc = yield admin.create_receiver(self.tipReceiver1)
        self.receiver2_desc = yield admin.create_receiver(self.tipReceiver2)

        self.assertEqual(self.receiver1_desc['contexts'], [ self.context_desc['id']])

        dummySubmissionDict = yield self.get_dummy_submission(self.context_desc['id'])
        basehandler.validate_jmessage(dummySubmissionDict, requests.wbSubmissionDesc)

        self.submission_desc = yield submission.create_submission(dummySubmissionDict, finalize=True)

        self.assertEqual(self.submission_desc['wb_steps'], dummySubmissionDict['wb_steps'])
        self.assertEqual(self.submission_desc['mark'], models.InternalTip._marker[1])
Ejemplo n.º 16
0
    def fill_data(self):
        yield do_appdata_init()

        receivers_ids = []

        # fill_data/create_receiver
        self.dummyReceiver_1 = yield create_receiver(self.dummyReceiver_1,
                                                     'en')
        receivers_ids.append(self.dummyReceiver_1['id'])
        self.dummyReceiver_2 = yield create_receiver(self.dummyReceiver_2,
                                                     'en')
        receivers_ids.append(self.dummyReceiver_2['id'])

        # fill_data/create_context
        self.dummyContext['receivers'] = receivers_ids
        self.dummyContext = yield create_context(
            copy.deepcopy(self.dummyContext), 'en')

        # fill_data: create field templates
        for idx, field in enumerate(self.dummyFieldTemplates):
            f = yield create_field(copy.deepcopy(field), 'en')
            self.dummyFieldTemplates[idx]['id'] = f['id']

        # fill_data: create fields and associate them to the context steps
        for idx, field in enumerate(self.dummyFields):
            field['is_template'] = False
            if idx <= 2:
                # "Field 1", "Field 2" and "Generalities" are associated to the first step
                field['step_id'] = self.dummyContext['steps'][0]['id']
            else:
                # Name, Surname, Gender" are associated to field "Generalities"
                # "Field 1" and "Field 2" are associated to the first step
                field['fieldgroup_id'] = self.dummyFields[2]['id']

            f = yield create_field(copy.deepcopy(field), 'en')
            self.dummyFields[idx]['id'] = f['id']

        self.dummyContext['steps'][0]['children'] = [
            self.dummyFields[0],  # Field 1
            self.dummyFields[1],  # Field 2
            self.dummyFields[2]  # Generalities
        ]

        yield update_context(self.dummyContext['id'],
                             copy.deepcopy(self.dummyContext), 'en')
Ejemplo n.º 17
0
    def do_setup_tip_environment(self):

        basehandler = MockHandler()

        # the test context need fields to be present
        from globaleaks.handlers.admin.field import create_field
        for idx, field in enumerate(self.dummyFields):
            f = yield create_field(field, 'en')
            self.dummyFields[idx]['id'] = f['id']

        self.tipContext['steps'][0]['children'] = [
            self.dummyFields[0], # Field 1
            self.dummyFields[1], # Field 2
            self.dummyFields[4]  # Generalities
        ]

        basehandler.validate_jmessage(self.tipContext, requests.adminContextDesc)
        self.context_desc = yield admin.create_context(self.tipContext)

        self.tipReceiver1['contexts'] = self.tipReceiver2['contexts'] = [ self.context_desc['id'] ]

        for attrname in models.Receiver.localized_strings:
            self.tipReceiver2[attrname] = u'222222’‘ª‘ª’‘ÐŊ'
            self.tipReceiver1[attrname] = u'⅛¡⅜⅛’ŊÑŦŊ1111111’‘ª‘ª’‘ÐŊ'

        basehandler.validate_jmessage( self.tipReceiver1, requests.adminReceiverDesc )
        basehandler.validate_jmessage( self.tipReceiver2, requests.adminReceiverDesc )

        try:
            self.receiver1_desc = yield admin.create_receiver(self.tipReceiver1)
            self.receiver2_desc = yield admin.create_receiver(self.tipReceiver2)
        except Exception as exxxx:
            self.assertTrue(False)

        self.assertEqual(self.receiver1_desc['contexts'], [ self.context_desc['id']])
        self.assertEqual(self.receiver2_desc['contexts'], [ self.context_desc['id']])

        dummySubmission = yield self.get_dummy_submission(self.context_desc['id'])
        basehandler.validate_jmessage( dummySubmission, requests.wbSubmissionDesc)

        self.submission_desc = yield submission.create_submission(dummySubmission, finalize=False)

        self.assertEqual(self.submission_desc['wb_steps'], dummySubmission['wb_steps'])
        self.assertEqual(self.submission_desc['mark'], models.InternalTip._marker[0])
Ejemplo n.º 18
0
    def setup_tip_environment(self):

        basehandler = MockHandler()

        stuff = u'⅛⅛⅛£"$"$¼³²¼²³¼²³“““““ð'
        for attrname in models.Context.localized_strings:
            self.tipContext[attrname] = stuff

        basehandler.validate_jmessage(self.tipContext,
                                      requests.adminContextDesc)

        self.context_desc = yield admin.create_context(self.tipContext)

        self.tipReceiver1['contexts'] = self.tipReceiver2['contexts'] = [
            self.context_desc['id']
        ]

        for attrname in models.Receiver.localized_strings:
            self.tipReceiver1[attrname] = stuff
            self.tipReceiver2[attrname] = stuff

        basehandler.validate_jmessage(self.tipReceiver1,
                                      requests.adminReceiverDesc)
        basehandler.validate_jmessage(self.tipReceiver2,
                                      requests.adminReceiverDesc)

        self.receiver1_desc = yield admin.create_receiver(self.tipReceiver1)
        self.receiver2_desc = yield admin.create_receiver(self.tipReceiver2)

        self.assertEqual(self.receiver1_desc['contexts'],
                         [self.context_desc['id']])

        dummySubmissionDict = self.get_dummy_submission(
            self.context_desc['id'], self.context_desc['fields'])
        basehandler.validate_jmessage(dummySubmissionDict,
                                      requests.wbSubmissionDesc)

        self.submission_desc = yield submission.create_submission(
            dummySubmissionDict, finalize=True)

        self.assertEqual(self.submission_desc['wb_fields'],
                         dummySubmissionDict['wb_fields'])
        self.assertEqual(self.submission_desc['mark'],
                         models.InternalTip._marker[1])
Ejemplo n.º 19
0
    def setup_tip_environment(self):

        basehandler = MockHandler()

        stuff = u'⅛⅛⅛£"$"$¼³²¼²³¼²³“““““ð'
        for attrname in models.Context.localized_strings:
            self.tipContext[attrname] = stuff

        basehandler.validate_jmessage(self.tipContext, requests.adminContextDesc)

        for idx, field in enumerate(self.dummyFields):
            f = yield create_field(field, 'en')
            self.dummyFields[idx]['id'] = f['id']

        self.tipContext['steps'][0]['children'] = [
            self.dummyFields[0], # Field 1
            self.dummyFields[1], # Field 2
            self.dummyFields[4]  # Generalities
        ]

        self.context_desc = yield admin.create_context(self.tipContext, 'en')

        self.tipReceiver1['contexts'] = self.tipReceiver2['contexts'] = [ self.context_desc['id'] ]

        for attrname in models.Receiver.localized_strings:
            self.tipReceiver1[attrname] = stuff
            self.tipReceiver2[attrname] = stuff

        basehandler.validate_jmessage( self.tipReceiver1, requests.adminReceiverDesc )
        basehandler.validate_jmessage( self.tipReceiver2, requests.adminReceiverDesc )

        self.receiver1_desc = yield admin.create_receiver(self.tipReceiver1, 'en')
        self.receiver2_desc = yield admin.create_receiver(self.tipReceiver2, 'en')

        self.assertEqual(self.receiver1_desc['contexts'], [ self.context_desc['id']])

        dummySubmissionDict = yield self.get_dummy_submission(self.context_desc['id'])
        basehandler.validate_jmessage(dummySubmissionDict, requests.wbSubmissionDesc)

        self.submission_desc = yield submission.create_submission(dummySubmissionDict, True, 'en')

        self.assertEqual(self.submission_desc['wb_steps'], dummySubmissionDict['wb_steps'])
        self.assertEqual(self.submission_desc['mark'], u'finalize')
Ejemplo n.º 20
0
    def test_tor2web_absence(self):
        """
        This test checks:
        https://github.com/globaleaks/GlobaLeaks/issues/268
        """

        ### INITIALIZE BLOCK
        self.mockContext = helpers.MockDict().dummyContext
        self.mockReceiver = helpers.MockDict().dummyReceiver
        self.mockNode = helpers.MockDict().dummyNode

        self.createdContext = yield admin.create_context(self.mockContext)
        self.assertTrue(self.createdContext.has_key('id'))

        self.mockReceiver['contexts'] = [ self.createdContext['id'] ]

        self.createdReceiver = yield admin.create_receiver(self.mockReceiver)
        self.assertTrue(self.createdReceiver.has_key('id'))

        self.createdNode = yield admin.update_node(self.mockNode)
        self.assertTrue(self.createdNode.has_key('version'))
        ### END OF THE INITIALIZE BLOCK

        # be sure of Tor2Web capability
        for attrname in Node.localized_strings:
            self.mockNode[attrname] = self.mockNode[attrname]['en']
        self.createdNode = yield admin.update_node(self.mockNode)
        yield admin.import_memory_variables()

        self._load_defaults()

        self.mockSubmission = helpers.MockDict().dummySubmission
        self.mockSubmission['finalize'] = True
        self.mockSubmission['context_id'] = self.createdReceiver['contexts'][0]
        self.mockSubmission['receivers'] = [ self.createdReceiver['id'] ]
        self.mockSubmission['wb_fields'] = helpers.fill_random_fields(self.createdContext)
        self.createdSubmission = yield submission.create_submission(self.mockSubmission, finalize=True)

        created_rtip = yield delivery_sched.tip_creation()
        self.assertEqual(len(created_rtip), 1)

        yield self._fill_event(u'encrypted_tip', 'Tip', created_rtip[0])

        # adding funny configured variables 
        self.templates['default_ETNT.txt']['en'] += " %OttimoDireiOOOttimoDirei%"

        # with the event, we can finally call the format checks
        gentext = Templating().format_template(self.templates['default_ETNT.txt'], self.event)

        self.assertSubstring(self.createdContext['name'], gentext)
        self.assertSubstring(created_rtip[0], gentext)
        self.assertNotSubstring("%TipT2WURL%", gentext)

        # test against funny configured variables
        self.assertSubstring("%OttimoDireiOOOttimoDirei%", gentext)
Ejemplo n.º 21
0
    def fill_data(self):
        yield do_appdata_init()

        receivers_ids = []

        # fill_data/create_receiver
        self.dummyReceiver_1 = yield create_receiver(self.dummyReceiver_1, 'en')
        receivers_ids.append(self.dummyReceiver_1['id'])
        self.dummyReceiver_2 = yield create_receiver(self.dummyReceiver_2, 'en')
        receivers_ids.append(self.dummyReceiver_2['id'])

        # fill_data/create_context
        self.dummyContext['receivers'] = receivers_ids
        self.dummyContext = yield create_context(copy.deepcopy(self.dummyContext), 'en')

        # fill_data: create field templates
        for idx, field in enumerate(self.dummyFieldTemplates):
            f = yield create_field(copy.deepcopy(field), 'en')
            self.dummyFieldTemplates[idx]['id'] = f['id']

        # fill_data: create fields and associate them to the context steps
        for idx, field in enumerate(self.dummyFields):
            field['is_template'] = False
            if idx <= 2:
                # "Field 1", "Field 2" and "Generalities" are associated to the first step
                field['step_id'] = self.dummyContext['steps'][0]['id']
            else:
                # Name, Surname, Gender" are associated to field "Generalities"
                # "Field 1" and "Field 2" are associated to the first step
                field['fieldgroup_id'] = self.dummyFields[2]['id']

            f = yield create_field(copy.deepcopy(field), 'en')
            self.dummyFields[idx]['id'] = f['id']

        self.dummyContext['steps'][0]['children'] = [
            self.dummyFields[0],  # Field 1
            self.dummyFields[1],  # Field 2
            self.dummyFields[2]   # Generalities
        ]

        yield update_context(self.dummyContext['id'], copy.deepcopy(self.dummyContext), 'en')
Ejemplo n.º 22
0
    def test_1_setup_submission_environment(self):
        helpers.TestGL.setUp(self)

        basehandler = MockHandler()

        # context creation
        try:
            basehandler.validate_jmessage(SubmissionTest.aContext1, adminContextDesc)
            SubmissionTest.context_used = yield admin.create_context(SubmissionTest.aContext1)
            # Correctly, TTip.tipContext has not selectable receiver, and we want test it in the 2nd test
            SubmissionTest.context_used["selectable_receiver"] = True
            SubmissionTest.context_used = yield admin.update_context(
                SubmissionTest.context_used["context_gus"], SubmissionTest.context_used
            )
            basehandler.validate_jmessage(SubmissionTest.aContext2, adminContextDesc)
            SubmissionTest.context_unused = yield admin.create_context(SubmissionTest.aContext2)
        except Exception as excep:
            log.err("Unable to create context used/unused in UT: %s" % excep.message)
            raise excep

        self.assertTrue(len(SubmissionTest.context_used["context_gus"]) > 1)
        self.assertTrue(len(SubmissionTest.context_unused["context_gus"]) > 1)

        SubmissionTest.aReceiver1["contexts"] = [SubmissionTest.context_used["context_gus"]]
        basehandler.validate_jmessage(SubmissionTest.aReceiver1, adminReceiverDesc)
        SubmissionTest.receiver_used = yield admin.create_receiver(SubmissionTest.aReceiver1)

        SubmissionTest.aReceiver2["contexts"] = [SubmissionTest.context_unused["context_gus"]]
        basehandler.validate_jmessage(SubmissionTest.aReceiver2, adminReceiverDesc)
        SubmissionTest.receiver_unused = yield admin.create_receiver(SubmissionTest.aReceiver2)

        self.assertTrue(SubmissionTest.receiver_used["name"] == SubmissionTest.aReceiver1["name"])
        self.assertTrue(SubmissionTest.receiver_unused["name"] == SubmissionTest.aReceiver2["name"])

        self.assertTrue(len(SubmissionTest.receiver_used["contexts"]), 1)
        self.assertTrue(len(SubmissionTest.receiver_unused["contexts"]), 1)
Ejemplo n.º 23
0
    def test_default_template_keywords(self):

        self._load_defaults()

        ### INITIALIZE BLOCK
        self.mockContext = helpers.MockDict().dummyContext
        self.mockReceiver = helpers.MockDict().dummyReceiver
        self.mockNode = helpers.MockDict().dummyNode

        self.createdContext = yield admin.create_context(self.mockContext)
        self.assertTrue(self.createdContext.has_key('id'))

        self.mockReceiver['contexts'] = [self.createdContext['id']]

        self.createdReceiver = yield admin.create_receiver(self.mockReceiver)
        self.assertTrue(self.createdReceiver.has_key('id'))

        self.createdNode = yield admin.update_node(self.mockNode)
        self.assertTrue(self.createdNode.has_key('version'))
        ### END OF THE INITIALIZE BLOCK

        # THE REAL CONVERSION TEST START HERE:
        self.mockSubmission = helpers.MockDict().dummySubmission
        self.mockSubmission['finalize'] = True
        self.mockSubmission['context_id'] = self.createdReceiver['contexts'][0]
        self.mockSubmission['receivers'] = [self.createdReceiver['id']]
        self.mockSubmission['wb_fields'] = helpers.fill_random_fields(
            self.createdContext)
        self.createdSubmission = yield submission.create_submission(
            self.mockSubmission, finalize=True)

        created_rtip = yield delivery_sched.tip_creation()
        self.assertEqual(len(created_rtip), 1)

        yield self._fill_event(u'encrypted_tip', 'Tip', created_rtip[0])

        # with the event, we can finally call the template filler
        gentext = Templating().format_template(
            self.templates['default_ETNT.txt'], self.event)

        self.assertSubstring(self.createdContext['name'], gentext)
        self.assertSubstring(created_rtip[0], gentext)
        self.assertSubstring(self.createdNode['public_site'], gentext)
Ejemplo n.º 24
0
    def test_default_template_keywords(self):

        self._load_defaults()

        ### INITIALIZE BLOCK
        self.mockContext = helpers.MockDict().dummyContext
        self.mockReceiver = helpers.MockDict().dummyReceiver
        self.mockNode = helpers.MockDict().dummyNode

        self.createdContext = yield admin.create_context(self.mockContext)
        self.assertTrue(self.createdContext.has_key('id'))

        self.mockReceiver['contexts'] = [ self.createdContext['id'] ]

        self.createdReceiver = yield admin.create_receiver(self.mockReceiver)
        self.assertTrue(self.createdReceiver.has_key('id'))

        self.createdNode = yield admin.update_node(self.mockNode)
        self.assertTrue(self.createdNode.has_key('version'))
        ### END OF THE INITIALIZE BLOCK

        # THE REAL CONVERSION TEST START HERE:
        self.mockSubmission = helpers.MockDict().dummySubmission
        self.mockSubmission['finalize'] = True
        self.mockSubmission['context_id'] = self.createdReceiver['contexts'][0]
        self.mockSubmission['receivers'] = [ self.createdReceiver['id'] ]
        self.mockSubmission['wb_fields'] = helpers.fill_random_fields(self.createdContext)
        self.createdSubmission = yield submission.create_submission(self.mockSubmission, finalize=True)

        created_rtip = yield delivery_sched.tip_creation()
        self.assertEqual(len(created_rtip), 1)

        yield self._fill_event(u'encrypted_tip', 'Tip', created_rtip[0])

        # with the event, we can finally call the template filler
        gentext = Templating().format_template(self.templates['default_ETNT.txt'], self.event)

        self.assertSubstring(self.createdContext['name'], gentext)
        self.assertSubstring(created_rtip[0], gentext)
        self.assertSubstring(self.createdNode['public_site'], gentext)
Ejemplo n.º 25
0
    def fill_data(self):
        try:
            receiver = yield create_receiver(self.dummyReceiver)

            self.dummyReceiver['receiver_gus'] = receiver['receiver_gus']
            self.receiver_assertion(self.dummyReceiver, receiver)
        except Exception as excp:
            print "Fail fill_data/create_receiver: %s" % excp

        try:
            self.dummyContext['receivers'] = [ self.dummyReceiver['receiver_gus'] ]
            context = yield create_context(self.dummyContext)
            self.dummyContext['context_gus'] = context['context_gus']

        except Exception as excp:
            print "Fail fill_data/create_context: %s" % excp

        self.dummySubmission['context_gus'] = self.dummyContext['context_gus']
        self.dummySubmission['receivers'] = [ self.dummyReceiver['receiver_gus'] ]
        self.dummySubmission['wb_fields'] = fill_random_fields(self.dummyContext)

        try:
            submission = yield create_submission(self.dummySubmission, finalize=True)
            self.dummySubmission['id'] = submission['id']
            self.dummySubmission['submission_gus'] = submission['submission_gus']
        except Exception as excp:
            print "Fail fill_data/create_submission: %s" % excp

        try:
            self.dummyWBTip = yield create_whistleblower_tip(self.dummySubmission)
        except Exception as excp:
            print "Fail fill_data/create_whistleblower: %s" % excp

        assert self.dummyContext.has_key('context_gus')
        assert self.dummyReceiver.has_key('receiver_gus')
        assert self.dummySubmission.has_key('submission_gus')
Ejemplo n.º 26
0
    def fill_data(self):
        try:
            yield do_appdata_init()

        except Exception as excp:
            print "Fail fill_data/do_appdata_init: %s" % excp
            raise  excp

        receivers_ids = []

        try:
            self.dummyReceiver_1 = yield create_receiver(self.dummyReceiver_1)
            receivers_ids.append(self.dummyReceiver_1['id'])
            self.dummyReceiver_2 = yield create_receiver(self.dummyReceiver_2)
            receivers_ids.append(self.dummyReceiver_2['id'])
        except Exception as excp:
            print "Fail fill_data/create_receiver: %s" % excp
            raise  excp

        try:
            self.dummyContext['receivers'] = receivers_ids
            self.dummyContext = yield create_context(self.dummyContext)
        except Exception as excp:
            print "Fail fill_data/create_context: %s" % excp
            raise  excp

        self.dummySubmission['context_id'] = self.dummyContext['id']
        self.dummySubmission['receivers'] = receivers_ids
        self.dummySubmission['wb_fields'] = fill_random_fields(self.dummyContext)

        try:
            self.dummySubmissionNotFinalized = yield create_submission(self.dummySubmission, finalize=False)
        except Exception as excp:
            print "Fail fill_data/create_submission: %s" % excp
            raise  excp

        try:
            self.dummySubmission = yield create_submission(self.dummySubmission, finalize=False)
        except Exception as excp:
            print "Fail fill_data/create_submission: %s" % excp
            raise  excp

        yield self.emulate_file_upload(self.dummySubmission['id'])

        try:
            submission = yield update_submission(self.dummySubmission['id'], self.dummySubmission, finalize=True)
        except Exception as excp:
            print "Fail fill_data/update_submission: %s" % excp
            raise  excp

        try:
            self.dummyWBTip = yield create_whistleblower_tip(self.dummySubmission)
        except Exception as excp:
            print "Fail fill_data/create_whistleblower: %s" % excp
            raise  excp

        assert self.dummyReceiver_1.has_key('id')
        assert self.dummyReceiver_2.has_key('id')
        assert self.dummyContext.has_key('id')
        assert self.dummySubmission.has_key('id')

        yield delivery_sched.DeliverySchedule().operation()
        yield notification_sched.NotificationSchedule().operation()

        commentCreation = {
            'content': 'comment!',
        }

        messageCreation = {
            'content': 'message!',
        }

        rtips_desc = yield self.get_rtips()

        for rtip_desc in rtips_desc:
            yield rtip.create_comment_receiver(rtip_desc['receiver_id'],
                                               rtip_desc['rtip_id'],
                                               commentCreation)

            yield rtip.create_message_receiver(rtip_desc['receiver_id'],
                                               rtip_desc['rtip_id'],
                                               messageCreation)


        wbtips_desc = yield self.get_wbtips()

        for wbtip_desc in wbtips_desc: 
            yield wbtip.create_comment_wb(wbtip_desc['wbtip_id'],
                                          commentCreation)

            for receiver_id in wbtip_desc['wbtip_receivers']:
                yield wbtip.create_message_wb(wbtip_desc['wbtip_id'], receiver_id, messageCreation)

        yield delivery_sched.DeliverySchedule().operation()
        yield notification_sched.NotificationSchedule().operation()
Ejemplo n.º 27
0
    def test_submission_file_delivery_gpg(self):

        new_context = dict(MockDict().dummyContext)
        new_context['name'] = "this uniqueness is no more checked due to the lang"
        new_context_output = yield create_context(new_context)
        self.context_assertion(new_context, new_context_output)

        doubletest = yield get_context_list('en')
        self.assertEqual(len(doubletest), 2)

        yanr = dict(MockDict().dummyReceiver)
        yanr['name'] = yanr['notification_fields']['mail_address'] = "*****@*****.**"
        yanr['gpg_key_armor'] = unicode(DeveloperKey.__doc__)
        yanr['gpg_enable_files'] = True
        yanr['contexts'] = [ new_context_output['context_gus']]
        yanr_output = yield create_receiver(yanr)
        self.receiver_assertion(yanr, yanr_output)

        asdr = dict(MockDict().dummyReceiver)
        asdr['name'] = asdr['notification_fields']['mail_address'] = "*****@*****.**"
        asdr['gpg_key_armor'] = unicode(DeveloperKey.__doc__)
        asdr['gpg_enable_files'] = True
        asdr['contexts'] = [ new_context_output['context_gus']]
        asdr_output = yield create_receiver(asdr)
        self.receiver_assertion(asdr, asdr_output)

        new_subm = dict(MockDict().dummySubmission)
        new_subm['finalize'] = False
        new_subm['context_gus'] = new_context_output['context_gus']
        new_subm['receivers'] = [ asdr_output['receiver_gus'],
                                  yanr_output['receiver_gus'] ]
        new_subm_output = yield create_submission(new_subm, False)
        # self.submission_assertion(new_subm, new_subm_output)

        new_file = dict(MockDict().dummyFile)

        (relationship1, cksum, fsize) = yield threads.deferToThread(files.dump_file_fs, new_file)
        # encrypted output is always greater than the not encrypted
        self.assertGreater(fsize, new_file['body_len'])

        self.registered_file1 = yield files.register_file_db(
            new_file, relationship1, cksum, new_subm_output['submission_gus'] )

        new_subm['submission_gus'] = new_subm_output['submission_gus']
        new_subm['finalize'] = True
        new_subm_output = yield update_submission(new_subm['submission_gus'], new_subm, True)

        yield APSDelivery().operation()

        # now get a lots of receivertips/receiverfiles and check!
        ifilist = yield get_files_by_itip(new_subm_output['submission_gus'])

        self.assertTrue(isinstance(ifilist, list))
        self.assertEqual(len(ifilist), 1)
        self.assertEqual(ifilist[0]['mark'], u'delivered')

        rfilist = yield get_receiverfile_by_itip(new_subm_output['submission_gus'])

        self.assertTrue(isinstance(ifilist, list))
        self.assertEqual(len(rfilist), 2)
        self.assertLess(ifilist[0]['size'], rfilist[0]['size'])
        self.assertLess(ifilist[0]['size'], rfilist[1]['size'])
        self.assertEqual(rfilist[0]['status'], u"encrypted" )
Ejemplo n.º 28
0
    def test_submission_file_delivery_gpg(self):

        new_context = dict(MockDict().dummyContext)
        new_context['name'] = "this uniqueness is no more checked due to the lang"
        new_context_output = yield create_context(new_context)
        self.context_assertion(new_context, new_context_output)

        doubletest = yield get_context_list('en')
        self.assertEqual(len(doubletest), 2)

        yanr = dict(MockDict().dummyReceiver)
        yanr['name'] = yanr['mail_address'] = u"*****@*****.**"
        yanr['gpg_key_armor'] = unicode(VALID_PGP_KEY)
        yanr['contexts'] = [ new_context_output['id']]
        yanr_output = yield create_receiver(yanr)
        self.receiver_assertion(yanr, yanr_output)

        asdr = dict(MockDict().dummyReceiver)
        asdr['name'] = asdr['mail_address'] = u"*****@*****.**"
        asdr['gpg_key_armor'] = unicode(VALID_PGP_KEY)
        asdr['contexts'] = [ new_context_output['id']]
        asdr_output = yield create_receiver(asdr)
        self.receiver_assertion(asdr, asdr_output)

        new_subm = dict(MockDict().dummySubmission)

        new_subm['finalize'] = False

        new_subm['context_id'] = new_context_output['id']
        new_subm['receivers'] = [ asdr_output['id'],
                                  yanr_output['id'] ]
        new_subm['wb_fields'] = fill_random_fields(new_context_output)
        new_subm_output = yield create_submission(new_subm, False)
        # self.submission_assertion(new_subm, new_subm_output)

        self.emulate_file_upload(new_subm_output['id'])

        new_file = self.get_dummy_file()

        new_subm['id'] = new_subm_output['id']
        new_subm['finalize'] = True
        new_subm_output = yield update_submission(new_subm['id'], new_subm, True)

        yield DeliverySchedule().operation()

        # now get a lots of receivertips/receiverfiles and check!
        ifilist = yield get_files_by_itip(new_subm_output['id'])

        self.assertTrue(isinstance(ifilist, list))
        self.assertEqual(len(ifilist), 2)
        self.assertEqual(ifilist[0]['mark'], u'delivered')

        rfilist = yield get_receiverfile_by_itip(new_subm_output['id'])

        self.assertTrue(isinstance(ifilist, list))
        self.assertEqual(len(rfilist), 2)

        for i in range(0, 2):
            self.assertLess(ifilist[0]['size'], rfilist[i]['size'])

        self.assertEqual(rfilist[0]['status'], u"encrypted" )
Ejemplo n.º 29
0
    def test_keywords_conversion(self):
        self.templates = {}
        for t, keywords_list in templates_desc.iteritems():

            self.templates[t] = ""

            for kwl in keywords_list:
                for keyword in kwl:
                    self.templates[t] += " " + keyword + " / "

        ### INITIALIZE DATABASE
        self.mockContext = helpers.MockDict().dummyContext
        self.mockReceiver = helpers.MockDict().dummyReceiverGPG
        self.mockNode = helpers.MockDict().dummyNode

        self.createdContext = yield admin.create_context(
            self.mockContext, 'en')
        self.assertTrue('id' in self.createdContext)

        self.mockReceiver['contexts'] = [self.createdContext['id']]

        self.createdReceiver = yield admin.create_receiver(
            self.mockReceiver, 'en')
        self.assertTrue('id' in self.createdReceiver)

        self.createdNode = yield admin.update_node(self.mockNode, True, 'en')
        self.assertTrue('version' in self.createdNode)
        ### END OF THE INITIALIZE BLOCK

        # THE REAL CONVERSION TEST START HERE:
        self.mockSubmission = helpers.MockDict().dummySubmission
        self.mockSubmission['finalize'] = True
        self.mockSubmission['context_id'] = self.createdReceiver['contexts'][0]
        self.mockSubmission['receivers'] = [self.createdReceiver['id']]
        self.mockSubmission['wb_fields'] = helpers.fill_random_fields(
            self.createdContext)
        self.createdSubmission = yield submission.create_submission(
            self.mockSubmission, True, 'en')

        created_rtip = yield delivery_sched.tip_creation()
        self.assertEqual(len(created_rtip), 1)

        # some doubt in the next two lines: is just to have a mock tip
        self.tip = dict(self.mockSubmission)
        self.tip['id'] = created_rtip[0]

        for template_name, template in self.templates.iteritems():
            # look for appropriate event_type, event_trigger
            event_type = u''
            event_trigger = ''
            for e_t, e_tri in supported_event_types.iteritems():
                if template_name.startswith(e_t):
                    event_type = e_t
                    event_trigger = e_tri
                    break

            if not event_type:
                # we've nothing to do not!
                continue

            yield self._fill_event_dict(event_type, event_trigger)

            # with the event, we can finally call the template filler
            gentext = Templating().format_template(template, self.event)

            if template_name != 'ping_mail_template' and template_name != 'ping_mail_title':
                self.assertSubstring(self.createdContext['name'], gentext)
                self.assertSubstring(self.createdNode['public_site'], gentext)
                self.assertSubstring(self.createdNode['hidden_service'],
                                     gentext)
Ejemplo n.º 30
0
    def test_submission_file_delivery_gpg(self):

        new_fields = MockDict().dummyFields
        new_context = MockDict().dummyContext

        new_context['steps'][0]['children'] = []

        new_context[
            'name'] = "this uniqueness is no more checked due to the lang"
        new_context_output = yield create_context(new_context, 'en')
        self.context_assertion(new_context, new_context_output)

        doubletest = yield get_context_list('en')
        self.assertEqual(len(doubletest), 2)

        yanr = dict(MockDict().dummyReceiver)
        yanr['name'] = yanr['mail_address'] = u"*****@*****.**"
        yanr['gpg_key_armor'] = unicode(VALID_PGP_KEY1)
        yanr['contexts'] = [new_context_output['id']]
        yanr_output = yield create_receiver(yanr, 'en')
        self.receiver_assertion(yanr, yanr_output)

        asdr = dict(MockDict().dummyReceiver)
        asdr['name'] = asdr['mail_address'] = u"*****@*****.**"
        asdr['gpg_key_armor'] = unicode(VALID_PGP_KEY1)
        asdr['contexts'] = [new_context_output['id']]
        asdr_output = yield create_receiver(asdr, 'en')
        self.receiver_assertion(asdr, asdr_output)

        new_subm = dict(MockDict().dummySubmission)

        new_subm['finalize'] = False

        new_subm['context_id'] = new_context_output['id']
        new_subm['receivers'] = [asdr_output['id'], yanr_output['id']]
        new_subm['wb_steps'] = yield fill_random_fields(
            new_context_output['id'])
        new_subm_output = yield create_submission(new_subm, False, 'en')
        # self.submission_assertion(new_subm, new_subm_output)

        self.emulate_file_upload(new_subm_output['id'])

        new_file = self.get_dummy_file()

        new_subm['id'] = new_subm_output['id']
        new_subm['finalize'] = True
        new_subm_output = yield update_submission(new_subm['id'], new_subm,
                                                  True, 'en')

        yield DeliverySchedule().operation()

        # now get a lots of receivertips/receiverfiles and check!
        ifilist = yield get_files_by_itip(new_subm_output['id'])

        self.assertTrue(isinstance(ifilist, list))
        self.assertEqual(len(ifilist), 2)
        self.assertEqual(ifilist[0]['mark'], u'delivered')

        rfilist = yield get_receiverfile_by_itip(new_subm_output['id'])

        self.assertTrue(isinstance(ifilist, list))
        self.assertEqual(len(rfilist), 2)

        for i in range(0, 2):
            self.assertLess(ifilist[0]['size'], rfilist[i]['size'])

        self.assertEqual(rfilist[0]['status'], u"encrypted")
Ejemplo n.º 31
0
    def fill_data(self):
        yield do_appdata_init()

        receivers_ids = []

        # fill_data/create_receiver
        self.dummyReceiver_1 = yield create_receiver(self.dummyReceiver_1)
        receivers_ids.append(self.dummyReceiver_1['id'])
        self.dummyReceiver_2 = yield create_receiver(self.dummyReceiver_2)
        receivers_ids.append(self.dummyReceiver_2['id'])

        # fill_data/create_context
        self.dummyContext['receivers'] = receivers_ids
        self.dummyContext = yield create_context(self.dummyContext)

        # fill_data: create cield templates
        for idx, field in enumerate(self.dummyFieldTemplates):
            f = yield create_field(field, 'en')
            self.dummyFieldTemplates[idx]['id'] = f['id']

        # fill_data: create fields and associate them to the context steps
        for idx, field in enumerate(self.dummyFields):
            field['is_template'] = False
            if idx <= 2:
                # "Field 1", "Field 2" and "Generalities" are associated to the first step
                field['step_id'] = self.dummyContext['steps'][0]['id']
            else:
                # Name, Surname, Gender" are associated to field "Generalities"
                # "Field 1" and "Field 2" are associated to the first step
                field['fieldgroup_id'] = self.dummyFields[2]['id']
               
            f = yield create_field(field, 'en')
            self.dummyFields[idx]['id'] = f['id']

        self.dummyContext['steps'][0]['children'] = [
            self.dummyFields[0], # Field 1
            self.dummyFields[1], # Field 2
            self.dummyFields[2]  # Generalities
        ]

        yield update_context(self.dummyContext['id'], self.dummyContext)

        # fill_data/create_submission
        self.dummySubmission['context_id'] = self.dummyContext['id']
        self.dummySubmission['receivers'] = receivers_ids
        self.dummySubmission['wb_steps'] = yield fill_random_fields(self.dummyContext['id'])
        self.dummySubmissionNotFinalized = yield create_submission(self.dummySubmission, finalize=False)
        self.dummySubmission = yield create_submission(self.dummySubmission, finalize=False)

        yield self.emulate_file_upload(self.dummySubmission['id'])
        # fill_data/update_submssion
        submission = yield update_submission(self.dummySubmission['id'], self.dummySubmission, finalize=True)
        # fill_data/create_whistleblower
        self.dummyWBTip = yield create_whistleblower_tip(self.dummySubmission)

        assert self.dummyReceiver_1.has_key('id')
        assert self.dummyReceiver_2.has_key('id')
        assert self.dummyContext.has_key('id')
        assert self.dummySubmission.has_key('id')

        yield delivery_sched.DeliverySchedule().operation()
        yield notification_sched.NotificationSchedule().operation()

        commentCreation = {
            'content': 'comment!',
        }

        messageCreation = {
            'content': 'message!',
        }

        rtips_desc = yield self.get_rtips()

        for rtip_desc in rtips_desc:
            yield rtip.create_comment_receiver(rtip_desc['receiver_id'],
                                               rtip_desc['rtip_id'],
                                               commentCreation)

            yield rtip.create_message_receiver(rtip_desc['receiver_id'],
                                               rtip_desc['rtip_id'],
                                               messageCreation)


        wbtips_desc = yield self.get_wbtips()

        for wbtip_desc in wbtips_desc:
            yield wbtip.create_comment_wb(wbtip_desc['wbtip_id'],
                                          commentCreation)

            for receiver_id in wbtip_desc['wbtip_receivers']:
                yield wbtip.create_message_wb(wbtip_desc['wbtip_id'], receiver_id, messageCreation)

        yield delivery_sched.DeliverySchedule().operation()
        yield notification_sched.NotificationSchedule().operation()
Ejemplo n.º 32
0
    def fill_data(self):
        try:
            yield do_appdata_init()

        except Exception as excp:
            print "Fail fill_data/do_appdata_init: %s" % excp
            raise excp

        receivers_ids = []

        try:
            self.dummyReceiver_1 = yield create_receiver(self.dummyReceiver_1)
            receivers_ids.append(self.dummyReceiver_1['id'])
            self.dummyReceiver_2 = yield create_receiver(self.dummyReceiver_2)
            receivers_ids.append(self.dummyReceiver_2['id'])
        except Exception as excp:
            print "Fail fill_data/create_receiver: %s" % excp
            raise excp

        try:
            self.dummyContext['receivers'] = receivers_ids
            self.dummyContext = yield create_context(self.dummyContext)
        except Exception as excp:
            print "Fail fill_data/create_context: %s" % excp
            raise excp

        self.dummySubmission['context_id'] = self.dummyContext['id']
        self.dummySubmission['receivers'] = receivers_ids
        self.dummySubmission['wb_fields'] = fill_random_fields(
            self.dummyContext)

        try:
            self.dummySubmissionNotFinalized = yield create_submission(
                self.dummySubmission, finalize=False)
        except Exception as excp:
            print "Fail fill_data/create_submission: %s" % excp
            raise excp

        try:
            self.dummySubmission = yield create_submission(
                self.dummySubmission, finalize=False)
        except Exception as excp:
            print "Fail fill_data/create_submission: %s" % excp
            raise excp

        yield self.emulate_file_upload(self.dummySubmission['id'])

        try:
            submission = yield update_submission(self.dummySubmission['id'],
                                                 self.dummySubmission,
                                                 finalize=True)
        except Exception as excp:
            print "Fail fill_data/update_submission: %s" % excp
            raise excp

        try:
            self.dummyWBTip = yield create_whistleblower_tip(
                self.dummySubmission)
        except Exception as excp:
            print "Fail fill_data/create_whistleblower: %s" % excp
            raise excp

        assert self.dummyReceiver_1.has_key('id')
        assert self.dummyReceiver_2.has_key('id')
        assert self.dummyContext.has_key('id')
        assert self.dummySubmission.has_key('id')

        yield delivery_sched.DeliverySchedule().operation()
        yield notification_sched.NotificationSchedule().operation()

        commentCreation = {
            'content': 'comment!',
        }

        messageCreation = {
            'content': 'message!',
        }

        rtips_desc = yield self.get_rtips()

        for rtip_desc in rtips_desc:
            yield rtip.create_comment_receiver(rtip_desc['receiver_id'],
                                               rtip_desc['rtip_id'],
                                               commentCreation)

            yield rtip.create_message_receiver(rtip_desc['receiver_id'],
                                               rtip_desc['rtip_id'],
                                               messageCreation)

        wbtips_desc = yield self.get_wbtips()

        for wbtip_desc in wbtips_desc:
            yield wbtip.create_comment_wb(wbtip_desc['wbtip_id'],
                                          commentCreation)

            for receiver_id in wbtip_desc['wbtip_receivers']:
                yield wbtip.create_message_wb(wbtip_desc['wbtip_id'],
                                              receiver_id, messageCreation)

        yield delivery_sched.DeliverySchedule().operation()
        yield notification_sched.NotificationSchedule().operation()
Ejemplo n.º 33
0
    def test_keywords_conversion(self):

        ### INITIALIZE BLOCK
        self.mockContext = helpers.MockDict().dummyContext
        self.mockReceiver = helpers.MockDict().dummyReceiver
        self.mockNode = helpers.MockDict().dummyNode

        self.createdContext = yield admin.create_context(self.mockContext)
        self.assertTrue(self.createdContext.has_key('id'))

        self.mockReceiver['contexts'] = [self.createdContext['id']]

        self.createdReceiver = yield admin.create_receiver(self.mockReceiver)
        self.assertTrue(self.createdReceiver.has_key('id'))

        self.createdNode = yield admin.update_node(self.mockNode)
        self.assertTrue(self.createdNode.has_key('version'))
        ### END OF THE INITIALIZE BLOCK

        self.templates = {}
        for t in self.templates_list:
            self.templates[t] = {'en': u""}

            for k in notifTemplateTest.generic_keyword_list:
                self.templates[t]['en'] += " " + k

        for k in notifTemplateTest.tip_keyword_list:
            self.templates['default_ETNT.txt']['en'] += " " + k
            self.templates['default_PTNT.txt']['en'] += " " + k

        for k in notifTemplateTest.protected_keyword_list:
            self.templates['default_ETNT.txt']['en'] += " " + k

        for k in notifTemplateTest.comment_keyword_list:
            self.templates['default_ECNT.txt']['en'] += " " + k
            self.templates['default_PCNT.txt']['en'] += " " + k

        for k in notifTemplateTest.file_keyword_list:
            self.templates['default_EFNT.txt']['en'] += " " + k
            self.templates['default_PFNT.txt']['en'] += " " + k

        # THE REAL CONVERSION TEST START HERE:
        self.mockSubmission = helpers.MockDict().dummySubmission
        self.mockSubmission['finalize'] = True
        self.mockSubmission['context_id'] = self.createdReceiver['contexts'][0]
        self.mockSubmission['receivers'] = [self.createdReceiver['id']]
        self.mockSubmission['wb_fields'] = helpers.fill_random_fields(
            self.createdContext)
        self.createdSubmission = yield submission.create_submission(
            self.mockSubmission, finalize=True)

        created_rtip = yield delivery_sched.tip_creation()
        self.assertEqual(len(created_rtip), 1)

        yield self._fill_event(u'encrypted_tip', 'Tip', created_rtip[0])

        # with the event, we can finally call the template filler
        gentext = Templating().format_template(
            self.templates['default_ETNT.txt'], self.event)

        self.assertSubstring(self.createdContext['name'], gentext)
        self.assertSubstring(created_rtip[0], gentext)
        self.assertSubstring(self.createdNode['public_site'], gentext)
        self.assertSubstring(self.createdNode['hidden_service'], gentext)

        ## HERE ARE ADDED SOME CHECK
        self.assertSubstring("=================", gentext)

        # http://witchwind.wordpress.com/2013/12/15/piv-is-always-rape-ok/
        # wtf has the internet in those days ? bwahahaah
        tip_num_test = Templating().format_template({'en': u'%TipNum%'},
                                                    self.event)
        new_id = self.event.trigger_info['id'].replace('1', '2')
        new_id.replace('3', '4')
        self.event.trigger_info['id'] = new_id.replace('5', '6')
        different_num = Templating().format_template({'en': u'%TipNum%'},
                                                     self.event)
        self.assertNotEqual(tip_num_test, different_num)
Ejemplo n.º 34
0
    def test_keywords_conversion(self):

        ### INITIALIZE BLOCK
        self.mockContext =helpers.MockDict().dummyContext
        self.mockReceiver = helpers.MockDict().dummyReceiver
        self.mockNode = helpers.MockDict().dummyNode

        self.createdContext = yield admin.create_context(self.mockContext)
        self.assertTrue(self.createdContext.has_key('id'))

        self.mockReceiver['contexts'] = [ self.createdContext['id'] ]
        
        self.createdReceiver = yield admin.create_receiver(self.mockReceiver)
        self.assertTrue(self.createdReceiver.has_key('id'))

        self.createdNode = yield admin.update_node(self.mockNode)
        self.assertTrue(self.createdNode.has_key('version'))
        ### END OF THE INITIALIZE BLOCK

        self.templates = {}
        for t in self.templates_list:
            self.templates[t] = { 'en': u"" }

            for k in notifTemplateTest.generic_keyword_list:
                self.templates[t]['en'] += " " + k

        for k in notifTemplateTest.tip_keyword_list:
            self.templates['default_ETNT.txt']['en'] += " " + k
            self.templates['default_PTNT.txt']['en'] += " " + k

        for k in notifTemplateTest.protected_keyword_list:
            self.templates['default_ETNT.txt']['en'] += " " + k

        for k in notifTemplateTest.comment_keyword_list:
            self.templates['default_ECNT.txt']['en'] += " " + k
            self.templates['default_PCNT.txt']['en'] += " " + k

        for k in notifTemplateTest.file_keyword_list:
            self.templates['default_EFNT.txt']['en'] += " " + k
            self.templates['default_PFNT.txt']['en'] += " " + k

        # THE REAL CONVERSION TEST START HERE:
        self.mockSubmission = helpers.MockDict().dummySubmission
        self.mockSubmission['finalize'] = True
        self.mockSubmission['context_id'] = self.createdReceiver['contexts'][0]
        self.mockSubmission['receivers'] = [ self.createdReceiver['id'] ]
        self.mockSubmission['wb_fields'] = helpers.fill_random_fields(self.createdContext)
        self.createdSubmission = yield submission.create_submission(self.mockSubmission, finalize=True)

        created_rtip = yield delivery_sched.tip_creation()
        self.assertEqual(len(created_rtip), 1)

        yield self._fill_event(u'encrypted_tip', 'Tip', created_rtip[0])

        # with the event, we can finally call the template filler
        gentext = Templating().format_template(self.templates['default_ETNT.txt'], self.event)

        self.assertSubstring(self.createdContext['name'], gentext)
        self.assertSubstring(created_rtip[0], gentext)
        self.assertSubstring(self.createdNode['public_site'], gentext)
        self.assertSubstring(self.createdNode['hidden_service'], gentext)

        ## HERE ARE ADDED SOME CHECK
        self.assertSubstring("=================", gentext)

        # http://witchwind.wordpress.com/2013/12/15/piv-is-always-rape-ok/
        # wtf has the internet in those days ? bwahahaah
        tip_num_test = Templating().format_template({'en': u'%TipNum%'}, self.event)
        new_id = self.event.trigger_info['id'].replace('1', '2')
        new_id.replace('3', '4')
        self.event.trigger_info['id'] = new_id.replace('5', '6')
        different_num = Templating().format_template({'en': u'%TipNum%'}, self.event)
        self.assertNotEqual(tip_num_test, different_num)
Ejemplo n.º 35
0
    def test_keywords_conversion(self):
        self.templates = {}
        for t, keywords_list in templates_desc.iteritems():

            self.templates[t] = ""

            for kwl in keywords_list:
                for keyword in kwl:
                    self.templates[t] += " " + keyword + " / "

        ### INITIALIZE DATABASE
        self.mockContext =helpers.MockDict().dummyContext
        self.mockReceiver = helpers.MockDict().dummyReceiver
        self.mockNode = helpers.MockDict().dummyNode

        self.createdContext = yield admin.create_context(self.mockContext)
        self.assertTrue(self.createdContext.has_key('id'))

        self.mockReceiver['contexts'] = [ self.createdContext['id'] ]

        self.createdReceiver = yield admin.create_receiver(self.mockReceiver)
        self.assertTrue(self.createdReceiver.has_key('id'))

        self.createdNode = yield admin.update_node(self.mockNode)
        self.assertTrue(self.createdNode.has_key('version'))
        ### END OF THE INITIALIZE BLOCK

        # THE REAL CONVERSION TEST START HERE:
        self.mockSubmission = helpers.MockDict().dummySubmission
        self.mockSubmission['finalize'] = True
        self.mockSubmission['context_id'] = self.createdReceiver['contexts'][0]
        self.mockSubmission['receivers'] = [ self.createdReceiver['id'] ]
        self.mockSubmission['wb_fields'] = helpers.fill_random_fields(self.createdContext)
        self.createdSubmission = yield submission.create_submission(self.mockSubmission, finalize=True)

        created_rtip = yield delivery_sched.tip_creation()
        self.assertEqual(len(created_rtip), 1)

        # some doubt in the next two lines: is just to have a mock tip
        self.tip = dict(self.mockSubmission)
        self.tip['id'] = created_rtip[0]

        for fname, template in self.templates.iteritems():

            # look for appropriate event_type, event_trigger
            event_type = u''
            event_trigger = ''
            for e_t, e_tri in supported_event_types.iteritems():
                if fname.startswith(e_t):
                    event_type = e_t
                    event_trigger = e_tri
                    break

            if not event_type:
                # we've nothing to do not!
                break

            yield self._fill_event_dict(event_type, event_trigger)

            # with the event, we can finally call the template filler
            gentext = Templating().format_template(template, self.event)

            self.assertSubstring(self.createdContext['name'], gentext)
            self.assertSubstring(self.createdNode['public_site'], gentext)
            self.assertSubstring(self.createdNode['hidden_service'], gentext)
Ejemplo n.º 36
0
 def test_create_submission_with_wrong_receiver(self):
     disassociated_receiver = yield create_receiver(self.get_dummy_receiver('dumb'), 'en')
     self.submission_desc = yield self.get_dummy_submission(self.dummyContext['id'])
     self.submission_desc['receivers'].append(disassociated_receiver['id'])
     yield self.assertFailure(self.create_submission(self.submission_desc),
                              errors.InvalidInputFormat)