mockstack 0.11.2__tar.gz → 0.12.0__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.
- {mockstack-0.11.2 → mockstack-0.12.0}/PKG-INFO +1 -1
- {mockstack-0.11.2 → mockstack-0.12.0}/mockstack/routers/catchall.py +3 -1
- {mockstack-0.11.2 → mockstack-0.12.0}/mockstack/tests/strategies/test_proxyrules.py +22 -1
- {mockstack-0.11.2 → mockstack-0.12.0}/mockstack/tests/test_rules.py +41 -11
- {mockstack-0.11.2 → mockstack-0.12.0}/mockstack.egg-info/PKG-INFO +1 -1
- {mockstack-0.11.2 → mockstack-0.12.0}/.dockerignore +0 -0
- {mockstack-0.11.2 → mockstack-0.12.0}/.env.example +0 -0
- {mockstack-0.11.2 → mockstack-0.12.0}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
- {mockstack-0.11.2 → mockstack-0.12.0}/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
- {mockstack-0.11.2 → mockstack-0.12.0}/.github/workflows/ci.yml +0 -0
- {mockstack-0.11.2 → mockstack-0.12.0}/.github/workflows/publish-docs.yml +0 -0
- {mockstack-0.11.2 → mockstack-0.12.0}/.github/workflows/publish-to-pypi.yml +0 -0
- {mockstack-0.11.2 → mockstack-0.12.0}/.gitignore +0 -0
- {mockstack-0.11.2 → mockstack-0.12.0}/.pre-commit-config.yaml +0 -0
- {mockstack-0.11.2 → mockstack-0.12.0}/CODE_OF_CONDUCT.md +0 -0
- {mockstack-0.11.2 → mockstack-0.12.0}/CONTRIBUTING.md +0 -0
- {mockstack-0.11.2 → mockstack-0.12.0}/Dockerfile +0 -0
- {mockstack-0.11.2 → mockstack-0.12.0}/LICENSE +0 -0
- {mockstack-0.11.2 → mockstack-0.12.0}/README.md +0 -0
- {mockstack-0.11.2 → mockstack-0.12.0}/SECURITY.md +0 -0
- {mockstack-0.11.2 → mockstack-0.12.0}/docker-entrypoint.sh +0 -0
- {mockstack-0.11.2 → mockstack-0.12.0}/docs/assets/favicon.ico +0 -0
- {mockstack-0.11.2 → mockstack-0.12.0}/docs/assets/logo.png +0 -0
- {mockstack-0.11.2 → mockstack-0.12.0}/docs/assets/mockstack.png +0 -0
- {mockstack-0.11.2 → mockstack-0.12.0}/docs/configuration.md +0 -0
- {mockstack-0.11.2 → mockstack-0.12.0}/docs/ollama.md +0 -0
- {mockstack-0.11.2 → mockstack-0.12.0}/docs/strategies/base.md +0 -0
- {mockstack-0.11.2 → mockstack-0.12.0}/docs/strategies/filefixtures.md +0 -0
- {mockstack-0.11.2 → mockstack-0.12.0}/docs/strategies/proxyrules.md +0 -0
- {mockstack-0.11.2 → mockstack-0.12.0}/examples/filefixtures-with-templates/.env.example +0 -0
- {mockstack-0.11.2 → mockstack-0.12.0}/examples/filefixtures-with-templates/README.md +0 -0
- {mockstack-0.11.2 → mockstack-0.12.0}/examples/filefixtures-with-templates/templates/servicename-api-v1-items.j2 +0 -0
- {mockstack-0.11.2 → mockstack-0.12.0}/examples/filefixtures-with-templates/templates/servicename2-api-v2-user.533ec889-7c68-45c8-b21e-4a7e455d1234.j2 +0 -0
- {mockstack-0.11.2 → mockstack-0.12.0}/examples/llm/README.md +0 -0
- {mockstack-0.11.2 → mockstack-0.12.0}/examples/llm/mockstack-langchain-example.ipynb +0 -0
- {mockstack-0.11.2 → mockstack-0.12.0}/examples/llm/templates/ollama-openai-v1-chat-completions.j2 +0 -0
- {mockstack-0.11.2 → mockstack-0.12.0}/examples/llm/templates/openai-v1-chat-completions.j2 +0 -0
- {mockstack-0.11.2 → mockstack-0.12.0}/examples/llm/templates/openai-v1-deployments-gpt-4o-chat-completions.j2 +0 -0
- {mockstack-0.11.2 → mockstack-0.12.0}/examples/proxyrules-with-rules-file/.env.example +0 -0
- {mockstack-0.11.2 → mockstack-0.12.0}/examples/proxyrules-with-rules-file/README.md +0 -0
- {mockstack-0.11.2 → mockstack-0.12.0}/examples/proxyrules-with-rules-file/rules.yml +0 -0
- {mockstack-0.11.2 → mockstack-0.12.0}/mkdocs.yml +0 -0
- {mockstack-0.11.2 → mockstack-0.12.0}/mockstack/__init__.py +0 -0
- {mockstack-0.11.2 → mockstack-0.12.0}/mockstack/config.py +0 -0
- {mockstack-0.11.2 → mockstack-0.12.0}/mockstack/constants.py +0 -0
- {mockstack-0.11.2 → mockstack-0.12.0}/mockstack/display.py +0 -0
- {mockstack-0.11.2 → mockstack-0.12.0}/mockstack/exceptions.py +0 -0
- {mockstack-0.11.2 → mockstack-0.12.0}/mockstack/identifiers.py +0 -0
- {mockstack-0.11.2 → mockstack-0.12.0}/mockstack/intent.py +0 -0
- {mockstack-0.11.2 → mockstack-0.12.0}/mockstack/lifespan.py +0 -0
- {mockstack-0.11.2 → mockstack-0.12.0}/mockstack/llm/__init__.py +0 -0
- {mockstack-0.11.2 → mockstack-0.12.0}/mockstack/llm/ollama.py +0 -0
- {mockstack-0.11.2 → mockstack-0.12.0}/mockstack/main.py +0 -0
- {mockstack-0.11.2 → mockstack-0.12.0}/mockstack/middleware.py +0 -0
- {mockstack-0.11.2 → mockstack-0.12.0}/mockstack/routers/__init__.py +0 -0
- {mockstack-0.11.2 → mockstack-0.12.0}/mockstack/routers/homepage.py +0 -0
- {mockstack-0.11.2 → mockstack-0.12.0}/mockstack/rules.py +0 -0
- {mockstack-0.11.2 → mockstack-0.12.0}/mockstack/strategies/__init__.py +0 -0
- {mockstack-0.11.2 → mockstack-0.12.0}/mockstack/strategies/base.py +0 -0
- {mockstack-0.11.2 → mockstack-0.12.0}/mockstack/strategies/create_mixin.py +0 -0
- {mockstack-0.11.2 → mockstack-0.12.0}/mockstack/strategies/factory.py +0 -0
- {mockstack-0.11.2 → mockstack-0.12.0}/mockstack/strategies/filefixtures.py +0 -0
- {mockstack-0.11.2 → mockstack-0.12.0}/mockstack/strategies/proxyrules.py +0 -0
- {mockstack-0.11.2 → mockstack-0.12.0}/mockstack/telemetry.py +0 -0
- {mockstack-0.11.2 → mockstack-0.12.0}/mockstack/templating.py +0 -0
- {mockstack-0.11.2 → mockstack-0.12.0}/mockstack/tests/__init__.py +0 -0
- {mockstack-0.11.2 → mockstack-0.12.0}/mockstack/tests/conftest.py +0 -0
- {mockstack-0.11.2 → mockstack-0.12.0}/mockstack/tests/fixtures/__init__.py +0 -0
- {mockstack-0.11.2 → mockstack-0.12.0}/mockstack/tests/fixtures/proxyrules.yml +0 -0
- {mockstack-0.11.2 → mockstack-0.12.0}/mockstack/tests/fixtures/templates/__init__.py +0 -0
- {mockstack-0.11.2 → mockstack-0.12.0}/mockstack/tests/fixtures/templates/example-template.j2 +0 -0
- {mockstack-0.11.2 → mockstack-0.12.0}/mockstack/tests/llm/__init__.py +0 -0
- {mockstack-0.11.2 → mockstack-0.12.0}/mockstack/tests/llm/test_ollama.py +0 -0
- {mockstack-0.11.2 → mockstack-0.12.0}/mockstack/tests/routers/__init__.py +0 -0
- {mockstack-0.11.2 → mockstack-0.12.0}/mockstack/tests/routers/test_catchall.py +0 -0
- {mockstack-0.11.2 → mockstack-0.12.0}/mockstack/tests/routers/test_homepage.py +0 -0
- {mockstack-0.11.2 → mockstack-0.12.0}/mockstack/tests/strategies/__init__.py +0 -0
- {mockstack-0.11.2 → mockstack-0.12.0}/mockstack/tests/strategies/test_create_mixin.py +0 -0
- {mockstack-0.11.2 → mockstack-0.12.0}/mockstack/tests/strategies/test_filefixtures.py +0 -0
- {mockstack-0.11.2 → mockstack-0.12.0}/mockstack/tests/test_display.py +0 -0
- {mockstack-0.11.2 → mockstack-0.12.0}/mockstack/tests/test_identifiers.py +0 -0
- {mockstack-0.11.2 → mockstack-0.12.0}/mockstack/tests/test_intent.py +0 -0
- {mockstack-0.11.2 → mockstack-0.12.0}/mockstack/tests/test_middleware.py +0 -0
- {mockstack-0.11.2 → mockstack-0.12.0}/mockstack/tests/test_telemetry.py +0 -0
- {mockstack-0.11.2 → mockstack-0.12.0}/mockstack/tests/test_templating.py +0 -0
- {mockstack-0.11.2 → mockstack-0.12.0}/mockstack.egg-info/SOURCES.txt +0 -0
- {mockstack-0.11.2 → mockstack-0.12.0}/mockstack.egg-info/dependency_links.txt +0 -0
- {mockstack-0.11.2 → mockstack-0.12.0}/mockstack.egg-info/entry_points.txt +0 -0
- {mockstack-0.11.2 → mockstack-0.12.0}/mockstack.egg-info/requires.txt +0 -0
- {mockstack-0.11.2 → mockstack-0.12.0}/mockstack.egg-info/top_level.txt +0 -0
- {mockstack-0.11.2 → mockstack-0.12.0}/pyproject.toml +0 -0
- {mockstack-0.11.2 → mockstack-0.12.0}/setup.cfg +0 -0
- {mockstack-0.11.2 → mockstack-0.12.0}/uv.lock +0 -0
|
@@ -8,7 +8,9 @@ from mockstack.config import Settings
|
|
|
8
8
|
def catchall_router_provider(app: FastAPI, settings: Settings) -> None:
|
|
9
9
|
"""Create the catch-all routes for the mockstack app."""
|
|
10
10
|
|
|
11
|
-
@app.
|
|
11
|
+
@app.api_route(
|
|
12
|
+
"/{full_path:path}", methods=["GET", "PATCH", "POST", "PUT", "DELETE"]
|
|
13
|
+
)
|
|
12
14
|
async def catch_all(request: Request):
|
|
13
15
|
"""Catch all requests and delegate to the strategy."""
|
|
14
16
|
return await app.state.strategy.apply(request)
|
|
@@ -7,7 +7,7 @@ import httpx
|
|
|
7
7
|
import pytest
|
|
8
8
|
from fastapi import Request, status
|
|
9
9
|
from fastapi.responses import RedirectResponse
|
|
10
|
-
from starlette.datastructures import Headers
|
|
10
|
+
from starlette.datastructures import Headers, URL
|
|
11
11
|
|
|
12
12
|
from mockstack.constants import ProxyRulesRedirectVia
|
|
13
13
|
from mockstack.strategies.proxyrules import (
|
|
@@ -79,6 +79,27 @@ async def test_proxy_rules_strategy_apply(settings, span):
|
|
|
79
79
|
assert response.headers["location"] == "/projects/123"
|
|
80
80
|
|
|
81
81
|
|
|
82
|
+
@pytest.mark.asyncio
|
|
83
|
+
async def test_proxy_rules_strategy_apply_with_fragment(settings, span):
|
|
84
|
+
"""Test applying a rule to a request with URL fragment."""
|
|
85
|
+
strategy = ProxyRulesStrategy(settings)
|
|
86
|
+
request = Request(
|
|
87
|
+
scope={
|
|
88
|
+
"type": "http",
|
|
89
|
+
"method": "GET",
|
|
90
|
+
"path": "/api/v1/projects/123",
|
|
91
|
+
"query_string": b"",
|
|
92
|
+
"headers": [],
|
|
93
|
+
}
|
|
94
|
+
)
|
|
95
|
+
# Set URL with fragment (fragments are client-side only in HTTP, but we test the logic)
|
|
96
|
+
request._url = URL("http://testserver/api/v1/projects/123#section")
|
|
97
|
+
request.state.span = span
|
|
98
|
+
response = await strategy.apply(request)
|
|
99
|
+
assert isinstance(response, RedirectResponse)
|
|
100
|
+
assert response.headers["location"] == "/projects/123%23section"
|
|
101
|
+
|
|
102
|
+
|
|
82
103
|
@pytest.mark.asyncio
|
|
83
104
|
async def test_proxy_rules_strategy_apply_no_match(settings, span):
|
|
84
105
|
"""Test applying strategy when no rule matches."""
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import pytest
|
|
4
4
|
from fastapi import Request
|
|
5
|
+
from starlette.datastructures import URL
|
|
5
6
|
|
|
6
7
|
from mockstack.rules import Rule, TemplateRuleResult, URLRuleResult
|
|
7
8
|
|
|
@@ -79,34 +80,63 @@ def test_rule_matches_with_method(pattern, path, method, expected):
|
|
|
79
80
|
|
|
80
81
|
|
|
81
82
|
@pytest.mark.parametrize(
|
|
82
|
-
"pattern,replacement,path,expected_url",
|
|
83
|
+
"pattern,replacement,path,fragment,expected_url",
|
|
83
84
|
[
|
|
84
85
|
(
|
|
85
86
|
r"/api/v1/projects/(\d+)",
|
|
86
87
|
r"/projects/\1",
|
|
87
88
|
"/api/v1/projects/123",
|
|
89
|
+
None,
|
|
88
90
|
"/projects/123",
|
|
89
91
|
),
|
|
90
92
|
(
|
|
91
93
|
r"/api/v1/users/([^/]+)",
|
|
92
94
|
r"/users/\1",
|
|
93
95
|
"/api/v1/users/john",
|
|
96
|
+
None,
|
|
94
97
|
"/users/john",
|
|
95
98
|
),
|
|
99
|
+
(
|
|
100
|
+
r"/api/v1/projects/(\d+)",
|
|
101
|
+
r"/projects/\1",
|
|
102
|
+
"/api/v1/projects/123",
|
|
103
|
+
"section",
|
|
104
|
+
"/projects/123%23section",
|
|
105
|
+
),
|
|
106
|
+
(
|
|
107
|
+
r"/api/v1/users/([^/]+)",
|
|
108
|
+
r"/users/\1",
|
|
109
|
+
"/api/v1/users/john",
|
|
110
|
+
"profile",
|
|
111
|
+
"/users/john%23profile",
|
|
112
|
+
),
|
|
113
|
+
(
|
|
114
|
+
r"/api/v1/projects/(\d+)",
|
|
115
|
+
r"/projects/\1",
|
|
116
|
+
"/api/v1/projects/456",
|
|
117
|
+
"top",
|
|
118
|
+
"/projects/456%23top",
|
|
119
|
+
),
|
|
96
120
|
],
|
|
97
121
|
)
|
|
98
|
-
def test_rule_apply(pattern, replacement, path, expected_url):
|
|
122
|
+
def test_rule_apply(pattern, replacement, path, fragment, expected_url):
|
|
99
123
|
"""Test the rule application logic."""
|
|
100
124
|
rule = Rule(pattern=pattern, replacement=replacement)
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
125
|
+
scope = {
|
|
126
|
+
"type": "http",
|
|
127
|
+
"method": "GET",
|
|
128
|
+
"path": path,
|
|
129
|
+
"query_string": b"",
|
|
130
|
+
"headers": [],
|
|
131
|
+
}
|
|
132
|
+
request = Request(scope=scope)
|
|
133
|
+
|
|
134
|
+
# If fragment is specified, we need to manually set the URL with the fragment
|
|
135
|
+
# since fragments are not part of standard HTTP requests (they're client-side)
|
|
136
|
+
if fragment:
|
|
137
|
+
url_with_fragment = f"http://testserver{path}#{fragment}"
|
|
138
|
+
request._url = URL(url_with_fragment)
|
|
139
|
+
|
|
110
140
|
result = rule.apply(request)
|
|
111
141
|
assert isinstance(result, URLRuleResult)
|
|
112
142
|
assert result.get_result_type() == "url"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{mockstack-0.11.2 → mockstack-0.12.0}/examples/llm/templates/ollama-openai-v1-chat-completions.j2
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{mockstack-0.11.2 → mockstack-0.12.0}/mockstack/tests/fixtures/templates/example-template.j2
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|