mockstack 0.11.0__tar.gz → 0.11.2__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.
Files changed (94) hide show
  1. {mockstack-0.11.0 → mockstack-0.11.2}/PKG-INFO +1 -1
  2. {mockstack-0.11.0 → mockstack-0.11.2}/mkdocs.yml +1 -1
  3. {mockstack-0.11.0 → mockstack-0.11.2}/mockstack/rules.py +6 -1
  4. {mockstack-0.11.0 → mockstack-0.11.2}/mockstack/strategies/proxyrules.py +5 -2
  5. {mockstack-0.11.0 → mockstack-0.11.2}/mockstack/tests/strategies/test_proxyrules.py +13 -10
  6. {mockstack-0.11.0 → mockstack-0.11.2}/mockstack.egg-info/PKG-INFO +1 -1
  7. {mockstack-0.11.0 → mockstack-0.11.2}/mockstack.egg-info/SOURCES.txt +0 -1
  8. mockstack-0.11.0/.github/workflows/publish-to-dockerhub.yml +0 -58
  9. {mockstack-0.11.0 → mockstack-0.11.2}/.dockerignore +0 -0
  10. {mockstack-0.11.0 → mockstack-0.11.2}/.env.example +0 -0
  11. {mockstack-0.11.0 → mockstack-0.11.2}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
  12. {mockstack-0.11.0 → mockstack-0.11.2}/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
  13. {mockstack-0.11.0 → mockstack-0.11.2}/.github/workflows/ci.yml +0 -0
  14. {mockstack-0.11.0 → mockstack-0.11.2}/.github/workflows/publish-docs.yml +0 -0
  15. {mockstack-0.11.0 → mockstack-0.11.2}/.github/workflows/publish-to-pypi.yml +0 -0
  16. {mockstack-0.11.0 → mockstack-0.11.2}/.gitignore +0 -0
  17. {mockstack-0.11.0 → mockstack-0.11.2}/.pre-commit-config.yaml +0 -0
  18. {mockstack-0.11.0 → mockstack-0.11.2}/CODE_OF_CONDUCT.md +0 -0
  19. {mockstack-0.11.0 → mockstack-0.11.2}/CONTRIBUTING.md +0 -0
  20. {mockstack-0.11.0 → mockstack-0.11.2}/Dockerfile +0 -0
  21. {mockstack-0.11.0 → mockstack-0.11.2}/LICENSE +0 -0
  22. {mockstack-0.11.0 → mockstack-0.11.2}/README.md +0 -0
  23. {mockstack-0.11.0 → mockstack-0.11.2}/SECURITY.md +0 -0
  24. {mockstack-0.11.0 → mockstack-0.11.2}/docker-entrypoint.sh +0 -0
  25. {mockstack-0.11.0 → mockstack-0.11.2}/docs/assets/favicon.ico +0 -0
  26. {mockstack-0.11.0 → mockstack-0.11.2}/docs/assets/logo.png +0 -0
  27. {mockstack-0.11.0 → mockstack-0.11.2}/docs/assets/mockstack.png +0 -0
  28. {mockstack-0.11.0 → mockstack-0.11.2}/docs/configuration.md +0 -0
  29. {mockstack-0.11.0 → mockstack-0.11.2}/docs/ollama.md +0 -0
  30. {mockstack-0.11.0 → mockstack-0.11.2}/docs/strategies/base.md +0 -0
  31. {mockstack-0.11.0 → mockstack-0.11.2}/docs/strategies/filefixtures.md +0 -0
  32. {mockstack-0.11.0 → mockstack-0.11.2}/docs/strategies/proxyrules.md +0 -0
  33. {mockstack-0.11.0 → mockstack-0.11.2}/examples/filefixtures-with-templates/.env.example +0 -0
  34. {mockstack-0.11.0 → mockstack-0.11.2}/examples/filefixtures-with-templates/README.md +0 -0
  35. {mockstack-0.11.0 → mockstack-0.11.2}/examples/filefixtures-with-templates/templates/servicename-api-v1-items.j2 +0 -0
  36. {mockstack-0.11.0 → mockstack-0.11.2}/examples/filefixtures-with-templates/templates/servicename2-api-v2-user.533ec889-7c68-45c8-b21e-4a7e455d1234.j2 +0 -0
  37. {mockstack-0.11.0 → mockstack-0.11.2}/examples/llm/README.md +0 -0
  38. {mockstack-0.11.0 → mockstack-0.11.2}/examples/llm/mockstack-langchain-example.ipynb +0 -0
  39. {mockstack-0.11.0 → mockstack-0.11.2}/examples/llm/templates/ollama-openai-v1-chat-completions.j2 +0 -0
  40. {mockstack-0.11.0 → mockstack-0.11.2}/examples/llm/templates/openai-v1-chat-completions.j2 +0 -0
  41. {mockstack-0.11.0 → mockstack-0.11.2}/examples/llm/templates/openai-v1-deployments-gpt-4o-chat-completions.j2 +0 -0
  42. {mockstack-0.11.0 → mockstack-0.11.2}/examples/proxyrules-with-rules-file/.env.example +0 -0
  43. {mockstack-0.11.0 → mockstack-0.11.2}/examples/proxyrules-with-rules-file/README.md +0 -0
  44. {mockstack-0.11.0 → mockstack-0.11.2}/examples/proxyrules-with-rules-file/rules.yml +0 -0
  45. {mockstack-0.11.0 → mockstack-0.11.2}/mockstack/__init__.py +0 -0
  46. {mockstack-0.11.0 → mockstack-0.11.2}/mockstack/config.py +0 -0
  47. {mockstack-0.11.0 → mockstack-0.11.2}/mockstack/constants.py +0 -0
  48. {mockstack-0.11.0 → mockstack-0.11.2}/mockstack/display.py +0 -0
  49. {mockstack-0.11.0 → mockstack-0.11.2}/mockstack/exceptions.py +0 -0
  50. {mockstack-0.11.0 → mockstack-0.11.2}/mockstack/identifiers.py +0 -0
  51. {mockstack-0.11.0 → mockstack-0.11.2}/mockstack/intent.py +0 -0
  52. {mockstack-0.11.0 → mockstack-0.11.2}/mockstack/lifespan.py +0 -0
  53. {mockstack-0.11.0 → mockstack-0.11.2}/mockstack/llm/__init__.py +0 -0
  54. {mockstack-0.11.0 → mockstack-0.11.2}/mockstack/llm/ollama.py +0 -0
  55. {mockstack-0.11.0 → mockstack-0.11.2}/mockstack/main.py +0 -0
  56. {mockstack-0.11.0 → mockstack-0.11.2}/mockstack/middleware.py +0 -0
  57. {mockstack-0.11.0 → mockstack-0.11.2}/mockstack/routers/__init__.py +0 -0
  58. {mockstack-0.11.0 → mockstack-0.11.2}/mockstack/routers/catchall.py +0 -0
  59. {mockstack-0.11.0 → mockstack-0.11.2}/mockstack/routers/homepage.py +0 -0
  60. {mockstack-0.11.0 → mockstack-0.11.2}/mockstack/strategies/__init__.py +0 -0
  61. {mockstack-0.11.0 → mockstack-0.11.2}/mockstack/strategies/base.py +0 -0
  62. {mockstack-0.11.0 → mockstack-0.11.2}/mockstack/strategies/create_mixin.py +0 -0
  63. {mockstack-0.11.0 → mockstack-0.11.2}/mockstack/strategies/factory.py +0 -0
  64. {mockstack-0.11.0 → mockstack-0.11.2}/mockstack/strategies/filefixtures.py +0 -0
  65. {mockstack-0.11.0 → mockstack-0.11.2}/mockstack/telemetry.py +0 -0
  66. {mockstack-0.11.0 → mockstack-0.11.2}/mockstack/templating.py +0 -0
  67. {mockstack-0.11.0 → mockstack-0.11.2}/mockstack/tests/__init__.py +0 -0
  68. {mockstack-0.11.0 → mockstack-0.11.2}/mockstack/tests/conftest.py +0 -0
  69. {mockstack-0.11.0 → mockstack-0.11.2}/mockstack/tests/fixtures/__init__.py +0 -0
  70. {mockstack-0.11.0 → mockstack-0.11.2}/mockstack/tests/fixtures/proxyrules.yml +0 -0
  71. {mockstack-0.11.0 → mockstack-0.11.2}/mockstack/tests/fixtures/templates/__init__.py +0 -0
  72. {mockstack-0.11.0 → mockstack-0.11.2}/mockstack/tests/fixtures/templates/example-template.j2 +0 -0
  73. {mockstack-0.11.0 → mockstack-0.11.2}/mockstack/tests/llm/__init__.py +0 -0
  74. {mockstack-0.11.0 → mockstack-0.11.2}/mockstack/tests/llm/test_ollama.py +0 -0
  75. {mockstack-0.11.0 → mockstack-0.11.2}/mockstack/tests/routers/__init__.py +0 -0
  76. {mockstack-0.11.0 → mockstack-0.11.2}/mockstack/tests/routers/test_catchall.py +0 -0
  77. {mockstack-0.11.0 → mockstack-0.11.2}/mockstack/tests/routers/test_homepage.py +0 -0
  78. {mockstack-0.11.0 → mockstack-0.11.2}/mockstack/tests/strategies/__init__.py +0 -0
  79. {mockstack-0.11.0 → mockstack-0.11.2}/mockstack/tests/strategies/test_create_mixin.py +0 -0
  80. {mockstack-0.11.0 → mockstack-0.11.2}/mockstack/tests/strategies/test_filefixtures.py +0 -0
  81. {mockstack-0.11.0 → mockstack-0.11.2}/mockstack/tests/test_display.py +0 -0
  82. {mockstack-0.11.0 → mockstack-0.11.2}/mockstack/tests/test_identifiers.py +0 -0
  83. {mockstack-0.11.0 → mockstack-0.11.2}/mockstack/tests/test_intent.py +0 -0
  84. {mockstack-0.11.0 → mockstack-0.11.2}/mockstack/tests/test_middleware.py +0 -0
  85. {mockstack-0.11.0 → mockstack-0.11.2}/mockstack/tests/test_rules.py +0 -0
  86. {mockstack-0.11.0 → mockstack-0.11.2}/mockstack/tests/test_telemetry.py +0 -0
  87. {mockstack-0.11.0 → mockstack-0.11.2}/mockstack/tests/test_templating.py +0 -0
  88. {mockstack-0.11.0 → mockstack-0.11.2}/mockstack.egg-info/dependency_links.txt +0 -0
  89. {mockstack-0.11.0 → mockstack-0.11.2}/mockstack.egg-info/entry_points.txt +0 -0
  90. {mockstack-0.11.0 → mockstack-0.11.2}/mockstack.egg-info/requires.txt +0 -0
  91. {mockstack-0.11.0 → mockstack-0.11.2}/mockstack.egg-info/top_level.txt +0 -0
  92. {mockstack-0.11.0 → mockstack-0.11.2}/pyproject.toml +0 -0
  93. {mockstack-0.11.0 → mockstack-0.11.2}/setup.cfg +0 -0
  94. {mockstack-0.11.0 → mockstack-0.11.2}/uv.lock +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mockstack
