dothttp-req 0.0.44a27__tar.gz → 0.0.44a29__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {dothttp_req-0.0.44a27 → dothttp_req-0.0.44a29}/PKG-INFO +1 -2
- {dothttp_req-0.0.44a27 → dothttp_req-0.0.44a29}/dothttp/http.tx +7 -7
- {dothttp_req-0.0.44a27 → dothttp_req-0.0.44a29}/dothttp/models/computed.py +1 -1
- {dothttp_req-0.0.44a27 → dothttp_req-0.0.44a29}/dothttp/models/parse_models.py +1 -6
- {dothttp_req-0.0.44a27 → dothttp_req-0.0.44a29}/dothttp/parse/__init__.py +10 -10
- {dothttp_req-0.0.44a27 → dothttp_req-0.0.44a29}/dothttp/parse/request_base.py +9 -4
- {dothttp_req-0.0.44a27 → dothttp_req-0.0.44a29}/dothttp/script/js3py.py +0 -54
- {dothttp_req-0.0.44a27 → dothttp_req-0.0.44a29}/dothttp/utils/common.py +11 -0
- {dothttp_req-0.0.44a27 → dothttp_req-0.0.44a29}/pyproject.toml +4 -5
- {dothttp_req-0.0.44a27 → dothttp_req-0.0.44a29}/LICENSE.txt +0 -0
- {dothttp_req-0.0.44a27 → dothttp_req-0.0.44a29}/README.md +0 -0
- {dothttp_req-0.0.44a27 → dothttp_req-0.0.44a29}/dotextensions/__init__.py +0 -0
- {dothttp_req-0.0.44a27 → dothttp_req-0.0.44a29}/dotextensions/server/__init__.py +0 -0
- {dothttp_req-0.0.44a27 → dothttp_req-0.0.44a29}/dotextensions/server/__main__.py +0 -0
- {dothttp_req-0.0.44a27 → dothttp_req-0.0.44a29}/dotextensions/server/agent.py +0 -0
- {dothttp_req-0.0.44a27 → dothttp_req-0.0.44a29}/dotextensions/server/handlers/__init__.py +0 -0
- {dothttp_req-0.0.44a27 → dothttp_req-0.0.44a29}/dotextensions/server/handlers/basic_handlers.py +0 -0
- {dothttp_req-0.0.44a27 → dothttp_req-0.0.44a29}/dotextensions/server/handlers/fs_handlers.py +0 -0
- {dothttp_req-0.0.44a27 → dothttp_req-0.0.44a29}/dotextensions/server/handlers/gohandler.py +0 -0
- {dothttp_req-0.0.44a27 → dothttp_req-0.0.44a29}/dotextensions/server/handlers/har2httphandler.py +0 -0
- {dothttp_req-0.0.44a27 → dothttp_req-0.0.44a29}/dotextensions/server/handlers/http2har.py +0 -0
- {dothttp_req-0.0.44a27 → dothttp_req-0.0.44a29}/dotextensions/server/handlers/http2postman.py +0 -0
- {dothttp_req-0.0.44a27 → dothttp_req-0.0.44a29}/dotextensions/server/handlers/postman2http.py +0 -0
- {dothttp_req-0.0.44a27 → dothttp_req-0.0.44a29}/dotextensions/server/models/__init__.py +0 -0
- {dothttp_req-0.0.44a27 → dothttp_req-0.0.44a29}/dotextensions/server/models/har.py +0 -0
- {dothttp_req-0.0.44a27 → dothttp_req-0.0.44a29}/dotextensions/server/postman/__init__.py +0 -0
- {dothttp_req-0.0.44a27 → dothttp_req-0.0.44a29}/dotextensions/server/postman2_1/__init__.py +0 -0
- {dothttp_req-0.0.44a27 → dothttp_req-0.0.44a29}/dotextensions/server/server.py +0 -0
- {dothttp_req-0.0.44a27 → dothttp_req-0.0.44a29}/dotextensions/server/utils.py +0 -0
- {dothttp_req-0.0.44a27 → dothttp_req-0.0.44a29}/dotextensions/version/__init__.py +0 -0
- {dothttp_req-0.0.44a27 → dothttp_req-0.0.44a29}/dotextensions/version/__main__.py +0 -0
- {dothttp_req-0.0.44a27 → dothttp_req-0.0.44a29}/dothttp/__init__.py +0 -0
- {dothttp_req-0.0.44a27 → dothttp_req-0.0.44a29}/dothttp/__main__.py +0 -0
- {dothttp_req-0.0.44a27 → dothttp_req-0.0.44a29}/dothttp/__version__.py +0 -0
- {dothttp_req-0.0.44a27 → dothttp_req-0.0.44a29}/dothttp/auth/__init__.py +0 -0
- {dothttp_req-0.0.44a27 → dothttp_req-0.0.44a29}/dothttp/auth/azure_auth.py +0 -0
- {dothttp_req-0.0.44a27 → dothttp_req-0.0.44a29}/dothttp/exceptions.py +0 -0
- {dothttp_req-0.0.44a27 → dothttp_req-0.0.44a29}/dothttp/models/__init__.py +0 -0
- {dothttp_req-0.0.44a27 → dothttp_req-0.0.44a29}/dothttp/parse/dsl_jsonparser.py +0 -0
- {dothttp_req-0.0.44a27 → dothttp_req-0.0.44a29}/dothttp/parse/expression.py +0 -0
- {dothttp_req-0.0.44a27 → dothttp_req-0.0.44a29}/dothttp/postScript.js +0 -0
- {dothttp_req-0.0.44a27 → dothttp_req-0.0.44a29}/dothttp/property_schema.py +0 -0
- {dothttp_req-0.0.44a27 → dothttp_req-0.0.44a29}/dothttp/script/__init__.py +0 -0
- {dothttp_req-0.0.44a27 → dothttp_req-0.0.44a29}/dothttp/utils/__init__.py +0 -0
- {dothttp_req-0.0.44a27 → dothttp_req-0.0.44a29}/dothttp/utils/constants.py +0 -0
- {dothttp_req-0.0.44a27 → dothttp_req-0.0.44a29}/dothttp/utils/curl_utils.py +0 -0
- {dothttp_req-0.0.44a27 → dothttp_req-0.0.44a29}/dothttp/utils/json_utils.py +0 -0
- {dothttp_req-0.0.44a27 → dothttp_req-0.0.44a29}/dothttp/utils/log_utils.py +0 -0
- {dothttp_req-0.0.44a27 → dothttp_req-0.0.44a29}/dothttp/utils/property_util.py +0 -0
- {dothttp_req-0.0.44a27 → dothttp_req-0.0.44a29}/dothttp_test/__init__.py +0 -0
- {dothttp_req-0.0.44a27 → dothttp_req-0.0.44a29}/dothttp_test/__main__.py +0 -0
- {dothttp_req-0.0.44a27 → dothttp_req-0.0.44a29}/dothttp_test/conftest.py +0 -0
- {dothttp_req-0.0.44a27 → dothttp_req-0.0.44a29}/dothttp_test/dothttp_test.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dothttp-req
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.44a29
|
|
4
4
|
Summary: Dothttp is Simple http client for testing and development
|
|
5
5
|
License: MIT
|
|
6
6
|
License-File: LICENSE.txt
|
|
@@ -16,7 +16,6 @@ Classifier: Programming Language :: Python :: 3.11
|
|
|
16
16
|
Classifier: Programming Language :: Python :: 3.12
|
|
17
17
|
Classifier: Programming Language :: Python :: 3.13
|
|
18
18
|
Classifier: Programming Language :: Python :: 3.14
|
|
19
|
-
Provides-Extra: js
|
|
20
19
|
Requires-Dist: faker (==37.12.0)
|
|
21
20
|
Requires-Dist: jsonschema (==4.23.0)
|
|
22
21
|
Requires-Dist: jstyleson (==0.0.2)
|
|
@@ -169,13 +169,13 @@ METHODTYPE:
|
|
|
169
169
|
| "SEARCH"
|
|
170
170
|
;
|
|
171
171
|
|
|
172
|
-
QUERY:
|
|
173
|
-
'query' '(' key=DotString ',' value=
|
|
172
|
+
QUERY:
|
|
173
|
+
'query' '(' key=DotString ',' value=TRIPLE_OR_DOUBLE_STRING ')'
|
|
174
174
|
|('?' | "&") (
|
|
175
|
-
'(' key=DotString ',' value=
|
|
176
|
-
| key=DotString ',' value=
|
|
177
|
-
| key=DotString ':' value=
|
|
178
|
-
| key=DotString '=' value=
|
|
175
|
+
'(' key=DotString ',' value=TRIPLE_OR_DOUBLE_STRING ')'
|
|
176
|
+
| key=DotString ',' value=TRIPLE_OR_DOUBLE_STRING
|
|
177
|
+
| key=DotString ':' value=TRIPLE_OR_DOUBLE_STRING
|
|
178
|
+
| key=DotString '=' value=TRIPLE_OR_DOUBLE_STRING
|
|
179
179
|
)
|
|
180
180
|
;
|
|
181
181
|
|
|
@@ -314,7 +314,7 @@ HTTP_TEST_SCRIPT:
|
|
|
314
314
|
;
|
|
315
315
|
|
|
316
316
|
SCRIPT_LANGUAGE:
|
|
317
|
-
'python'
|
|
317
|
+
'python'
|
|
318
318
|
;
|
|
319
319
|
|
|
320
320
|
SLASH:
|
|
@@ -86,7 +86,7 @@ class HttpDef:
|
|
|
86
86
|
session_clear = False
|
|
87
87
|
no_parent_script = False
|
|
88
88
|
test_script: str = ""
|
|
89
|
-
test_script_lang: ScriptType = ScriptType.
|
|
89
|
+
test_script_lang: ScriptType = ScriptType.PYTHON
|
|
90
90
|
proxy: Optional[Dict[str, str]] = None
|
|
91
91
|
|
|
92
92
|
def get_har(self):
|
|
@@ -179,7 +179,6 @@ class ToFile:
|
|
|
179
179
|
|
|
180
180
|
@dataclass
|
|
181
181
|
class LangOption:
|
|
182
|
-
javascript: Optional[str]
|
|
183
182
|
python: Optional[str]
|
|
184
183
|
|
|
185
184
|
|
|
@@ -511,11 +510,7 @@ class HttpFileType(enum.Enum):
|
|
|
511
510
|
|
|
512
511
|
class ScriptType(enum.Enum):
|
|
513
512
|
PYTHON = "python"
|
|
514
|
-
JAVA_SCRIPT = "javascript"
|
|
515
513
|
|
|
516
514
|
@staticmethod
|
|
517
515
|
def get_script_type(script_type: LangOption):
|
|
518
|
-
|
|
519
|
-
return ScriptType.JAVA_SCRIPT
|
|
520
|
-
else:
|
|
521
|
-
return ScriptType.PYTHON
|
|
516
|
+
return ScriptType.PYTHON
|
|
@@ -21,6 +21,11 @@ from requests.auth import HTTPBasicAuth, HTTPDigestAuth
|
|
|
21
21
|
from requests.structures import CaseInsensitiveDict
|
|
22
22
|
from textx import TextXSyntaxError, metamodel_from_file
|
|
23
23
|
|
|
24
|
+
try:
|
|
25
|
+
import magic
|
|
26
|
+
except ImportError:
|
|
27
|
+
magic = None
|
|
28
|
+
|
|
24
29
|
from ..exceptions import *
|
|
25
30
|
from ..models.computed import *
|
|
26
31
|
from ..models.parse_models import (
|
|
@@ -41,8 +46,8 @@ from ..models.parse_models import (
|
|
|
41
46
|
TestScript,
|
|
42
47
|
)
|
|
43
48
|
from ..property_schema import property_schema
|
|
44
|
-
from ..script import
|
|
45
|
-
from ..utils.common import get_real_file_path, triple_or_double_tostring
|
|
49
|
+
from ..script import ScriptExecutionPython
|
|
50
|
+
from ..utils.common import get_real_file_path, triple_or_double_tostring, single_triple_or_double_tostring
|
|
46
51
|
from ..utils.constants import *
|
|
47
52
|
from ..utils.property_util import PropertyProvider, StringFormatPropertyResolver
|
|
48
53
|
from .dsl_jsonparser import json_or_array_to_json, jsonmodel_to_json
|
|
@@ -422,12 +427,12 @@ class HttpDefBase(BaseModelProcessor):
|
|
|
422
427
|
for line in parent.lines:
|
|
423
428
|
if query := line.query:
|
|
424
429
|
params[self.get_updated_content(query.key)].append(
|
|
425
|
-
|
|
430
|
+
single_triple_or_double_tostring(query.value, self.get_updated_content)
|
|
426
431
|
)
|
|
427
432
|
for line in self.http.lines:
|
|
428
433
|
if query := line.query:
|
|
429
434
|
params[self.get_updated_content(query.key)].append(
|
|
430
|
-
|
|
435
|
+
single_triple_or_double_tostring(query.value, self.get_updated_content)
|
|
431
436
|
)
|
|
432
437
|
request_logger.debug(f"computed query params from `{self.file}` are `{params}`")
|
|
433
438
|
self.httpdef.query = params
|
|
@@ -936,12 +941,7 @@ class HttpDefBase(BaseModelProcessor):
|
|
|
936
941
|
self.script_execution.pre_request_script()
|
|
937
942
|
|
|
938
943
|
def run_prerequest_script(self):
|
|
939
|
-
|
|
940
|
-
ScriptExecutionJs
|
|
941
|
-
if self.httpdef.test_script_lang == ScriptType.JAVA_SCRIPT
|
|
942
|
-
else ScriptExecutionPython
|
|
943
|
-
)
|
|
944
|
-
self.script_execution = execution_cls(self.httpdef, self.property_util)
|
|
944
|
+
self.script_execution = ScriptExecutionPython(self.httpdef, self.property_util)
|
|
945
945
|
self.script_execution.init_request_script()
|
|
946
946
|
for key, value in self.script_execution.client.properties.updated.items():
|
|
947
947
|
self.property_util.add_command_line_property(key, value)
|
|
@@ -32,7 +32,7 @@ from ..parse import (
|
|
|
32
32
|
eprint,
|
|
33
33
|
)
|
|
34
34
|
from ..script import ScriptResult
|
|
35
|
-
from ..utils.common import apply_quote_or_unquote, quote_or_unquote
|
|
35
|
+
from ..utils.common import apply_quote_or_unquote, quote_or_unquote, single_triple_or_double_tostring
|
|
36
36
|
from ..utils.curl_utils import to_curl
|
|
37
37
|
from ..utils.json_utils import JSONEncoder
|
|
38
38
|
from .dsl_jsonparser import json_or_array_to_json
|
|
@@ -371,7 +371,7 @@ class HttpFileFormatter(RequestBase):
|
|
|
371
371
|
map(
|
|
372
372
|
query_to_http,
|
|
373
373
|
filter(
|
|
374
|
-
lambda line: line.query and isinstance(line.query.value, str),
|
|
374
|
+
lambda line: line.query and (isinstance(line.query.value, str) or hasattr(line.query.value, 'triple') or hasattr(line.query.value, 'str')),
|
|
375
375
|
lines,
|
|
376
376
|
),
|
|
377
377
|
)
|
|
@@ -473,8 +473,13 @@ class HttpFileFormatter(RequestBase):
|
|
|
473
473
|
|
|
474
474
|
|
|
475
475
|
def query_to_http(line):
|
|
476
|
-
|
|
477
|
-
|
|
476
|
+
# Handle TRIPLE_OR_DOUBLE_STRING object
|
|
477
|
+
if hasattr(line.query.value, 'triple') or hasattr(line.query.value, 'str'):
|
|
478
|
+
value_str = single_triple_or_double_tostring(line.query.value, lambda x: x)
|
|
479
|
+
else:
|
|
480
|
+
value_str = line.query.value
|
|
481
|
+
quote_type = quote_or_unquote(value_str)[0]
|
|
482
|
+
return f"? {quote_type}{line.query.key}{quote_type}= {quote_type}{value_str}{quote_type}"
|
|
478
483
|
|
|
479
484
|
|
|
480
485
|
class RequestCompiler(RequestBase):
|
|
@@ -32,12 +32,6 @@ from ..parse import MIME_TYPE_JSON, HttpDef, request_logger
|
|
|
32
32
|
from ..utils.common import get_real_file_path
|
|
33
33
|
from ..utils.property_util import PropertyProvider
|
|
34
34
|
|
|
35
|
-
try:
|
|
36
|
-
import js2py
|
|
37
|
-
from js2py.base import JsObjectWrapper
|
|
38
|
-
from js2py.internals.simplex import JsException
|
|
39
|
-
except:
|
|
40
|
-
pass
|
|
41
35
|
|
|
42
36
|
|
|
43
37
|
def write_guard(x):
|
|
@@ -79,11 +73,6 @@ allowed_global = {
|
|
|
79
73
|
}
|
|
80
74
|
allowed_global.update(safe_globals)
|
|
81
75
|
|
|
82
|
-
# disable python imports
|
|
83
|
-
# js2py.disable_pyimport() # so that few libraries can be imported
|
|
84
|
-
|
|
85
|
-
with open(get_real_file_path("../postScript.js", __file__)) as f:
|
|
86
|
-
js_template = f.read()
|
|
87
76
|
|
|
88
77
|
|
|
89
78
|
@dataclass
|
|
@@ -228,49 +217,6 @@ class ScriptExecutionEnvironmentBase:
|
|
|
228
217
|
return script_result
|
|
229
218
|
|
|
230
219
|
|
|
231
|
-
class ScriptExecutionJs(ScriptExecutionEnvironmentBase):
|
|
232
|
-
def _execute_test_script(self, resp) -> None:
|
|
233
|
-
# enable require will only be used for
|
|
234
|
-
# those who want to use require in dothttp scripts
|
|
235
|
-
# i will write up a document on how to do it
|
|
236
|
-
context = js2py.EvalJs(enable_require=True)
|
|
237
|
-
try:
|
|
238
|
-
context.execute(
|
|
239
|
-
js_template.replace("JS_CODE_REPLACE", self.client.request.test_script)
|
|
240
|
-
)
|
|
241
|
-
except JsException as exc:
|
|
242
|
-
raise ScriptException(payload=str(exc), function="''")
|
|
243
|
-
content_type = resp.headers.get("content-type", "text/plain")
|
|
244
|
-
# in some cases mimetype can have charset
|
|
245
|
-
# like text/plain; charset=utf-8
|
|
246
|
-
content_type = (
|
|
247
|
-
content_type.split(";")[0] if ";" in content_type else content_type
|
|
248
|
-
)
|
|
249
|
-
client = context.jsHandler(
|
|
250
|
-
content_type == MIME_TYPE_JSON,
|
|
251
|
-
self.client.properties,
|
|
252
|
-
resp.text,
|
|
253
|
-
resp.status_code,
|
|
254
|
-
dict(resp.headers),
|
|
255
|
-
)
|
|
256
|
-
script_result = ScriptResult(stdout="", error="", properties={}, tests=[])
|
|
257
|
-
for test_name in client.tests:
|
|
258
|
-
test_result = TestResult(test_name)
|
|
259
|
-
try:
|
|
260
|
-
test_result.result = client.tests[test_name]()
|
|
261
|
-
test_result.success = True
|
|
262
|
-
except Exception as exc:
|
|
263
|
-
test_result.error = str(exc)
|
|
264
|
-
test_result.success = False
|
|
265
|
-
request_logger.error(f"test execution failed {exc}")
|
|
266
|
-
script_result.tests.append(test_result)
|
|
267
|
-
for i in client.properties.updated:
|
|
268
|
-
if not isinstance(client.properties.vars[i], JsObjectWrapper):
|
|
269
|
-
script_result.properties[i] = client.properties.vars[i] or ""
|
|
270
|
-
script_result.stdout += "\n".join(client.stdout)
|
|
271
|
-
return script_result
|
|
272
|
-
|
|
273
|
-
|
|
274
220
|
class ScriptExecutionPython(ScriptExecutionEnvironmentBase):
|
|
275
221
|
def __init__(self, httpdef: HttpDef, prop: PropertyProvider) -> None:
|
|
276
222
|
super().__init__(httpdef, prop)
|
|
@@ -37,6 +37,17 @@ def triple_or_double_tostring(list_of_triple_or_double, update_content_func):
|
|
|
37
37
|
)
|
|
38
38
|
|
|
39
39
|
|
|
40
|
+
def single_triple_or_double_tostring(triple_or_double, update_content_func):
|
|
41
|
+
"""Convert a single TRIPLE_OR_DOUBLE_STRING object to string"""
|
|
42
|
+
if hasattr(triple_or_double, 'triple') and triple_or_double.triple:
|
|
43
|
+
return update_content_func(triple_or_double.triple[3:-3])
|
|
44
|
+
elif hasattr(triple_or_double, 'str') and triple_or_double.str:
|
|
45
|
+
return update_content_func(triple_or_double.str)
|
|
46
|
+
else:
|
|
47
|
+
# This shouldn't happen with proper grammar, but handle edge cases
|
|
48
|
+
return update_content_func(str(triple_or_double))
|
|
49
|
+
|
|
50
|
+
|
|
40
51
|
def quote_or_unquote(line: str):
|
|
41
52
|
if '"' in line and "'" in line:
|
|
42
53
|
return '"', line.replace("'", "\\'")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "dothttp-req"
|
|
3
|
-
version = "0.0.
|
|
3
|
+
version = "0.0.44a29"
|
|
4
4
|
description = "Dothttp is Simple http client for testing and development"
|
|
5
5
|
authors = ["Prasanth <kesavarapu.siva@gmail.com>"]
|
|
6
6
|
license = "MIT"
|
|
@@ -42,13 +42,12 @@ xmltodict = "^1.0.2"
|
|
|
42
42
|
waitress = "3.0.2"
|
|
43
43
|
flask = "3.1.2"
|
|
44
44
|
python-magic = "^0.4.27"
|
|
45
|
-
js2py = "0.74"
|
|
46
45
|
flask-cors = "^6.0.1"
|
|
47
46
|
pytest = "^8.3.5"
|
|
48
47
|
pytest-html = "^4.1.1"
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
pytest-xdist = "^3.6.1"
|
|
49
|
+
gunicorn = "^23.0.0"
|
|
50
|
+
httpbin = "^0.10.2"
|
|
52
51
|
|
|
53
52
|
[build-system]
|
|
54
53
|
requires = ["poetry-core"]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{dothttp_req-0.0.44a27 → dothttp_req-0.0.44a29}/dotextensions/server/handlers/basic_handlers.py
RENAMED
|
File without changes
|
{dothttp_req-0.0.44a27 → dothttp_req-0.0.44a29}/dotextensions/server/handlers/fs_handlers.py
RENAMED
|
File without changes
|
|
File without changes
|
{dothttp_req-0.0.44a27 → dothttp_req-0.0.44a29}/dotextensions/server/handlers/har2httphandler.py
RENAMED
|
File without changes
|
|
File without changes
|
{dothttp_req-0.0.44a27 → dothttp_req-0.0.44a29}/dotextensions/server/handlers/http2postman.py
RENAMED
|
File without changes
|
{dothttp_req-0.0.44a27 → dothttp_req-0.0.44a29}/dotextensions/server/handlers/postman2http.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|