Add regression test for PR 174

master
alufers 5 days ago
parent 72638cd34c
commit 8098a7c0d0

@ -50,6 +50,24 @@ def test_mitmproxy2swagger_generates_swagger_from_mitmproxy_flow_file_with_form_
)
def test_mitmproxy2swagger_generates_swagger_from_har_file_with_form_data():
# Regression test for https://github.com/alufers/mitmproxy2swagger/pull/174
# HAR bodies are already decoded strings; calling .decode() on them raised AttributeError
data = mitmproxy2swagger_e2e_test(
"testdata/form_data_har.har",
"https://httpbin.org/",
)
assert data is not None
assert (
get_nested_key(
data,
"paths./post.post.requestBody.content.application/x-www-form-urlencoded.schema",
)
is not None
)
def test_mitmproxy2swagger_generates_swagger_from_mitmproxy_flow_file_with_generic_keys():
data = mitmproxy2swagger_e2e_test(
"testdata/generic_keys_flows",

@ -0,0 +1,41 @@
{
"log": {
"version": "1.2",
"creator": { "name": "test", "version": "1.0" },
"entries": [
{
"request": {
"method": "POST",
"url": "https://httpbin.org/post",
"headers": [
{ "name": "Content-Type", "value": "application/x-www-form-urlencoded" }
],
"postData": {
"mimeType": "application/x-www-form-urlencoded",
"text": "username=alice&password=secret"
},
"queryString": [],
"cookies": [],
"headersSize": -1,
"bodySize": 29
},
"response": {
"status": 200,
"statusText": "OK",
"headers": [
{ "name": "Content-Type", "value": "application/json" }
],
"cookies": [],
"content": { "size": 2, "mimeType": "application/json", "text": "{}" },
"redirectURL": "",
"headersSize": -1,
"bodySize": 2
},
"cache": {},
"timings": { "send": 0, "wait": 1, "receive": 1 },
"startedDateTime": "2024-01-01T00:00:00.000Z",
"time": 2
}
]
}
}
Loading…
Cancel
Save