schemathesis 3.38.9__py3-none-any.whl → 3.38.10__py3-none-any.whl

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.
@@ -52,6 +52,7 @@ class CheckContext:
52
52
  auth: HTTPDigestAuth | RawAuth | None
53
53
  headers: CaseInsensitiveDict | None
54
54
  config: CheckConfig = field(default_factory=CheckConfig)
55
+ transport_kwargs: dict | None = None
55
56
 
56
57
 
57
58
  def wrap_check(check: Callable) -> CheckFunction:
schemathesis/models.py CHANGED
@@ -474,6 +474,7 @@ class Case:
474
474
  excluded_checks: tuple[CheckFunction, ...] = (),
475
475
  code_sample_style: str | None = None,
476
476
  headers: dict[str, Any] | None = None,
477
+ transport_kwargs: dict[str, Any] | None = None,
477
478
  ) -> None:
478
479
  """Validate application response.
479
480
 
@@ -507,7 +508,10 @@ class Case:
507
508
  additional_checks = tuple(check for check in _additional_checks if check not in excluded_checks)
508
509
  failed_checks = []
509
510
  ctx = CheckContext(
510
- override=self._override, auth=None, headers=CaseInsensitiveDict(headers) if headers else None
511
+ override=self._override,
512
+ auth=None,
513
+ headers=CaseInsensitiveDict(headers) if headers else None,
514
+ transport_kwargs=transport_kwargs,
511
515
  )
512
516
  for check in chain(checks, additional_checks):
513
517
  copied_case = self.partial_deepcopy()
@@ -591,6 +595,7 @@ class Case:
591
595
  headers=headers,
592
596
  additional_checks=additional_checks,
593
597
  excluded_checks=excluded_checks,
598
+ transport_kwargs=kwargs,
594
599
  )
595
600
  return response
596
601
 
@@ -994,18 +994,18 @@ def _network_test(
994
994
  max_response_time: int | None,
995
995
  ) -> requests.Response:
996
996
  check_results: list[Check] = []
997
+ hook_context = HookContext(operation=case.operation)
998
+ kwargs: dict[str, Any] = {
999
+ "session": session,
1000
+ "headers": headers,
1001
+ "timeout": request_config.prepared_timeout,
1002
+ "verify": request_config.tls_verify,
1003
+ "cert": request_config.cert,
1004
+ }
1005
+ if request_config.proxy is not None:
1006
+ kwargs["proxies"] = {"all": request_config.proxy}
1007
+ hooks.dispatch("process_call_kwargs", hook_context, case, kwargs)
997
1008
  try:
998
- hook_context = HookContext(operation=case.operation)
999
- kwargs: dict[str, Any] = {
1000
- "session": session,
1001
- "headers": headers,
1002
- "timeout": request_config.prepared_timeout,
1003
- "verify": request_config.tls_verify,
1004
- "cert": request_config.cert,
1005
- }
1006
- if request_config.proxy is not None:
1007
- kwargs["proxies"] = {"all": request_config.proxy}
1008
- hooks.dispatch("process_call_kwargs", hook_context, case, kwargs)
1009
1009
  response = case.call(**kwargs)
1010
1010
  except CheckFailed as exc:
1011
1011
  check_name = "request_timeout"
@@ -1030,6 +1030,7 @@ def _network_test(
1030
1030
  auth=ctx.auth,
1031
1031
  headers=CaseInsensitiveDict(headers) if headers else None,
1032
1032
  config=ctx.checks_config,
1033
+ transport_kwargs=kwargs,
1033
1034
  )
1034
1035
  try:
1035
1036
  run_checks(
@@ -1127,6 +1128,7 @@ def _wsgi_test(
1127
1128
  auth=ctx.auth,
1128
1129
  headers=CaseInsensitiveDict(headers) if headers else None,
1129
1130
  config=ctx.checks_config,
1131
+ transport_kwargs=kwargs,
1130
1132
  )
1131
1133
  try:
1132
1134
  run_checks(
@@ -1212,6 +1214,7 @@ def _asgi_test(
1212
1214
  auth=ctx.auth,
1213
1215
  headers=CaseInsensitiveDict(headers) if headers else None,
1214
1216
  config=ctx.checks_config,
1217
+ transport_kwargs=kwargs,
1215
1218
  )
1216
1219
  try:
1217
1220
  run_checks(
@@ -83,11 +83,14 @@ class GraphQLCase(Case):
83
83
  excluded_checks: tuple[CheckFunction, ...] = (),
84
84
  code_sample_style: str | None = None,
85
85
  headers: dict[str, Any] | None = None,
86
+ transport_kwargs: dict[str, Any] | None = None,
86
87
  ) -> None:
87
88
  checks = checks or (not_a_server_error,)
88
89
  checks += additional_checks
89
90
  checks = tuple(check for check in checks if check not in excluded_checks)
90
- return super().validate_response(response, checks, code_sample_style=code_sample_style, headers=headers)
91
+ return super().validate_response(
92
+ response, checks, code_sample_style=code_sample_style, headers=headers, transport_kwargs=transport_kwargs
93
+ )
91
94
 
92
95
 
93
96
  C = TypeVar("C", bound=Case)
@@ -404,14 +404,21 @@ def ignored_auth(ctx: CheckContext, response: GenericResponse, case: Case) -> bo
404
404
  # Auth is explicitly set, it is expected to be valid
405
405
  # Check if invalid auth will give an error
406
406
  _remove_auth_from_case(case, security_parameters)
407
- new_response = case.operation.schema.transport.send(case)
407
+ kwargs = ctx.transport_kwargs or {}
408
+ kwargs.copy()
409
+ if "headers" in kwargs:
410
+ headers = kwargs["headers"].copy()
411
+ _remove_auth_from_explicit_headers(headers, security_parameters)
412
+ kwargs["headers"] = headers
413
+ kwargs.pop("session", None)
414
+ new_response = case.operation.schema.transport.send(case, **kwargs)
408
415
  if new_response.status_code != 401:
409
416
  _update_response(response, new_response)
410
417
  _raise_no_auth_error(new_response, case.operation.verbose_name, "that requires authentication")
411
418
  # Try to set invalid auth and check if it succeeds
412
419
  for parameter in security_parameters:
413
420
  _set_auth_for_case(case, parameter)
414
- new_response = case.operation.schema.transport.send(case)
421
+ new_response = case.operation.schema.transport.send(case, **kwargs)
415
422
  if new_response.status_code != 401:
416
423
  _update_response(response, new_response)
417
424
  _raise_no_auth_error(new_response, case.operation.verbose_name, "with any auth")
@@ -526,6 +533,13 @@ def _remove_auth_from_case(case: Case, security_parameters: list[SecurityParamet
526
533
  case.cookies.pop(name, None)
527
534
 
528
535
 
536
+ def _remove_auth_from_explicit_headers(headers: dict, security_parameters: list[SecurityParameter]) -> None:
537
+ for parameter in security_parameters:
538
+ name = parameter["name"]
539
+ if parameter["in"] == "header":
540
+ headers.pop(name, None)
541
+
542
+
529
543
  def _set_auth_for_case(case: Case, parameter: SecurityParameter) -> None:
530
544
  name = parameter["name"]
531
545
  for location, attr_name in (
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: schemathesis
3
- Version: 3.38.9
3
+ Version: 3.38.10
4
4
  Summary: Property-based testing framework for Open API and GraphQL based apps
5
5
  Project-URL: Documentation, https://schemathesis.readthedocs.io/en/stable/
6
6
  Project-URL: Changelog, https://schemathesis.readthedocs.io/en/stable/changelog.html
@@ -18,7 +18,7 @@ schemathesis/graphql.py,sha256=XiuKcfoOB92iLFC8zpz2msLkM0_V0TLdxPNBqrrGZ8w,216
18
18
  schemathesis/hooks.py,sha256=p5AXgjVGtka0jn9MOeyBaRUtNbqZTs4iaJqytYTacHc,14856
19
19
  schemathesis/lazy.py,sha256=Ddhkk7Tpc_VcRGYkCtKDmP2gpjxVmEZ3b01ZTNjbm8I,19004
20
20
  schemathesis/loaders.py,sha256=MoEhcdOEBJxNRn5X-ZNhWB9jZDHQQNpkNfEdQjf_NDw,4590
21
- schemathesis/models.py,sha256=zE-j-5uyQdIxnWx-rqJyXCbyrWZlrTyiTml109yZeN4,49797
21
+ schemathesis/models.py,sha256=QNeK1sGcNAhrJ452YZoLZIRsOHS6cOt1AYFLJhBPcJs,49962
22
22
  schemathesis/parameters.py,sha256=izlu4MFYT1RWrC4RBxrV6weeCal-ODbdLQLMb0PYCZY,2327
23
23
  schemathesis/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
24
24
  schemathesis/sanitization.py,sha256=Lycn1VVfula9B6XpzkxTHja7CZ7RHqbUh9kBic0Yi4M,9056
@@ -63,7 +63,7 @@ schemathesis/generation/_hypothesis.py,sha256=74fzLPHugZgMQXerWYFAMqCAjtAXz5E4ge
63
63
  schemathesis/generation/_methods.py,sha256=r8oVlJ71_gXcnEhU-byw2E0R2RswQQFm8U7yGErSqbw,1204
64
64
  schemathesis/generation/coverage.py,sha256=XgT1yX6iy__qEXN3lFs0PYZkFwXFHAgJf7ow3nmjcDc,39243
65
65
  schemathesis/internal/__init__.py,sha256=93HcdG3LF0BbQKbCteOsFMa1w6nXl8yTmx87QLNJOik,161
66
- schemathesis/internal/checks.py,sha256=EI5EjN_PI9QWNwJlsnUKjC6B1r0arRdpqniVZT-N0mE,2672
66
+ schemathesis/internal/checks.py,sha256=_9fDm9w7rKzdztXYH7FsLwW2DVn3L1gzsPhJJ9o2qQQ,2713
67
67
  schemathesis/internal/copy.py,sha256=DcL56z-d69kKR_5u8mlHvjSL1UTyUKNMAwexrwHFY1s,1031
68
68
  schemathesis/internal/datetime.py,sha256=zPLBL0XXLNfP-KYel3H2m8pnsxjsA_4d-zTOhJg2EPQ,136
69
69
  schemathesis/internal/deprecation.py,sha256=Ty5VBFBlufkITpP0WWTPIPbnB7biDi0kQgXVYWZp820,1273
@@ -80,7 +80,7 @@ schemathesis/runner/probes.py,sha256=no5AfO3kse25qvHevjeUfB0Q3C860V2AYzschUW3QMQ
80
80
  schemathesis/runner/serialization.py,sha256=vZi1wd9HX9Swp9VJ_hZFeDgy3Y726URpHra-TbPvQhk,20762
81
81
  schemathesis/runner/impl/__init__.py,sha256=1E2iME8uthYPBh9MjwVBCTFV-P3fi7AdphCCoBBspjs,199
82
82
  schemathesis/runner/impl/context.py,sha256=8pedlvOnh7pjvEMveaSWCUiG4s12ST4EZCJqcWLu5Bg,2950
83
- schemathesis/runner/impl/core.py,sha256=3bCwPcZB1br-clz3oQz8KV9yF9hZK7t3F29ZEq2ErBQ,47642
83
+ schemathesis/runner/impl/core.py,sha256=GfE_5_Ye9OwuayXIPu5kziTt90N6Zhvkus-pSl1mV9o,47697
84
84
  schemathesis/runner/impl/solo.py,sha256=y5QSxgK8nBCEjZVD5BpFvYUXmB6tEjk6TwxAo__NejA,2911
85
85
  schemathesis/runner/impl/threadpool.py,sha256=yNR5LYE8f3N_4t42OwSgy0_qdGgBPM7d11F9c9oEAAs,15075
86
86
  schemathesis/service/__init__.py,sha256=cDVTCFD1G-vvhxZkJUwiToTAEQ-0ByIoqwXvJBCf_V8,472
@@ -102,12 +102,12 @@ schemathesis/specs/graphql/_cache.py,sha256=7ras3q_InDJBPykgHroerl9f2jFamC8xJD35
102
102
  schemathesis/specs/graphql/loaders.py,sha256=-PUdzGiGo1BZWe9slaUmqeamMqCM6daq2lSrFblomCc,12339
103
103
  schemathesis/specs/graphql/nodes.py,sha256=bE3G1kNmqJ8OV4igBvIK-UORrkQA6Nofduf87O3TD9I,541
104
104
  schemathesis/specs/graphql/scalars.py,sha256=9tvLTiYVe8A_E8ASA0czz3Z0Mp9lyak7R4wHpAE_jKo,1805
105
- schemathesis/specs/graphql/schemas.py,sha256=b7QwglKbcYQCMjuYmqDsVoFu2o4xaA_kduUzEXJnvow,14332
105
+ schemathesis/specs/graphql/schemas.py,sha256=6oTsg730KBswaeZK9EttVCxxk8FWV1JHjyiVzU6qXlQ,14445
106
106
  schemathesis/specs/graphql/validation.py,sha256=uINIOt-2E7ZuQV2CxKzwez-7L9tDtqzMSpnVoRWvxy0,1635
107
107
  schemathesis/specs/openapi/__init__.py,sha256=HDcx3bqpa6qWPpyMrxAbM3uTo0Lqpg-BUNZhDJSJKnw,279
108
108
  schemathesis/specs/openapi/_cache.py,sha256=PAiAu4X_a2PQgD2lG5H3iisXdyg4SaHpU46bRZvfNkM,4320
109
109
  schemathesis/specs/openapi/_hypothesis.py,sha256=nU8UDn1PzGCre4IVmwIuO9-CZv1KJe1fYY0d2BojhSo,22981
110
- schemathesis/specs/openapi/checks.py,sha256=MbFRk78U1m5iVGVOJNKifM2KgaGHQaT1DOF6HdR1UZQ,24496
110
+ schemathesis/specs/openapi/checks.py,sha256=VqrgvUbD8dUULxozjcuHZqP6sLrhEeP47Rz2EAQz84Q,25104
111
111
  schemathesis/specs/openapi/constants.py,sha256=JqM_FHOenqS_MuUE9sxVQ8Hnw0DNM8cnKDwCwPLhID4,783
112
112
  schemathesis/specs/openapi/converter.py,sha256=Yxw9lS_JKEyi-oJuACT07fm04bqQDlAu-iHwzkeDvE4,3546
113
113
  schemathesis/specs/openapi/definitions.py,sha256=WTkWwCgTc3OMxfKsqh6YDoGfZMTThSYrHGp8h0vLAK0,93935
@@ -153,8 +153,8 @@ schemathesis/transports/auth.py,sha256=urSTO9zgFO1qU69xvnKHPFQV0SlJL3d7_Ojl0tLnZ
153
153
  schemathesis/transports/content_types.py,sha256=MiKOm-Hy5i75hrROPdpiBZPOTDzOwlCdnthJD12AJzI,2187
154
154
  schemathesis/transports/headers.py,sha256=hr_AIDOfUxsJxpHfemIZ_uNG3_vzS_ZeMEKmZjbYiBE,990
155
155
  schemathesis/transports/responses.py,sha256=OFD4ZLqwEFpo7F9vaP_SVgjhxAqatxIj38FS4XVq8Qs,1680
156
- schemathesis-3.38.9.dist-info/METADATA,sha256=c8_79jrn5P4jA6wzGq1UDK-LdZ74GyVDXzFajk4U6rc,12923
157
- schemathesis-3.38.9.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
158
- schemathesis-3.38.9.dist-info/entry_points.txt,sha256=VHyLcOG7co0nOeuk8WjgpRETk5P1E2iCLrn26Zkn5uk,158
159
- schemathesis-3.38.9.dist-info/licenses/LICENSE,sha256=PsPYgrDhZ7g9uwihJXNG-XVb55wj2uYhkl2DD8oAzY0,1103
160
- schemathesis-3.38.9.dist-info/RECORD,,
156
+ schemathesis-3.38.10.dist-info/METADATA,sha256=_4IfLofMFUrs7rZwAEyZzOdjcafLgb4OiivgOJzIzko,12924
157
+ schemathesis-3.38.10.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
158
+ schemathesis-3.38.10.dist-info/entry_points.txt,sha256=VHyLcOG7co0nOeuk8WjgpRETk5P1E2iCLrn26Zkn5uk,158
159
+ schemathesis-3.38.10.dist-info/licenses/LICENSE,sha256=PsPYgrDhZ7g9uwihJXNG-XVb55wj2uYhkl2DD8oAzY0,1103
160
+ schemathesis-3.38.10.dist-info/RECORD,,