def add_host_check_with_whitelisted_hosts(self, whitelisted_hosts):
    def wsgi_application(environ, start_response):
      del environ  # Unused for test wsgi app
      start_response('200 OK', [])
      return ['Host check passed']

    self.server.set_app(wsgi_server.WsgiHostCheck(whitelisted_hosts,
                                                  wsgi_application))
Esempio n. 2
0
    def __init__(self,
                 host,
                 port,
                 app_id,
                 use_grpc=False,
                 grpc_api_port=0,
                 enable_host_checking=True):
        self._app_id = app_id
        self._host = host

        if enable_host_checking:
            api_server_module = wsgi_server.WsgiHostCheck([host], self)
        else:
            api_server_module = self
        super(APIServer, self).__init__((host, port), api_server_module)

        self.set_balanced_address('localhost:8080')

        self._use_grpc = use_grpc
        self._grpc_api_port = grpc_api_port
Esempio n. 3
0
    def __init__(self,
                 host,
                 port,
                 dispatch,
                 configuration,
                 xsrf_token_path,
                 enable_host_checking=True,
                 enable_console=False):
        """Initializer for AdminServer.

    Args:
      host: A string containing the name of the host that the server should bind
          to e.g. "localhost".
      port: An int containing the port that the server should bind to e.g. 80.
      dispatch: A dispatcher.Dispatcher instance used to route requests and
          provide state about running servers.
      configuration: An application_configuration.ApplicationConfiguration
          instance containing the configuration for the application.
      xsrf_token_path: A string containing the path to a file that contains the
          XSRF configuration for the admin UI.
      enable_host_checking: A bool indicating that HTTP Host checking should
          be enforced for incoming requests.
      enable_console: A bool indicating that the interactive console should
          be enabled.

    """
        self._host = host
        self._xsrf_token_path = xsrf_token_path

        admin_app = AdminApplication(dispatch, configuration, host, port,
                                     enable_console)
        if enable_host_checking:
            admin_app_module = wsgi_server.WsgiHostCheck([host], admin_app)
        else:
            admin_app_module = admin_app
        super(AdminServer, self).__init__((host, port), admin_app_module)