auth 3.5.0__tar.gz → 3.5.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 (100) hide show
  1. {auth-3.5.0 → auth-3.5.2}/PKG-INFO +7 -2
  2. {auth-3.5.0 → auth-3.5.2}/auth/__init__.py +23 -7
  3. auth-3.5.2/auth/core/__init__.py +18 -0
  4. {auth-3.5.0 → auth-3.5.2}/auth/schema_check.py +16 -2
  5. {auth-3.5.0 → auth-3.5.2}/auth.egg-info/PKG-INFO +7 -2
  6. {auth-3.5.0 → auth-3.5.2}/auth.egg-info/SOURCES.txt +2 -0
  7. {auth-3.5.0 → auth-3.5.2}/auth.egg-info/requires.txt +7 -1
  8. {auth-3.5.0 → auth-3.5.2}/pyproject.toml +16 -2
  9. auth-3.5.2/tests/test_deploy_lock.py +91 -0
  10. auth-3.5.2/tests/test_import_footprint.py +93 -0
  11. {auth-3.5.0 → auth-3.5.2}/tests/test_schema_check.py +14 -1
  12. auth-3.5.0/auth/core/__init__.py +0 -6
  13. {auth-3.5.0 → auth-3.5.2}/LICENSE +0 -0
  14. {auth-3.5.0 → auth-3.5.2}/README.md +0 -0
  15. {auth-3.5.0 → auth-3.5.2}/auth/api_keys.py +0 -0
  16. {auth-3.5.0 → auth-3.5.2}/auth/audit.py +0 -0
  17. {auth-3.5.0 → auth-3.5.2}/auth/circuit_breaker.py +0 -0
  18. {auth-3.5.0 → auth-3.5.2}/auth/client/__init__.py +0 -0
  19. {auth-3.5.0 → auth-3.5.2}/auth/client/_transport.py +0 -0
  20. {auth-3.5.0 → auth-3.5.2}/auth/client/base.py +0 -0
  21. {auth-3.5.0 → auth-3.5.2}/auth/client/keys.py +0 -0
  22. {auth-3.5.0 → auth-3.5.2}/auth/client/rbac.py +0 -0
  23. {auth-3.5.0 → auth-3.5.2}/auth/client/workflow.py +0 -0
  24. {auth-3.5.0 → auth-3.5.2}/auth/cmd/__init__.py +0 -0
  25. {auth-3.5.0 → auth-3.5.2}/auth/cmd/server.py +0 -0
  26. {auth-3.5.0 → auth-3.5.2}/auth/config.py +0 -0
  27. {auth-3.5.0 → auth-3.5.2}/auth/core/REST/__init__.py +0 -0
  28. {auth-3.5.0 → auth-3.5.2}/auth/core/REST/client.py +0 -0
  29. {auth-3.5.0 → auth-3.5.2}/auth/core/models/__init__.py +0 -0
  30. {auth-3.5.0 → auth-3.5.2}/auth/database.py +0 -0
  31. {auth-3.5.0 → auth-3.5.2}/auth/decorators.py +0 -0
  32. {auth-3.5.0 → auth-3.5.2}/auth/docs_page.py +0 -0
  33. {auth-3.5.0 → auth-3.5.2}/auth/encryption.py +0 -0
  34. {auth-3.5.0 → auth-3.5.2}/auth/keycheck.py +0 -0
  35. {auth-3.5.0 → auth-3.5.2}/auth/logging_config.py +0 -0
  36. {auth-3.5.0 → auth-3.5.2}/auth/main.py +0 -0
  37. {auth-3.5.0 → auth-3.5.2}/auth/models/sql.py +0 -0
  38. {auth-3.5.0 → auth-3.5.2}/auth/response_format.py +0 -0
  39. {auth-3.5.0 → auth-3.5.2}/auth/rls.py +0 -0
  40. {auth-3.5.0 → auth-3.5.2}/auth/routes/__init__.py +0 -0
  41. {auth-3.5.0 → auth-3.5.2}/auth/routes/_common.py +0 -0
  42. {auth-3.5.0 → auth-3.5.2}/auth/routes/apikeys.py +0 -0
  43. {auth-3.5.0 → auth-3.5.2}/auth/routes/membership.py +0 -0
  44. {auth-3.5.0 → auth-3.5.2}/auth/routes/permissions.py +0 -0
  45. {auth-3.5.0 → auth-3.5.2}/auth/routes/public.py +0 -0
  46. {auth-3.5.0 → auth-3.5.2}/auth/routes/roles.py +0 -0
  47. {auth-3.5.0 → auth-3.5.2}/auth/routes/tenant.py +0 -0
  48. {auth-3.5.0 → auth-3.5.2}/auth/routes/workflow.py +0 -0
  49. {auth-3.5.0 → auth-3.5.2}/auth/sanitizer.py +0 -0
  50. {auth-3.5.0 → auth-3.5.2}/auth/schema_reconcile.py +0 -0
  51. {auth-3.5.0 → auth-3.5.2}/auth/server.py +0 -0
  52. {auth-3.5.0 → auth-3.5.2}/auth/services/base.py +0 -0
  53. {auth-3.5.0 → auth-3.5.2}/auth/services/keys.py +0 -0
  54. {auth-3.5.0 → auth-3.5.2}/auth/services/queries.py +0 -0
  55. {auth-3.5.0 → auth-3.5.2}/auth/services/rbac.py +0 -0
  56. {auth-3.5.0 → auth-3.5.2}/auth/services/recovery.py +0 -0
  57. {auth-3.5.0 → auth-3.5.2}/auth/services/rotation.py +0 -0
  58. {auth-3.5.0 → auth-3.5.2}/auth/services/service.py +0 -0
  59. {auth-3.5.0 → auth-3.5.2}/auth/services/tenant.py +0 -0
  60. {auth-3.5.0 → auth-3.5.2}/auth/static_docs/__init__.py +0 -0
  61. {auth-3.5.0 → auth-3.5.2}/auth/static_docs/api_reference.md +0 -0
  62. {auth-3.5.0 → auth-3.5.2}/auth/static_docs/claude_guide.md +0 -0
  63. {auth-3.5.0 → auth-3.5.2}/auth/static_docs/landing.md +0 -0
  64. {auth-3.5.0 → auth-3.5.2}/auth/static_docs/page.html +0 -0
  65. {auth-3.5.0 → auth-3.5.2}/auth/validation.py +0 -0
  66. {auth-3.5.0 → auth-3.5.2}/auth/workflow_checker.py +0 -0
  67. {auth-3.5.0 → auth-3.5.2}/auth.egg-info/dependency_links.txt +0 -0
  68. {auth-3.5.0 → auth-3.5.2}/auth.egg-info/entry_points.txt +0 -0
  69. {auth-3.5.0 → auth-3.5.2}/auth.egg-info/top_level.txt +0 -0
  70. {auth-3.5.0 → auth-3.5.2}/setup.cfg +0 -0
  71. {auth-3.5.0 → auth-3.5.2}/tests/test_api_keys.py +0 -0
  72. {auth-3.5.0 → auth-3.5.2}/tests/test_api_keys_encryption.py +0 -0
  73. {auth-3.5.0 → auth-3.5.2}/tests/test_audit_integrity.py +0 -0
  74. {auth-3.5.0 → auth-3.5.2}/tests/test_client.py +0 -0
  75. {auth-3.5.0 → auth-3.5.2}/tests/test_client_exceptions_do_not_render_payload.py +0 -0
  76. {auth-3.5.0 → auth-3.5.2}/tests/test_client_rest.py +0 -0
  77. {auth-3.5.0 → auth-3.5.2}/tests/test_cmd_server.py +0 -0
  78. {auth-3.5.0 → auth-3.5.2}/tests/test_config.py +0 -0
  79. {auth-3.5.0 → auth-3.5.2}/tests/test_correctness_hardening.py +0 -0
  80. {auth-3.5.0 → auth-3.5.2}/tests/test_database_pool_settings.py +0 -0
  81. {auth-3.5.0 → auth-3.5.2}/tests/test_database_sslmode.py +0 -0
  82. {auth-3.5.0 → auth-3.5.2}/tests/test_degraded_response_is_a_contract.py +0 -0
  83. {auth-3.5.0 → auth-3.5.2}/tests/test_docs_page.py +0 -0
  84. {auth-3.5.0 → auth-3.5.2}/tests/test_encryption.py +0 -0
  85. {auth-3.5.0 → auth-3.5.2}/tests/test_encryption_integration.py +0 -0
  86. {auth-3.5.0 → auth-3.5.2}/tests/test_flask.py +0 -0
  87. {auth-3.5.0 → auth-3.5.2}/tests/test_gunicorn_config_invariants.py +0 -0
  88. {auth-3.5.0 → auth-3.5.2}/tests/test_key_rotation.py +0 -0
  89. {auth-3.5.0 → auth-3.5.2}/tests/test_log_redaction.py +0 -0
  90. {auth-3.5.0 → auth-3.5.2}/tests/test_no_bundled_libpq.py +0 -0
  91. {auth-3.5.0 → auth-3.5.2}/tests/test_phase_a_hardening.py +0 -0
  92. {auth-3.5.0 → auth-3.5.2}/tests/test_provision_script_no_dsn_leak.py +0 -0
  93. {auth-3.5.0 → auth-3.5.2}/tests/test_reencryption.py +0 -0
  94. {auth-3.5.0 → auth-3.5.2}/tests/test_routes_errors.py +0 -0
  95. {auth-3.5.0 → auth-3.5.2}/tests/test_self_service_audit.py +0 -0
  96. {auth-3.5.0 → auth-3.5.2}/tests/test_server.py +0 -0
  97. {auth-3.5.0 → auth-3.5.2}/tests/test_service_lifecycle.py +0 -0
  98. {auth-3.5.0 → auth-3.5.2}/tests/test_settings_do_not_echo_secrets.py +0 -0
  99. {auth-3.5.0 → auth-3.5.2}/tests/test_strict_default.py +0 -0
  100. {auth-3.5.0 → auth-3.5.2}/tests/test_strict_users.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: auth
