def __init__(self, config=None):
     if config is None:
         self.config = getConfig()
     else:
         self.config = config
     logging.getLogger().info("Initializing BiPostal")
     super(BiPostalMilter, self).__init__()
     # Ask for permissions
     self.CanChangeBody()
     self.CanChangeHeaders()
     self.CanAddHeaders()
     #init variables
     self._hasCT = False
     self._mutations = []
     self._boundary = None
     self._newbody = []
     self._toCount = 1
     self._info = {}
     self._split = None
     template_dir = os.path.join(self.config.get('default.template_dir',
                                                 'templates'))
     self.txt_head_template = Template(filename = os.path.join(template_dir, 
             'head_txt.mako'))
     self.txt_foot_template = Template(filename = os.path.join(template_dir, 
             'foot_txt.mako'))
     self.html_head_template = Template(filename = os.path.join(template_dir, 
             'head_html.mako'))
     self.html_foot_template = Template(filename = os.path.join(template_dir, 
             'foot_html.mako'))
     self.storage = configure_from_settings('storage', self.config)
Example #2
0
 def __init__(self, listener, config, **kw):
     # pass listener=None for testing purposes (to prevent socket creation)
     if listener is not None:
         super(ResolveServer, self).__init__(listener, **kw)
     self.config = config
     self.storage = configure_from_settings('storage',
             self.config)
Example #3
0
 def __init__(self, config=None):
     if config is None:
         self.config = getConfig()
     else:
         self.config = config
     logging.getLogger().info("Initializing BiPostal")
     super(BiPostalMilter, self).__init__()
     # Ask for permissions
     self.CanChangeBody()
     self.CanChangeHeaders()
     self.CanAddHeaders()
     #init variables
     self._hasCT = False
     self._mutations = []
     self._boundary = None
     self._newbody = []
     self._toCount = 1
     self._info = {}
     self._split = None
     template_dir = os.path.join(
         self.config.get('default.template_dir', 'templates'))
     self.txt_head_template = Template(
         filename=os.path.join(template_dir, 'head_txt.mako'))
     self.txt_foot_template = Template(
         filename=os.path.join(template_dir, 'foot_txt.mako'))
     self.html_head_template = Template(
         filename=os.path.join(template_dir, 'head_html.mako'))
     self.html_foot_template = Template(
         filename=os.path.join(template_dir, 'foot_html.mako'))
     self.storage = configure_from_settings('storage', self.config)
Example #4
0
def main(global_config, **settings):
    config_file = global_config['__file__']
    load_into_settings(config_file, settings)

    config = Configurator(root_factory=Root, settings=settings)

    config.registry['storage'] = configure_from_settings(
        'storage', settings['config'].get_map('storage'))

    # Adds authorization.
    config.include("pyramid_multiauth")

    # Adds cornice.
    config.include("cornice")

    # Adds Mozilla default views.
    config.include("mozsvc")

    # Adds application-specific views.
    config.scan("bipostal.views")

    config.add_static_view('/', 'bipostal:backbone/',
                           permission='authenticated')

    return config.make_wsgi_app()
Example #5
0
 def setUp(self):
     raw_config = Config('src/tests/test_config.ini').get_map()
     config = {}
     for key in filter(lambda x: x.startswith('storage'), raw_config):
         config[key[8:]] = raw_config[key]
     self.storage = configure_from_settings('storage', config)
     self.alias_t = '*****@*****.**'
     self.user_t = '*****@*****.**'
     self.storage.add_alias(email=self.user_t,
                            alias=self.alias_t,
                            origin='example.com')
     self.milter = BiPostalMilter(config=raw_config)
 def setUp(self):
     raw_config = Config('src/tests/test_config.ini').get_map()
     config={}
     for key in filter(lambda x: x.startswith('storage'), raw_config):
         config[key[8:]] = raw_config[key]
     self.storage = configure_from_settings('storage', config)
     self.alias_t = '*****@*****.**'
     self.user_t = '*****@*****.**'
     self.storage.add_alias(
             email=self.user_t,
             alias=self.alias_t,
             origin='example.com')
     self.milter = BiPostalMilter(config=raw_config)
Example #7
0
class MysqlMemcacheTest(StorageTest):
    __test__ = True

    def setUp(self):
        try:
            import memcache
            import MySQLdb
        except ImportError, e:
            print("Missing Components for MyswlMemcache. Skipping tests. %s" %
                  str(e))
        settings = {
            'backend': 'bipostal.storage.mysql_memcache.Storage',
            'mysql.user': '******',
            'mysql.password': '******',
            'mysql.host': 'localhost',
            'mysql.user_db': 'bipostal.user',
            'memcache.servers': 'localhost:11211'
        }
        self.storage = configure_from_settings('storage', settings)
Example #8
0
 def setUp(self):
     settings = {'backend': 'bipostal.storage.mem.Storage'}
     self.storage = configure_from_settings('storage', settings)
Example #9
0
            t_start = time.time()
            sock = Sock(self.conf_get('test_milter', 'host'),
                   self.conf_get('test_milter', 'port'))
            #option negotiation
            #Do everything
            #resp = sock.mexchange ("O\00\00\00\06\00\00\01\xFF\00\x1F\xFF\xFF", single=True)
            resp = sock.mexchange ('R<%s>\000RCPT\x3Drfc822;%s\00' % (
                alias,
                alias))
            #resp should be 'c'
            resp = sock.mexchange ('Btesting 123\n\n')
            resp = sock.mexchange ('E\00\00\00')
            t_stop = time.time()
            #self.failUnless(resp[0][:1] == 'm' and (self.user_t % rand) in resp[0])
            #self.failUnless(resp[1][:1] == 'b' and 'testing 123' in resp[1])
            t_delta = t_stop - t_start
            self.total_time += t_delta
            self.total_pages += 1
            self.logd(' Done in %.3fs' % t_delta)
            self._log_response(DummyResponse(alias), 'sock', alias, t_start, t_stop) 

if __name__ in ('main', '__main__'):
    bi_config = Config('../src/bipostmap.ini').get_map()
    #filter the config.
    config = {}
    for key in filter(lambda x: x.startswith('storage'), bi_config):
        config[key[8:]] = bi_config[key]
    storage = configure_from_settings('storage', config)
    unittest.main()
    storage.flushall(pattern='alias_%')
Example #10
0
 def setUp(self):
     settings = {'backend': 'bipostal.storage.mem.Storage'}
     self.storage = configure_from_settings('storage', settings)
 def __init__(self, listener, config, **kw):
     # pass listener=None for testing purposes (to prevent socket creation)
     if listener is not None:
         super(ResolveServer, self).__init__(listener, **kw)
     self.config = config
     self.storage = configure_from_settings('storage', self.config)
Example #12
0
 def setUp(self):
     # Use a separate db for testing.
     settings = {'backend': 'bipostal.storage.redis_.Storage', 'db': 1}
     self.storage = configure_from_settings('storage', settings)
     # Clear out the db for testing.
     self.storage.redis.flushall()