Coverage for webapp/config.py: 93%

27 statements  

« prev     ^ index     » next       coverage.py v7.10.6, created at 2025-09-17 22:07 +0000

1import os 

2from canonicalwebteam.flask_base.env import load_plain_env_variables 

3 

4 

5class ConfigurationError(Exception): 

6 pass 

7 

8 

9# Load the prefixed FLASK_* env vars into env vars without the prefix. We have 

10# to do this explicitly here because otherwise the config module is imported 

11# by other files before the FlaskBase app gets initialized and does this by 

12# itself, meaning that the variables below are not set correctly 

13load_plain_env_variables() 

14 

15SECRET_KEY = os.getenv("SECRET_KEY") 

16LOGIN_URL = os.getenv("LOGIN_URL", "https://login.ubuntu.com") 

17BSI_URL = os.getenv("BSI_URL", "https://build.snapcraft.io") 

18ENVIRONMENT = os.getenv("ENVIRONMENT", "devel") 

19IS_DEVELOPMENT = ENVIRONMENT == "devel" 

20COMMIT_ID = os.getenv("COMMIT_ID", "commit_id") 

21SENTRY_DSN = os.getenv("SENTRY_DSN", "").strip() 

22SENTRY_CONFIG = {"release": COMMIT_ID, "environment": ENVIRONMENT} 

23DNS_VERIFICATION_SALT = os.getenv("DNS_VERIFICATION_SALT") 

24VITE_PORT = os.getenv("VITE_PORT", 5173) 

25VITE_OUTPUT_DIR = os.getenv("VITE_OUTPUT_DIR", "static/js/dist/vite") 

26 

27if ENVIRONMENT != "devel": 

28 SESSION_COOKIE_SAMESITE = "None" 

29 SESSION_COOKIE_SECURE = True 

30 

31WEBAPP_CONFIG = {"LAYOUT": "_layout.html", "STORE_NAME": "Snap store"} 

32 

33WEBAPP_EXTRA_HEADERS = {} 

34 

35# Ten years default cache time on static files 

36SEND_FILE_MAX_AGE_DEFAULT = 10 * 365 * 24 * 60 * 60 

37 

38CONTENT_DIRECTORY = {"PUBLISHER_PAGES": "store/content/publishers/"} 

39 

40# Docs search 

41SEARCH_API_KEY = os.getenv("SEARCH_API_KEY") 

42SEARCH_API_URL = "https://www.googleapis.com/customsearch/v1" 

43SEARCH_CUSTOM_ID = "009048213575199080868:i3zoqdwqk8o" 

44 

45APP_NAME = "snapcraft"