3
- Version: 0.11.0
3
+ Version: 0.11.2
4
4
  Summary: An API mocking workhorse
5
5
  Author-email: Adam Ever-Hadani <mockstack.contact@gmail.com>
6
6
  License-Expression: MIT
@@ -64,4 +64,4 @@ extra:
64
64
  - icon: simple/github
65
65
  link: https://github.com/promptromp/mockstack
66
66
 
67
- copyright: Copyright &copy; 2025 Adam Ever-Hadani
67
+ copyright: Copyright &copy; 2025 PromptRomp
@@ -4,6 +4,7 @@ import re
4
4
  from abc import ABC, abstractmethod
5
5
  from dataclasses import dataclass
6
6
  from typing import Self
7
+ from urllib.parse import quote
7
8
 
8
9
  from fastapi import Request
9
10
 
@@ -75,7 +76,11 @@ class Rule:
75
76
 
76
77
  def apply(self, request: Request) -> RuleResult:
77
78
  """Apply the rule to the request."""
78
- path = request.url.path
79
+ path = f"{request.url.path}"
80
+ if request.url.fragment:
81
+ # If a URL fragment component is present, we URL encode it and include it in the path to proxy.
82
+ path += quote("#") + request.url.fragment
83
+
79
84
  result = self._url_for(path)
