2013-01-10 19:05:53 +01:00
|
|
|
import os
|
2016-10-06 01:42:24 +02:00
|
|
|
# test_settings.py works differently from
|
|
|
|
# dev_settings.py/prod_settings.py; it actually is directly referenced
|
|
|
|
# by the test suite as DJANGO_SETTINGS_MODULE and imports settings.py
|
|
|
|
# directly and then hacks up the values that are different for the
|
|
|
|
# test suite. As will be explained, this is kinda messy and probably
|
|
|
|
# we'd be better off switching it to work more like dev_settings.py,
|
|
|
|
# but for now, this is what we have.
|
|
|
|
#
|
|
|
|
# An important downside of the test_settings.py approach is that if we
|
|
|
|
# want to change any settings that settings.py then computes
|
|
|
|
# additional settings from (e.g. EXTERNAL_HOST), we need to do a hack
|
|
|
|
# like the below line(s) before we import from settings, for
|
|
|
|
# transmitting the value of EXTERNAL_HOST to dev_settings.py so that
|
|
|
|
# it can be set there, at the right place in the settings.py flow.
|
|
|
|
# Ick.
|
|
|
|
if os.getenv("EXTERNAL_HOST") is None:
|
|
|
|
os.environ["EXTERNAL_HOST"] = "testserver"
|
|
|
|
from .settings import *
|
2012-10-02 17:57:46 +02:00
|
|
|
|
2019-08-30 00:21:36 +02:00
|
|
|
FAKE_EMAIL_DOMAIN = "zulip.testserver"
|
|
|
|
|
2017-11-11 21:32:33 +01:00
|
|
|
# Clear out the REALM_HOSTS set in dev_settings.py
|
|
|
|
REALM_HOSTS = {}
|
|
|
|
|
2017-04-13 11:24:44 +02:00
|
|
|
# Used to clone DBs in backend tests.
|
|
|
|
BACKEND_DATABASE_TEMPLATE = 'zulip_test_template'
|
|
|
|
|
2016-12-28 05:16:12 +01:00
|
|
|
DATABASES["default"] = {
|
2018-07-09 08:56:55 +02:00
|
|
|
"NAME": os.getenv("ZULIP_DB_NAME", "zulip_test"),
|
2016-12-28 05:16:12 +01:00
|
|
|
"USER": "zulip_test",
|
|
|
|
"PASSWORD": LOCAL_DATABASE_PASSWORD,
|
|
|
|
"HOST": "localhost",
|
|
|
|
"SCHEMA": "zulip",
|
2019-01-24 02:03:38 +01:00
|
|
|
"ENGINE": "django.db.backends.postgresql",
|
2016-12-28 05:16:12 +01:00
|
|
|
"TEST_NAME": "django_zulip_tests",
|
|
|
|
"OPTIONS": {"connection_factory": TimeTrackingConnection},
|
|
|
|
}
|
2013-05-08 05:30:42 +02:00
|
|
|
|
2013-01-10 19:05:53 +01:00
|
|
|
if "TORNADO_SERVER" in os.environ:
|
2016-04-28 07:32:27 +02:00
|
|
|
# This covers the Casper test suite case
|
2013-01-10 19:05:53 +01:00
|
|
|
TORNADO_SERVER = os.environ["TORNADO_SERVER"]
|
|
|
|
else:
|
2016-04-28 07:32:27 +02:00
|
|
|
# This covers the backend test suite case
|
2013-01-10 19:05:53 +01:00
|
|
|
TORNADO_SERVER = None
|
2018-10-25 23:44:54 +02:00
|
|
|
CAMO_URI = 'https://external-content.zulipcdn.net/external_content/'
|
2016-04-28 07:32:27 +02:00
|
|
|
CAMO_KEY = 'dummy'
|
2012-12-11 18:12:40 +01:00
|
|
|
|
2016-12-15 07:02:42 +01:00
|
|
|
if "CASPER_TESTS" in os.environ:
|
|
|
|
CASPER_TESTS = True
|
2018-06-08 09:45:13 +02:00
|
|
|
# Disable search pills prototype for production use
|
|
|
|
SEARCH_PILLS_ENABLED = False
|
2016-12-15 07:02:42 +01:00
|
|
|
|
2019-10-21 12:43:00 +02:00
|
|
|
if "RUNNING_OPENAPI_CURL_TEST" in os.environ:
|
|
|
|
RUNNING_OPENAPI_CURL_TEST = True
|
|
|
|
|
2012-12-11 18:12:40 +01:00
|
|
|
# Decrease the get_updates timeout to 1 second.
|
|
|
|
# This allows CasperJS to proceed quickly to the next test step.
|
|
|
|
POLL_TIMEOUT = 1000
|
2013-01-09 00:10:37 +01:00
|
|
|
|
2013-01-10 19:05:53 +01:00
|
|
|
# Don't use the real message log for tests
|
2013-10-31 19:07:43 +01:00
|
|
|
EVENT_LOG_DIR = '/tmp/zulip-test-event-log'
|
2013-01-10 19:05:53 +01:00
|
|
|
|
2017-10-04 20:36:40 +02:00
|
|
|
# Stores the messages in `django.core.mail.outbox` rather than sending them.
|
2013-01-10 19:05:53 +01:00
|
|
|
EMAIL_BACKEND = 'django.core.mail.backends.locmem.EmailBackend'
|
2013-01-10 19:41:49 +01:00
|
|
|
|
2015-08-20 08:34:25 +02:00
|
|
|
# The test suite uses EmailAuthBackend
|
|
|
|
AUTHENTICATION_BACKENDS += ('zproject.backends.EmailAuthBackend',)
|
|
|
|
|
2016-09-13 21:30:18 +02:00
|
|
|
# Configure Google Oauth2
|
|
|
|
GOOGLE_OAUTH2_CLIENT_ID = "test_client_id"
|
|
|
|
|
2016-04-21 18:34:54 +02:00
|
|
|
# Makes testing LDAP backend require less mocking
|
|
|
|
AUTH_LDAP_ALWAYS_UPDATE_USER = False
|
2019-10-16 18:01:38 +02:00
|
|
|
AUTH_LDAP_USER_SEARCH = LDAPSearch("ou=users,dc=zulip,dc=com",
|
|
|
|
ldap.SCOPE_ONELEVEL, "(uid=%(user)s)")
|
2019-10-05 03:54:48 +02:00
|
|
|
AUTH_LDAP_USERNAME_ATTR = "uid"
|
|
|
|
AUTH_LDAP_REVERSE_EMAIL_SEARCH = LDAPSearch("ou=users,dc=zulip,dc=com",
|
|
|
|
ldap.SCOPE_ONELEVEL,
|
|
|
|
"(mail=%(email)s)")
|
2016-04-21 18:34:54 +02:00
|
|
|
|
2013-01-10 19:41:49 +01:00
|
|
|
TEST_SUITE = True
|
2013-05-29 23:58:07 +02:00
|
|
|
RATE_LIMITING = False
|
2013-01-11 21:16:42 +01:00
|
|
|
# Don't use rabbitmq from the test suite -- the user_profile_ids for
|
|
|
|
# any generated queue elements won't match those being used by the
|
|
|
|
# real app.
|
|
|
|
USING_RABBITMQ = False
|
|
|
|
|
2013-03-18 18:40:47 +01:00
|
|
|
# Disable the tutorial because it confuses the client tests.
|
|
|
|
TUTORIAL_ENABLED = False
|
|
|
|
|
2013-01-10 19:05:53 +01:00
|
|
|
# Disable use of memcached for caching
|
2013-07-02 23:29:00 +02:00
|
|
|
CACHES['database'] = {
|
2017-01-24 06:21:14 +01:00
|
|
|
'BACKEND': 'django.core.cache.backends.dummy.DummyCache',
|
2013-10-26 04:24:40 +02:00
|
|
|
'LOCATION': 'zulip-database-test-cache',
|
2017-01-24 06:21:14 +01:00
|
|
|
'TIMEOUT': 3600,
|
2013-11-08 17:35:40 +01:00
|
|
|
'CONN_MAX_AGE': 600,
|
2013-07-02 23:29:00 +02:00
|
|
|
'OPTIONS': {
|
|
|
|
'MAX_ENTRIES': 100000
|
|
|
|
}
|
|
|
|
}
|
2013-01-22 23:16:56 +01:00
|
|
|
|
2017-10-06 21:22:20 +02:00
|
|
|
# Disable caching on sessions to make query counts consistent
|
|
|
|
SESSION_ENGINE = "django.contrib.sessions.backends.db"
|
|
|
|
|
2017-05-24 00:03:53 +02:00
|
|
|
# Use production config from Webpack in tests
|
2017-05-25 20:12:33 +02:00
|
|
|
if CASPER_TESTS:
|
|
|
|
WEBPACK_FILE = 'webpack-stats-production.json'
|
|
|
|
else:
|
2017-07-18 21:47:47 +02:00
|
|
|
WEBPACK_FILE = os.path.join('var', 'webpack-stats-test.json')
|
|
|
|
WEBPACK_LOADER['DEFAULT']['STATS_FILE'] = os.path.join(DEPLOY_ROOT, WEBPACK_FILE)
|
2017-03-18 04:43:27 +01:00
|
|
|
|
2017-10-28 01:17:38 +02:00
|
|
|
# Don't auto-restart Tornado server during automated tests
|
|
|
|
AUTORELOAD = False
|
|
|
|
|
|
|
|
if not CASPER_TESTS:
|
2017-03-18 04:43:27 +01:00
|
|
|
# Use local memory cache for backend tests.
|
2017-02-13 08:31:12 +01:00
|
|
|
CACHES['default'] = {
|
|
|
|
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache'
|
|
|
|
}
|
2017-09-27 02:28:28 +02:00
|
|
|
|
2017-11-27 14:35:36 +01:00
|
|
|
def set_loglevel(logger_name, level) -> None:
|
2017-09-27 02:28:28 +02:00
|
|
|
LOGGING['loggers'].setdefault(logger_name, {})['level'] = level
|
|
|
|
set_loglevel('zulip.requests', 'CRITICAL')
|
|
|
|
set_loglevel('zulip.management', 'CRITICAL')
|
|
|
|
set_loglevel('django.request', 'ERROR')
|
|
|
|
set_loglevel('fakeldap', 'ERROR')
|
2017-10-28 00:34:36 +02:00
|
|
|
set_loglevel('zulip.send_email', 'ERROR')
|
2018-11-27 18:45:45 +01:00
|
|
|
set_loglevel('zerver.lib.push_notifications', 'WARNING')
|
2017-10-28 00:44:15 +02:00
|
|
|
set_loglevel('zerver.lib.digest', 'ERROR')
|
2017-10-28 00:50:15 +02:00
|
|
|
set_loglevel('zerver.lib.email_mirror', 'ERROR')
|
2017-12-20 18:08:35 +01:00
|
|
|
set_loglevel('zerver.worker.queue_processors', 'WARNING')
|
2018-12-28 07:26:52 +01:00
|
|
|
set_loglevel('stripe', 'WARNING')
|
2017-02-13 08:31:12 +01:00
|
|
|
|
2016-03-10 17:17:40 +01:00
|
|
|
# Enable file:/// hyperlink support by default in tests
|
|
|
|
ENABLE_FILE_LINKS = True
|
|
|
|
|
2019-07-02 22:15:51 +02:00
|
|
|
# These settings are set dynamically in `zerver/lib/test_runner.py`:
|
|
|
|
TEST_WORKER_DIR = ''
|
2019-07-16 08:10:29 +02:00
|
|
|
# Allow setting LOCAL_UPLOADS_DIR in the environment so that the
|
|
|
|
# Casper/API tests in test_server.py can control this.
|
|
|
|
if "LOCAL_UPLOADS_DIR" in os.environ:
|
|
|
|
LOCAL_UPLOADS_DIR = os.getenv("LOCAL_UPLOADS_DIR")
|
2019-08-07 20:46:05 +02:00
|
|
|
# Otherwise, we use the default value from dev_settings.py
|
2019-07-02 22:15:51 +02:00
|
|
|
|
2016-04-20 21:51:21 +02:00
|
|
|
S3_KEY = 'test-key'
|
|
|
|
S3_SECRET_KEY = 'test-secret-key'
|
|
|
|
S3_AUTH_UPLOADS_BUCKET = 'test-authed-bucket'
|
2017-12-21 09:37:59 +01:00
|
|
|
S3_AVATAR_BUCKET = 'test-avatar-bucket'
|
2016-05-11 19:29:29 +02:00
|
|
|
|
2016-10-27 12:06:44 +02:00
|
|
|
INLINE_URL_EMBED_PREVIEW = False
|
2017-03-18 01:58:45 +01:00
|
|
|
|
2018-12-04 02:12:08 +01:00
|
|
|
HOME_NOT_LOGGED_IN = '/login/'
|
|
|
|
LOGIN_URL = '/accounts/login/'
|
2017-01-30 23:19:38 +01:00
|
|
|
|
|
|
|
# By default will not send emails when login occurs.
|
|
|
|
# Explicity set this to True within tests that must have this on.
|
|
|
|
SEND_LOGIN_EMAILS = False
|
2017-08-16 18:28:09 +02:00
|
|
|
|
|
|
|
GOOGLE_OAUTH2_CLIENT_ID = "id"
|
|
|
|
GOOGLE_OAUTH2_CLIENT_SECRET = "secret"
|
|
|
|
|
|
|
|
SOCIAL_AUTH_GITHUB_KEY = "key"
|
|
|
|
SOCIAL_AUTH_GITHUB_SECRET = "secret"
|
2019-02-02 16:51:26 +01:00
|
|
|
SOCIAL_AUTH_GOOGLE_KEY = "key"
|
|
|
|
SOCIAL_AUTH_GOOGLE_SECRET = "secret"
|
2018-07-10 08:07:23 +02:00
|
|
|
SOCIAL_AUTH_SUBDOMAIN = 'www'
|
2017-07-12 09:36:51 +02:00
|
|
|
|
|
|
|
# By default two factor authentication is disabled in tests.
|
|
|
|
# Explicitly set this to True within tests that must have this on.
|
|
|
|
TWO_FACTOR_AUTHENTICATION_ENABLED = False
|
2018-05-04 01:40:46 +02:00
|
|
|
PUSH_NOTIFICATION_BOUNCER_URL = None
|
2018-05-19 03:21:15 +02:00
|
|
|
|
|
|
|
# Disable messages from slow queries as they affect backend tests.
|
2018-07-31 02:37:24 +02:00
|
|
|
SLOW_QUERY_LOGS_STREAM = None
|
2018-03-08 09:37:09 +01:00
|
|
|
|
|
|
|
THUMBOR_URL = 'http://127.0.0.1:9995'
|
2019-01-04 16:22:04 +01:00
|
|
|
THUMBNAIL_IMAGES = True
|
2018-12-17 17:27:05 +01:00
|
|
|
THUMBOR_SERVES_CAMO = True
|
2018-08-06 11:40:31 +02:00
|
|
|
|
|
|
|
# Logging the emails while running the tests adds them
|
|
|
|
# to /emails page.
|
|
|
|
DEVELOPMENT_LOG_EMAILS = False
|
2019-09-29 06:32:56 +02:00
|
|
|
|
|
|
|
SOCIAL_AUTH_SAML_SP_ENTITY_ID = 'http://' + EXTERNAL_HOST
|
|
|
|
SOCIAL_AUTH_SAML_SP_PUBLIC_CERT = get_from_file_if_exists("zerver/tests/fixtures/saml/zulip.crt")
|
|
|
|
SOCIAL_AUTH_SAML_SP_PRIVATE_KEY = get_from_file_if_exists("zerver/tests/fixtures/saml/zulip.key")
|
|
|
|
|
|
|
|
SOCIAL_AUTH_SAML_ORG_INFO = {
|
|
|
|
"en-US": {
|
|
|
|
"name": "example",
|
|
|
|
"displayname": "Example Inc.",
|
|
|
|
"url": "%s%s" % ('http://', EXTERNAL_HOST),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SOCIAL_AUTH_SAML_TECHNICAL_CONTACT = {
|
|
|
|
"givenName": "Tech Gal",
|
|
|
|
"emailAddress": "technical@example.com"
|
|
|
|
}
|
|
|
|
|
|
|
|
SOCIAL_AUTH_SAML_SUPPORT_CONTACT = {
|
|
|
|
"givenName": "Support Guy",
|
|
|
|
"emailAddress": "support@example.com",
|
|
|
|
}
|
|
|
|
|
|
|
|
SOCIAL_AUTH_SAML_ENABLED_IDPS = {
|
|
|
|
"test_idp": {
|
|
|
|
"entity_id": "https://idp.testshib.org/idp/shibboleth",
|
|
|
|
"url": "https://idp.testshib.org/idp/profile/SAML2/Redirect/SSO",
|
|
|
|
"x509cert": get_from_file_if_exists("zerver/tests/fixtures/saml/idp.crt"),
|
|
|
|
"attr_user_permanent_id": "email",
|
|
|
|
"attr_first_name": "first_name",
|
|
|
|
"attr_last_name": "last_name",
|
|
|
|
"attr_username": "email",
|
|
|
|
"attr_email": "email",
|
2019-10-22 18:23:57 +02:00
|
|
|
"display_name": "Test IdP",
|
2019-11-05 00:08:27 +01:00
|
|
|
"display_icon": None,
|
2019-09-29 06:32:56 +02:00
|
|
|
}
|
|
|
|
}
|