def test_caiwireless_lp_917720(self): # https://bugs.launchpad.net/flufl.bounce/+bug/917720 with closing( resource_stream('flufl.bounce.tests.data', 'simple_01.txt')) as fp: msg = parse(fp) self.assertEqual(scan_message(msg), set([b'*****@*****.**']))
def setUp(self): """See `unittest.TestCase`.""" module_name = 'flufl.bounce._detectors.' + self.bounce_module __import__(module_name) self.module = sys.modules[module_name] with closing(resource_stream('flufl.bounce.tests.data', self.sample_file)) as fp: self.message = parse(fp)
def test_SMTP32_failure(self): # This file has no X-Mailer: header with closing(resource_stream('flufl.bounce.tests.data', 'postfix_01.txt')) as fp: msg = parse(fp) self.failIf(msg['x-mailer'] is not None) temporary, permanent = SMTP32().process(msg) self.failIf(temporary) self.failIf(permanent)
def setUp(self): """See `unittest.TestCase`.""" module_name = 'flufl.bounce._detectors.' + self.bounce_module __import__(module_name) self.module = sys.modules[module_name] with closing( resource_stream('flufl.bounce.tests.data', self.sample_file)) as fp: self.message = parse(fp)
def process(self, label, recipe): self.M.select(FOLDER_LABEL+'/' + label) status, data = self.M.uid('search', None, 'UnSeen') if data[0]: for num in data[0].split(): status, data = self.M.uid('fetch', num, '(RFC822)') msg = parse(data[0][1]) skip_spf = any([True for s in SKIP_SPF if s in msg['From']]) if 'pass' in msg.get('Received-SPF', '') or skip_spf: print(recipe(msg)) else: from_fallback = msg.get('From', 'No sender') print("Didn't pass sender checks: %s" % from_fallback) self.M.uid('store', num, '+FLAGS', 'Seen') self.M.expunge()
def __init__(self, data): super().__init__('run_test') if len(data) == 3: bounce_module, filename, expected = data self.is_temporary = False else: bounce_module, filename, expected, self.is_temporary = data self.expected = set(expected) self.description = '{}: [{}] detecting {} in {}'.format( bounce_module, ('T' if self.is_temporary else 'P'), self.expected, filename) module_name = 'flufl.bounce._detectors.{}'.format(bounce_module) module = import_module(module_name) with closing(resource_stream( 'flufl.bounce.tests.data', filename)) as fp: self.message = parse(fp) missing = object() for name in getattr(module, '__all__', []): component_class = getattr(module, name, missing) if component_class is missing: raise RuntimeError( 'skipping missing __all__ entry: {}'.format(name)) self.component = component_class()
def test_caiwireless_lp_917720(self): # https://bugs.launchpad.net/flufl.bounce/+bug/917720 with closing(resource_stream('flufl.bounce.tests.data', 'simple_01.txt')) as fp: msg = parse(fp) self.assertEqual(scan_message(msg), set([b'*****@*****.**']))