dothttp-req 0.0.44a40__tar.gz → 0.0.44a42__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.
Files changed (53) hide show
  1. {dothttp_req-0.0.44a40 → dothttp_req-0.0.44a42}/PKG-INFO +1 -1
  2. {dothttp_req-0.0.44a40 → dothttp_req-0.0.44a42}/dotextensions/server/handlers/basic_handlers.py +19 -43
  3. {dothttp_req-0.0.44a40 → dothttp_req-0.0.44a42}/dothttp/script/js3py.py +51 -0
  4. {dothttp_req-0.0.44a40 → dothttp_req-0.0.44a42}/pyproject.toml +1 -1
  5. {dothttp_req-0.0.44a40 → dothttp_req-0.0.44a42}/LICENSE.txt +0 -0
  6. {dothttp_req-0.0.44a40 → dothttp_req-0.0.44a42}/README.md +0 -0
  7. {dothttp_req-0.0.44a40 → dothttp_req-0.0.44a42}/dotextensions/__init__.py +0 -0
  8. {dothttp_req-0.0.44a40 → dothttp_req-0.0.44a42}/dotextensions/server/__init__.py +0 -0
  9. {dothttp_req-0.0.44a40 → dothttp_req-0.0.44a42}/dotextensions/server/__main__.py +0 -0
  10. {dothttp_req-0.0.44a40 → dothttp_req-0.0.44a42}/dotextensions/server/agent.py +0 -0
  11. {dothttp_req-0.0.44a40 → dothttp_req-0.0.44a42}/dotextensions/server/handlers/__init__.py +0 -0
  12. {dothttp_req-0.0.44a40 → dothttp_req-0.0.44a42}/dotextensions/server/handlers/fs_handlers.py +0 -0
  13. {dothttp_req-0.0.44a40 → dothttp_req-0.0.44a42}/dotextensions/server/handlers/gohandler.py +0 -0
  14. {dothttp_req-0.0.44a40 → dothttp_req-0.0.44a42}/dotextensions/server/handlers/har2httphandler.py +0 -0
  15. {dothttp_req-0.0.44a40 → dothttp_req-0.0.44a42}/dotextensions/server/handlers/http2har.py +0 -0
  16. {dothttp_req-0.0.44a40 → dothttp_req-0.0.44a42}/dotextensions/server/handlers/http2postman.py +0 -0
  17. {dothttp_req-0.0.44a40 → dothttp_req-0.0.44a42}/dotextensions/server/handlers/postman2http.py +0 -0
  18. {dothttp_req-0.0.44a40 → dothttp_req-0.0.44a42}/dotextensions/server/models/__init__.py +0 -0
  19. {dothttp_req-0.0.44a40 → dothttp_req-0.0.44a42}/dotextensions/server/models/har.py +0 -0
  20. {dothttp_req-0.0.44a40 → dothttp_req-0.0.44a42}/dotextensions/server/postman/__init__.py +0 -0
  21. {dothttp_req-0.0.44a40 → dothttp_req-0.0.44a42}/dotextensions/server/postman2_1/__init__.py +0 -0
  22. {dothttp_req-0.0.44a40 → dothttp_req-0.0.44a42}/dotextensions/server/server.py +0 -0
  23. {dothttp_req-0.0.44a40 → dothttp_req-0.0.44a42}/dotextensions/server/utils.py +0 -0
  24. {dothttp_req-0.0.44a40 → dothttp_req-0.0.44a42}/dotextensions/version/__init__.py +0 -0
  25. {dothttp_req-0.0.44a40 → dothttp_req-0.0.44a42}/dotextensions/version/__main__.py +0 -0
  26. {dothttp_req-0.0.44a40 → dothttp_req-0.0.44a42}/dothttp/__init__.py +0 -0
  27. {dothttp_req-0.0.44a40 → dothttp_req-0.0.44a42}/dothttp/__main__.py +0 -0
  28. {dothttp_req-0.0.44a40 → dothttp_req-0.0.44a42}/dothttp/__version__.py +0 -0
  29. {dothttp_req-0.0.44a40 → dothttp_req-0.0.44a42}/dothttp/auth/__init__.py +0 -0
  30. {dothttp_req-0.0.44a40 → dothttp_req-0.0.44a42}/dothttp/auth/azure_auth.py +0 -0
  31. {dothttp_req-0.0.44a40 → dothttp_req-0.0.44a42}/dothttp/exceptions.py +0 -0
  32. {dothttp_req-0.0.44a40 → dothttp_req-0.0.44a42}/dothttp/http.tx +0 -0
  33. {dothttp_req-0.0.44a40 → dothttp_req-0.0.44a42}/dothttp/models/__init__.py +0 -0
  34. {dothttp_req-0.0.44a40 → dothttp_req-0.0.44a42}/dothttp/models/computed.py +0 -0
  35. {dothttp_req-0.0.44a40 → dothttp_req-0.0.44a42}/dothttp/models/parse_models.py +0 -0
  36. {dothttp_req-0.0.44a40 → dothttp_req-0.0.44a42}/dothttp/parse/__init__.py +0 -0
  37. {dothttp_req-0.0.44a40 → dothttp_req-0.0.44a42}/dothttp/parse/dsl_jsonparser.py +0 -0
  38. {dothttp_req-0.0.44a40 → dothttp_req-0.0.44a42}/dothttp/parse/expression.py +0 -0
  39. {dothttp_req-0.0.44a40 → dothttp_req-0.0.44a42}/dothttp/parse/request_base.py +0 -0
  40. {dothttp_req-0.0.44a40 → dothttp_req-0.0.44a42}/dothttp/postScript.js +0 -0
  41. {dothttp_req-0.0.44a40 → dothttp_req-0.0.44a42}/dothttp/property_schema.py +0 -0
  42. {dothttp_req-0.0.44a40 → dothttp_req-0.0.44a42}/dothttp/script/__init__.py +0 -0
  43. {dothttp_req-0.0.44a40 → dothttp_req-0.0.44a42}/dothttp/utils/__init__.py +0 -0
  44. {dothttp_req-0.0.44a40 → dothttp_req-0.0.44a42}/dothttp/utils/common.py +0 -0
  45. {dothttp_req-0.0.44a40 → dothttp_req-0.0.44a42}/dothttp/utils/constants.py +0 -0
  46. {dothttp_req-0.0.44a40 → dothttp_req-0.0.44a42}/dothttp/utils/curl_utils.py +0 -0
  47. {dothttp_req-0.0.44a40 → dothttp_req-0.0.44a42}/dothttp/utils/json_utils.py +0 -0
  48. {dothttp_req-0.0.44a40 → dothttp_req-0.0.44a42}/dothttp/utils/log_utils.py +0 -0
  49. {dothttp_req-0.0.44a40 → dothttp_req-0.0.44a42}/dothttp/utils/property_util.py +0 -0
  50. {dothttp_req-0.0.44a40 → dothttp_req-0.0.44a42}/dothttp_test/__init__.py +0 -0
  51. {dothttp_req-0.0.44a40 → dothttp_req-0.0.44a42}/dothttp_test/__main__.py +0 -0
  52. {dothttp_req-0.0.44a40 → dothttp_req-0.0.44a42}/dothttp_test/conftest.py +0 -0
  53. {dothttp_req-0.0.44a40 → dothttp_req-0.0.44a42}/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.44a40
