當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。