示例#1
0
 def test_provision_spam(self):
     with self.make_context(
             data={'X-Mailgun-Sscore': message.SSCORE_MAX_VALUE + 1}):
         msg = message.ConferenceMessage()
         utils.provision_node(self.conference, msg, self.node, self.user)
     assert_false(self.node.is_public)
     assert_in(self.conference.admins.first(), self.node.contributors)
     assert_in('emailed', self.node.system_tags)
     assert_in('spam', self.node.system_tags)
示例#2
0
 def test_sender_email(self):
     emails = [
         (u'*****@*****.**', u'*****@*****.**'),
         (u'*****@*****.**', u'*****@*****.**')
     ]
     for email in emails:
         with self.make_context(data={'from': email[0]}):
             msg = message.ConferenceMessage()
             assert_equal(msg.sender_email, email[1])
示例#3
0
 def test_text(self):
     text = 'welcome to my nuclear family'
     ctx = self.make_context(
         method='POST',
         data={'stripped-text': text},
     )
     with ctx:
         msg = message.ConferenceMessage()
         assert_equal(msg.text, text)
示例#4
0
 def test_recipient(self):
     address = '*****@*****.**'
     ctx = self.make_context(
         method='POST',
         data={'recipient': address},
     )
     with ctx:
         msg = message.ConferenceMessage()
         assert_equal(msg.recipient, address)
示例#5
0
 def test_provision_private(self):
     self.conference.public_projects = False
     self.conference.save()
     with self.make_context():
         msg = message.ConferenceMessage()
         utils.provision_node(self.conference, msg, self.node, self.user)
     assert_false(self.node.is_public)
     assert_in(self.conference.admins[0], self.node.contributors)
     assert_in('emailed', self.node.system_tags)
     assert_not_in('spam', self.node.system_tags)
示例#6
0
 def test_provision(self):
     with self.make_context():
         msg = message.ConferenceMessage()
         utils.provision_node(self.conference, msg, self.node, self.user)
     assert_true(self.node.is_public)
     assert_in(self.conference.admins[0], self.node.contributors)
     assert_in('emailed', self.node.system_tags)
     assert_in(self.conference.endpoint, self.node.system_tags)
     assert_in(self.conference.endpoint, self.node.tags)
     assert_not_in('spam', self.node.system_tags)
    def test_add_poster_by_email(self, mock_upload_attachments):
        conference = ConferenceFactory()

        with self.make_context(data={'from': '*****@*****.**', 'subject': 'It\'s PARTY TIME!'}):
            msg = message.ConferenceMessage()
            views.add_poster_by_email(conference, msg)

        user = OSFUser.objects.get(username='******')
        assert user.email == '*****@*****.**'
        assert user.fullname == user._id  # user's shouldn't be able to use email as fullname, so we use the guid.
示例#8
0
 def test_is_spam_true_dkim(self):
     ctx = self.make_context(
         method='POST',
         data={
             'X-Mailgun-Dkim-Check-Result':
             message.DKIM_PASS_VALUES[0][::-1]
         },
     )
     with ctx:
         msg = message.ConferenceMessage()
         assert msg.is_spam
示例#9
0
 def test_sender_name(self):
     names = [
         (' Fred', 'Fred'),
         (u'Me䬟', u'Me䬟'),
         (u'Fred <*****@*****.**>', u'Fred'),
         (u'"Fred" <*****@*****.**>', u'Fred'),
     ]
     for name in names:
         with self.make_context(data={'from': name[0]}):
             msg = message.ConferenceMessage()
             assert_equal(msg.sender_name, name[1])
示例#10
0
 def test_is_spam_false_all_headers(self):
     ctx = self.make_context(
         method='POST',
         data={
             'X-Mailgun-Sscore': message.SSCORE_MAX_VALUE - 1,
             'X-Mailgun-Dkim-Check-Result': message.DKIM_PASS_VALUES[0],
             'X-Mailgun-Spf': message.SPF_PASS_VALUES[0],
         },
     )
     with ctx:
         msg = message.ConferenceMessage()
         assert not msg.is_spam
示例#11
0
 def test_route_valid_alternate(self):
     conf = ConferenceFactory(endpoint='chocolate', active=True)
     conf.name = 'Chocolate Conference'
     conf.field_names['submission2'] = 'data'
     conf.save()
     recipient = '{0}[email protected]'.format('test-' if settings.DEV_MODE else '')
     with self.make_context(data={'recipient': recipient}):
         self.app.app.preprocess_request()
         msg = message.ConferenceMessage()
         assert_equal(msg.conference_name, 'chocolate')
         assert_equal(msg.conference_category, 'data')
     conf.__class__.remove_one(conf)
示例#12
0
 def test_attachments_count_one(self):
     content = 'slightly mad'
     sio = StringIO(content)
     ctx = self.make_context(
         method='POST',
         data={
             'attachment-count': 1,
             'attachment-1': (sio, 'attachment-1'),
         },
     )
     with ctx:
         msg = message.ConferenceMessage()
         assert_equal(len(msg.attachments), 1)
         assert_equal(msg.attachments[0].read(), content)
示例#13
0
 def test_attachments_count_zero(self):
     with self.make_context(data={'attachment-count': '0'}):
         msg = message.ConferenceMessage()
         assert_equal(msg.attachments, [])
示例#14
0
 def test_route_invalid_pattern(self):
     with self.make_context(data={'recipient': '*****@*****.**'}):
         self.app.app.preprocess_request()
         msg = message.ConferenceMessage()
         with assert_raises(message.ConferenceError):
             msg.route
示例#15
0
 def test_verify_signature_invalid(self):
     with self.make_context(data={'signature': 'fake'}):
         self.app.app.preprocess_request()
         msg = message.ConferenceMessage()
         with assert_raises(message.ConferenceError):
             msg.verify_signature()
示例#16
0
 def test_verify_signature_valid(self):
     with self.make_context():
         msg = message.ConferenceMessage()
         msg.verify_signature()