File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -278,7 +278,7 @@ def test_template():
278278 User-Agent: OWASP CRS
279279 method: {{ method }}
280280 port: 80
281- uri: "{{ uri }}
281+ uri: "{{ uri }}"
282282 output:
283283 log_contains: id "{{ id }}"
284284"""
Original file line number Diff line number Diff line change @@ -1105,17 +1105,17 @@ def test_action_ctl_force_request_body_variable() -> None:
11051105def test_multiple_actions_combined () -> None :
11061106 """Test rule with multiple different actions"""
11071107 rule_text = """
1108- SecRule ARGS "@rx attack" \
1109- "id:999001,\
1110- phase:2,\
1111- deny,\
1112- status:403,\
1113- log,\
1114- msg:'SQL Injection Attempt',\
1115- severity:CRITICAL,\
1116- tag:'attack-sqli',\
1117- setvar:'tx.anomaly_score=+5',\
1118- t:lowercase,\
1108+ SecRule ARGS "@rx attack" \\
1109+ "id:999001,\\
1110+ phase:2,\\
1111+ deny,\\
1112+ status:403,\\
1113+ log,\\
1114+ msg:'SQL Injection Attempt',\\
1115+ severity:CRITICAL,\\
1116+ tag:'attack-sqli',\\
1117+ setvar:'tx.anomaly_score=+5',\\
1118+ t:lowercase,\\
11191119 t:urlDecode"
11201120 """
11211121 parsed_rule = parser .process_from_str (rule_text )
Original file line number Diff line number Diff line change 55These examples show how the shared fixtures and helper functions from conftest.py
66can simplify test code and reduce duplication.
77
8- Note: The helper functions from conftest.py are automatically available in the test
9- namespace when using pytest. You can also import them explicitly using:
8+ Note: Fixtures defined in conftest.py are automatically available in the test
9+ namespace when using pytest. Plain helper functions must be imported explicitly,
10+ for example:
1011 from tests.conftest import parse_rule, assert_parse_success, etc.
1112"""
1213import pytest
1314
1415# Import helper functions from conftest.py
15- # These are automatically available via pytest's conftest mechanism
16- import sys
17- import os
18- sys .path .insert (0 , os .path .dirname (__file__ ))
19- from conftest import (
16+ # Fixtures are auto-discovered by pytest; helper functions are imported explicitly
17+ from tests .conftest import (
2018 parse_rule ,
2119 assert_parse_success ,
2220 get_rules_by_type ,
Original file line number Diff line number Diff line change @@ -83,7 +83,7 @@ def test_operator_contains_word() -> None:
8383 for rule in parsed_rule .rules :
8484 assert rule .__class__ .__name__ == "SecRule"
8585 # containsWord is parsed but STRING may be empty - just verify it exists
86- if hasattr (rule .operator , ' containsWord' ) :
86+ if getattr (rule .operator , " containsWord" , None ) is not None :
8787 matches += 1
8888 assert matches == 1
8989
You can’t perform that action at this time.
0 commit comments