3
- Version: 3.5.0
3
+ Version: 3.5.2
4
4
  Summary: Authorization for humans
5
5
  Author-email: Farshid Ashouri <farsheed.ashouri@gmail.com>
6
6
  License-Expression: MIT
@@ -35,13 +35,18 @@ Requires-Dist: pydantic<3,>=2.0.0
35
35
  Requires-Dist: pydantic-settings<3,>=2.0.0
36
36
  Requires-Dist: requests<3,>=2.25.0
37
37
  Requires-Dist: bleach<7,>=5.0.0
38
- Requires-Dist: python-json-logger<4,>=3.1.0
38
+ Requires-Dist: python-json-logger<5,>=3.1.0
39
39
  Provides-Extra: c
40
40
  Requires-Dist: psycopg[c]<4,>=3.0.0; extra == "c"
41
41
  Provides-Extra: ratelimit
42
42
  Requires-Dist: flask-limiter>=3.0.0; extra == "ratelimit"
43
43
  Provides-Extra: migrations
44
44
  Requires-Dist: migretti>=0.10.0; extra == "migrations"
45
+ Provides-Extra: server
46
+ Requires-Dist: gunicorn[setproctitle]>=26.2.0; extra == "server"
47
+ Requires-Dist: supervice<0.4,>=0.3.0; extra == "server"
48
+ Requires-Dist: click>=8.3.3; extra == "server"
49
+ Requires-Dist: setuptools>=84.1.0; extra == "server"
45
50
  Provides-Extra: dev
