fix(tests): resolve AmbiguousStep collisions in pyyaml_security tests
Three step patterns in pyyaml_security_steps.py clashed with existing step files, causing all Behave features to error at load time: - "I call load_yaml_text with YAML text" clashed with actor_config_coverage_boost_steps.py:103 - "the load_yaml_text result should have key" clashed with actor_config_coverage_boost_steps.py:90 - "a ValueError should be raised" clashed with lsp_registry_steps.py:475 Rename all three to unique patterns and update pyyaml_security.feature to match. Also fix typings/behave/runner.pyi ruff format (.pyi convention: single blank line before class, no blank lines between stub methods) and add missing fastapi>=0.100.0 to pyproject.toml (asgi_app.py imports fastapi but it was absent from declared dependencies, causing typecheck and integration test failures). Refs: #9055
This commit is contained in:
@@ -9,10 +9,10 @@ Feature: PyYAML security constraint
|
|||||||
Then the version should be at least 6.0.3
|
Then the version should be at least 6.0.3
|
||||||
|
|
||||||
Scenario: yaml_loader uses safe_load for plain YAML input
|
Scenario: yaml_loader uses safe_load for plain YAML input
|
||||||
When I call load_yaml_text with YAML text "provider: anthropic\nmodel: claude-3-5-sonnet\n"
|
When I load the YAML text "provider: anthropic\nmodel: claude-3-5-sonnet\n" using the secure yaml_loader
|
||||||
Then the load_yaml_text result should have key "provider" equal to "anthropic"
|
Then the secure yaml_loader result for key "provider" should be "anthropic"
|
||||||
And the load_yaml_text result should have key "model" equal to "claude-3-5-sonnet"
|
And the secure yaml_loader result for key "model" should be "claude-3-5-sonnet"
|
||||||
|
|
||||||
Scenario: yaml_loader rejects YAML with Python object tags
|
Scenario: yaml_loader rejects YAML with Python object tags
|
||||||
When I call load_yaml_text with unsafe YAML containing a Python object tag
|
When I call load_yaml_text with unsafe YAML containing a Python object tag
|
||||||
Then a ValueError should be raised
|
Then a pyyaml security ValueError should be raised
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ def step_assert_pyyaml_version(context: Context) -> None:
|
|||||||
# ── yaml_loader safe_load enforcement ───────────────────────────────
|
# ── yaml_loader safe_load enforcement ───────────────────────────────
|
||||||
|
|
||||||
|
|
||||||
@when('I call load_yaml_text with YAML text "{yaml_text}"')
|
@when('I load the YAML text "{yaml_text}" using the secure yaml_loader')
|
||||||
def step_load_yaml_text(context: Context, yaml_text: str) -> None:
|
def step_load_yaml_text(context: Context, yaml_text: str) -> None:
|
||||||
"""Call load_yaml_text with the given YAML text and store the result.
|
"""Call load_yaml_text with the given YAML text and store the result.
|
||||||
|
|
||||||
@@ -62,7 +62,7 @@ def step_load_yaml_text(context: Context, yaml_text: str) -> None:
|
|||||||
context.load_yaml_result: dict[str, Any] = load_yaml_text(normalised)
|
context.load_yaml_result: dict[str, Any] = load_yaml_text(normalised)
|
||||||
|
|
||||||
|
|
||||||
@then('the load_yaml_text result should have key "{key}" equal to "{value}"')
|
@then('the secure yaml_loader result for key "{key}" should be "{value}"')
|
||||||
def step_assert_yaml_result_key(context: Context, key: str, value: str) -> None:
|
def step_assert_yaml_result_key(context: Context, key: str, value: str) -> None:
|
||||||
"""Assert that the parsed YAML result contains the expected key/value pair."""
|
"""Assert that the parsed YAML result contains the expected key/value pair."""
|
||||||
result: dict[str, Any] = context.load_yaml_result
|
result: dict[str, Any] = context.load_yaml_result
|
||||||
@@ -91,7 +91,7 @@ def step_load_unsafe_yaml(context: Context) -> None:
|
|||||||
context.caught_error = exc
|
context.caught_error = exc
|
||||||
|
|
||||||
|
|
||||||
@then("a ValueError should be raised")
|
@then("a pyyaml security ValueError should be raised")
|
||||||
def step_assert_value_error_raised(context: Context) -> None:
|
def step_assert_value_error_raised(context: Context) -> None:
|
||||||
"""Assert that an error was raised when loading unsafe YAML."""
|
"""Assert that an error was raised when loading unsafe YAML."""
|
||||||
assert context.caught_error is not None, (
|
assert context.caught_error is not None, (
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ dependencies = [
|
|||||||
# CLI Framework (ADR-009)
|
# CLI Framework (ADR-009)
|
||||||
"typer>=0.9.0",
|
"typer>=0.9.0",
|
||||||
"uvicorn>=0.30.1",
|
"uvicorn>=0.30.1",
|
||||||
|
"fastapi>=0.100.0",
|
||||||
"watchdog>=4.0.0",
|
"watchdog>=4.0.0",
|
||||||
"faiss-cpu>=1.7.4", # Vector store backend
|
"faiss-cpu>=1.7.4", # Vector store backend
|
||||||
"rx>=3.2.0", # Reactive streams for routing
|
"rx>=3.2.0", # Reactive streams for routing
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
|
|
||||||
class Context:
|
class Context:
|
||||||
"""Behave scenario context object."""
|
"""Behave scenario context object."""
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user