square-administration 3.2.0__py3-none-any.whl → 3.2.1__py3-none-any.whl

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.
@@ -23,6 +23,9 @@ try:
23
23
  # environment
24
24
  config_str_host_ip = ldict_configuration["ENVIRONMENT"]["HOST_IP"]
25
25
  config_int_host_port = int(ldict_configuration["ENVIRONMENT"]["HOST_PORT"])
26
+ config_list_allow_origins = eval(
27
+ ldict_configuration["ENVIRONMENT"]["ALLOW_ORIGINS"]
28
+ )
26
29
  config_str_log_file_name = ldict_configuration["ENVIRONMENT"]["LOG_FILE_NAME"]
27
30
  config_str_admin_password_hash = ldict_configuration["ENVIRONMENT"][
28
31
  "ADMIN_PASSWORD_HASH"
@@ -36,11 +39,8 @@ try:
36
39
  ]
37
40
  config_str_cookie_domain = ldict_configuration["ENVIRONMENT"]["COOKIE_DOMAIN"]
38
41
  config_str_db_ip = ldict_configuration["ENVIRONMENT"]["DB_IP"]
39
-
40
42
  config_int_db_port = int(ldict_configuration["ENVIRONMENT"]["DB_PORT"])
41
-
42
43
  config_str_db_username = ldict_configuration["ENVIRONMENT"]["DB_USERNAME"]
43
-
44
44
  config_str_db_password = ldict_configuration["ENVIRONMENT"]["DB_PASSWORD"]
45
45
  # ===========================================
46
46
 
@@ -5,6 +5,7 @@ APP_NAME = square_admin
5
5
  [ENVIRONMENT]
6
6
  HOST_IP = 0.0.0.0
7
7
  HOST_PORT = 10111
8
+ ALLOW_ORIGINS = ["http://localhost:10111"]
8
9
 
9
10
  LOG_FILE_NAME = square_administration
10
11
 
@@ -5,6 +5,7 @@ APP_NAME = square_admin
5
5
  [ENVIRONMENT]
6
6
  HOST_IP = 0.0.0.0
7
7
  HOST_PORT = 10111
8
+ ALLOW_ORIGINS = ["http://localhost:10111"]
8
9
 
9
10
  LOG_FILE_NAME = square_administration
10
11
 
@@ -11,6 +11,7 @@ from square_administration.configuration import (
11
11
  config_str_module_name,
12
12
  config_str_ssl_key_file_path,
13
13
  config_str_ssl_crt_file_path,
14
+ config_list_allow_origins,
14
15
  )
15
16
  from square_administration.routes import core, authentication
16
17
  from square_administration.utils.common import is_https