46
51
  Requires-Dist: pytest>=6.0; extra == "dev"
47
52
  Requires-Dist: pytest-cov>=2.0; extra == "dev"
@@ -1,23 +1,39 @@
1
1
  __author__ = "Farshid Ashouri"
2
2
 
3
3
  from importlib.metadata import PackageNotFoundError, version
4
- from typing import Optional
4
+ from typing import TYPE_CHECKING, Optional
5
5
 
6
- from auth.client import ( # Import the new client
7
- AuthRefused,
8
- AuthTransportError,
9
- Client,
10
- EnhancedAuthClient,
11
- )
12
6
  from auth.database import SessionLocal
13
7
  from auth.schema_check import SchemaMismatchError, check_schema
14
8
  from auth.services.service import AuthorizationService
15
9
 
10
+ if TYPE_CHECKING:
11
+ from auth.client import (
12
+ AuthRefused,
13
+ AuthTransportError,
14
+ Client,
15
+ EnhancedAuthClient,
16
+ )
17
+
16
18
  try:
17
19
  __version__ = version("auth")
18
20
  except PackageNotFoundError: # running from a source checkout without install
19
21
  __version__ = "0.0.0.dev0"
20
22
 
23
+ _CLIENT_EXPORTS = frozenset(
24
+ {"AuthRefused", "AuthTransportError", "Client", "EnhancedAuthClient"}
25
+ )
26
+
27
+
28
+ def __getattr__(name: str):
29
+ if name in _CLIENT_EXPORTS:
30
+ import auth.client
31
+
32
+ value = getattr(auth.client, name)
33
+ globals()[name] = value
34
+ return value
35
+ raise AttributeError(f"module 'auth' has no attribute {name!r}")
36
+
21
37
 
