File tree 2 files changed +32
-1
lines changed
2 files changed +32
-1
lines changed Original file line number Diff line number Diff line change 20
20
# Run WSGI handler for the application
21
21
application = WSGIHandler ()
22
22
23
+
24
+ warmup_host_name = settings .ALLOWED_HOSTS [0 ] if settings .ALLOWED_HOSTS [0 ] != "*" else "127.0.0.1"
25
+
23
26
# trigger a warmup of the application
24
27
application (
25
28
{
26
29
"PATH_INFO" : reverse ("sentry-warmup" ),
27
30
"REQUEST_METHOD" : "GET" ,
28
- "SERVER_NAME" : "127.0.0.1" ,
31
+ "SERVER_NAME" : warmup_host_name ,
29
32
"SERVER_PORT" : "9001" ,
30
33
"wsgi.input" : io .BytesIO (),
31
34
"wsgi.url_scheme" : "https" ,
Original file line number Diff line number Diff line change @@ -42,3 +42,31 @@ def test_wsgi_init():
42
42
subprocess .check_call (
43
43
[sys .executable , "-c" , SUBPROCESS_TEST_WGI_WARMUP ],
44
44
)
45
+
46
+
47
+ SUBPROCESS_TEST_WGI_WARMUP_WITH_SUBDOMAIN = f"""
48
+ import sys
49
+ from django.conf import settings
50
+ from sentry.runner import configure
51
+ configure()
52
+ settings.ALLOWED_HOSTS = [".test.com"]
53
+
54
+ import sentry.wsgi
55
+ { assert_in_sys_modules }
56
+ import django.urls.resolvers
57
+ from django.conf import settings
58
+ resolver = django.urls.resolvers.get_resolver()
59
+ assert resolver._populated is True
60
+ for lang, _ in settings.LANGUAGES:
61
+ assert lang in resolver._reverse_dict
62
+ """
63
+
64
+
65
+ def test_wsgi_init_with_subdomain ():
66
+ """
67
+ In production, we have settings.ALLOWED_HOSTS set, so override it for this test
68
+ and ensure that the wsgi.py file correctly pre-loads the application it set.
69
+ """
70
+ subprocess .check_call (
71
+ [sys .executable , "-c" , SUBPROCESS_TEST_WGI_WARMUP_WITH_SUBDOMAIN ],
72
+ )
You can’t perform that action at this time.
0 commit comments