open-api-framework 0.9.6__tar.gz → 0.10.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.
Files changed (37) hide show
  1. {open_api_framework-0.9.6 → open_api_framework-0.10.0}/CHANGELOG.rst +13 -0
  2. {open_api_framework-0.9.6/open_api_framework.egg-info → open_api_framework-0.10.0}/PKG-INFO +4 -2
  3. {open_api_framework-0.9.6 → open_api_framework-0.10.0}/README.rst +1 -1
  4. {open_api_framework-0.9.6 → open_api_framework-0.10.0}/open_api_framework/conf/base.py +17 -4
  5. {open_api_framework-0.9.6 → open_api_framework-0.10.0}/open_api_framework/conf/utils.py +37 -0
  6. {open_api_framework-0.9.6 → open_api_framework-0.10.0/open_api_framework.egg-info}/PKG-INFO +4 -2
  7. {open_api_framework-0.9.6 → open_api_framework-0.10.0}/open_api_framework.egg-info/requires.txt +2 -0
  8. {open_api_framework-0.9.6 → open_api_framework-0.10.0}/pyproject.toml +4 -2
  9. {open_api_framework-0.9.6 → open_api_framework-0.10.0}/tests/test_generate_envvar_docs.py +20 -15
  10. open_api_framework-0.10.0/tests/test_settings.py +26 -0
  11. open_api_framework-0.9.6/tests/test_settings.py +0 -8
  12. {open_api_framework-0.9.6 → open_api_framework-0.10.0}/LICENSE +0 -0
  13. {open_api_framework-0.9.6 → open_api_framework-0.10.0}/MANIFEST.in +0 -0
  14. {open_api_framework-0.9.6 → open_api_framework-0.10.0}/open_api_framework/__init__.py +0 -0
  15. {open_api_framework-0.9.6 → open_api_framework-0.10.0}/open_api_framework/admin.py +0 -0
  16. {open_api_framework-0.9.6 → open_api_framework-0.10.0}/open_api_framework/apps.py +0 -0
  17. {open_api_framework-0.9.6 → open_api_framework-0.10.0}/open_api_framework/conf/__init__.py +0 -0
  18. {open_api_framework-0.9.6 → open_api_framework-0.10.0}/open_api_framework/context_processors.py +0 -0
  19. {open_api_framework-0.9.6 → open_api_framework-0.10.0}/open_api_framework/management/__init__.py +0 -0
  20. {open_api_framework-0.9.6 → open_api_framework-0.10.0}/open_api_framework/management/commands/__init__.py +0 -0
  21. {open_api_framework-0.9.6 → open_api_framework-0.10.0}/open_api_framework/management/commands/generate_envvar_docs.py +0 -0
  22. {open_api_framework-0.9.6 → open_api_framework-0.10.0}/open_api_framework/py.typed +0 -0
  23. {open_api_framework-0.9.6 → open_api_framework-0.10.0}/open_api_framework/static/open_api_framework/css/admin.css +0 -0
  24. {open_api_framework-0.9.6 → open_api_framework-0.10.0}/open_api_framework/templates/open_api_framework/admin/base_site.html +0 -0
  25. {open_api_framework-0.9.6 → open_api_framework-0.10.0}/open_api_framework/templates/open_api_framework/components/environment.html +0 -0
  26. {open_api_framework-0.9.6 → open_api_framework-0.10.0}/open_api_framework/templates/open_api_framework/components/version.html +0 -0
  27. {open_api_framework-0.9.6 → open_api_framework-0.10.0}/open_api_framework/templates/open_api_framework/env_config.rst +0 -0
  28. {open_api_framework-0.9.6 → open_api_framework-0.10.0}/open_api_framework/templatetags/__init__.py +0 -0
  29. {open_api_framework-0.9.6 → open_api_framework-0.10.0}/open_api_framework/templatetags/doc_tags.py +0 -0
  30. {open_api_framework-0.9.6 → open_api_framework-0.10.0}/open_api_framework/templatetags/open_api_framework.py +0 -0
  31. {open_api_framework-0.9.6 → open_api_framework-0.10.0}/open_api_framework/utils.py +0 -0
  32. {open_api_framework-0.9.6 → open_api_framework-0.10.0}/open_api_framework.egg-info/SOURCES.txt +0 -0
  33. {open_api_framework-0.9.6 → open_api_framework-0.10.0}/open_api_framework.egg-info/dependency_links.txt +0 -0
  34. {open_api_framework-0.9.6 → open_api_framework-0.10.0}/open_api_framework.egg-info/top_level.txt +0 -0
  35. {open_api_framework-0.9.6 → open_api_framework-0.10.0}/setup.cfg +0 -0
  36. {open_api_framework-0.9.6 → open_api_framework-0.10.0}/tests/test_admin.py +0 -0
  37. {open_api_framework-0.9.6 → open_api_framework-0.10.0}/tests/test_config_helpers.py +0 -0