22
38
  # Lazy import for Flask app to avoid immediate initialization
23
39
  def _get_app():
@@ -0,0 +1,18 @@
1
+ __author__ = "Farshid Ashouri"
2
+
3
+ from typing import TYPE_CHECKING
4
+
5
+ if TYPE_CHECKING:
6
+ from auth.client import Client, EnhancedAuthClient
7
+
8
+ __all__ = ["Client", "EnhancedAuthClient"]
9
+
10
+
11
+ def __getattr__(name: str):
12
+ if name in __all__:
13
+ import auth.client
14
+
15
+ value = getattr(auth.client, name)
16
+ globals()[name] = value
17
+ return value
18
+ raise AttributeError(f"module 'auth.core' has no attribute {name!r}")
@@ -8,10 +8,16 @@ Bind = Union[Engine, Connection]
8
8
 
9
9
  class SchemaMismatchError(RuntimeError):
10
10
  def __init__(
11
- self, missing_tables: Sequence[str], missing_columns: Sequence[str]
11
+ self,
12
+ missing_tables: Sequence[str],
13
+ missing_columns: Sequence[str],
14
+ message: Optional[str] = None,
12
15
  ) -> None:
13
16
  self.missing_tables = list(missing_tables)
14
17
  self.missing_columns = list(missing_columns)
18
+ if message is not None:
19
+ super().__init__(message)
20
+ return
15
21
  parts = []
16
22
  if self.missing_tables:
17
23
  parts.append("missing tables: " + ", ".join(self.missing_tables))
@@ -32,10 +38,18 @@ def find_schema_drift(bind: Bind) -> Tuple[List[str], List[str]]:
32
38
  import auth.audit # noqa: F401
33
39
  from auth.models.sql import Base
34
40
 
41
+ tables = sorted(Base.metadata.tables.values(), key=_qualified)
42
+ if not tables:
43
+ raise SchemaMismatchError(
44
+ [],
45
+ [],
46
+ "the installed auth models register no tables, so there is nothing"
47
+ " to compare the live database against.",
48
+ )
35
49
  inspector = inspect(bind)
36
50
  missing_tables: List[str] = []
37
51
  missing_columns: List[str] = []
38
- for table in sorted(Base.metadata.tables.values(), key=_qualified):
52
+ for table in tables:
39
53
  if not inspector.has_table(table.name, schema=table.schema):
40
54
  missing_tables.append(_qualified(table))
41
55
  continue
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: auth
3
- Version: 3.5.0
3
+ Version: 3.5.2
4
4
  Summary: Authorization for humans
5
5
  Author-email: Farshid Ashouri <farsheed.ashouri@gmail.com>
6
6
  License-Expression: MIT
@@ -35,13 +35,18 @@ Requires-Dist: pydantic<3,>=2.0.0
35
35
  Requires-Dist: pydantic-settings<3,>=2.0.0
36
36
  Requires-Dist: requests<3,>=2.25.0
37
37
  Requires-Dist: bleach<7,>=5.0.0
38
- Requires-Dist: python-json-logger<4,>=3.1.0
38
+ Requires-Dist: python-json-logger<5,>=3.1.0
39
39
  Provides-Extra: c
40
40
  Requires-Dist: psycopg[c]<4,>=3.0.0; extra == "c"
41
41
  Provides-Extra: ratelimit
42
42
  Requires-Dist: flask-limiter>=3.0.0; extra == "ratelimit"
43
43
  Provides-Extra: migrations
44
44
  Requires-Dist: migretti>=0.10.0; extra == "migrations"
