Exemplo n.º 1
0
    def test_put(self):
        """
            Attempt to update a field, changing its type via a put request.
            """
        attrs = self.get_dummy_field()
        attrs['is_template'] = False
        self.dummyContext = yield create_context(self.dummyContext, 'en')
        attrs['step_id'] = yield get_step_id(self.dummyContext['id'])
        field = yield create_field(attrs, 'en')

        updated_sample_field = self.get_dummy_field()
        updated_sample_field['is_template'] = False
        self.dummyContext = yield create_context(self.dummyContext, 'en')
        updated_sample_field['step_id'] = yield get_step_id(
            self.dummyContext['id'])
        updated_sample_field.update(type='inputbox')
        handler = self.request(updated_sample_field, role='admin')
        yield handler.put(field['id'])
        self.assertEqual(len(self.responses), 1)
        self.assertEqual(field['id'], self.responses[0]['id'])
        self.assertEqual(self.responses[0]['type'], 'inputbox')

        wrong_sample_field = self.get_dummy_field()
        attrs['is_template'] = False
        attrs['step_id'] = yield get_step_id(self.dummyContext['id'])
        wrong_sample_field.update(type='nonexistingfieldtype')
        handler = self.request(wrong_sample_field, role='admin')
        self.assertFailure(handler.put(field['id']), errors.InvalidInputFormat)
Exemplo 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)
Exemplo n.º 3
0
        def test_put(self):
            """
            Attempt to update a field, changing its type via a put request.
            """
            attrs = self.get_dummy_field()
            attrs['is_template'] = False
            self.dummyContext = yield create_context(self.dummyContext, 'en')
            attrs['step_id'] = yield get_step_id(self.dummyContext['id'])
            field = yield create_field(attrs, 'en')

            updated_sample_field = self.get_dummy_field()
            updated_sample_field['is_template'] = False
            self.dummyContext = yield create_context(self.dummyContext, 'en')
            updated_sample_field['step_id'] = yield get_step_id(self.dummyContext['id'])
            updated_sample_field.update(type='inputbox')
            handler = self.request(updated_sample_field, role='admin')
            yield handler.put(field['id'])
            self.assertEqual(len(self.responses), 1)
            self.assertEqual(field['id'], self.responses[0]['id'])
            self.assertEqual(self.responses[0]['type'], 'inputbox')

            wrong_sample_field = self.get_dummy_field()
            attrs['is_template'] = False
            attrs['step_id'] = yield get_step_id(self.dummyContext['id'])
            wrong_sample_field.update(type='nonexistingfieldtype')
            handler = self.request(wrong_sample_field, role='admin')
            self.assertFailure(handler.put(field['id']), errors.InvalidInputFormat)
Exemplo n.º 4
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)
Exemplo 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']
Exemplo n.º 6
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])
Exemplo n.º 7
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
Exemplo n.º 8
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])
Exemplo n.º 9
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']
Exemplo n.º 10
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)
Exemplo n.º 11
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" )
    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)
Exemplo n.º 13
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" )
Exemplo n.º 14
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)
Exemplo n.º 15
0
    def test_get(self):
        """
            Create a new step, then get it back using the received id.
            """
        context = yield create_context(copy.deepcopy(self.dummyContext), 'en')
        step = copy.deepcopy(self.dummySteps[0])
        step['context_id'] = context['id']
        step = yield create_step(step, 'en')

        handler = self.request(role='admin')
        yield handler.get(step['id'])
        self.assertEqual(len(self.responses), 1)
        self.assertEqual(step['id'], self.responses[0]['id'])
Exemplo n.º 16
0
        def test_get(self):
            """
            Create a new step, then get it back using the received id.
            """
            context = yield create_context(copy.deepcopy(self.dummyContext), 'en')
            step = copy.deepcopy(self.dummySteps[0])
            step['context_id'] = context['id']
            step = yield create_step(step, 'en')

            handler = self.request(role='admin')
            yield handler.get(step['id'])
            self.assertEqual(len(self.responses), 1)
            self.assertEqual(step['id'], self.responses[0]['id'])
