当前位置: 首页>>代码示例>>Python>>正文


Python shared.Suspect类代码示例

本文整理汇总了Python中fuglu.shared.Suspect的典型用法代码示例。如果您正苦于以下问题:Python Suspect类的具体用法?Python Suspect怎么用?Python Suspect使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Suspect类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_ignore_sender

    def test_ignore_sender(self):
        from fuglu.shared import Suspect
        v = Vacation()
        v.ignoresender = u"unittests.fuglu.org [email protected]"
        v.awayuser = u'[email protected]'
        v.created = datetime.now()
        v.start = datetime.now()
        v.end = v.start + timedelta(days=2)
        v.subject = u'gone for good'
        v.body = u'outta here'
        self.session.add(v)
        self.session.flush()
        self.session.expunge_all()
        self.refreshcache()
        suspect = Suspect(
            '[email protected]', '[email protected]', '/dev/null')
        suspect.set_tag('nobounce', True)

        candidatevacation = self.candidate.on_vacation(suspect)
        self.assertTrue(
            candidatevacation != None, "Vacation object not found in database")
        # TODO had to disable due to sqlalchemy error
        # Instance <Vacation at 0x2938890> is not bound to a Session; attribute refresh operation cannot proceed
        #self.assertEqual(v.ignoresender,candidatevacation.ignoresender,"Vacation object did not get ignore list")
        self.assertTrue(self.candidate.ignore_sender(
            candidatevacation, suspect), "Test Message should generate vacation reply(ignored sender)")
        self.assertFalse(self.candidate.should_send_vacation_message(
            suspect), "Sender on ignorelist, still wants to send message?!")
开发者ID:Caomhin,项目名称:fuglu,代码行数:28,代码来源:plugins_vacation_test.py

示例2: test_result

    def test_result(self):
        """Test if EICAR virus is detected and message deleted"""

        suspect = Suspect(
            '[email protected]', '[email protected]', '/dev/null')
        stream = """Date: Mon, 08 Sep 2008 17:33:54 +0200
To: [email protected]
From: [email protected]
Subject: test eicar attachment
X-Mailer: swaks v20061116.0 jetmore.org/john/code/#swaks
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="----=_MIME_BOUNDARY_000_12140"

------=_MIME_BOUNDARY_000_12140
Content-Type: text/plain

Eicar test
------=_MIME_BOUNDARY_000_12140
Content-Type: application/octet-stream
Content-Transfer-Encoding: BASE64
Content-Disposition: attachment

UEsDBAoAAAAAAGQ7WyUjS4psRgAAAEYAAAAJAAAAZWljYXIuY29tWDVPIVAlQEFQWzRcUFpYNTQo
UF4pN0NDKTd9JEVJQ0FSLVNUQU5EQVJELUFOVElWSVJVUy1URVNULUZJTEUhJEgrSCoNClBLAQIU
AAoAAAAAAGQ7WyUjS4psRgAAAEYAAAAJAAAAAAAAAAEAIAD/gQAAAABlaWNhci5jb21QSwUGAAAA
AAEAAQA3AAAAbQAAAAAA

------=_MIME_BOUNDARY_000_12140--"""

        suspect.setMessageRep(email.message_from_string(stream))
        result = self.candidate.examine(suspect)
        if type(result) is tuple:
            result, message = result
        strresult = actioncode_to_string(result)
        self.assertEqual(strresult, "DELETE")
开发者ID:Caomhin,项目名称:fuglu,代码行数:35,代码来源:plugins_clamav_test.py

示例3: test_modified_message

    def test_modified_message(self):
        """Test if the modified message gets archived correctly"""
        from fuglu.shared import Suspect
        import shutil
        import tempfile

        tempfilename = tempfile.mktemp(
            suffix='archive', prefix='fuglu-unittest', dir='/tmp')
        shutil.copy(TESTDATADIR + '/helloworld.eml', tempfilename)
        self.tempfiles.append(tempfilename)

        self.config.set('ArchivePlugin', 'storeoriginal', '0')
        candidate = ArchivePlugin(self.config)
        suspect = Suspect(
            '[email protected]', '[email protected]', tempfilename)
        origmessage = suspect.get_source()
        # modify the mesg
        msgrep = suspect.get_message_rep()
        msgrep['X-Changed-Something'] = 'Yes'
        suspect.setMessageRep(msgrep)

        filename = candidate.archive(suspect)
        self.assertTrue(filename != None and filename)

        self.tempfiles.append(filename)

        archivedmessage = open(filename, 'r').read()
        self.assertNotEqual(origmessage.strip(), archivedmessage.strip(
        )), 'Archived message should have stored modified message'
开发者ID:sporkman,项目名称:fuglu,代码行数:29,代码来源:plugins_archive_test.py