45
+ Provides-Extra: server
46
+ Requires-Dist: gunicorn[setproctitle]>=26.2.0; extra == "server"
47
+ Requires-Dist: supervice<0.4,>=0.3.0; extra == "server"
48
+ Requires-Dist: click>=8.3.3; extra == "server"
49
+ Requires-Dist: setuptools>=84.1.0; extra == "server"
45
50
  Provides-Extra: dev
46
51
  Requires-Dist: pytest>=6.0; extra == "dev"
47
52
  Requires-Dist: pytest-cov>=2.0; extra == "dev"
@@ -74,11 +74,13 @@ tests/test_correctness_hardening.py
74
74
  tests/test_database_pool_settings.py
75
75
  tests/test_database_sslmode.py
76
76
  tests/test_degraded_response_is_a_contract.py
77
+ tests/test_deploy_lock.py
77
78
  tests/test_docs_page.py
78
79
  tests/test_encryption.py
79
80
  tests/test_encryption_integration.py
80
81
  tests/test_flask.py
81
82
  tests/test_gunicorn_config_invariants.py
83
+ tests/test_import_footprint.py
82
84
  tests/test_key_rotation.py
83
85
  tests/test_log_redaction.py
84
86
  tests/test_no_bundled_libpq.py
@@ -9,7 +9,7 @@ pydantic<3,>=2.0.0
9
9
  pydantic-settings<3,>=2.0.0
10
10
  requests<3,>=2.25.0
11
11
  bleach<7,>=5.0.0
12
- python-json-logger<4,>=3.1.0
12
+ python-json-logger<5,>=3.1.0
13
13
 
14
14
  [c]
15
15
  psycopg[c]<4,>=3.0.0
@@ -31,3 +31,9 @@ migretti>=0.10.0
31
31
 
32
32
  [ratelimit]
33
33
  flask-limiter>=3.0.0
34
+
35
+ [server]
36
+ gunicorn[setproctitle]>=26.2.0
37
+ supervice<0.4,>=0.3.0
38
+ click>=8.3.3
39
+ setuptools>=84.1.0
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "auth"
7
- version = "3.5.0"
7
+ version = "3.5.2"
8
8
  description = "Authorization for humans"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -47,7 +47,7 @@ dependencies = [
47
47
  "pydantic-settings>=2.0.0,<3",
48
48
  "requests>=2.25.0,<3",
49
49
  "bleach>=5.0.0,<7",
50
- "python-json-logger>=3.1.0,<4",
50
+ "python-json-logger>=3.1.0,<5",
51
51
  ]
52
52
 
53
53
  [project.optional-dependencies]
