schemathesis 4.1.1__py3-none-any.whl → 4.1.3__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.
- schemathesis/core/curl.py +5 -1
- schemathesis/specs/openapi/checks.py +12 -1
- schemathesis/specs/openapi/security.py +14 -6
- {schemathesis-4.1.1.dist-info → schemathesis-4.1.3.dist-info}/METADATA +1 -1
- {schemathesis-4.1.1.dist-info → schemathesis-4.1.3.dist-info}/RECORD +8 -8
- {schemathesis-4.1.1.dist-info → schemathesis-4.1.3.dist-info}/WHEEL +0 -0
- {schemathesis-4.1.1.dist-info → schemathesis-4.1.3.dist-info}/entry_points.txt +0 -0
- {schemathesis-4.1.1.dist-info → schemathesis-4.1.3.dist-info}/licenses/LICENSE +0 -0
schemathesis/core/curl.py
CHANGED
@@ -23,7 +23,11 @@ def generate(
|
|
23
23
|
_filter_headers(headers, known_generated_headers or {})
|
24
24
|
command = f"curl -X {method}"
|
25
25
|
for key, value in headers.items():
|
26
|
-
header
|
26
|
+
# To send an empty header with cURL we need to use `;`, otherwise empty header is ignored
|
27
|
+
if not value:
|
28
|
+
header = f"{key};"
|
29
|
+
else:
|
30
|
+
header = f"{key}: {value}"
|
27
31
|
command += f" -H {quote(header)}"
|
28
32
|
if body:
|
29
33
|
if isinstance(body, bytes):
|
@@ -497,7 +497,11 @@ def ignored_auth(ctx: CheckContext, response: Response, case: Case) -> bool | No
|
|
497
497
|
"""Check if an operation declares authentication as a requirement but does not actually enforce it."""
|
498
498
|
from .schemas import BaseOpenAPISchema
|
499
499
|
|
500
|
-
if
|
500
|
+
if (
|
501
|
+
not isinstance(case.operation.schema, BaseOpenAPISchema)
|
502
|
+
or is_unexpected_http_status_case(case)
|
503
|
+
or _has_optional_auth(case.operation)
|
504
|
+
):
|
501
505
|
return True
|
502
506
|
security_parameters = _get_security_parameters(case.operation)
|
503
507
|
# Authentication is required for this API operation and response is successful
|
@@ -585,6 +589,13 @@ def _get_security_parameters(operation: APIOperation) -> list[SecurityParameter]
|
|
585
589
|
]
|
586
590
|
|
587
591
|
|
592
|
+
def _has_optional_auth(operation: APIOperation) -> bool:
|
593
|
+
from .schemas import BaseOpenAPISchema
|
594
|
+
|
595
|
+
schema = cast(BaseOpenAPISchema, operation.schema)
|
596
|
+
return schema.security.has_optional_auth(schema.raw_schema, operation)
|
597
|
+
|
598
|
+
|
588
599
|
def _contains_auth(
|
589
600
|
ctx: CheckContext, case: Case, response: Response, security_parameters: list[SecurityParameter]
|
590
601
|
) -> AuthKind | None:
|
@@ -32,20 +32,28 @@ class BaseSecurityProcessor:
|
|
32
32
|
self.process_api_key_security_definition(definition, operation)
|
33
33
|
self.process_http_security_definition(definition, operation)
|
34
34
|
|
35
|
+
@staticmethod
|
36
|
+
def _get_security_requirements(schema: dict[str, Any], operation: APIOperation) -> list[dict]:
|
37
|
+
global_requirements = schema.get("security", [])
|
38
|
+
local_requirements = operation.definition.raw.get("security", None)
|
39
|
+
if local_requirements is not None:
|
40
|
+
return local_requirements
|
41
|
+
return global_requirements
|
42
|
+
|
35
43
|
@staticmethod
|
36
44
|
def get_security_requirements(schema: dict[str, Any], operation: APIOperation) -> list[str]:
|
37
45
|
"""Get applied security requirements for the given API operation."""
|
38
46
|
# https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#operation-object
|
39
47
|
# > This definition overrides any declared top-level security.
|
40
48
|
# > To remove a top-level security declaration, an empty array can be used.
|
41
|
-
|
42
|
-
local_requirements = operation.definition.raw.get("security", None)
|
43
|
-
if local_requirements is not None:
|
44
|
-
requirements = local_requirements
|
45
|
-
else:
|
46
|
-
requirements = global_requirements
|
49
|
+
requirements = BaseSecurityProcessor._get_security_requirements(schema, operation)
|
47
50
|
return [key for requirement in requirements for key in requirement]
|
48
51
|
|
52
|
+
@staticmethod
|
53
|
+
def has_optional_auth(schema: dict[str, Any], operation: APIOperation) -> bool:
|
54
|
+
requirements = BaseSecurityProcessor._get_security_requirements(schema, operation)
|
55
|
+
return {} in requirements
|
56
|
+
|
49
57
|
def _get_active_definitions(
|
50
58
|
self, schema: dict[str, Any], operation: APIOperation, resolver: RefResolver
|
51
59
|
) -> Generator[dict[str, Any], None, None]:
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: schemathesis
|
3
|
-
Version: 4.1.
|
3
|
+
Version: 4.1.3
|
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://github.com/schemathesis/schemathesis/blob/master/CHANGELOG.md
|
@@ -49,7 +49,7 @@ schemathesis/config/schema.json,sha256=3CRSBfUK2vLVl1h5PfeK_YDdEoBZSojYl8Q1kT-IT
|
|
49
49
|
schemathesis/core/__init__.py,sha256=h4gmDePIPvPiVuYxnjrpPKytSZPi6fZeVdTG6c822E4,1973
|
50
50
|
schemathesis/core/compat.py,sha256=9BWCrFoqN2sJIaiht_anxe8kLjYMR7t0iiOkXqLRUZ8,1058
|
51
51
|
schemathesis/core/control.py,sha256=IzwIc8HIAEMtZWW0Q0iXI7T1niBpjvcLlbuwOSmy5O8,130
|
52
|
-
schemathesis/core/curl.py,sha256=
|
52
|
+
schemathesis/core/curl.py,sha256=jrPL9KpNHteyJ6A1oxJRSkL5bfuBeuPs3xh9Z_ml2cE,1892
|
53
53
|
schemathesis/core/deserialization.py,sha256=qjXUPaz_mc1OSgXzTUSkC8tuVR8wgVQtb9g3CcAF6D0,2951
|
54
54
|
schemathesis/core/errors.py,sha256=pwiyGhX7tId88Toe2H4ZYsCDc_OvUJtW8Wv-xDv2UD4,16361
|
55
55
|
schemathesis/core/failures.py,sha256=yFpAxWdEnm0Ri8z8RqRI9H7vcLH5ztOeSIi4m4SGx5g,8996
|
@@ -123,7 +123,7 @@ schemathesis/specs/graphql/schemas.py,sha256=B6FULWIIWoN_gx9OeQOd-6qWsz9yVg5h1Xl
|
|
123
123
|
schemathesis/specs/graphql/validation.py,sha256=-W1Noc1MQmTb4RX-gNXMeU2qkgso4mzVfHxtdLkCPKM,1422
|
124
124
|
schemathesis/specs/openapi/__init__.py,sha256=C5HOsfuDJGq_3mv8CRBvRvb0Diy1p0BFdqyEXMS-loE,238
|
125
125
|
schemathesis/specs/openapi/_hypothesis.py,sha256=XK-g2284wCsqOuPhubpE-PQ5_YotUwNodAnjeHs_-R0,21712
|
126
|
-
schemathesis/specs/openapi/checks.py,sha256=
|
126
|
+
schemathesis/specs/openapi/checks.py,sha256=CVUBhJgdVZZdgCIydsO0OYf3K4gGgnYw6XDSJo3q6OU,30623
|
127
127
|
schemathesis/specs/openapi/constants.py,sha256=JqM_FHOenqS_MuUE9sxVQ8Hnw0DNM8cnKDwCwPLhID4,783
|
128
128
|
schemathesis/specs/openapi/converter.py,sha256=LkpCCAxZzET4Qa_3YStSNuhGlsm5G6TVwpxYu6lPO4g,4169
|
129
129
|
schemathesis/specs/openapi/definitions.py,sha256=8htclglV3fW6JPBqs59lgM4LnA25Mm9IptXBPb_qUT0,93949
|
@@ -134,7 +134,7 @@ schemathesis/specs/openapi/parameters.py,sha256=XpuZ2sex2aYUzKDK17GXVNWFBmvamuyV
|
|
134
134
|
schemathesis/specs/openapi/patterns.py,sha256=GqPZEXMRdWENQxanWjBOalIZ2MQUjuxk21kmdiI703E,18027
|
135
135
|
schemathesis/specs/openapi/references.py,sha256=40YcDExPLR2B8EOwt-Csw-5MYFi2xj_DXf91J0Pc9d4,8855
|
136
136
|
schemathesis/specs/openapi/schemas.py,sha256=qJ0ChkZuXQafQ-nPwMzckSk3iC32H2O5W9Cbd7DN_2I,51379
|
137
|
-
schemathesis/specs/openapi/security.py,sha256=
|
137
|
+
schemathesis/specs/openapi/security.py,sha256=Vv5Y76hM49ZqLlivViSURKQlxDd1F_FQRj5gEUfyBU0,7552
|
138
138
|
schemathesis/specs/openapi/serialization.py,sha256=VdDLmeHqxlWM4cxQQcCkvrU6XurivolwEEaT13ohelA,11972
|
139
139
|
schemathesis/specs/openapi/utils.py,sha256=ER4vJkdFVDIE7aKyxyYatuuHVRNutytezgE52pqZNE8,900
|
140
140
|
schemathesis/specs/openapi/expressions/__init__.py,sha256=hfuRtXD75tQFhzSo6QgDZ3zByyWeZRKevB8edszAVj4,2272
|
@@ -157,8 +157,8 @@ schemathesis/transport/prepare.py,sha256=erYXRaxpQokIDzaIuvt_csHcw72iHfCyNq8VNEz
|
|
157
157
|
schemathesis/transport/requests.py,sha256=XWiQVG4rGnFX0rOhOZAKVIPbrlknLuS7pHYwUcOiEGs,10942
|
158
158
|
schemathesis/transport/serialization.py,sha256=igUXKZ_VJ9gV7P0TUc5PDQBJXl_s0kK9T3ljGWWvo6E,10339
|
159
159
|
schemathesis/transport/wsgi.py,sha256=KoAfvu6RJtzyj24VGB8e-Iaa9smpgXJ3VsM8EgAz2tc,6152
|
160
|
-
schemathesis-4.1.
|
161
|
-
schemathesis-4.1.
|
162
|
-
schemathesis-4.1.
|
163
|
-
schemathesis-4.1.
|
164
|
-
schemathesis-4.1.
|
160
|
+
schemathesis-4.1.3.dist-info/METADATA,sha256=cl5HHC8Riq884RzJBvb-RN7TrUilt5T3x41W7X93G0M,8540
|
161
|
+
schemathesis-4.1.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
162
|
+
schemathesis-4.1.3.dist-info/entry_points.txt,sha256=hiK3un-xfgPdwj9uj16YVDtTNpO128bmk0U82SMv8ZQ,152
|
163
|
+
schemathesis-4.1.3.dist-info/licenses/LICENSE,sha256=2Ve4J8v5jMQAWrT7r1nf3bI8Vflk3rZVQefiF2zpxwg,1121
|
164
|
+
schemathesis-4.1.3.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|