open-api-framework 0.9.2__tar.gz → 0.9.3__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.2 → open_api_framework-0.9.3}/CHANGELOG.rst +38 -0
  2. {open_api_framework-0.9.2/open_api_framework.egg-info → open_api_framework-0.9.3}/PKG-INFO +5 -5
  3. {open_api_framework-0.9.2 → open_api_framework-0.9.3}/README.rst +1 -1
  4. {open_api_framework-0.9.2 → open_api_framework-0.9.3}/open_api_framework/conf/base.py +19 -27
  5. {open_api_framework-0.9.2 → open_api_framework-0.9.3/open_api_framework.egg-info}/PKG-INFO +5 -5
  6. {open_api_framework-0.9.2 → open_api_framework-0.9.3}/open_api_framework.egg-info/SOURCES.txt +2 -1
  7. {open_api_framework-0.9.2 → open_api_framework-0.9.3}/open_api_framework.egg-info/requires.txt +2 -2
  8. {open_api_framework-0.9.2 → open_api_framework-0.9.3}/pyproject.toml +10 -5
  9. {open_api_framework-0.9.2 → open_api_framework-0.9.3}/setup.cfg +1 -1
  10. open_api_framework-0.9.3/tests/test_generate_envvar_docs.py +159 -0
  11. open_api_framework-0.9.3/tests/test_settings.py +8 -0
  12. open_api_framework-0.9.2/tests/test_generate_envvar_docs.py +0 -85
  13. {open_api_framework-0.9.2 → open_api_framework-0.9.3}/LICENSE +0 -0
  14. {open_api_framework-0.9.2 → open_api_framework-0.9.3}/MANIFEST.in +0 -0
  15. {open_api_framework-0.9.2 → open_api_framework-0.9.3}/open_api_framework/__init__.py +0 -0
  16. {open_api_framework-0.9.2 → open_api_framework-0.9.3}/open_api_framework/admin.py +0 -0
  17. {open_api_framework-0.9.2 → open_api_framework-0.9.3}/open_api_framework/apps.py +0 -0
  18. {open_api_framework-0.9.2 → open_api_framework-0.9.3}/open_api_framework/conf/__init__.py +0 -0
  19. {open_api_framework-0.9.2 → open_api_framework-0.9.3}/open_api_framework/conf/utils.py +0 -0
  20. {open_api_framework-0.9.2 → open_api_framework-0.9.3}/open_api_framework/context_processors.py +0 -0
  21. {open_api_framework-0.9.2 → open_api_framework-0.9.3}/open_api_framework/management/__init__.py +0 -0
  22. {open_api_framework-0.9.2 → open_api_framework-0.9.3}/open_api_framework/management/commands/__init__.py +0 -0
  23. {open_api_framework-0.9.2 → open_api_framework-0.9.3}/open_api_framework/management/commands/generate_envvar_docs.py +0 -0
  24. {open_api_framework-0.9.2 → open_api_framework-0.9.3}/open_api_framework/py.typed +0 -0
  25. {open_api_framework-0.9.2 → open_api_framework-0.9.3}/open_api_framework/static/open_api_framework/css/admin.css +0 -0
  26. {open_api_framework-0.9.2 → open_api_framework-0.9.3}/open_api_framework/templates/open_api_framework/admin/base_site.html +0 -0
  27. {open_api_framework-0.9.2 → open_api_framework-0.9.3}/open_api_framework/templates/open_api_framework/components/environment.html +0 -0
  28. {open_api_framework-0.9.2 → open_api_framework-0.9.3}/open_api_framework/templates/open_api_framework/components/version.html +0 -0
  29. {open_api_framework-0.9.2 → open_api_framework-0.9.3}/open_api_framework/templates/open_api_framework/env_config.rst +0 -0
  30. {open_api_framework-0.9.2 → open_api_framework-0.9.3}/open_api_framework/templatetags/__init__.py +0 -0
  31. {open_api_framework-0.9.2 → open_api_framework-0.9.3}/open_api_framework/templatetags/doc_tags.py +0 -0
  32. {open_api_framework-0.9.2 → open_api_framework-0.9.3}/open_api_framework/templatetags/open_api_framework.py +0 -0
  33. {open_api_framework-0.9.2 → open_api_framework-0.9.3}/open_api_framework/utils.py +0 -0
  34. {open_api_framework-0.9.2 → open_api_framework-0.9.3}/open_api_framework.egg-info/dependency_links.txt +0 -0
  35. {open_api_framework-0.9.2 → open_api_framework-0.9.3}/open_api_framework.egg-info/top_level.txt +0 -0
  36. {open_api_framework-0.9.2 → open_api_framework-0.9.3}/tests/test_admin.py +0 -0
  37. {open_api_framework-0.9.2 → open_api_framework-0.9.3}/tests/test_config_helpers.py +0 -0
