Skip to content

Commit

Permalink
Script execution and dependency updates
Browse files Browse the repository at this point in the history
1. Now script execution split into three parts:
    1. Init (runs after loading variables)
    2. pre (runs after request is loaded

2. Chore Update faker, requests-pkcs12, waitress

This is best suited for laod binary files converting/transforming data before executing.
  • Loading branch information
cedric05 authored Feb 13, 2024
1 parent a36138a commit 13c0df6
Show file tree
Hide file tree
Showing 16 changed files with 479 additions and 377 deletions.
6 changes: 3 additions & 3 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@ jstyleson = "==0.0.2"
requests = "==2.31.0"
textx = "==4.0.1"
js2py = "==0.74"
requests-pkcs12 = "==1.22"
requests-pkcs12 = "==1.24"
parsys-requests-unixsocket = "==0.3.1"
requests-aws4auth = "==1.2.3"
requests-ntlm = "==1.2.0"
restrictedpython = "==7.0"
faker = "==22.7.0"
faker = "==23.1.0"
requests-hawk = "==1.2.1"
pyyaml = "==6.0.1"
toml = "==0.10.2"
msal = "==1.26.0"

[dev-packages]
python-magic = "*"
waitress = "==2.1.1"
waitress = "==3.0.0"
flask = "==3.0.2"
pyperf = "==2.6.2"
pytest-benchmark = "*"
Expand Down
20 changes: 10 additions & 10 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 3 additions & 5 deletions dotextensions/server/handlers/basic_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

from requests import RequestException

from dothttp import DotHttpException, Config, HttpDef, MultidefHttp, BaseModelProcessor, UndefinedHttpToExtend, js3py
from dothttp.exceptions import DotHttpException
from dothttp import Config, HttpDef, MultidefHttp, BaseModelProcessor, UndefinedHttpToExtend, js3py
from dothttp.request_base import CurlCompiler, RequestCompiler, HttpFileFormatter, dothttp_model
from dothttp.__version__ import __version__
from dothttp.parse_models import ScriptType
Expand Down Expand Up @@ -108,9 +109,6 @@ def get_config(self, command):

def get_request_result(self, command, comp: RequestCompiler):
comp.load_def()
execution_cls = js3py.ScriptExecutionJs if comp.httpdef.test_script_lang == ScriptType.JAVA_SCRIPT else js3py.ScriptExecutionPython
script_execution = execution_cls(comp.httpdef, comp.property_util)
script_execution.pre_request_script()
resp = comp.get_response()
if output := comp.httpdef.output:
# body = f"Output stored in {output}"
Expand All @@ -119,7 +117,7 @@ def get_request_result(self, command, comp: RequestCompiler):
except Exception as e:
output = f"Not!. unhandled error happened : {e}"
logger.warning("unable to write because", exc_info=True)
script_result = script_execution.execute_test_script(resp).as_json()
script_result = self.script_execution.execute_test_script(resp).as_json()
body = resp.text
response_data = {
"response": {
Expand Down
1 change: 0 additions & 1 deletion dotextensions/server/handlers/http2postman.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from dotextensions.server.postman2_1 import FormParameterType, File, Mode, AuthType, Variable
from dothttp import json_or_array_to_json, UndefinedHttpToExtend, ParameterException, HttpDef, \
request_logger, Payload, APPLICATION_JSON, CONTENT_TYPE, AWS4Auth, dothttp_model
from dothttp.parse_models import NtlmAuthWrap
from dothttp.request_base import RequestCompiler
from dothttp.utils import json_to_urlencoded_array
from . import logger
Expand Down
Loading

0 comments on commit 13c0df6

Please sign in to comment.