diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 2166c431..4d6ebe1b 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -6,6 +6,7 @@ - feat: make testsuite and run testsuite - feat: testcase/testsuite config support getting variables by function +- feat: har2case with request cookies **Fixed** diff --git a/httprunner/ext/har2case/core.py b/httprunner/ext/har2case/core.py index f7683eac..a65b2bfd 100644 --- a/httprunner/ext/har2case/core.py +++ b/httprunner/ext/har2case/core.py @@ -93,6 +93,14 @@ class HarParser(object): teststep_dict["request"]["method"] = method + def __make_request_cookies(self, teststep_dict, entry_json): + cookies = {} + for cookie in entry_json["request"].get("cookies", []): + cookies[cookie["name"]] = cookie["value"] + + if cookies: + teststep_dict["request"]["cookies"] = cookies + def __make_request_headers(self, teststep_dict, entry_json): """ parse HAR entry request headers, and make teststep headers. header in IGNORE_REQUEST_HEADERS will be ignored. @@ -288,6 +296,7 @@ class HarParser(object): self.__make_request_url(teststep_dict, entry_json) self.__make_request_method(teststep_dict, entry_json) + self.__make_request_cookies(teststep_dict, entry_json) self.__make_request_headers(teststep_dict, entry_json) self._make_request_data(teststep_dict, entry_json) self._make_validate(teststep_dict, entry_json)