Exemplo 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
Exemplo n.º 2
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
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