80
85
 
81
86
  # Check if the replacement is a file template
@@ -25,7 +25,7 @@ from mockstack.templating import templates_env_provider
25
25
  def maybe_update_response_headers(
26
26
  response_headers: ResponseHeaders,
27
27
  *,
28
- request_headers: Headers,
28
+ content_length: int,
29
29
  ) -> ResponseHeaders:
30
30
  """Update the response headers if needed, e.g. to adjust for compression etc."""
31
31
  _headers = response_headers.copy()
@@ -34,6 +34,8 @@ def maybe_update_response_headers(
34
34
  # If the response is compressed, we need to remove the content-encoding header
35
35
  # since httpx will automatically decompress the response while proxying.
36
36
  _headers["content-encoding"] = "identity"
37
+ # content length needs to be adjusted as well for uncompressed content.
38
+ _headers["content-length"] = str(content_length)
37
39
 
38
40
  return _headers
39
41
 
@@ -209,9 +211,10 @@ class ProxyRulesStrategy(BaseStrategy, CreateMixin):
209
211
 
210
212
  resp = await client.send(req, stream=False)
211
213
  content = resp.read()
214
+
212
215
  response_headers = maybe_update_response_headers(
213
216
  resp.headers,
214
- request_headers=request.headers,
217
+ content_length=len(content),
215
218
  )
216
219
 
217
220
  return Response(
@@ -359,15 +359,18 @@ async def test_proxy_rules_strategy_reverse_proxy(settings_reverse_proxy, span):
359
359
 
360
360
  mock_client.send.assert_called_once()
361
361
 
362
- def test_maybe_update_response_headers_updates_content_encoding():
363
- """Test maybe_update_response_headers updates content-encoding."""
364
- headers = Headers(
365
- {"content-encoding": "gzip", "content-type": "application/json"}
366
- )
367
- request_headers = Headers({"accept-encoding": "gzip"})
368
362
 
369
- updated_headers = maybe_update_response_headers(headers, request_headers)
363
+ def test_maybe_update_response_headers_updates_content_encoding():
364
+ """Test maybe_update_response_headers updates content-encoding."""
365
+ response_headers = httpx.Headers(
366
+ {"content-encoding": "gzip", "content-type": "application/json"}
367
+ )
368
+
369
+ updated_headers = maybe_update_response_headers(
370
+ response_headers=response_headers,
371
+ content_length=100,
372
+ )
370
373
 
371
- assert updated_headers["content-encoding"] == "identity"
372
- assert updated_headers["content-type"] == "application/json"
373
- assert updated_headers["accept-encoding"] == "gzip"
374
+ assert updated_headers["content-encoding"] == "identity"
375
+ assert updated_headers["content-type"] == "application/json"
376
+ assert updated_headers["content-length"] == "100"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mockstack
3
- Version: 0.11.0
3
+ Version: 0.11.2
4
4
  Summary: An API mocking workhorse
5
5
  Author-email: Adam Ever-Hadani <mockstack.contact@gmail.com>
6
6
  License-Expression: MIT
@@ -16,7 +16,6 @@ uv.lock
16
16
  .github/ISSUE_TEMPLATE/feature_request.md
17
17
  .github/workflows/ci.yml
18
18
  .github/workflows/publish-docs.yml
19
- .github/workflows/publish-to-dockerhub.yml
20
19
  .github/workflows/publish-to-pypi.yml
21
20
  docs/configuration.md
22
21
  docs/ollama.md
@@ -1,58 +0,0 @@
1
- name: Publish Docker image to DockerHub
2
-
3
- permissions:
4
- contents: read
5
- pull-requests: write
6
-
7
- on:
8
- push:
9
- branches:
10
- - "**"
11
- tags:
12
- - "*.*.*"
13
- release:
14
- types: [published]
15
- pull_request:
16
-
17
- jobs:
18
- docker:
19
- runs-on: ubuntu-latest
20
- steps:
21
- - name: Docker meta
22
- id: meta
23
- uses: docker/metadata-action@v5
24
- with:
25
- # list of Docker images to use as base name for tags
26
- images: |
27
- mockstack/mockstack
28
- # generate Docker tags based on the following events/attributes
29
- tags: |
30
- type=ref,event=branch
31
- type=ref,event=pr
32
- type=semver,pattern={{version}}
33
- type=semver,pattern={{major}}.{{minor}}
34
- type=semver,pattern={{major}}
35
- type=sha
36
-
37
- - name: Login to Docker Hub
38
- if: github.event_name != 'pull_request'
39
- uses: docker/login-action@v3
40
- with:
41
- username: ${{ secrets.DOCKERHUB_USERNAME }}
42
- password: ${{ secrets.DOCKERHUB_TOKEN }}
43
-
44
- - name: Set up QEMU
45
- uses: docker/setup-qemu-action@v3
46
-
47
- - name: Set up Docker Buildx
48
- uses: docker/setup-buildx-action@v3
49
-
50
- - name: Build and push
51
- uses: docker/build-push-action@v6
52
- with:
53
- build-args: |
54
- MOCKSTACK_VERSION=${{ github.event_name == 'release' && github.ref_name || format('0.0.0+dev.{0}', github.sha) }}
55
- platforms: linux/amd64,linux/arm64
56
- push: ${{ github.event_name == 'release' }}
57
- tags: ${{ steps.meta.outputs.tags }}
58
- labels: ${{ steps.meta.outputs.labels }}
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