Commit e5f44165 by ihoover

Made activation flag and ENV_TOKEN

parent 9eb1cce3
......@@ -952,7 +952,7 @@ def create_random_account_with_name_and_password(create_account_function):
# for load testing we want to create lots of accounts
# with controlled username and password
if settings.AUTOMATIC_AUTH_FOR_LOAD_TESTING:
if settings.MITX_FEATURES.get('AUTOMATIC_AUTH_FOR_LOAD_TESTING'):
create_account = create_random_account_with_name_and_password(create_account)
@ensure_csrf_cookie
......
......@@ -53,7 +53,7 @@ def courses(request):
def auto_auth(request):
"""
Automatically logs the anonymous user in with a generated random credentials
Automatically logs the user in with a generated random credentials
This view is only accessible when settings.AUTOMATIC_AUTH_FOR_LOAD_TESTING is
true.
"""
......@@ -62,7 +62,7 @@ def auto_auth(request):
from django.contrib.auth import login, authenticate
from random import randint
# generate random user ceredentials from a small name space
# generate random user ceredentials from a small name space (determined by settings)
name_base = 'USER_'
pass_base = 'PASS_'
......@@ -71,14 +71,14 @@ def auto_auth(request):
username = name_base + str(number)
password = pass_base + str(number)
# if they already are a user, log in
# if they already are a user, log in
try:
user = User.objects.get(username=username)
user = authenticate(username=username, password=password)
login(request, user)
# else create and activate account info
except:
# create and activate account info
student.views.create_account(request, username, password)
request.user.is_active = True
request.user.save()
......
......@@ -178,6 +178,8 @@ for name, value in ENV_TOKENS.get("CODE_JAIL", {}).items():
COURSES_WITH_UNSAFE_CODE = ENV_TOKENS.get("COURSES_WITH_UNSAFE_CODE", [])
# automatic log in for load testing
MITX_FEATURES['AUTOMATIC_AUTH_FOR_LOAD_TESTING'] = ENV_TOKENS.get('AUTOMATIC_AUTH_FOR_LOAD_TESTING')
############################## SECURE AUTH ITEMS ###############
# Secret things: passwords, access keys, etc.
......
......@@ -37,8 +37,8 @@ PLATFORM_NAME = "edX"
COURSEWARE_ENABLED = True
ENABLE_JASMINE = False
AUTOMATIC_AUTH_FOR_LOAD_TESTING = True
MAX_AUTO_AUTH_USERS = 2
# only relevant if MITX_FEATURES['AUTOMATIC_AUTH_FOR_LOAD_TESTING'] = True
MAX_AUTO_AUTH_USERS = 20
GENERATE_RANDOM_USER_CREDENTIALS = False
PERFSTATS = False
......@@ -150,6 +150,9 @@ MITX_FEATURES = {
# Allow use of the hint managment instructor view.
'ENABLE_HINTER_INSTRUCTOR_VIEW': False,
# for load testing
'AUTOMATIC_AUTH_FOR_LOAD_TESTING': False,
}
# Used for A/B testing
......@@ -233,7 +236,7 @@ TEMPLATE_CONTEXT_PROCESSORS = (
)
# add csrf support unless disabled for load testing
if not AUTOMATIC_AUTH_FOR_LOAD_TESTING:
if not MITX_FEATURES.get('AUTOMATIC_AUTH_FOR_LOAD_TESTING'):
TEMPLATE_CONTEXT_PROCESSORS += ('django.core.context_processors.csrf',) # necessary for csrf protection
STUDENT_FILEUPLOAD_MAX_SIZE = 4 * 1000 * 1000 # 4 MB
......@@ -491,7 +494,7 @@ MIDDLEWARE_CLASSES = (
)
# add in csrf middleware unless disabled for load testing
if not AUTOMATIC_AUTH_FOR_LOAD_TESTING:
if not MITX_FEATURES.get('AUTOMATIC_AUTH_FOR_LOAD_TESTING'):
MIDDLEWARE_CLASSES = MIDDLEWARE_CLASSES + ('django.middleware.csrf.CsrfViewMiddleware',)
############################### Pipeline #######################################
......
......@@ -440,7 +440,7 @@ if settings.DEBUG:
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
# enable automatic login
if settings.AUTOMATIC_AUTH_FOR_LOAD_TESTING:
if settings.MITX_FEATURES.get('AUTOMATIC_AUTH_FOR_LOAD_TESTING'):
urlpatterns += (
url(r'^auto_auth$', 'branding.views.auto_auth'),
)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment