mirror of
https://github.com/pretix/pretix.git
synced 2026-05-04 15:04:03 +00:00
Add session pinning by country (#3233)
This commit is contained in:
@@ -47,6 +47,7 @@ from django_otp.oath import TOTP
|
||||
from django_otp.plugins.otp_totp.models import TOTPDevice
|
||||
|
||||
from pretix.base.models import U2FDevice, User
|
||||
from pretix.helpers import security
|
||||
|
||||
|
||||
class LoginFormTest(TestCase):
|
||||
@@ -797,6 +798,25 @@ class SessionTimeOutTest(TestCase):
|
||||
response = self.client.get('/control/')
|
||||
self.assertEqual(response.status_code, 302)
|
||||
|
||||
@override_settings(HAS_GEOIP=True)
|
||||
def test_pinned_country(self):
|
||||
class FakeGeoIp:
|
||||
def country(self, ip):
|
||||
if ip == '1.2.3.4':
|
||||
return {'country_code': 'DE'}
|
||||
return {'country_code': 'US'}
|
||||
|
||||
security._geoip = FakeGeoIp()
|
||||
self.client.defaults['REMOTE_ADDR'] = '1.2.3.4'
|
||||
response = self.client.get('/control/')
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
self.client.defaults['REMOTE_ADDR'] = '4.3.2.1'
|
||||
response = self.client.get('/control/')
|
||||
self.assertEqual(response.status_code, 302)
|
||||
|
||||
security._geoip = None
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def user():
|
||||
|
||||
Reference in New Issue
Block a user