@@ -1,6 +1,44 @@
1
1
  Changelog
2
2
  =========
3
3
 
4
+ 0.9.3 (2025-02-24)
5
+ ------------------
6
+
7
+ **Bugfixes**
8
+
9
+ * [#88] Automatically initialize Sentry when importing base settings and expose ``SENTRY_CONFIG`` setting
10
+
11
+ .. warning::
12
+
13
+ The ``init_sentry`` function was removed and now Sentry is initialized immediately in
14
+ ``open_api_framework/conf/base.py``. If your project requires additional parameters
15
+ to be specified (e.g. a ``before_send`` hook), it is best to reinitialize Sentry manually in your project's base setting:
16
+
17
+ .. code-block:: python
18
+
19
+ from open_api_framework.conf.base import * # noqa
20
+ from open_api_framework.conf.utils import get_sentry_integrations
21
+
22
+ from your_project.utils import before_send_hook
23
+
24
+ # Reinitialize Sentry to add the before_send hook
25
+ SENTRY_CONFIG["before_send"] = before_send_hook
26
+ sentry_sdk.init(
27
+ **SENTRY_CONFIG,
28
+ integrations=get_sentry_integrations(),
29
+ send_default_pii=True,
30
+ )
31
+
32
+
33
+ **Maintenance**
34
+
35
+ * [#90] bump commonground api version to 2.1.2
36
+
37
+ **Documentation**
38
+
39
+ * [#108] Mention in docs that importing anything from ``base.py`` causes all settings to be loaded
40
+
41
+
4
42
  0.9.2 (2025-01-02)
5
43
  ------------------
6
44
 
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: open_api_framework
3
- Version: 0.9.2
3
+ Version: 0.9.3
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
@@ -44,9 +44,8 @@ Requires-Dist: django-filter>=24.2
44
44
  Requires-Dist: drf-spectacular[sidecar]>=0.27.2
45
45
  Requires-Dist: django-csp>=3.8
46
46
  Requires-Dist: djangorestframework-inclusions>=1.2.0
47
- Requires-Dist: commonground-api-common>=1.12.1
47
+ Requires-Dist: commonground-api-common>=2.1.2
48
48
  Requires-Dist: mozilla-django-oidc-db>=0.19.0
49
- Requires-Dist: zgw-consumers>=0.27.0
50
49
  Requires-Dist: psycopg2>=2.9.9
51
50
  Requires-Dist: bleach>=6.1.0
52
51
  Requires-Dist: python-dotenv>=1.0.0
@@ -63,6 +62,7 @@ Requires-Dist: django-sessionprofile>=3.0.0
63
62
  Provides-Extra: tests
64
63
  Requires-Dist: pytest; extra == "tests"
65
64
  Requires-Dist: pytest-django; extra == "tests"
65
+ Requires-Dist: pytest-env; extra == "tests"
66
66
  Requires-Dist: tox; extra == "tests"
67
67
  Requires-Dist: isort; extra == "tests"
68
68
  Requires-Dist: black; extra == "tests"
@@ -80,7 +80,7 @@ Requires-Dist: twine; extra == "release"
80
80
  Open API Framework
81
81
  ==================
82
82
 
83
- :Version: 0.9.2
83
+ :Version: 0.9.3
84
84
  :Source: https://github.com/maykinmedia/open-api-framework
85
85
  :Keywords: metapackage, dependencies
86
86
 
@@ -1,7 +1,7 @@
1
1
  Open API Framework
2
2
  ==================
3
3
 
4
- :Version: 0.9.2
4
+ :Version: 0.9.3
5
5
  :Source: https://github.com/maykinmedia/open-api-framework
6
6
  :Keywords: metapackage, dependencies
7
7
 
@@ -2,7 +2,6 @@ import datetime
2
2
  import os
3
3
  import warnings
4
4
  from pathlib import Path
5
- from typing import Callable
6
5
 
7
6
  from django.urls import reverse_lazy
8
7
 
@@ -809,36 +808,29 @@ NOTIFICATIONS_DISABLED = config(
809
808
  #
810
809
  # SENTRY - error monitoring
811
810
  #
811
+ SENTRY_DSN = config(
812
+ "SENTRY_DSN",
813
+ None,
814
+ help_text=(
815
+ "URL of the sentry project to send error reports to. Default empty, "
816
+ "i.e. -> no monitoring set up. Highly recommended to configure this."
817
+ ),
818
+ auto_display_default=False,
819
+ )
812
820
 
821
+ if SENTRY_DSN:
822
+ SENTRY_CONFIG = {
823
+ "dsn": SENTRY_DSN,
824
+ "release": RELEASE or "RELEASE not set",
825
+ "environment": ENVIRONMENT,
826
+ }
813
827
 
814
- def init_sentry(before_send: Callable | None = None):
815
- SENTRY_DSN = config(
816
- "SENTRY_DSN",
817
- None,
818
- help_text=(
819
- "URL of the sentry project to send error reports to. Default empty, "
820
- "i.e. -> no monitoring set up. Highly recommended to configure this."
821
- ),
822
- auto_display_default=False,
828
+ sentry_sdk.init(
829
+ **SENTRY_CONFIG,
830
+ integrations=get_sentry_integrations(),
831
+ send_default_pii=True,
823
832
  )
824
833
 
825
- if SENTRY_DSN:
826
- SENTRY_CONFIG = {
827
- "dsn": SENTRY_DSN,
828
- "release": RELEASE or "RELEASE not set",
829
- "environment": ENVIRONMENT,
830
- }
831
-
832
- # Allow projects to define their own before_send filters
833
- if before_send:
834
- SENTRY_CONFIG["before_send"] = before_send
835
-
836
- sentry_sdk.init(
837
- **SENTRY_CONFIG,
838
- integrations=get_sentry_integrations(),
839
- send_default_pii=True,
840
- )
841
-
842
834
 
843
835
  #
844
836
  # CELERY
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: open_api_framework
3
- Version: 0.9.2
3
+ Version: 0.9.3
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
@@ -44,9 +44,8 @@ Requires-Dist: django-filter>=24.2
44
44
  Requires-Dist: drf-spectacular[sidecar]>=0.27.2
45
45
  Requires-Dist: django-csp>=3.8
46
46
  Requires-Dist: djangorestframework-inclusions>=1.2.0
47
- Requires-Dist: commonground-api-common>=1.12.1
47
+ Requires-Dist: commonground-api-common>=2.1.2
48
48
  Requires-Dist: mozilla-django-oidc-db>=0.19.0
49
- Requires-Dist: zgw-consumers>=0.27.0
50
49
  Requires-Dist: psycopg2>=2.9.9
51
50
  Requires-Dist: bleach>=6.1.0
52
51
  Requires-Dist: python-dotenv>=1.0.0
@@ -63,6 +62,7 @@ Requires-Dist: django-sessionprofile>=3.0.0
63
62
  Provides-Extra: tests
64
63
  Requires-Dist: pytest; extra == "tests"
65
64
  Requires-Dist: pytest-django; extra == "tests"
65
+ Requires-Dist: pytest-env; extra == "tests"
66
66
  Requires-Dist: tox; extra == "tests"
67
67
  Requires-Dist: isort; extra == "tests"
68
68
  Requires-Dist: black; extra == "tests"
@@ -80,7 +80,7 @@ Requires-Dist: twine; extra == "release"
80
80
  Open API Framework
81
81
  ==================
82
82
 
83
- :Version: 0.9.2
83
+ :Version: 0.9.3
84
84
  :Source: https://github.com/maykinmedia/open-api-framework
85
85
  :Keywords: metapackage, dependencies
86
86
 
@@ -31,4 +31,5 @@ open_api_framework/templatetags/doc_tags.py
31
31
  open_api_framework/templatetags/open_api_framework.py
32
32
  tests/test_admin.py
33
33
  tests/test_config_helpers.py
34
- tests/test_generate_envvar_docs.py
34
+ tests/test_generate_envvar_docs.py
35
+ tests/test_settings.py
@@ -12,9 +12,8 @@ django-filter>=24.2
12
12
  drf-spectacular[sidecar]>=0.27.2
13
13
  django-csp>=3.8
14
14
  djangorestframework-inclusions>=1.2.0
15
- commonground-api-common>=1.12.1
15
+ commonground-api-common>=2.1.2
16
16
  mozilla-django-oidc-db>=0.19.0
17
- zgw-consumers>=0.27.0
18
17
  psycopg2>=2.9.9
19
18
  bleach>=6.1.0
20
19
  python-dotenv>=1.0.0
@@ -43,6 +42,7 @@ twine
43
42
  [tests]
44
43
  pytest
45
44
  pytest-django
45
+ pytest-env
46
46
  tox
47
47
  isort
48
48
  black
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "open_api_framework"
7
- version = "0.9.2"
7
+ version = "0.9.3"
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"}
@@ -41,9 +41,8 @@ dependencies = [
41
41
  "drf-spectacular[sidecar]>=0.27.2",
42
42
  "django-csp>=3.8",
43
43
  "djangorestframework-inclusions>=1.2.0",
44
- "commonground-api-common>=1.12.1",
44
+ "commonground-api-common>=2.1.2",
45
45
  "mozilla-django-oidc-db>=0.19.0",
46
- "zgw-consumers>=0.27.0",
47
46
  "psycopg2>=2.9.9",
48
47
  "bleach>=6.1.0",
49
48
  "python-dotenv>=1.0.0",
@@ -69,6 +68,7 @@ Documentation = "http://open_api_framework.readthedocs.io/en/latest/"
69
68
  tests = [
70
69
  "pytest",
71
70
  "pytest-django",
71
+ "pytest-env",
72
72
  "tox",
73
73
  "isort",
74
74
  "black",
@@ -100,10 +100,15 @@ sections=["FUTURE", "STDLIB", "DJANGO", "THIRDPARTY", "FIRSTPARTY", "LOCALFOLDER
100
100
 
101
101
  [tool.pytest.ini_options]
102
102
  testpaths = ["tests"]
103
- DJANGO_SETTINGS_MODULE = "testapp.settings"
103
+ pythonpath = "."
104
+ env = [
105
+ "DJANGO_SETTINGS_MODULE=testapp.settings",
106
+ "SECRET_KEY=not-so-secret",
107
+ "SENTRY_DSN=https://public@sentry.example.com/1"
108
+ ]
104
109
 
105
110
  [tool.bumpversion]
106
- current_version = "0.9.2"
111
+ current_version = "0.9.3"
107
112
  files = [
108
113
  {filename = "pyproject.toml"},
109
114
  {filename = "README.rst"},
@@ -1,6 +1,6 @@
1
1
  [flake8]
2
2
  max-line-length = 119
3
- exclude = env,.tox,doc
3
+ exclude = env,.tox,doc,tests/test_generate_envvar_docs.py
4
4
 
5
5
  [egg_info]
6
6
  tag_build =
@@ -0,0 +1,159 @@
1
+ from unittest.mock import mock_open, patch
2
+
3
+ from django.core.management import call_command
4
+
5
+ EXPECTED_OUTPUT = """\
6
+ .. _installation_env_config:
7
+
8
+ ===================================
9
+ Environment configuration reference
10
+ ===================================
11
+
12
+
13
+
14
+ Available environment variables
15
+ ===============================
16
+
17
+
18
+ Required
19
+ --------
20
+
21
+ * ``SECRET_KEY``: Secret key that's used for certain cryptographic utilities. Defaults to: ``so-secret-i-cant-believe-you-are-looking-at-this``.
22
+ * ``ALLOWED_HOSTS``: a comma separated (without spaces!) list of domains that serve the installation. Used to protect against Host header attacks. Defaults to: ``(empty string)``.
23
+ * ``CACHE_DEFAULT``: redis cache address for the default cache (this **MUST** be set when using Docker). Defaults to: ``localhost:6379/0``.
24
+ * ``CACHE_AXES``: redis cache address for the brute force login protection cache (this **MUST** be set when using Docker). Defaults to: ``localhost:6379/0``.
25
+ * ``EMAIL_HOST``: hostname for the outgoing e-mail server (this **MUST** be set when using Docker). Defaults to: ``localhost``.
26
+
27
+
28
+ Database
29
+ --------
30
+
31
+ * ``DB_NAME``: name of the PostgreSQL database. Defaults to: ``testapp``.
32
+ * ``DB_USER``: username of the database user. Defaults to: ``testapp``.
33
+ * ``DB_PASSWORD``: password of the database user. Defaults to: ``testapp``.
34
+ * ``DB_HOST``: hostname of the PostgreSQL database. Defaults to ``db`` for the docker environment, otherwise defaults to ``localhost``.
35
+ * ``DB_PORT``: port number of the database. Defaults to: ``5432``.
36
+
37
+
38
+ Cross-Origin-Resource-Sharing
39
+ -----------------------------
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: ``[]``.
45
+
46
+
47
+ Celery
48
+ ------
49
+
50
+ * ``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
+
52
+
53
+ Elastic APM
54
+ -----------
55
+
56
+ * ``ELASTIC_APM_SERVER_URL``: URL where Elastic APM is hosted. Defaults to: ``None``.
57
+ * ``ELASTIC_APM_SERVICE_NAME``: Name of the service for this application in Elastic APM. Defaults to ``testapp - <environment>``.
58
+ * ``ELASTIC_APM_SECRET_TOKEN``: Token used to communicate with Elastic APM. Defaults to: ``default``.
59
+ * ``ELASTIC_APM_TRANSACTION_SAMPLE_RATE``: By default, the agent will sample every transaction (e.g. request to your service). To reduce overhead and storage requirements, set the sample rate to a value between 0.0 and 1.0. Defaults to: ``0.1``.
60
+
61
+
62
+ Content Security Policy
63
+ -----------------------
64
+
65
+ * ``CSP_EXTRA_DEFAULT_SRC``: Extra default source URLs for CSP other than ``self``. Used for ``img-src``, ``style-src`` and ``script-src``. Defaults to: ``[]``.
66
+ * ``CSP_REPORT_URI``: URI of the``report-uri`` directive. Defaults to: ``None``.
67
+ * ``CSP_REPORT_PERCENTAGE``: Percentage of requests that get the ``report-uri`` directive. Defaults to: ``0``.
68
+ * ``CSP_EXTRA_FORM_ACTION``: Add additional ``form-action`` source to the default . Defaults to: ``[]``.
69
+ * ``CSP_FORM_ACTION``: Override the default ``form-action`` source. Defaults to: ``['"\\'self\\'"']``.
70
+ * ``CSP_EXTRA_IMG_SRC``: Extra ``img-src`` sources for CSP other than ``CSP_DEFAULT_SRC``. Defaults to: ``[]``.
71
+ * ``CSP_OBJECT_SRC``: ``object-src`` urls. Defaults to: ``['"\\'none\\'"']``.
72
+
73
+
74
+ Optional
75
+ --------
76
+
77
+ * ``SITE_ID``: The database ID of the site object. You usually won't have to touch this. Defaults to: ``1``.
78
+ * ``DEBUG``: Only set this to ``True`` on a local development environment. Various other security settings are derived from this setting!. Defaults to: ``False``.
79
+ * ``USE_X_FORWARDED_HOST``: whether to grab the domain/host from the X-Forwarded-Host header or not. This header is typically set by reverse proxies (such as nginx, traefik, Apache...). Note: this is a header that can be spoofed and you need to ensure you control it before enabling this. Defaults to: ``False``.
80
+ * ``IS_HTTPS``: Used to construct absolute URLs and controls a variety of security settings. Defaults to the inverse of ``DEBUG``.
81
+ * ``EMAIL_PORT``: port number of the outgoing e-mail server. Note that if you're on Google Cloud, sending e-mail via port 25 is completely blocked and you should use 487 for TLS. Defaults to: ``25``.
82
+ * ``EMAIL_HOST_USER``: username to connect to the mail server. Defaults to: ``(empty string)``.
83
+ * ``EMAIL_HOST_PASSWORD``: password to connect to the mail server. Defaults to: ``(empty string)``.
84
+ * ``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
+ * ``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
+ * ``SESSION_COOKIE_AGE``: For how long, in seconds, the session cookie will be valid. Defaults to: ``1209600``.
92
+ * ``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
+ * ``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``.
94
+ * ``ENVIRONMENT``: An identifier for the environment, displayed in the admin depending on the settings module used and included in the error monitoring (see ``SENTRY_DSN``). The default is set according to ``DJANGO_SETTINGS_MODULE``.
95
+ * ``SUBPATH``: If hosted on a subpath, provide the value here. If you provide ``/gateway``, the component assumes its running at the base URL: ``https://somedomain/gateway/``. Defaults to an empty string. Defaults to: ``None``.
96
+ * ``RELEASE``: The version number or commit hash of the application (this is also sent to Sentry).
97
+ * ``NUM_PROXIES``: the number of reverse proxies in front of the application, as an integer. This is used to determine the actual client IP adres. On Kubernetes with an ingress you typically want to set this to 2. Defaults to: ``1``.
98
+ * ``CSRF_TRUSTED_ORIGINS``: A list of trusted origins for unsafe requests (e.g. POST). Defaults to: ``[]``.
99
+ * ``NOTIFICATIONS_DISABLED``: indicates whether or not notifications should be sent to the Notificaties API for operations on the API endpoints. Defaults to ``True`` for the ``dev`` environment, otherwise defaults to ``False``.
100
+ * ``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.
101
+ * ``DISABLE_2FA``: Whether or not two factor authentication should be disabled. Defaults to: ``False``.
102
+ * ``LOG_OUTGOING_REQUESTS_EMIT_BODY``: Whether or not outgoing request bodies should be logged. Defaults to: ``True``.
103
+ * ``LOG_OUTGOING_REQUESTS_DB_SAVE``: Whether or not outgoing request logs should be saved to the database. Defaults to: ``False``.
104
+ * ``LOG_OUTGOING_REQUESTS_DB_SAVE_BODY``: Whether or not outgoing request bodies should be saved to the database. Defaults to: ``True``.
105
+ * ``LOG_OUTGOING_REQUESTS_MAX_AGE``: The amount of time after which request logs should be deleted from the database. Defaults to: ``7``.
106
+
107
+
108
+
109
+
110
+
111
+ Specifying the environment variables
112
+ =====================================
113
+
114
+ There are two strategies to specify the environment variables:
115
+
116
+ * provide them in a ``.env`` file
117
+ * start the component processes (with uwsgi/gunicorn/celery) in a process
118
+ manager that defines the environment variables
119
+
120
+ Providing a .env file
121
+ ---------------------
122
+
123
+ This is the most simple setup and easiest to debug. The ``.env`` file must be
124
+ at the root of the project - i.e. on the same level as the ``src`` directory (
125
+ NOT *in* the ``src`` directory).
126
+
127
+ The syntax is key-value:
128
+
129
+ .. code::
130
+
131
+ SOME_VAR=some_value
132
+ OTHER_VAR="quoted_value"
133
+
134
+
135
+ Provide the envvars via the process manager
136
+ -------------------------------------------
137
+
138
+ If you use a process manager (such as supervisor/systemd), use their techniques
139
+ to define the envvars. The component will pick them up out of the box.
140
+ """
141
+
142
+
143
+ def test_generate_envvar_docs():
144
+ mock_file = mock_open()
145
+ with patch(
146
+ "open_api_framework.management.commands.generate_envvar_docs.open", mock_file
147
+ ):
148
+ call_command(
149
+ "generate_envvar_docs", file="some/file/path.txt", exclude_group="Excluded"
150
+ )
151
+
152
+ mock_file.assert_called_once_with("some/file/path.txt", "w")
153
+
154
+ handle = mock_file()
155
+
156
+ # Check the entire content written to the mock file
157
+ written_content = "".join(call.args[0] for call in handle.write.call_args_list)
158
+
159
+ assert written_content == EXPECTED_OUTPUT
@@ -0,0 +1,8 @@
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
@@ -1,85 +0,0 @@
1
- from unittest.mock import mock_open, patch
2
-
3
- from django.core.management import call_command
4
-
5
- EXPECTED_OUTPUT = """\
6
- .. _installation_env_config:
7
-
8
- ===================================
9
- Environment configuration reference
10
- ===================================
11
-
12
-
13
-
14
- Available environment variables
15
- ===============================
16
-
17
-
18
- Required
19
- --------
20
-
21
- * ``SECRET_KEY``: Secret key that's used for certain cryptographic utilities. Defaults to: \
22
- ``so-secret-i-cant-believe-you-are-looking-at-this``.
23
-
24
-
25
- Optional
26
- --------
27
-
28
- * ``DEBUG``: Only set this to ``True`` on a local development environment. Various other \
29
- security settings are derived from this setting!. Defaults to: ``False``.
30
- * ``IS_HTTPS``: Used to construct absolute URLs and controls a variety of security settings. \
31
- Defaults to the inverse of ``DEBUG``.
32
-
33
-
34
-
35
-
36
-
37
- Specifying the environment variables
38
- =====================================
39
-
40
- There are two strategies to specify the environment variables:
41
-
42
- * provide them in a ``.env`` file
43
- * start the component processes (with uwsgi/gunicorn/celery) in a process
44
- manager that defines the environment variables
45
-
46
- Providing a .env file
47
- ---------------------
48
-
49
- This is the most simple setup and easiest to debug. The ``.env`` file must be
50
- at the root of the project - i.e. on the same level as the ``src`` directory (
51
- NOT *in* the ``src`` directory).
52
-
53
- The syntax is key-value:
54
-
55
- .. code::
56
-
57
- SOME_VAR=some_value
58
- OTHER_VAR="quoted_value"
59
-
60
-
61
- Provide the envvars via the process manager
62
- -------------------------------------------
63
-
64
- If you use a process manager (such as supervisor/systemd), use their techniques
65
- to define the envvars. The component will pick them up out of the box.
66
- """
67
-
68
-
69
- def test_generate_envvar_docs():
70
- mock_file = mock_open()
71
- with patch(
72
- "open_api_framework.management.commands.generate_envvar_docs.open", mock_file
73
- ):
74
- call_command(
75
- "generate_envvar_docs", file="some/file/path.txt", exclude_group="Excluded"
76
- )
77
-
78
- mock_file.assert_called_once_with("some/file/path.txt", "w")
79
-
80
- handle = mock_file()
81
-
82
- # Check the entire content written to the mock file
83
- written_content = "".join(call.args[0] for call in handle.write.call_args_list)
84
-
85
- assert written_content == EXPECTED_OUTPUT