Exemplo n.º 17
0
    def test_post(self):
        """
            Attempt to create a new step via a post request.
            """
        context = yield create_context(copy.deepcopy(self.dummyContext), 'en')
        step = copy.deepcopy(self.dummySteps[0])
        step['context_id'] = context['id']
        handler = self.request(step, role='admin')
        yield handler.post()
        self.assertEqual(len(self.responses), 1)

        resp, = self.responses
        self.assertIn('id', resp)
        self.assertNotEqual(resp.get('context_id'), None)
Exemplo n.º 18
0
    def test_get(self):
        """
            Create a new field, then get it back using the received id.
            """
        values = self.get_dummy_field()
        values['is_template'] = False
        context = yield create_context(copy.deepcopy(self.dummyContext), 'en')
        values['step_id'] = yield get_step_id(context['id'])
        field = yield create_field(values, 'en')

        handler = self.request(role='admin')
        yield handler.get(field['id'])
        self.assertEqual(len(self.responses), 1)
        self.assertEqual(field['id'], self.responses[0]['id'])
Exemplo n.º 19
0
    def test_get(self):
        """
            Create a new field, the get it back using the receieved id.
            """
        attrs = self.get_dummy_field()
        attrs['is_template'] = False
        self.dummyContext = yield create_context(self.dummyContext, 'en')
        attrs['step_id'] = yield get_step_id(self.dummyContext['id'])
        field = yield create_field(attrs, 'en')

        handler = self.request(role='admin')
        yield handler.get(field['id'])
        self.assertEqual(len(self.responses), 1)
        self.assertEqual(field['id'], self.responses[0]['id'])
Exemplo n.º 20
0
    def test_delete(self):
        """
            Create a new step, then attempt to delete it.
            """
        context = yield create_context(copy.deepcopy(self.dummyContext), 'en')
        step = copy.deepcopy(self.dummySteps[0])
        step['context_id'] = context['id']
        step = yield create_step(step, 'en')

        handler = self.request(role='admin')
        yield handler.delete(step['id'])
        self.assertEqual(handler.get_status(), 200)
        # second deletion operation should fail
        self.assertFailure(handler.delete(step['id']), errors.StepIdNotFound)
Exemplo n.º 21
0
        def test_post(self):
            """
            Attempt to create a new step via a post request.
            """
            context = yield create_context(copy.deepcopy(self.dummyContext), 'en')
            step = copy.deepcopy(self.dummySteps[0])
            step['context_id'] = context['id']
            handler = self.request(step, role='admin')
            yield handler.post()
            self.assertEqual(len(self.responses), 1)

            resp, = self.responses
            self.assertIn('id', resp)
            self.assertNotEqual(resp.get('context_id'), None)
Exemplo n.º 22
0
        def test_get(self):
            """
            Create a new field, then get it back using the received id.
            """
            values = self.get_dummy_field()
            values['is_template'] = False
            context = yield create_context(copy.deepcopy(self.dummyContext), 'en')
            values['step_id'] = yield get_step_id(context['id'])
            field = yield create_field(values, 'en')

            handler = self.request(role='admin')
            yield handler.get(field['id'])
            self.assertEqual(len(self.responses), 1)
            self.assertEqual(field['id'], self.responses[0]['id'])
Exemplo n.º 23
0
        def test_get(self):
            """
            Create a new field, the get it back using the receieved id.
            """
            attrs = self.get_dummy_field()
            attrs['is_template'] = False
            self.dummyContext = yield create_context(self.dummyContext, 'en')
            attrs['step_id'] = yield get_step_id(self.dummyContext['id'])
            field = yield create_field(attrs, 'en')

            handler = self.request(role='admin')
            yield handler.get(field['id'])
            self.assertEqual(len(self.responses), 1)
            self.assertEqual(field['id'], self.responses[0]['id'])
Exemplo n.º 24
0
        def test_delete(self):
            """
            Create a new step, then attempt to delete it.
            """
            context = yield create_context(copy.deepcopy(self.dummyContext), 'en')
            step = copy.deepcopy(self.dummySteps[0])
            step['context_id'] = context['id']
            step = yield create_step(step, 'en')

            handler = self.request(role='admin')
            yield handler.delete(step['id'])
            self.assertEqual(handler.get_status(), 200)
            # second deletion operation should fail
            self.assertFailure(handler.delete(step['id']), errors.StepIdNotFound)
Exemplo n.º 25
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)
Exemplo n.º 26
0
    def 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)
        except Exception, e:
            self.assertTrue(False)