示例4: test_generated_message

    def test_generated_message(self):
        from fuglu.shared import Suspect
        suspect = Suspect(
            u'[email protected]', '[email protected]', '/dev/null')
        suspect.tags['nobounce'] = True

        v = Vacation()
        v.ignoresender = u""
        v.awayuser = u'[email protected]'
        v.created = datetime.now()
        v.start = datetime.now()
        v.end = v.start + timedelta(days=2)
        v.subject = u'Döner mit schärf!'
        v.body = u"""Je m'envole pour l'Allemagne, où je suis né."""
        # v.body="Away!"
        self.session.add(v)
        self.session.flush()
        self.session.expunge_all()
        self.refreshcache()

        candidatevacation = self.candidate.on_vacation(suspect)
        self.assertTrue(
            candidatevacation != None, "Vacation object not found in database")

        message = self.candidate.send_vacation_reply(
            suspect, candidatevacation)
开发者ID:Caomhin,项目名称:fuglu,代码行数:26,代码来源:plugins_vacation_test.py

示例5: test_sf_get_args

    def test_sf_get_args(self):
        """Test SuspectFilter files"""
        suspect = Suspect('[email protected]',
                          '[email protected]', TESTDATADIR + '/helloworld.eml')
        suspect.tags['testtag'] = 'testvalue'

        headermatches = self.candidate.get_args(suspect)
        self.assertTrue(
            'Sent to unittest domain!' in headermatches, "To_domain not found in headercheck")
        self.assertTrue('Envelope sender is [email protected]' in headermatches,
                        "Envelope Sender not matched in header chekc")
        self.assertTrue('Mime Version is 1.0' in headermatches,
                        "Standard header Mime Version not found")
        self.assertTrue(
            'A tag match' in headermatches, "Tag match did not work")
        self.assertTrue(
            'Globbing works' in headermatches, "header globbing failed")
        self.assertTrue(
            'body rule works' in headermatches, "decoded body rule failed")
        self.assertTrue(
            'full body rule works' in headermatches, "full body failed")
        self.assertTrue('mime rule works' in headermatches, "mime rule failed")
        self.assertFalse('this should not match in a body rule' in headermatches,
                         'decoded body rule matched raw body')

        # perl style advanced rules
        self.assertTrue('perl-style /-notation works!' in headermatches,
                        "new rule format failed: %s" % headermatches)
        self.assertTrue('perl-style recipient match' in headermatches,
                        "new rule format failed for to_domain: %s" % headermatches)
        self.assertFalse('this should not match' in headermatches,
                         "rule flag ignorecase was not detected")
开发者ID:steigr,项目名称:fuglu,代码行数:32,代码来源:shared_test.py

示例6: test_localpartblacklist

    def test_localpartblacklist(self):
        """test messages from mailer-daemon"""
        from fuglu.shared import Suspect
        import email
        v = Vacation()
        v.ignoresender = u""
        v.awayuser = u'[email protected]'
        v.created = datetime.now()
        v.start = datetime.now()
        v.end = v.start + timedelta(days=2)
        v.subject = u'awaaay'
        v.body = u'cya'
        self.session.add(v)
        self.session.flush()
        self.session.expunge_all()
        self.refreshcache()
        botmsg = """From: [email protected]
Subject: mailinglist membership reminder...
"""

        suspect = Suspect('[email protected]',
                          '[email protected]', '/dev/null')
        suspect.set_tag('nobounce', True)
        suspect.set_source(botmsg)

        candidatevacation = self.candidate.on_vacation(suspect)
        self.assertTrue(
            candidatevacation != None, "Vacation object not found in database")
        self.assertFalse(self.candidate.should_send_vacation_message(
            suspect), "Test Message should NOT generate vacation reply(automated)")
开发者ID:Caomhin,项目名称:fuglu,代码行数:30,代码来源:plugins_vacation_test.py

示例7: test_something

 def test_something(self):
     """Test if examine runs through"""
     from fuglu.shared import Suspect
     suspect=Suspect('[email protected]','[email protected]','/dev/null')
     self.candidate.examine(suspect)
     self.failIf(suspect.get_tag('ExamplePlugin.time')==None, "Examine didn't run through")
     
开发者ID:gryphius,项目名称:fuglu-travis-test,代码行数:6,代码来源:example.py

示例8: test_parse_rcvd_header

 def test_parse_rcvd_header(self):
     suspect = Suspect('[email protected]',
                       '[email protected]', '/dev/null')
     self.assertEqual(suspect._parse_rcvd_header(
         "from helo1 (rdns1 [10.0.0.1])"), ('helo1', 'rdns1', '10.0.0.1'))
     self.assertEqual(suspect._parse_rcvd_header("from mx0.slc.paypal.com (mx1.slc.paypal.com [173.0.84.226])"), (
         'mx0.slc.paypal.com', 'mx1.slc.paypal.com', '173.0.84.226'))
     self.assertEqual(suspect._parse_rcvd_header("from mail1a.tilaa.nl (mail1a.tilaa.nl [IPv6:2a02:2770:6:0:21a:4aff:fea8:1328])"), (
         'mail1a.tilaa.nl', 'mail1a.tilaa.nl', '2a02:2770:6:0:21a:4aff:fea8:1328'))
