示例#1
0
文件: http_api_test.py 项目: avmi/grr
  def setUp(self):
    super().setUp()

    config_overrider = test_lib.ConfigOverrider({
        "API.DefaultRouter": compatibility.GetName(TestHttpApiRouter),
    })
    config_overrider.Start()
    self.addCleanup(config_overrider.Stop)

    patcher = mock.patch.object(api_call_router_registry,
                                "_API_CALL_ROUTER_REGISTRY", {})
    patcher.start()
    self.addCleanup(patcher.stop)
    api_call_router_registry.RegisterApiCallRouter("TestHttpApiRouter",
                                                   TestHttpApiRouter)
    # pylint: disable=g-long-lambda
    self.addCleanup(lambda: api_call_router_registry.UnregisterApiCallRouter(
        "TestHttpApiRouter"))
    api_call_router_registry.RegisterApiCallRouter("TestHttpApiRouter",
                                                   TestHttpApiRouter)

    # Make sure ApiAuthManager is initialized with this configuration setting.
    api_auth_manager.InitializeApiAuthManager()

    self.request_handler = http_api.HttpRequestHandler()
示例#2
0
文件: registry_init.py 项目: avmi/grr
def RegisterApiCallRouters():
  """Registers all API call routers."""

  # keep-sorted start
  api_call_router_registry.RegisterApiCallRouter(
      "ApiCallRobotRouter", api_call_robot_router.ApiCallRobotRouter)
  api_call_router_registry.RegisterApiCallRouter(
      "ApiCallRouterStub", api_call_router.ApiCallRouterStub)
  api_call_router_registry.RegisterApiCallRouter(
      "ApiCallRouterWithApprovalChecks",
      api_call_router_with_approval_checks.ApiCallRouterWithApprovalChecks)
  api_call_router_registry.RegisterApiCallRouter(
      "ApiCallRouterWithApprovalChecksWithRobotAccess",
      api_call_router_with_approval_checks
      .ApiCallRouterWithApprovalChecksWithRobotAccess)
  api_call_router_registry.RegisterApiCallRouter(
      "ApiCallRouterWithApprovalChecksWithoutRobotAccess",
      api_call_router_with_approval_checks
      .ApiCallRouterWithApprovalChecksWithoutRobotAccess)
  api_call_router_registry.RegisterApiCallRouter(
      "ApiCallRouterWithoutChecks",
      api_call_router_without_checks.ApiCallRouterWithoutChecks)
  api_call_router_registry.RegisterApiCallRouter(
      "ApiLabelsRestrictedCallRouter",
      api_labels_restricted_call_router.ApiLabelsRestrictedCallRouter)
  api_call_router_registry.RegisterApiCallRouter("ApiRootRouter",
                                                 api_root_router.ApiRootRouter)
  api_call_router_registry.RegisterApiCallRouter(
      "DisabledApiCallRouter", api_call_router.DisabledApiCallRouter)
示例#3
0
    def setUp(self):
        super().setUp()

        default_router = RootApiBinaryManagementTestRouter
        root_api_config_overrider = test_lib.ConfigOverrider(
            {"API.DefaultRouter": compatibility.GetName(default_router)})
        root_api_config_overrider.Start()
        self.addCleanup(root_api_config_overrider.Stop)

        patcher = mock.patch.object(api_call_router_registry,
                                    "_API_CALL_ROUTER_REGISTRY", {})
        patcher.start()
        self.addCleanup(patcher.stop)
        api_call_router_registry.RegisterApiCallRouter(
            "RootApiBinaryManagementTestRouter",
            RootApiBinaryManagementTestRouter)
        self.addCleanup(
            lambda: api_call_router_registry.UnregisterApiCallRouter(  # pylint:disable=g-long-lambda
                "RootApiBinaryManagementTestRouter"))

        # Force creation of new APIAuthorizationManager, so that configuration
        # changes are picked up.
        api_auth_manager.InitializeApiAuthManager()
示例#4
0
 def __enter__(self):
     api_call_router_registry.RegisterApiCallRouter(self._name,
                                                    self._api_call_router)