Exemplo n.º 27
0
        def test_post(self):
            """
            Attempt to create a new field via a post request.
            """
            attrs = self.get_dummy_field()
            attrs['is_template'] = False
            context = yield create_context(self.dummyContext, 'en')
            attrs['step_id'] = yield get_step_id(context['id'])
            handler = self.request(attrs, role='admin')
            yield handler.post()
            self.assertEqual(len(self.responses), 1)

            resp, = self.responses
            self.assertIn('id', resp)
            self.assertNotEqual(resp.get('options'), None)
Exemplo n.º 28
0
    def test_002_fail_submission_missing_required_file(self):
        mycopy = dict(self.dummyContext)
        mycopy['file_required'] = True
        del mycopy['id']

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

        context_status = yield create_context(mycopy)
        submission_desc = dict(self.dummySubmission)

        submission_desc['context_id'] = context_status['id']
        submission_desc['finalize'] = True
        submission_desc['wb_fields'] = helpers.fill_random_fields(mycopy)
        yield self.assertFailure(submission.create_submission(submission_desc, finalize=True), errors.FileRequiredMissing)
Exemplo n.º 29
0
        def test_delete(self):
            """
            Create a new field, then attempt to delete it.
            """
            attrs = self.get_dummy_field()
            attrs['is_template'] = False
            self.dummyContext = yield create_context(self.dummyContext, 'en')
            attrs['step_id'] = yield get_step_id(self.dummyContext['id'])
            field = yield create_field(attrs, 'en')

            handler = self.request(role='admin')
            yield handler.delete(field['id'])
            self.assertEqual(handler.get_status(), 200)
            # second deletion operation should fail
            self.assertFailure(handler.delete(field['id']), errors.FieldIdNotFound)
Exemplo n.º 30
0
    def test_post(self):
        """
            Attempt to create a new field via a post request.
            """
        attrs = self.get_dummy_field()
        attrs['is_template'] = False
        context = yield create_context(self.dummyContext, 'en')
        attrs['step_id'] = yield get_step_id(context['id'])
        handler = self.request(attrs, role='admin')
        yield handler.post()
        self.assertEqual(len(self.responses), 1)

        resp, = self.responses
        self.assertIn('id', resp)
        self.assertNotEqual(resp.get('options'), None)
Exemplo n.º 31
0
    def test_delete(self):
        """
            Create a new field, then attempt to delete it.
            """
        attrs = self.get_dummy_field()
        attrs['is_template'] = False
        self.dummyContext = yield create_context(self.dummyContext, 'en')
        attrs['step_id'] = yield get_step_id(self.dummyContext['id'])
        field = yield create_field(attrs, 'en')

        handler = self.request(role='admin')
        yield handler.delete(field['id'])
        self.assertEqual(handler.get_status(), 200)
        # second deletion operation should fail
        self.assertFailure(handler.delete(field['id']), errors.FieldIdNotFound)
Exemplo n.º 32
0
    def test_put(self):
        """
            Attempt to update a step, changing it presentation order
            """
        context = yield create_context(copy.deepcopy(self.dummyContext), 'en')
        step = copy.deepcopy(self.dummySteps[0])
        step['context_id'] = context['id']
        step = yield create_step(step, 'en')

        step['presentation_order'] = 666

        handler = self.request(step, role='admin')
        yield handler.put(step['id'])
        self.assertEqual(len(self.responses), 1)
        self.assertEqual(step['id'], self.responses[0]['id'])
        self.assertEqual(self.responses[0]['presentation_order'], 666)
Exemplo n.º 33
0
        def test_put(self):
            """
            Attempt to update a step, changing it presentation order
            """
            context = yield create_context(copy.deepcopy(self.dummyContext), 'en')
            step = copy.deepcopy(self.dummySteps[0])
            step['context_id'] = context['id']
            step = yield create_step(step, 'en')

            step['presentation_order'] = 666

            handler = self.request(step, role='admin')
            yield handler.put(step['id'])
            self.assertEqual(len(self.responses), 1)
            self.assertEqual(step['id'], self.responses[0]['id'])
            self.assertEqual(self.responses[0]['presentation_order'], 666)