@@ -20,7 +21,7 @@ app = FastAPI()
20
21
  app.add_middleware(
21
22
  CORSMiddleware,
22
23
  allow_credentials=True,
23
- allow_origins=["*"],
24
+ allow_origins=config_list_allow_origins,
24
25
  allow_methods=["*"],
25
26
  allow_headers=["*"],
26
27
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: square-administration
3
- Version: 3.2.0
3
+ Version: 3.2.1
4
4
  Summary: common business layer for my personal server.
5
5
  Home-page: https://github.com/thepmsquare/square_administration
6
6
  Author: thePmSquare
@@ -44,6 +44,13 @@ pip install square_administration
44
44
 
45
45
  ## changelog
46
46
 
47
+ ### v3.2.1
48
+
49
+ - testing
50
+ - update get_patched_configuration and create_client_and_cleanup to be session scoped.
51
+ - env
52
+ - add ALLOW_ORIGINS
53
+
47
54
  ### v3.2.0
48
55
 
49
56
  - move global_int_app_id getting logic from configuration.py to utils->common
@@ -1,9 +1,9 @@
1
1
  square_administration/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- square_administration/configuration.py,sha256=u3MB-vHaKMIPz0ccBrgehRNdC3wvhn06XNxEEnCM284,4332
3
- square_administration/main.py,sha256=jQqoNCfO4X6U8GoqEzn8BD9FhSPRM8PXMptv7uIPTKs,1609
2
+ square_administration/configuration.py,sha256=kP2zfEvt-knzrzFIeINI1kz7260eXz_DbNjIjakByEY,4433
3
+ square_administration/main.py,sha256=vvKBMn4JkDp8B2L_zwBMIfYaSA41rXxhL3ZFsSv8ly8,1660
4
4
  square_administration/messages.py,sha256=VYjJGW0Kvtjrx1Mw7ekksLVMoxcexLol2OckvqhZ3n0,1063
5
- square_administration/data/config.ini,sha256=mPO_mTQU2RT3d6re-SY7Ip7zcUXjxehCRntN857ncMw,1102
6
- square_administration/data/config.testing.ini,sha256=byHvkFGaShkU-Oh0DBa5w1mbT284PlQV_8mqY4hsnis,1150
5
+ square_administration/data/config.ini,sha256=kkSbjJP7qR8ah44Oyv2IyCgYfmheYYh4zSU7wD7v3ec,1145
6
+ square_administration/data/config.testing.ini,sha256=vdW01yJdCqdI6uK-jXHfWa9B9IJVuecYdx0n3y7dS2k,1193
7
7
  square_administration/pydantic_models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
8
  square_administration/pydantic_models/authentication.py,sha256=QEfM5ezG45hc_qATXpFIPNPl4bjf8ICW_bY5tY4cqO4,259
9
9
  square_administration/pydantic_models/core.py,sha256=HUMrBmfKrXeL-126gE5j2povdVmktn8XLg2tHEdeXTk,344
@@ -13,9 +13,9 @@ square_administration/routes/core.py,sha256=H5pfPuPDzSn8-HN40gyI7eDVxFW7821urYq0
13
13
  square_administration/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
14
14
  square_administration/utils/common.py,sha256=bnyBF10EDMLIYXnfV3ZZOApNKScHRmw-Jcj2zIFE8kE,1157
15
15
  tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
- tests/conftest.py,sha256=KJoXQBlfbyyep60EDWAzLMhV1QpWezPmCGE6FCF7JVE,1767
16
+ tests/conftest.py,sha256=Lu7qQkrnSeV1WKlN0zVyNLLXRf3Sv8ghPlIWAByv1NQ,1921
17
17
  tests/test_1.py,sha256=hikxL01-2dcax594y8ceanjRmLJXvuhLpcY-FMPIdY8,378
18
- square_administration-3.2.0.dist-info/METADATA,sha256=2hiyaCyFxPbFZiQ2w38Mrzi9w6qHbAsRPNVfTJhnXOM,2867
19
- square_administration-3.2.0.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
20
- square_administration-3.2.0.dist-info/top_level.txt,sha256=tyroqpdXXQAiA7Y_V1wCqPPt6nnS_orcY9txLeHjm1s,28
21
- square_administration-3.2.0.dist-info/RECORD,,
18
+ square_administration-3.2.1.dist-info/METADATA,sha256=NzJek8yM3W4b1tqj7kRkXvXxc7-HhWnvmcZN6PQQLQM,3011
19
+ square_administration-3.2.1.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
20
+ square_administration-3.2.1.dist-info/top_level.txt,sha256=tyroqpdXXQAiA7Y_V1wCqPPt6nnS_orcY9txLeHjm1s,28
21
+ square_administration-3.2.1.dist-info/RECORD,,
tests/conftest.py CHANGED
@@ -1,30 +1,34 @@
1
+ import importlib
1
2
  import os
2
3
 
3
4
  import pytest
4
5
  from fastapi.testclient import TestClient
5
6
 
6
7
 
7
- def patched_join(*args):
8
+ @pytest.fixture(scope="session")
9
+ def get_patched_configuration():
10
+ def patched_join(*args):
11
+ *rest, last = args
12
+ if last == "config.ini":
13
+ last = "config.testing.ini"
8
14
 
9
- *rest, last = args
10
- if last == "config.ini":
11
- last = "config.testing.ini"
15
+ return original_join(*rest, last)
12
16
 
13
- return original_join(*rest, last)
17
+ original_join = os.path.join
18
+ os.path.join = patched_join
14
19
 
20
+ import square_administration.configuration
15
21
 
16
- original_join = os.path.join
17
-
22
+ importlib.reload(square_administration.configuration)
23
+ config = square_administration.configuration
18
24
 
19
- @pytest.fixture
20
- def get_patched_configuration(monkeypatch, tmp_path):
21
- monkeypatch.setattr(os.path, "join", patched_join)
22
- import square_administration.configuration
25
+ yield config
23
26
 
24
- return square_administration.configuration
27
+ # cleanup
28
+ os.path.join = original_join
25
29
 
26
30
 
27
- @pytest.fixture
31
+ @pytest.fixture(scope="session")
28
32
  def create_client_and_cleanup(get_patched_configuration):
29
33
  from square_database_structure import create_database_and_tables
30
34