@@ -68,6 +68,12 @@ ratelimit = [
68
68
  migrations = [
69
69
  "migretti>=0.10.0",
70
70
  ]
71
+ server = [
72
+ "gunicorn[setproctitle]>=26.2.0",
73
+ "supervice>=0.3.0,<0.4",
74
+ "click>=8.3.3",
75
+ "setuptools>=84.1.0",
76
+ ]
71
77
  dev = [
72
78
  "pytest>=6.0",
73
79
  "pytest-cov>=2.0",
@@ -84,6 +90,14 @@ dev = [
84
90
  [project.scripts]
85
91
  auth-server = "auth.server:main"
86
92
 
93
+ [tool.uv]
94
+ constraint-dependencies = [
95
+ "werkzeug>=3.1.9",
96
+ "certifi>=2026.10.19",
97
+ "urllib3>=2.8.0",
98
+ "setuptools>=84.1.0",
99
+ ]
100
+
87
101
  [tool.setuptools.packages.find]
88
102
  where = ["."]
89
103
  include = ["auth*"]
@@ -0,0 +1,91 @@
1
+ import re
2
+ from pathlib import Path
3
+
4
+ import pytest
5
+ from packaging.version import Version
6
+
7
+ tomllib = pytest.importorskip("tomllib")
8
+
9
+ ROOT = Path(__file__).resolve().parent.parent
10
+ LOCK = ROOT / "deploy" / "requirements-vm2.txt"
11
+ UV_LOCK = ROOT / "uv.lock"
12
+
13
+ FLOORS = {
14
+ "werkzeug": "3.1.9",
15
+ "certifi": "2026.10.19",
16
+ "urllib3": "2.8.0",
17
+ "setuptools": "84.1.0",
18
+ "click": "8.3.3",
19
+ }
20
+ EXCLUDED = {"pillow", "pyjwt", "filelock", "brotli", "psycopg-binary"}
21
+ REQUIRED = {
22
+ "psycopg",
23
+ "psycopg-c",
24
+ "gunicorn",
25
+ "supervice",
26
+ "migretti",
27
+ "flask",
28
+ "sqlalchemy",
29
+ }
30
+
31
+ REQUIREMENT = re.compile(r"^([A-Za-z0-9][A-Za-z0-9._-]*)==([^\s;\\]+)")
32
+
33
+
34
+ def _norm(name):
35
+ return re.sub(r"[-_.]+", "-", name).lower()
36
+
37
+
38
+ def _entries():
39
+ entries = []
40
+ current = None
41
+ for line in LOCK.read_text().splitlines():
42
+ match = REQUIREMENT.match(line)
43
+ if match:
44
+ current = {
45
+ "name": _norm(match.group(1)),
46
+ "version": match.group(2),
47
+ "hashes": 0,
48
+ }
49
+ entries.append(current)
50
+ elif current is not None and "--hash=sha256:" in line:
51
+ current["hashes"] += 1
52
+ return entries
53
+
54
+
55
+ @pytest.fixture(scope="module")
56
+ def entries():
57
+ found = _entries()
58
+ assert {e["name"] for e in found} >= {"flask", "psycopg"}
59
+ return found
60
+
61
+
62
+ def test_every_requirement_is_hash_pinned(entries):
63
+ unhashed = [e["name"] for e in entries if e["hashes"] == 0]
64
+ assert unhashed == []
65
+
66
+
67
+ def test_lock_carries_the_server_runtime(entries):
68
+ assert REQUIRED <= {e["name"] for e in entries}
69
+
70
+
71
+ def test_lock_excludes_packages_auth_does_not_use(entries):
72
+ assert EXCLUDED.isdisjoint({e["name"] for e in entries})
73
+
74
+
75
+ @pytest.mark.parametrize("name,floor", sorted(FLOORS.items()))
76
+ def test_fixed_versions_are_pinned(entries, name, floor):
77
+ versions = [Version(e["version"]) for e in entries if e["name"] == name]
78
+ assert versions, f"{name} missing from the deploy lock"
79
+ assert all(v >= Version(floor) for v in versions)
80
+
81
+
82
+ def test_deploy_lock_matches_uv_lock(entries):
83
+ locked: dict[str, set[str]] = {}
84
+ for package in tomllib.loads(UV_LOCK.read_text())["package"]:
85
+ locked.setdefault(_norm(package["name"]), set()).add(package["version"])
86
+ drift = sorted(
87
+ (e["name"], e["version"])
88
+ for e in entries
89
+ if e["version"] not in locked.get(e["name"], set())
90
+ )
91
+ assert drift == []
@@ -0,0 +1,93 @@
1
+ import json
2
+ import os
3
+ import subprocess
4
+ import sys
5
+
6
+ import pytest
7
+
8
+ import auth
9
+
10
+ FOOTPRINT_SCRIPT = """
11
+ import json, sys
12
+ import auth, auth.main
13
+ served = sorted(m for m in ("requests", "urllib3", "brotli") if m in sys.modules)
14
+ from auth import AuthRefused, AuthTransportError, Client, EnhancedAuthClient
15
+ from auth.core import Client as CoreClient, EnhancedAuthClient as CoreEnhanced
16
+ import auth.client as real
17
+ same = {
18
+ "Client": Client is real.Client,
19
+ "EnhancedAuthClient": EnhancedAuthClient is real.EnhancedAuthClient,
20
+ "AuthRefused": AuthRefused is real.AuthRefused,
21
+ "AuthTransportError": AuthTransportError is real.AuthTransportError,
22
+ "core.Client": CoreClient is real.Client,
23
+ "core.EnhancedAuthClient": CoreEnhanced is real.EnhancedAuthClient,
24
+ }
25
+ after_client = sorted(m for m in ("requests", "urllib3") if m in sys.modules)
26
+ print(json.dumps({"served": served, "same": same, "after_client": after_client}))
27
+ """
28
+
29
+
30
+ def _run(tmp_path, script):
31
+ env = {
32
+ key: value
33
+ for key, value in os.environ.items()
34
+ if not key.startswith("AUTH_") and key != "PGSSLMODE"
35
+ }
36
+ package_root = os.path.dirname(os.path.dirname(os.path.abspath(auth.__file__)))
37
+ env.update(
38
+ PYTHONPATH=package_root,
39
+ AUTH_DATABASE_TYPE="sqlite",
40
+ AUTH_SQLITE_PATH=f"{tmp_path}/footprint.db",
41
+ AUTH_ENABLE_ENCRYPTION="false",
42
+ AUTH_JWT_SECRET_KEY="import-footprint-test-secret-0001",
43
+ AUTH_AUDIT_PEPPER="import-footprint-test-pepper-0001",
44
+ AUTH_ENABLE_RATE_LIMIT="false",
45
+ )
46
+ return subprocess.run(
47
+ [sys.executable, "-c", script],
48
+ env=env,
49
+ cwd=tmp_path,
50
+ capture_output=True,
51
+ text=True,
52
+ timeout=120,
53
+ )
54
+
55
+
56
+ @pytest.fixture(scope="module")
57
+ def footprint(tmp_path_factory):
58
+ result = _run(tmp_path_factory.mktemp("footprint"), FOOTPRINT_SCRIPT)
59
+ assert result.returncode == 0, result.stderr
60
+ return json.loads(result.stdout.strip().splitlines()[-1])
61
+
62
+
63
+ def test_serving_process_does_not_load_the_http_client_stack(footprint):
64
+ assert footprint["served"] == []
65
+
66
+
67
+ def test_detector_sees_the_client_stack_once_the_client_is_used(footprint):
68
+ assert footprint["after_client"] == ["requests", "urllib3"]
69
+
70
+
71
+ @pytest.mark.parametrize(
72
+ "name",
73
+ [
74
+ "Client",
75
+ "EnhancedAuthClient",
76
+ "AuthRefused",
77
+ "AuthTransportError",
78
+ "core.Client",
79
+ "core.EnhancedAuthClient",
80
+ ],
81
+ )
82
+ def test_lazy_exports_are_the_client_module_objects(footprint, name):
83
+ assert footprint["same"][name] is True
84
+
85
+
86
+ def test_unknown_attribute_still_raises_attribute_error():
87
+ with pytest.raises(AttributeError, match="no attribute 'NoSuchThing'"):
88
+ auth.NoSuchThing # noqa: B018
89
+
90
+
91
+ def test_client_names_stay_in_the_public_api():
92
+ for name in ("AuthRefused", "AuthTransportError", "Client", "EnhancedAuthClient"):
93
+ assert name in auth.__all__
@@ -1,7 +1,7 @@
1
1
  import logging
2
2
 
3
3
  import pytest
4
- from sqlalchemy import create_engine, event, text
4
+ from sqlalchemy import MetaData, create_engine, event, text
5
5
 
6
6
  import auth
7
7
  import auth.audit # noqa: F401
@@ -128,6 +128,19 @@ def test_create_tables_on_current_schema_reports_success(current_engine, monkeyp
128
128
  assert "Tables created successfully." in caplog.text
129
129
 
130
130
 
131
+ def test_empty_model_metadata_refuses_instead_of_passing(current_engine, monkeypatch):
132
+ seen = _statements(current_engine)
133
+ monkeypatch.setattr(Base, "metadata", MetaData())
134
+ with pytest.raises(SchemaMismatchError) as caught:
135
+ check_schema(current_engine)
136
+ assert "register no tables" in str(caught.value)
137
+ assert caught.value.missing_tables == []
138
+ assert caught.value.missing_columns == []
139
+ with pytest.raises(SchemaMismatchError):
140
+ find_schema_drift(current_engine)
141
+ assert seen == []
142
+
143
+
131
144
  def test_public_exports():
132
145
  assert auth.check_schema is check_schema
133
146
  assert auth.SchemaMismatchError is SchemaMismatchError
@@ -1,6 +0,0 @@
1
- __author__ = "Farshid Ashouri"
2
-
3
- # Import and expose the enhanced client
4
- from auth.client import Client, EnhancedAuthClient
5
-
6
- __all__ = ["Client", "EnhancedAuthClient"]
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
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