Exemplo n.º 34
0
    def test_002_fail_submission_missing_required_file(self):
        mycopy = dict(self.dummyContext)
        mycopy['file_required'] = True
        del mycopy['id']

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

        context_status = yield create_context(mycopy)
        submission_desc = dict(self.dummySubmission)

        submission_desc['context_id'] = context_status['id']
        submission_desc['finalize'] = True
        submission_desc['wb_fields'] = helpers.fill_random_fields(mycopy)
        yield self.assertFailure(
            submission.create_submission(submission_desc, finalize=True),
            errors.FileRequiredMissing)
Exemplo n.º 35
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])
Exemplo n.º 36
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')
Exemplo n.º 37
0
    def test_fail_submission_missing_file(self):

        mycopy = dict(self.dummyContext)
        mycopy["file_required"] = True

        context_status = yield create_context(mycopy)
        submission_desc = dict(self.dummySubmission)

        submission_desc["context_gus"] = context_status["context_gus"]
        submission_desc["finalize"] = True
        submission_desc["wb_fields"] = helpers.fill_random_fields(self.dummyContext)

        try:
            yield submission.create_submission(submission_desc, finalize=True)
        except errors.FileRequiredMissing:
            self.assertTrue(True)
            return
        self.assertTrue(False)
Exemplo n.º 38
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])
Exemplo n.º 39
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])
Exemplo n.º 40
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')
Exemplo n.º 41
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)
Exemplo n.º 42
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')
Exemplo n.º 43
0
    def test_post_create_from_template(self):
        """
            Attempt to create a new field from template via post request
            """
        values = self.get_dummy_field()
        values['is_template'] = True
        field_template = yield create_field(values, 'en')

        context = yield create_context(copy.deepcopy(self.dummyContext), 'en')
        step_id = yield get_step_id(context['id'])

        values = self.get_dummy_field()
        values['template_id'] = field_template['id']

        handler = self.request(values, role='admin')
        yield handler.post()
        self.assertEqual(len(self.responses), 1)

        resp, = self.responses
        self.assertIn('id', resp)
        self.assertNotEqual(resp.get('options'), None)
Exemplo n.º 44
0
        def test_post_create_from_template(self):
            """
            Attempt to create a new field from template via post request
            """
            values = self.get_dummy_field()
            values['is_template'] = True
            field_template = yield create_field(values, 'en')

            context = yield create_context(copy.deepcopy(self.dummyContext), 'en')
            step_id = yield get_step_id(context['id'])

            values = self.get_dummy_field()
            values['template_id'] = field_template['id']

            handler = self.request(values, role='admin')
            yield handler.post()
            self.assertEqual(len(self.responses), 1)

            resp, = self.responses
            self.assertIn('id', resp)
            self.assertNotEqual(resp.get('options'), None)
Exemplo n.º 45
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)
Exemplo n.º 46
0
        def test_post_create_from_template(self):
            """
            Attempt to create a new field from template via post request
            """
            attrs = self.get_dummy_field()
            attrs['is_template'] = True
            field_template = yield create_field(attrs, 'en')

            context = yield create_context(self.dummyContext, 'en')
            step_id = yield get_step_id(context['id'])

            attrs = {
                'template_id': field_template['id'],
                'context_id': '',
                'step_id': step_id
            }

            handler = self.request(attrs, role='admin')
            yield handler.post()
            self.assertEqual(len(self.responses), 1)

            resp, = self.responses
            self.assertIn('id', resp)
            self.assertNotEqual(resp.get('options'), None)
Exemplo n.º 47
0
    def test_post_create_from_template(self):
        """
            Attempt to create a new field from template via post request
            """
        attrs = self.get_dummy_field()
        attrs['is_template'] = True
        field_template = yield create_field(attrs, 'en')

        context = yield create_context(self.dummyContext, 'en')
        step_id = yield get_step_id(context['id'])

        attrs = {
            'template_id': field_template['id'],
            'context_id': '',
            'step_id': step_id
        }

        handler = self.request(attrs, role='admin')
        yield handler.post()
        self.assertEqual(len(self.responses), 1)

        resp, = self.responses
        self.assertIn('id', resp)
        self.assertNotEqual(resp.get('options'), None)
Exemplo n.º 48
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')
Exemplo n.º 49
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)
Exemplo n.º 50
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)
Exemplo n.º 51
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()
Exemplo n.º 52
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")
Exemplo n.º 53
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()
Exemplo n.º 54
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" )