3
+ Version: 0.0.44a42
4
4
  Summary: Dothttp is Simple http client for testing and development
5
5
  License: MIT
6
6
  License-File: LICENSE.txt
@@ -1,4 +1,5 @@
1
1
  import mimetypes
2
+ import platform
2
3
  from typing import List
3
4
 
4
5
  from urllib.parse import urlencode
@@ -38,7 +39,18 @@ class VersionHandler(BaseHandler):
38
39
  return VersionHandler.name
39
40
 
40
41
  def run(self, command: Command) -> Result:
41
- return Result(id=command.id, result={"version": __version__})
42
+ os_name = platform.system().lower()
43
+ if os_name not in {"darwin", "linux", "windows"}:
44
+ os_name = "unknown"
45
+ arch = platform.machine() or platform.processor() or "unknown"
46
+ return Result(
47
+ id=command.id,
48
+ result={
49
+ "version": __version__,
50
+ "os": os_name,
51
+ "arch": arch,
52
+ },
53
+ )
42
54
 
43
55
 
44
56
  class RunHttpFileHandler(BaseHandler):
@@ -157,7 +169,6 @@ class RunHttpFileHandler(BaseHandler):
157
169
  )
158
170
  resp = comp.get_response()
159
171
  if output := comp.httpdef.output:
160
- # body = f"Output stored in {output}"
161
172
  try:
162
173
  comp.write_to_output(resp)
163
174
  except Exception as e:
@@ -167,7 +178,7 @@ class RunHttpFileHandler(BaseHandler):
167
178
  body = resp.text
