(self, teststep_dict, entry_json)
parse HAR entry response and make teststep validate.

        Args:
            entry_json (dict):
                {
                    "request": {},
                    "response": {
                        "status": 200,
                        "headers": [
                            {
                                "name": "Content-Type",
                                "value": "application/json; charset=utf-8"
                            },
                        ],
                        "content": {
                            "size": 71,
                            "mimeType": "application/json; charset=utf-8",
                            "text": "eyJJc1N1Y2Nlc3MiOnRydWUsIkNvZGUiOjIwMCwiTWVzc2FnZSI6bnVsbCwiVmFsdWUiOnsiQmxuUmVzdWx0Ijp0cnVlfX0=",
                            "encoding": "base64"
                        }
                    }
                }

        Returns:
            {
                "validate": [
                    {"eq": ["status_code", 200]}
                ]
            }
parse HAR entry response and make teststep validate.
parse HAR entry response and make teststep validate .
def _make_validate(self, teststep_dict, entry_json):
        """ parse HAR entry response and make teststep validate.

        Args:
            entry_json (dict):
                {
                    "request": {},
                    "response": {
                        "status": 200,
                        "headers": [
                            {
                                "name": "Content-Type",
                                "value": "application/json; charset=utf-8"
                            },
                        ],
                        "content": {
                            "size": 71,
                            "mimeType": "application/json; charset=utf-8",
                            "text": "eyJJc1N1Y2Nlc3MiOnRydWUsIkNvZGUiOjIwMCwiTWVzc2FnZSI6bnVsbCwiVmFsdWUiOnsiQmxuUmVzdWx0Ijp0cnVlfX0=",
                            "encoding": "base64"
                        }
                    }
                }

        Returns:
            {
                "validate": [
                    {"eq": ["status_code", 200]}
                ]
            }

        """
        teststep_dict["validate"].append(
            {"eq": ["status_code", entry_json["response"].get("status")]}
        )

        resp_content_dict = entry_json["response"].get("content")

        headers_mapping = utils.convert_list_to_dict(
            entry_json["response"].get("headers", [])
        )
        if "Content-Type" in headers_mapping:
            teststep_dict["validate"].append(
                {"eq": ["headers.Content-Type", headers_mapping["Content-Type"]]}
            )

        text = resp_content_dict.get("text")
        if not text:
            return

        mime_type = resp_content_dict.get("mimeType")
        if mime_type and mime_type.startswith("application/json"):

            encoding = resp_content_dict.get("encoding")
            if encoding and encoding == "base64":
                content = base64.b64decode(text)
                try:
                    content = content.decode("utf-8")
                except UnicodeDecodeError:
                    logger.warning(f"failed to decode base64 content with utf-8 !")
                    return
            else:
                content = text

            try:
                resp_content_json = json.loads(content)
            except JSONDecodeError:
                logger.warning(f"response content can not be loaded as json: {content}")
                return

            if not isinstance(resp_content_json, dict):
                # e.g. ['a', 'b']
                return

            for key, value in resp_content_json.items():
                if isinstance(value, (dict, list)):
                    continue

                teststep_dict["validate"].append({"eq": ["body.{}".format(key), value]})
def _make_validate ( self , teststep_dict , entry_json ) : teststep_dict [ "validate" ] . append ( { "eq" : [ "status_code" , entry_json [ "response" ] . get ( "status" ) ] } ) resp_content_dict = entry_json [ "response" ] . get ( "content" ) headers_mapping = utils . convert_list_to_dict ( entry_json [ "response" ] . get ( "headers" , [ ] ) ) if "Content-Type" in headers_mapping : teststep_dict [ "validate" ] . append ( { "eq" : [ "headers.Content-Type" , headers_mapping [ "Content-Type" ] ] } ) text = resp_content_dict . get ( "text" ) if not text : return mime_type = resp_content_dict . get ( "mimeType" ) if mime_type and mime_type . startswith ( "application/json" ) : encoding = resp_content_dict . get ( "encoding" ) if encoding and encoding == "base64" : content = base64 . b64decode ( text ) try : content = content . decode ( "utf-8" ) except UnicodeDecodeError : logger . warning ( f"failed to decode base64 content with utf-8 !" ) return else : content = text try : resp_content_json = json . loads ( content ) except JSONDecodeError : logger . warning ( f"response content can not be loaded as json: {content}" ) return if not isinstance ( resp_content_json , dict ) : # e.g. ['a', 'b'] return for key , value in resp_content_json . items ( ) : if isinstance ( value , ( dict , list ) ) : continue teststep_dict [ "validate" ] . append ( { "eq" : [ "body.{}" . format ( key ) , value ] } )