开发者ID:steigr,项目名称:fuglu,代码行数:9,代码来源:shared_test.py

示例9: test_id

 def test_id(self):
     """Check the length and uniqueness of the generated id"""
     s = Suspect('[email protected]', '[email protected]', '/dev/null')
     known = []
     for i in range(10000):
         suspect_id = s._generate_id()
         self.assertTrue(
             suspect_id not in known, 'duplicate id %s generated' % suspect_id)
         known.append(suspect_id)
         self.assertEqual(len(suspect_id), 32)
         for c in suspect_id:
             self.assertTrue(c in string.hexdigits)
开发者ID:steigr,项目名称:fuglu,代码行数:12,代码来源:shared_test.py

示例10: get_suspect

 def get_suspect(self):
     success=self.sess.getincomingmail()
     if not success:
         self.logger.error('incoming smtp transfer did not finish')
         return None
     
     sess=self.sess
     fromaddr=sess.from_address
     toaddr=sess.to_address
     tempfilename=sess.tempfilename
     
     suspect=Suspect(fromaddr,toaddr,tempfilename)
     suspect.recipients=set(sess.recipients)
     return suspect
开发者ID:gryphius,项目名称:fuglu-travis-test,代码行数:14,代码来源:smtpconnector.py

示例11: get_suspect

    def get_suspect(self):
        succ = self.sess.getincomingmail()
        if not succ:
            self.logger.error('MILTER SESSION NOT COMPLETED')
            return None

        sess = self.sess
        fromaddr = sess.from_address
        tempfilename = sess.tempfilename
        suspect = Suspect(fromaddr, sess.recipients, tempfilename)

        if sess.helo is not None and sess.addr is not None and sess.rdns is not None:
            suspect.clientinfo = sess.helo, sess.addr, sess.rdns

        return suspect
开发者ID:oasiswork,项目名称:fuglu,代码行数:15,代码来源:milterconnector.py

示例12: get_suspect

 def get_suspect(self):
     success=self.sess.getincomingmail()
     if not success:
         self.logger.error('incoming smtp transfer did not finish')
         return None
     
     sess=self.sess
     fromaddr="[email protected]"
     toaddr="[email protected]"
     
     tempfilename=sess.tempfilename
     
     suspect=Suspect(fromaddr,toaddr,tempfilename)
     suspect.recipients=[toaddr,]
     return suspect
开发者ID:gryphius,项目名称:fuglu-travis-test,代码行数:15,代码来源:ncblackholeconnector.py

示例13: test_template

    def test_template(self):
        """Test Basic Template function"""

        suspect = Suspect('[email protected]',
                          '[email protected]', TESTDATADIR + '/helloworld.eml')
        suspect.tags['nobounce'] = True

        reason = "a three-headed monkey stole it"

        template = """Your message '${subject}' from ${from_address} to ${to_address} could not be delivered because ${reason}"""

        result = apply_template(template, suspect, dict(reason=reason))
        expected = """Your message 'Hello world!' from [email protected] to [email protected] could not be delivered because a three-headed monkey stole it"""
        self.assertEqual(
            result, expected), "Got unexpected template result: %s" % result
开发者ID:steigr,项目名称:fuglu,代码行数:15,代码来源:shared_test.py

示例14: test_score

    def test_score(self):
        suspect=Suspect('[email protected]','[email protected]','/dev/null')
        stream="""Date: Mon, 08 Sep 2008 17:33:54 +0200
To: [email protected]
From: [email protected]
Subject: test scanner

  XJS*C4JDBQADN1.NSBN3*2IDNEN*GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL*C.34X
"""
        suspect.setSource(stream)
        result=self.candidate.examine(suspect)
        if type(result) is tuple:
            result,message=result
        score=int( suspect.get_tag('SAPlugin.spamscore'))
        self.failUnless(score>999, "GTUBE mails should score ~1000 , we got %s"%score)
        self.failUnless(result==REJECT,'High spam should be rejected')
开发者ID:gryphius,项目名称:fuglu-travis-test,代码行数:16,代码来源:sa.py

示例15: get_suspect

 def get_suspect(self):
     succ=self.sess.getincomingmail()
     if not succ:
         self.logger.error('MILTER SESSION NOT COMPLETED')
         return None
     
     sess=self.sess
     fromaddr=sess.from_address
     toaddr=sess.to_address
     tempfilename=sess.tempfilename
     body=open(tempfilename).read()
     #self.logger.info("BODY=%s"%body)
     #self.logger.info("MILTER: from=%s to=%s"%(fromaddr,toaddr))
     suspect=Suspect(fromaddr,toaddr,tempfilename)
     suspect.recipients=set(sess.recipients)
     return suspect
开发者ID:gryphius,项目名称:fuglu-travis-test,代码行数:16,代码来源:milterconnector.py


注:本文中的fuglu.shared.Suspect类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。