168
179
  response_data = {
169
180
  "response": {
170
- "body": body, # for binary out, it will fail, check for alternatives
181
+ "body": body,
171
182
  "output_file": output or "",
172
183
  **self._get_resp_data(resp),
173
184
  },
@@ -178,13 +189,11 @@ class RunHttpFileHandler(BaseHandler):
178
189
  response_data["history"] = [
179
190
  self._get_resp_data(hist_item) for hist_item in resp.history
180
191
  ]
181
- # will be used for response
182
192
  data = {}
183
- data.update(response_data["response"]) # deprecated
193
+ data.update(response_data["response"])
184
194
  data.update(response_data)
185
195
  data["request_headers"] = dict(resp.request.headers)
186
196
  if not comp.args.no_cookie and "cookie" in resp.request.headers:
187
- # redirects can add cookies
188
197
  comp.httpdef.headers["cookie"] = resp.request.headers["cookie"]
189
198
  try:
190
199
  data.update(
@@ -204,8 +213,6 @@ class RunHttpFileHandler(BaseHandler):
204
213
  "status": resp.status_code,
205
214
  "method": resp.request.method,
206
215
  "url": resp.url,
207
- # capture the request too so the response round-trips for a
208
- # tests-only replay (redirect hops keep their own request)
209
216
  "request": {
210
217
  "method": resp.request.method,
211
218
  "url": resp.request.url,
@@ -233,24 +240,16 @@ class ContentBase(BaseModelProcessor):
233
240
  self.args = config
234
241
 
235
242
  def load_content(self):
236
- # joining contexts to content is not correct approach
237
- # as any error in one of context could bring down main usecase
238
243
  self.original_content = self.content = self.args.content
239
244
 
240
245
  def load_model(self):
241
- # reqcomp will try to resolve properties right after model is generated
242
246
  super(ContentBase, self).load_model()
243
- ##
244
- # context has varibles defined
245
- # for resolving purpose, including them into content
246
247
  self.content = self.content + CONTEXT_SEP + CONTEXT_SEP.join(self.args.contexts)
247
248
 
248
249
  def select_target(self):
249
250
  for context in self.args.contexts:
250
251
  try:
251
- # if model is generated, try to figure out target
252
252
  model: MultidefHttp = dothttp_model.model_from_str(context)
253
- # by including targets in to model
254
253
  self.load_properties_from_var(model, self.property_util, can_override=False)
255
254
  self.model.allhttps = self.model.allhttps + model.allhttps
256
255
  if model.import_list and model.import_list.filename:
@@ -261,10 +260,7 @@ class ContentBase(BaseModelProcessor):
261
260
  self.load_imports()
262
261
  self.content += context + "\n\n" + context
263
262
 
264
- except Exception as e:
265
- # contexts, can not always be correct syntax
266
- # in such scenarios, don't complain, try to resolve with
267
- # next contexts
263
+ except Exception:
268
264
  logger.info("ignoring exception, context is not looking good")
269
265
  return super(ContentBase, self).select_target()
270
266
 
@@ -282,7 +278,6 @@ class ContentExecuteHandler(RunHttpFileHandler):
282
278
 
283
279
  def get_config(self, command):
284
280
  config = super().get_config(command)
285
- # config.file = command.params.get('content')
286
281
  return config
287
282
 
288
283
  def get_method(self):
@@ -295,10 +290,6 @@ class ContentExecuteHandler(RunHttpFileHandler):
295
290
  return ContentCurlCompiler(config)
296
291
 
297
292
  def run(self, command: Command) -> Result:
298
- """
299
- When handling content, if an exception is raised, the response is not in the usual format.
300
- Instead, it returns an error message. It is better to respond with a structured response.
301
- """
302
293
  try:
303
294
  return self.execute(command)
304
295
  except DotHttpException as exc:
@@ -315,9 +306,7 @@ class ContentExecuteHandler(RunHttpFileHandler):
315
306
  "status": 0,
316
307
  "method": "REQUEST_EXECUTION_ERROR",
317
308
  "url": "REQUEST_EXECUTION_ERROR",
318
- "headers": {
319
- "Content-Type": "text/plain",
320
- },
309
+ "headers": {"Content-Type": "text/plain"},
321
310
  "output_file": "",
322
311
  "error": True,
323
312
  "error_message": error_result,
@@ -337,16 +326,9 @@ class RunTestBase:
337
326
  """
338
327
  Runs only the test script of a dothttp definition against a
339
328
  previously-captured response, without re-issuing the HTTP request.
340
-
341
- The captured response is passed in ``command.params["response"]`` using
342
- the same serialized shape that the execute handlers emit
343
- (``{body, output_file, headers, status, method, url}``) and is adapted
344
- into a ``requests.Response``-like object via ``DothttpResponse``.
345
329
  """
346
330
 
347
331
  def get_test_result(self, command, comp: RequestCompiler) -> Result:
348
- # parse + resolve + compile the test script (and pre/init scripts);
349
- # crucially this does NOT call comp.get_response(), so no request goes out
350
332
  comp.load_def()
351
333
  if comp.property_util.errors:
352
334
  return Result(
@@ -446,15 +428,12 @@ class ResolveBase:
446
428
  resolved = comp.httpdef.url
447
429
  elif type_type == DothttpTypes.NAME.value:
448
430
  resolved = comp.httpdef.name
449
- # header
450
- # query is pending
451
431
  elif type_type == DothttpTypes.VARIABLE.value:
452
432
  variable_name = type_dict["name"]
453
433
  resolved = comp.property_util.resolve_property_string(variable_name)
454
434
  elif type_type == DothttpTypes.HEADER.value:
455
- resolved = dict(comp.httpdef.headers)
435
+ resolved = dict(comp.httpdef.headers)
456
436
  elif type_type == DothttpTypes.URL_PARAMS.value:
457
- # generate url params
458
437
  resolved = urlencode(comp.httpdef.query, doseq=True)
459
438
  elif type_type == DothttpTypes.PAYLOAD_DATA.value:
460
439
  resolved = comp.httpdef.payload.data
@@ -472,9 +451,6 @@ class ResolveBase:
472
451
  return Result(id=command.id, result=type_dict)
473
452
 
474
453
 
475
- # return resolved string instead of model object
476
-
477
-
478
454
  class GetHoveredResolvedParamFileHandler(RunHttpFileHandler, ResolveBase):
479
455
  method = "/file/resolve"
480
456
 
@@ -592,7 +568,7 @@ class ContentNameReferencesHandler(GetNameReferencesHandler):
592
568
  ) = self.parse_n_get(context_context, filename)
593
569
  imported_names += _all_names + _imported_names
594
570
  imported_urls += _all_urls + _imported_urls
595
- except:
571
+ except Exception:
596
572
  pass
597
573
  result = Result(
598
574
  id=command.id,
@@ -19,6 +19,9 @@ import xmltodict
19
19
  import jsonschema
20
20
  import requests
21
21
  import yaml
22
+ import collections
23
+ import itertools
24
+ import re
22
25
  from cryptography import *
23
26
  from faker import Faker
24
27
  from requests import Response
@@ -67,10 +70,58 @@ allowed_global = {
67
70
  "open": open,
68
71
  "json": json,
69
72
  "yaml": yaml,
73
+ "dict": dict,
74
+ "next": next,
75
+ "list": list,
76
+ "tuple": tuple,
77
+ "set": set,
78
+ "str": str,
79
+ "int": int,
80
+ "float": float,
81
+ "bool": bool,
82
+ "bytes": bytes,
83
+ "bytearray": bytearray,
84
+ "frozenset": frozenset,
85
+ "enumerate": enumerate,
86
+ "zip": zip,
87
+ "range": range,
88
+ "reversed": reversed,
89
+ "sorted": sorted,
90
+ "filter": filter,
91
+ "map": map,
92
+ "slice": slice,
93
+ "len": len,
94
+ "max": max,
95
+ "min": min,
96
+ "sum": sum,
97
+ "abs": abs,
98
+ "round": round,
99
+ "pow": pow,
100
+ "divmod": divmod,
101
+ "any": any,
102
+ "all": all,
103
+ "collections": collections,
104
+ "defaultdict": collections.defaultdict,
105
+ "Counter": collections.Counter,
106
+ "OrderedDict": collections.OrderedDict,
107
+ "deque": collections.deque,
108
+ "namedtuple": collections.namedtuple,
109
+ "itertools": itertools,
110
+ "re": re,
111
+ "isinstance": isinstance,
112
+ "issubclass": issubclass,
70
113
  "cryptography": cryptography,
71
114
  "jsonschema": jsonschema,
72
115
  "requests": requests,
73
116
  "xmltodict": xmltodict,
117
+ "Exception": Exception,
118
+ "ValueError": ValueError,
119
+ "KeyError": KeyError,
120
+ "IndexError": IndexError,
121
+ "TypeError": TypeError,
122
+ "AttributeError": AttributeError,
123
+ "AssertionError": AssertionError,
124
+ "ZeroDivisionError": ZeroDivisionError,
74
125
  }
75
126
  allowed_global.update(safe_globals)
76
127
 
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "dothttp-req"
3
- version = "0.0.44a40"
3
+ version = "0.0.44a42"
4
4
  description = "Dothttp is Simple http client for testing and development"
5
5
  authors = ["Prasanth <kesavarapu.siva@gmail.com>"]
6
6
  license = "MIT"