Esempio n. 1
0
    def make_server(host_port, handler, state):
        app = http_app.HTTPApp(state)
        application = oauth_middleware.OAuthMiddleware(app, None)
        application.get_oauth_data_store = lambda: tests.testingOAuthStore
        from OpenSSL import SSL
        cert_file = os.path.join(os.path.dirname(__file__), 'testing-certs',
                                 'testing.cert')
        key_file = os.path.join(os.path.dirname(__file__), 'testing-certs',
                                'testing.key')
        ssl_context = SSL.Context(SSL.SSLv23_METHOD)
        ssl_context.use_privatekey_file(key_file)
        ssl_context.use_certificate_chain_file(cert_file)
        srv = httpserver.WSGIServerBase(application,
                                        host_port,
                                        handler,
                                        ssl_context=ssl_context)
        # workaround apparent interface mismatch
        orig_shutdown_request = srv.shutdown_request

        def shutdown_request(req):
            req.shutdown()
            srv.close_request(req)

        srv.shutdown_request = shutdown_request
        application.base_url = "https://localhost:%s" % srv.server_address[1]
        return srv
Esempio n. 2
0
def make_server(host, port, working_dir):
    """Make a server on host and port exposing dbs living in working_dir."""
    state = server_state.ServerState()
    state.set_workingdir(working_dir)
    application = http_app.HTTPApp(state)
    server = httpserver.WSGIServer(application, (host, port),
                                   httpserver.WSGIHandler)
    return server
Esempio n. 3
0
 def make_server(host_port, handler, state):
     app = http_app.HTTPApp(state)
     application = oauth_middleware.OAuthMiddleware(app, None)
     application.get_oauth_data_store = lambda: tests.testingOAuthStore
     srv = simple_server.WSGIServer(host_port, handler)
     # patch the value in
     application.base_url = "http://%s:%s" % srv.server_address
     srv.set_app(application)
     return srv
Esempio n. 4
0
 def make_server(host_port, handler, state):
     application = http_app.HTTPApp(state)
     srv = simple_server.WSGIServer(host_port, handler)
     srv.set_app(application)
     #srv = httpserver.WSGIServerBase(application,
     #                                host_port,
     #                                handler
     #                                )
     return srv
Esempio n. 5
0
def make_server(host, port, working_dir, accept_cors_connections=None):
    """Make a server on host and port exposing dbs living in working_dir."""
    state = DbListingServerState()
    state.set_workingdir(working_dir)
    application = http_app.HTTPApp(state)
    if accept_cors_connections:
        application = cors_middleware.CORSMiddleware(application,
                                                     accept_cors_connections)
    server = httpserver.WSGIServer(application, (host, port),
                                   httpserver.WSGIHandler)
    return server
Esempio n. 6
0
    def setUp(self):
        super(TestHTTPAppErrorHandling, self).setUp()
        self.exc = None
        self.state = tests.ServerStateForTests()

        class ErroringResource(object):
            def post(_, args, content):
                raise self.exc

        def lookup_resource(environ, responder):
            return ErroringResource()

        self.http_app = http_app.HTTPApp(self.state)
        self.http_app._lookup_resource = lookup_resource
        self.app = paste.fixture.TestApp(self.http_app)
Esempio n. 7
0
 def setUp(self):
     super(TestHTTPApp, self).setUp()
     self.state = tests.ServerStateForTests()
     self.http_app = http_app.HTTPApp(self.state)
     self.app = paste.fixture.TestApp(self.http_app)
     self.db0 = self.state._create_database('db0')
def make_oauth_http_app(state):
    app = http_app.HTTPApp(state)
    application = oauth_middleware.OAuthMiddleware(app, None, prefix='/~/')
    application.get_oauth_data_store = lambda: tests.testingOAuthStore
    return application
def make_http_app(state):
    return http_app.HTTPApp(state)