2016-08-08 17:24:07 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
|
|
|
|
import django
|
|
|
|
|
|
|
|
from django.conf import settings
|
|
|
|
|
|
|
|
|
|
|
|
DEFAULT_SETTINGS = dict(
|
|
|
|
|
2018-02-01 17:00:57 +00:00
|
|
|
DEBUG=False,
|
2016-08-08 17:24:07 +00:00
|
|
|
|
2018-02-01 17:00:57 +00:00
|
|
|
DATABASES={
|
2016-08-08 17:24:07 +00:00
|
|
|
'default': {
|
|
|
|
'ENGINE': 'django.db.backends.sqlite3',
|
|
|
|
'NAME': ':memory:',
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2018-02-01 17:00:57 +00:00
|
|
|
SITE_ID=1,
|
2016-08-08 17:24:07 +00:00
|
|
|
|
2018-02-01 17:00:57 +00:00
|
|
|
MIDDLEWARE_CLASSES=[
|
2016-08-08 17:24:07 +00:00
|
|
|
'django.middleware.common.CommonMiddleware',
|
|
|
|
'django.contrib.sessions.middleware.SessionMiddleware',
|
|
|
|
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
|
|
|
],
|
|
|
|
|
2018-02-01 17:00:57 +00:00
|
|
|
MIDDLEWARE=[
|
|
|
|
'django.middleware.common.CommonMiddleware',
|
|
|
|
'django.contrib.sessions.middleware.SessionMiddleware',
|
|
|
|
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
|
|
|
],
|
|
|
|
|
|
|
|
TEMPLATES=[
|
2016-08-08 17:24:07 +00:00
|
|
|
{
|
|
|
|
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
|
|
|
'DIRS': [],
|
|
|
|
'APP_DIRS': True,
|
|
|
|
'OPTIONS': {
|
|
|
|
'context_processors': [
|
|
|
|
'django.template.context_processors.debug',
|
|
|
|
'django.template.context_processors.request',
|
|
|
|
'django.contrib.auth.context_processors.auth',
|
|
|
|
'django.contrib.messages.context_processors.messages',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
|
2018-02-01 17:00:57 +00:00
|
|
|
LOGGING={
|
2016-08-08 17:24:07 +00:00
|
|
|
'version': 1,
|
|
|
|
'disable_existing_loggers': False,
|
|
|
|
'handlers': {
|
|
|
|
'console': {
|
|
|
|
'class': 'logging.StreamHandler',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'loggers': {
|
|
|
|
'oidc_provider': {
|
|
|
|
'handlers': ['console'],
|
|
|
|
'level': os.getenv('DJANGO_LOG_LEVEL', 'DEBUG'),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2018-02-01 17:00:57 +00:00
|
|
|
INSTALLED_APPS=[
|
2016-08-08 17:24:07 +00:00
|
|
|
'django.contrib.auth',
|
|
|
|
'django.contrib.contenttypes',
|
|
|
|
'django.contrib.sessions',
|
|
|
|
'django.contrib.sites',
|
|
|
|
'django.contrib.messages',
|
|
|
|
'django.contrib.admin',
|
|
|
|
'oidc_provider',
|
|
|
|
],
|
|
|
|
|
2018-02-01 17:00:57 +00:00
|
|
|
SECRET_KEY='this-should-be-top-secret',
|
2016-08-08 17:24:07 +00:00
|
|
|
|
2018-02-01 17:00:57 +00:00
|
|
|
ROOT_URLCONF='oidc_provider.tests.app.urls',
|
2016-08-08 17:24:07 +00:00
|
|
|
|
2018-02-01 17:00:57 +00:00
|
|
|
TEMPLATE_DIRS=[
|
2016-08-08 17:24:07 +00:00
|
|
|
'oidc_provider/tests/templates',
|
|
|
|
],
|
|
|
|
|
2018-02-01 17:00:57 +00:00
|
|
|
USE_TZ=True,
|
2016-08-08 17:24:07 +00:00
|
|
|
|
|
|
|
# OIDC Provider settings.
|
|
|
|
|
2018-02-01 17:00:57 +00:00
|
|
|
SITE_URL='http://localhost:8000',
|
|
|
|
OIDC_USERINFO='oidc_provider.tests.app.utils.userinfo',
|
2016-08-08 17:24:07 +00:00
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
def runtests(*test_args):
|
|
|
|
if not settings.configured:
|
|
|
|
settings.configure(**DEFAULT_SETTINGS)
|
|
|
|
|
|
|
|
django.setup()
|
|
|
|
|
|
|
|
parent = os.path.dirname(os.path.abspath(__file__))
|
|
|
|
sys.path.insert(0, parent)
|
|
|
|
|
|
|
|
try:
|
|
|
|
from django.test.runner import DiscoverRunner
|
|
|
|
runner_class = DiscoverRunner
|
2016-08-11 22:19:10 +00:00
|
|
|
if not test_args:
|
|
|
|
test_args = ["oidc_provider.tests"]
|
2016-08-08 17:24:07 +00:00
|
|
|
except ImportError:
|
|
|
|
from django.test.simple import DjangoTestSuiteRunner
|
|
|
|
runner_class = DjangoTestSuiteRunner
|
2016-08-11 22:19:10 +00:00
|
|
|
if not test_args:
|
|
|
|
test_args = ["tests"]
|
2016-08-08 17:24:07 +00:00
|
|
|
|
|
|
|
failures = runner_class(verbosity=1, interactive=True, failfast=False).run_tests(test_args)
|
|
|
|
sys.exit(failures)
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
runtests(*sys.argv[1:])
|