tests: ensure testserver is used as host name in all tests (#44055)
testserver is the default name in the Django test client and in django-webtest. Constraint on django-webtest in tox.ini is relaxed to make app.set_cookie() works for test on cookies.
This commit is contained in:
parent
862673a793
commit
47ee640f79
|
@ -78,7 +78,7 @@ def app(request, db):
|
|||
wtm = django_webtest.WebTestMixin()
|
||||
wtm._patch_settings()
|
||||
request.addfinalizer(wtm._unpatch_settings)
|
||||
return django_webtest.DjangoTestApp(extra_environ={'HTTP_HOST': 'localhost'})
|
||||
return django_webtest.DjangoTestApp(extra_environ={'HTTP_HOST': 'testserver'})
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
|
|
@ -54,7 +54,7 @@ def app_factory():
|
|||
wtm = django_webtest.WebTestMixin()
|
||||
wtm._patch_settings()
|
||||
try:
|
||||
def factory(hostname='localhost'):
|
||||
def factory(hostname='testserver'):
|
||||
return django_webtest.DjangoTestApp(extra_environ={'HTTP_HOST': hostname})
|
||||
yield factory
|
||||
finally:
|
||||
|
|
|
@ -39,7 +39,7 @@ if 'postgres' in DATABASES['default']['ENGINE']:
|
|||
DATABASES['default'][key[2:]] = os.environ[key]
|
||||
|
||||
|
||||
ALLOWED_HOSTS = ALLOWED_HOSTS + ['example.net', 'cache1.example.com', 'cache2.example.com']
|
||||
ALLOWED_HOSTS = ALLOWED_HOSTS + ['testserver', 'example.net', 'cache1.example.com', 'cache2.example.com']
|
||||
|
||||
A2_AUTH_KERBEROS_ENABLED = False
|
||||
|
||||
|
@ -50,7 +50,7 @@ A2_HOOKS_PROPAGATE_EXCEPTIONS = True
|
|||
TEMPLATES[0]['DIRS'].append('tests/templates')
|
||||
TEMPLATES[0]['OPTIONS']['debug'] = True
|
||||
|
||||
SITE_BASE_URL = 'http://localhost'
|
||||
SITE_BASE_URL = 'http://testserver'
|
||||
|
||||
A2_MAX_EMAILS_PER_IP = None
|
||||
A2_MAX_EMAILS_FOR_ADDRESS = None
|
||||
|
|
|
@ -1295,7 +1295,7 @@ def test_api_get_role_list(app, admin_ou1, role_ou1, role_random):
|
|||
|
||||
|
||||
def test_no_opened_session_cookie_on_api(app, user, settings):
|
||||
settings.A2_OPENED_SESSION_COOKIE_DOMAIN = 'localhost'
|
||||
settings.A2_OPENED_SESSION_COOKIE_DOMAIN = 'testserver'
|
||||
app.authorization = ('Basic', (user.username, user.username))
|
||||
resp = app.get('/api/users/')
|
||||
assert 'A2_OPENED_SESSION' not in app.cookies
|
||||
|
|
|
@ -168,7 +168,7 @@ def test_clean_unused_account_login_url(simple_user, mailoutbox):
|
|||
simple_user.save()
|
||||
management.call_command('clean-unused-accounts')
|
||||
mail = mailoutbox[0]
|
||||
assert 'href="http://localhost/login/"' in mail.message().as_string()
|
||||
assert 'href="http://testserver/login/"' in mail.message().as_string()
|
||||
|
||||
|
||||
def test_cleanupauthentic(db):
|
||||
|
|
|
@ -154,7 +154,7 @@ class SamlSP(object):
|
|||
self.base_url = 'https://sp.example.com'
|
||||
self.name = 'Test SP'
|
||||
self.slug = 'test-sp'
|
||||
self.idp_entity_idp = 'http://localhost/idp/saml2/metadata',
|
||||
self.idp_entity_idp = 'http://testserver/idp/saml2/metadata',
|
||||
self.default_name_id_format = 'email'
|
||||
self.accepted_name_id_format = ['email', 'persistent', 'transient', 'username']
|
||||
self.ou = OrganizationalUnit.objects.get()
|
||||
|
|
|
@ -668,7 +668,7 @@ def test_reset_password_ldap_user(slapd, settings, app, db):
|
|||
assert user.email == EMAIL
|
||||
# logout
|
||||
response = response.click('Logout')
|
||||
if response.status_code == 200: # Django 1.7, same_origin is bugged; localhost != localhost:80
|
||||
if response.status_code == 200: # Django 1.7, same_origin is bugged; testserver != localhost:80
|
||||
response = response.form.submit().maybe_follow()
|
||||
else:
|
||||
response = response.maybe_follow()
|
||||
|
|
Loading…
Reference in New Issue