Skip to content

Commit c69fdad

Browse files
Copilotkuboschek
andcommitted
Fix tests to use testserver host for URL validation
Co-authored-by: kuboschek <1071495+kuboschek@users.noreply.github.com>
1 parent 9ba74f8 commit c69fdad

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

custom_auth/tests/test_02_login_redirect.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ def test_redirect_with_next_parameter(self):
2929
'token': token,
3030
'next': '/payments/'
3131
})
32+
# Set the host for URL validation (use testserver for test compatibility)
33+
request.META['HTTP_HOST'] = 'testserver'
3234

3335
with mock.patch('custom_auth.views.authenticate', return_value=self.user):
3436
with mock.patch('custom_auth.views.login'):
@@ -46,6 +48,8 @@ def test_redirect_without_next_parameter(self):
4648
request = self.factory.post('/auth/magic/', {
4749
'token': token
4850
})
51+
# Set the host for URL validation (use testserver for test compatibility)
52+
request.META['HTTP_HOST'] = 'testserver'
4953

5054
with mock.patch('custom_auth.views.authenticate', return_value=self.user):
5155
with mock.patch('custom_auth.views.login'):
@@ -64,6 +68,8 @@ def test_redirect_with_empty_next_parameter(self):
6468
'token': token,
6569
'next': ''
6670
})
71+
# Set the host for URL validation (use testserver for test compatibility)
72+
request.META['HTTP_HOST'] = 'testserver'
6773

6874
with mock.patch('custom_auth.views.authenticate', return_value=self.user):
6975
with mock.patch('custom_auth.views.login'):
@@ -82,6 +88,8 @@ def test_redirect_blocks_external_urls(self):
8288
'token': token,
8389
'next': 'https://evil.com/phishing'
8490
})
91+
# Set the host for URL validation (use testserver for test compatibility)
92+
request.META['HTTP_HOST'] = 'testserver'
8593

8694
with mock.patch('custom_auth.views.authenticate', return_value=self.user):
8795
with mock.patch('custom_auth.views.login'):

0 commit comments

Comments
 (0)