@@ -1,6 +1,19 @@
1
1
  Changelog
2
2
  =========
3
3
 
4
+ 0.10.0 (2025-05-19)
5
+ -------------------
6
+
7
+ **New features**
8
+
9
+ * Add separate "Logging" group for logging related environment variables in docs
10
+ * Add ``open_api_framework.conf.utils.mute_logging`` util to silence logging in CI
11
+ * [maykinmedia/objects-api#592] Silence log events in Sentry if structlog is used
12
+
13
+ **Bugfixes**
14
+
15
+ * [#127] Make ``LOGIN_URL`` non-lazy to avoid errors when using ``django-rosetta``
16
+
4
17
  0.9.6 (2025-03-28)
5
18
  ------------------
6
19
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: open-api-framework
3
- Version: 0.9.6
3
+ Version: 0.10.0
4
4
  Summary: A metapackage for registration components, that bundles the dependencies shared between these components and provides generic settings
5
5
  Author-email: Maykin Media <support@maykinmedia.nl>
6
6
  License: Copyright © Maykin 2024
@@ -69,6 +69,8 @@ Requires-Dist: isort; extra == "tests"
69
69
  Requires-Dist: black; extra == "tests"
70
70
  Requires-Dist: flake8; extra == "tests"
71
71
  Requires-Dist: factory-boy; extra == "tests"
72
+ Requires-Dist: django-rosetta; extra == "tests"
73
+ Requires-Dist: django-webtest; extra == "tests"
72
74
  Provides-Extra: coverage
73
75
  Requires-Dist: pytest-cov; extra == "coverage"
74
76
  Provides-Extra: docs
@@ -82,7 +84,7 @@ Dynamic: license-file
82
84
  Open API Framework
83
85
  ==================
84
86
 
85
- :Version: 0.9.6
87
+ :Version: 0.10.0
86
88
  :Source: https://github.com/maykinmedia/open-api-framework
87
89
  :Keywords: metapackage, dependencies
88
90
 
@@ -1,7 +1,7 @@
1
1
  Open API Framework
2
2
  ==================
3
3
 
4
- :Version: 0.9.6
4
+ :Version: 0.10.0
5
5
  :Source: https://github.com/maykinmedia/open-api-framework
6
6
  :Keywords: metapackage, dependencies
7
7
 
@@ -347,7 +347,10 @@ DEFAULT_FROM_EMAIL = config(
347
347
  # LOGGING
348
348
  #
349
349
  LOG_STDOUT = config(
350
- "LOG_STDOUT", default=True, help_text="whether to log to stdout or not"
350
+ "LOG_STDOUT",
351
+ default=True,
352
+ help_text="whether to log to stdout or not",
353
+ group="Logging",
351
354
  )
352
355
  LOG_LEVEL = config(
353
356
  "LOG_LEVEL",
@@ -356,6 +359,7 @@ LOG_LEVEL = config(
356
359
  "control the verbosity of logging output. "
357
360
  "Available values are ``CRITICAL``, ``ERROR``, ``WARNING``, ``INFO`` and ``DEBUG``"
358
361
  ),
362
+ group="Logging",
359
363
  )
360
364
  LOG_QUERIES = config(
361
365
  "LOG_QUERIES",
@@ -364,9 +368,14 @@ LOG_QUERIES = config(
364
368
  "enable (query) logging at the database backend level. Note that you "
365
369
  "must also set ``DEBUG=1``, which should be done very sparingly!"
366
370
  ),
371
+ group="Logging",
367
372
  )
373
+ # XXX: this should be renamed to `LOG_OUTGOING_REQUESTS` in the next major release
368
374
  LOG_REQUESTS = config(
369
- "LOG_REQUESTS", default=False, help_text="enable logging of the outgoing requests"
375
+ "LOG_REQUESTS",
376
+ default=False,
377
+ help_text="enable logging of the outgoing requests",
378
+ group="Logging",
370
379
  )
371
380
  if LOG_QUERIES and not DEBUG:
372
381
  warnings.warn(
@@ -379,6 +388,7 @@ CELERY_LOGLEVEL = config(
379
388
  default="INFO",
380
389
  help_text="control the verbosity of logging output for celery, independent of ``LOG_LEVEL``."
381
390
  " Available values are ``CRITICAL``, ``ERROR``, ``WARNING``, ``INFO`` and ``DEBUG``",
391
+ group="Celery",
382
392
  )
383
393
 
384
394
  LOGGING_DIR = Path(BASE_DIR) / "log"
@@ -564,8 +574,7 @@ SESSION_COOKIE_AGE = config(
564
574
  help_text="For how long, in seconds, the session cookie will be valid.",
565
575
  )
566
576
 
567
-
568
- LOGIN_URL = reverse_lazy("admin:login")
577
+ LOGIN_URL = "admin:login"
569
578
  LOGIN_REDIRECT_URL = reverse_lazy("admin:index")
570
579
  LOGOUT_REDIRECT_URL = reverse_lazy("admin:index")
571
580
 
@@ -953,22 +962,26 @@ LOG_OUTGOING_REQUESTS_EMIT_BODY = config(
953
962
  "LOG_OUTGOING_REQUESTS_EMIT_BODY",
954
963
  default=True,
955
964
  help_text="Whether or not outgoing request bodies should be logged",
965
+ group="Logging",
956
966
  )
957
967
  LOG_OUTGOING_REQUESTS_DB_SAVE = config(
958
968
  "LOG_OUTGOING_REQUESTS_DB_SAVE",
959
969
  default=False,
960
970
  help_text="Whether or not outgoing request logs should be saved to the database",
971
+ group="Logging",
961
972
  )
962
973
  LOG_OUTGOING_REQUESTS_DB_SAVE_BODY = config(
963
974
  "LOG_OUTGOING_REQUESTS_DB_SAVE_BODY",
964
975
  default=True,
965
976
  help_text="Whether or not outgoing request bodies should be saved to the database",
977
+ group="Logging",
966
978
  )
967
979
  LOG_OUTGOING_REQUESTS_RESET_DB_SAVE_AFTER = None
968
980
  LOG_OUTGOING_REQUESTS_MAX_AGE = config(
969
981
  "LOG_OUTGOING_REQUESTS_MAX_AGE",
970
982
  default=7,
971
983
  help_text="The amount of time after which request logs should be deleted from the database",
984
+ group="Logging",
972
985
  ) # number of days
973
986
 
974
987
 
@@ -1,3 +1,4 @@
1
+ import logging # noqa: TID251
1
2
  import sys
2
3
  from dataclasses import dataclass
3
4
  from pathlib import Path
@@ -6,6 +7,7 @@ from urllib.parse import urlparse
6
7
 
7
8
  from decouple import Csv, Undefined, config as _config, undefined
8
9
  from sentry_sdk.integrations import DidNotEnable, django, redis
10
+ from sentry_sdk.integrations.logging import LoggingIntegration
9
11
 
10
12
 
11
13
  @dataclass
@@ -103,6 +105,20 @@ def get_sentry_integrations() -> list:
103
105
  else:
104
106
  extra.append(celery.CeleryIntegration())
105
107
 
108
+ try:
109
+ import structlog # type: ignore # noqa
110
+ except ImportError:
111
+ pass
112
+ else:
113
+ extra.append(
114
+ LoggingIntegration(
115
+ level=logging.INFO, # breadcrumbs
116
+ # do not send any logs as event to Sentry at all - these must be scraped by
117
+ # the (container) infrastructure instead.
118
+ event_level=None,
119
+ ),
120
+ )
121
+
106
122
  return [*default, *extra]
107
123
 
108
124
 
@@ -119,3 +135,24 @@ def get_django_project_dir() -> str:
119
135
  # Get the path of the importing module
120
136
  base_dirname = get_project_dirname()
121
137
  return Path(sys.modules[base_dirname].__file__).parent
138
+
139
+
140
+ def mute_logging(config: dict) -> None: # pragma: no cover
141
+ """
142
+ Disable (console) output from logging.
143
+ :arg config: The logging config, typically the django LOGGING setting.
144
+ """
145
+
146
+ # set up the null handler for all loggers so that nothing gets emitted
147
+ for name, logger in config["loggers"].items():
148
+ if name == "flaky_tests":
149
+ continue
150
+ logger["handlers"] = ["null"]
151
+
152
+ # some tooling logs to a logger which isn't defined, and that ends up in the root
153
+ # logger -> add one so that we can mute that output too.
154
+ config["loggers"].update(
155
+ {
156
+ "": {"handlers": ["null"], "level": "CRITICAL", "propagate": False},
157
+ }
158
+ )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: open-api-framework
3
- Version: 0.9.6
3
+ Version: 0.10.0
4
4
  Summary: A metapackage for registration components, that bundles the dependencies shared between these components and provides generic settings
5
5
  Author-email: Maykin Media <support@maykinmedia.nl>
6
6
  License: Copyright © Maykin 2024
@@ -69,6 +69,8 @@ Requires-Dist: isort; extra == "tests"
69
69
  Requires-Dist: black; extra == "tests"
70
70
  Requires-Dist: flake8; extra == "tests"
71
71
  Requires-Dist: factory-boy; extra == "tests"
72
+ Requires-Dist: django-rosetta; extra == "tests"
73
+ Requires-Dist: django-webtest; extra == "tests"
72
74
  Provides-Extra: coverage
73
75
  Requires-Dist: pytest-cov; extra == "coverage"
74
76
  Provides-Extra: docs
@@ -82,7 +84,7 @@ Dynamic: license-file
82
84
  Open API Framework
83
85
  ==================
84
86
 
85
- :Version: 0.9.6
87
+ :Version: 0.10.0
86
88
  :Source: https://github.com/maykinmedia/open-api-framework
87
89
  :Keywords: metapackage, dependencies
88
90
 
@@ -48,3 +48,5 @@ isort
48
48
  black
49
49
  flake8
50
50
  factory-boy
51
+ django-rosetta
52
+ django-webtest
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "open-api-framework"
7
- version = "0.9.6"
7
+ version = "0.10.0"
8
8
  description = "A metapackage for registration components, that bundles the dependencies shared between these components and provides generic settings"
9
9
  authors = [
10
10
  {name = "Maykin Media", email = "support@maykinmedia.nl"}
@@ -75,6 +75,8 @@ tests = [
75
75
  "black",
76
76
  "flake8",
77
77
  "factory-boy",
78
+ "django-rosetta",
79
+ "django-webtest"
78
80
  ]
79
81
  coverage = [
80
82
  "pytest-cov",
@@ -109,7 +111,7 @@ env = [
109
111
  ]
110
112
 
111
113
  [tool.bumpversion]
112
- current_version = "0.9.6"
114
+ current_version = "0.10.0"
113
115
  files = [
114
116
  {filename = "pyproject.toml"},
115
117
  {filename = "README.rst"},
@@ -35,21 +35,35 @@ Database
35
35
  * ``DB_PORT``: port number of the database. Defaults to: ``5432``.
36
36
 
37
37
 
38
- Cross-Origin-Resource-Sharing
39
- -----------------------------
38
+ Logging
39
+ -------
40
40
 
41
- * ``CORS_ALLOW_ALL_ORIGINS``: allow cross-domain access from any client. Defaults to: ``False``.
42
- * ``CORS_ALLOWED_ORIGINS``: explicitly list the allowed origins for cross-domain requests. Example: http://localhost:3000,https://some-app.gemeente.nl. Defaults to: ``[]``.
43
- * ``CORS_ALLOWED_ORIGIN_REGEXES``: same as ``CORS_ALLOWED_ORIGINS``, but supports regular expressions. Defaults to: ``[]``.
44
- * ``CORS_EXTRA_ALLOW_HEADERS``: headers that are allowed to be sent as part of the cross-domain request. By default, Authorization, Accept-Crs and Content-Crs are already included. The value of this variable is added to these already included headers. Defaults to: ``[]``.
41
+ * ``LOG_STDOUT``: whether to log to stdout or not. Defaults to: ``True``.
42
+ * ``LOG_LEVEL``: control the verbosity of logging output. Available values are ``CRITICAL``, ``ERROR``, ``WARNING``, ``INFO`` and ``DEBUG``. Defaults to: ``WARNING``.
43
+ * ``LOG_QUERIES``: enable (query) logging at the database backend level. Note that you must also set ``DEBUG=1``, which should be done very sparingly!. Defaults to: ``False``.
44
+ * ``LOG_REQUESTS``: enable logging of the outgoing requests. Defaults to: ``False``.
45
+ * ``LOG_OUTGOING_REQUESTS_EMIT_BODY``: Whether or not outgoing request bodies should be logged. Defaults to: ``True``.
46
+ * ``LOG_OUTGOING_REQUESTS_DB_SAVE``: Whether or not outgoing request logs should be saved to the database. Defaults to: ``False``.
47
+ * ``LOG_OUTGOING_REQUESTS_DB_SAVE_BODY``: Whether or not outgoing request bodies should be saved to the database. Defaults to: ``True``.
48
+ * ``LOG_OUTGOING_REQUESTS_MAX_AGE``: The amount of time after which request logs should be deleted from the database. Defaults to: ``7``.
45
49
 
46
50
 
47
51
  Celery
48
52
  ------
49
53
 
54
+ * ``CELERY_LOGLEVEL``: control the verbosity of logging output for celery, independent of ``LOG_LEVEL``. Available values are ``CRITICAL``, ``ERROR``, ``WARNING``, ``INFO`` and ``DEBUG``. Defaults to: ``INFO``.
50
55
  * ``CELERY_RESULT_BACKEND``: the URL of the backend/broker that will be used by Celery to send the notifications. Defaults to: ``redis://localhost:6379/1``.
51
56
 
52
57
 
58
+ Cross-Origin-Resource-Sharing
59
+ -----------------------------
60
+
61
+ * ``CORS_ALLOW_ALL_ORIGINS``: allow cross-domain access from any client. Defaults to: ``False``.
62
+ * ``CORS_ALLOWED_ORIGINS``: explicitly list the allowed origins for cross-domain requests. Example: http://localhost:3000,https://some-app.gemeente.nl. Defaults to: ``[]``.
63
+ * ``CORS_ALLOWED_ORIGIN_REGEXES``: same as ``CORS_ALLOWED_ORIGINS``, but supports regular expressions. Defaults to: ``[]``.
64
+ * ``CORS_EXTRA_ALLOW_HEADERS``: headers that are allowed to be sent as part of the cross-domain request. By default, Authorization, Accept-Crs and Content-Crs are already included. The value of this variable is added to these already included headers. Defaults to: ``[]``.
65
+
66
+
53
67
  Elastic APM
54
68
  -----------
55
69
 
@@ -83,11 +97,6 @@ Optional
83
97
  * ``EMAIL_HOST_PASSWORD``: password to connect to the mail server. Defaults to: ``(empty string)``.
84
98
  * ``EMAIL_USE_TLS``: whether to use TLS or not to connect to the mail server. Should be True if you're changing the ``EMAIL_PORT`` to 487. Defaults to: ``False``.
85
99
  * ``DEFAULT_FROM_EMAIL``: The default email address from which emails are sent. Defaults to: ``testapp@example.com``.
86
- * ``LOG_STDOUT``: whether to log to stdout or not. Defaults to: ``True``.
87
- * ``LOG_LEVEL``: control the verbosity of logging output. Available values are ``CRITICAL``, ``ERROR``, ``WARNING``, ``INFO`` and ``DEBUG``. Defaults to: ``WARNING``.
88
- * ``LOG_QUERIES``: enable (query) logging at the database backend level. Note that you must also set ``DEBUG=1``, which should be done very sparingly!. Defaults to: ``False``.
89
- * ``LOG_REQUESTS``: enable logging of the outgoing requests. Defaults to: ``False``.
90
- * ``CELERY_LOGLEVEL``: control the verbosity of logging output for celery, independent of ``LOG_LEVEL``. Available values are ``CRITICAL``, ``ERROR``, ``WARNING``, ``INFO`` and ``DEBUG``. Defaults to: ``INFO``.
91
100
  * ``SESSION_COOKIE_AGE``: For how long, in seconds, the session cookie will be valid. Defaults to: ``1209600``.
92
101
  * ``SESSION_COOKIE_SAMESITE``: The value of the SameSite flag on the session cookie. This flag prevents the cookie from being sent in cross-site requests thus preventing CSRF attacks and making some methods of stealing session cookie impossible.Currently interferes with OIDC. Keep the value set at Lax if used. Defaults to: ``Lax``.
93
102
  * ``CSRF_COOKIE_SAMESITE``: The value of the SameSite flag on the CSRF cookie. This flag prevents the cookie from being sent in cross-site requests. Defaults to: ``Strict``.
@@ -100,10 +109,6 @@ Optional
100
109
  * ``SITE_DOMAIN``: Defines the primary domain where the application is hosted. Defaults to: ``(empty string)``.
101
110
  * ``SENTRY_DSN``: URL of the sentry project to send error reports to. Default empty, i.e. -> no monitoring set up. Highly recommended to configure this.
102
111
  * ``DISABLE_2FA``: Whether or not two factor authentication should be disabled. Defaults to: ``False``.
103
- * ``LOG_OUTGOING_REQUESTS_EMIT_BODY``: Whether or not outgoing request bodies should be logged. Defaults to: ``True``.
104
- * ``LOG_OUTGOING_REQUESTS_DB_SAVE``: Whether or not outgoing request logs should be saved to the database. Defaults to: ``False``.
105
- * ``LOG_OUTGOING_REQUESTS_DB_SAVE_BODY``: Whether or not outgoing request bodies should be saved to the database. Defaults to: ``True``.
106
- * ``LOG_OUTGOING_REQUESTS_MAX_AGE``: The amount of time after which request logs should be deleted from the database. Defaults to: ``7``.
107
112
 
108
113
 
109
114
 
@@ -0,0 +1,26 @@
1
+ from django.conf import settings
2
+ from django.urls import reverse
3
+
4
+ import requests_mock
5
+ from django_webtest import WebTest
6
+
7
+
8
+ def test_sentry_settings():
9
+ """
10
+ test that sentry settings are initialized
11
+ """
12
+
13
+ assert hasattr(settings, "SENTRY_CONFIG") is True
14
+ assert hasattr(settings, "SENTRY_DSN") is True
15
+
16
+
17
+ @requests_mock.Mocker()
18
+ class RosettaTests(WebTest):
19
+ def test_rosetta_redirect_fails_with_lazy_login_url(self, m):
20
+ response = self.app.get("/admin/rosetta/files/project/")
21
+
22
+ expected_login_url = (
23
+ reverse(settings.LOGIN_URL) + "?next=/admin/rosetta/files/project/"
24
+ )
25
+ self.assertEqual(response.status_code, 302)
26
+ self.assertEqual(response.location, expected_login_url)
@@ -1,8 +0,0 @@
1
- def test_sentry_settings():
2
- """
3
- test that sentry settings are initialized
4
- """
5
- from django.conf import settings
6
-
7
- assert hasattr(settings, "SENTRY_CONFIG") is True
8
- assert hasattr(settings, "SENTRY_DSN") is True