grr/server/grr_response_server/gui/api_regression_http.py
def HandleCheck(self, method_metadata, args=None, replace=None):
    """Does regression check for given method, args and a replace function."""

    if not replace:
      raise ValueError("replace can't be None")

    if self.__class__.api_version == 1:
      request, prepped_request = self._PrepareV1Request(
          method_metadata.name, args=args)
    elif self.__class__.api_version == 2:
      request, prepped_request = self._PrepareV2Request(
          method_metadata.name, args=args)
    else:
      raise ValueError(
          "api_version may be only 1 or 2, not %d" % flags.FLAGS.api_version)

    session = requests.Session()
    response = session.send(prepped_request)

    check_result = {
        "url": replace(prepped_request.path_url),
        "method": request.method
    }

    if request.data:
      request_payload = self._ParseJSON(replace(request.data))
      if request_payload:
        check_result["request_payload"] = request_payload

    if (method_metadata.result_type ==
        api_call_router.RouterMethodMetadata.BINARY_STREAM_RESULT_TYPE):
      check_result["response"] = replace(utils.SmartUnicode(response.content))
    else:
      check_result["response"] = self._ParseJSON(replace(response.content))

    if self.__class__.api_version == 1:
      stripped_response = api_value_renderers.StripTypeInfo(
          check_result["response"])
      if stripped_response != check_result["response"]:
        check_result["type_stripped_response"] = stripped_response

    return check_result
Does regression check for given method, args and a replace function.
Does regression check for given method, args and a replace function.
Does regression check for given method args and a replace function .
def HandleCheck(self, method_metadata, args=None, replace=None):
    if not replace:
      raise ValueError("replace can't be None")
    if self.__class__.api_version == 1:
      request, prepped_request = self._PrepareV1Request(
          method_metadata.name, args=args)
    elif self.__class__.api_version == 2:
      request, prepped_request = self._PrepareV2Request(
          method_metadata.name, args=args)
    else:
      raise ValueError(
          "api_version may be only 1 or 2, not %d" % flags.FLAGS.api_version)
    session = requests.Session()
    response = session.send(prepped_request)
    check_result = {
        "url": replace(prepped_request.path_url),
        "method": request.method
    }
    if request.data:
      request_payload = self._ParseJSON(replace(request.data))
      if request_payload:
        check_result["request_payload"] = request_payload
    if (method_metadata.result_type ==
        api_call_router.RouterMethodMetadata.BINARY_STREAM_RESULT_TYPE):
      check_result["response"] = replace(utils.SmartUnicode(response.content))
    else:
      check_result["response"] = self._ParseJSON(replace(response.content))
    if self.__class__.api_version == 1:
      stripped_response = api_value_renderers.StripTypeInfo(
          check_result["response"])
      if stripped_response != check_result["response"]:
        check_result["type_stripped_response"] = stripped_response
    return check_result
def HandleCheck ( self , method_metadata , args = None , replace = None ) : if not replace : raise ValueError ( "replace can't be None" ) if self . __class__ . api_version == 1 : request , prepped_request = self . _PrepareV1Request ( method_metadata . name , args = args ) elif self . __class__ . api_version == 2 : request , prepped_request = self . _PrepareV2Request ( method_metadata . name , args = args ) else : raise ValueError ( "api_version may be only 1 or 2, not %d" % flags . FLAGS . api_version ) session = requests . Session ( ) response = session . send ( prepped_request ) check_result = { "url" : replace ( prepped_request . path_url ) , "method" : request . method } if request . data : request_payload = self . _ParseJSON ( replace ( request . data ) ) if request_payload : check_result [ "request_payload" ] = request_payload if ( method_metadata . result_type == api_call_router . RouterMethodMetadata . BINARY_STREAM_RESULT_TYPE ) : check_result [ "response" ] = replace ( utils . SmartUnicode ( response . content ) ) else : check_result [ "response" ] = self . _ParseJSON ( replace ( response . content ) ) if self . __class__ . api_version == 1 : stripped_response = api_value_renderers . StripTypeInfo ( check_result [ "response" ] ) if stripped_response != check_result [ "response" ] : check_result [ "type_stripped_response" ] = stripped_response return check_result
Does regression check for given method, args and a replace function.
Does regression check for given method args and a replace function .
"""Does regression check for given method, args and a replace function."""
self
method_metadata
args
replace