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): ...@@ -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 # for load testing we want to create lots of accounts
# with controlled username and password # 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) create_account = create_random_account_with_name_and_password(create_account)
@ensure_csrf_cookie @ensure_csrf_cookie
......
...@@ -53,7 +53,7 @@ def courses(request): ...@@ -53,7 +53,7 @@ def courses(request):
def auto_auth(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 This view is only accessible when settings.AUTOMATIC_AUTH_FOR_LOAD_TESTING is
true. true.
""" """
...@@ -62,7 +62,7 @@ def auto_auth(request): ...@@ -62,7 +62,7 @@ def auto_auth(request):
from django.contrib.auth import login, authenticate from django.contrib.auth import login, authenticate
from random import randint 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_' name_base = 'USER_'
pass_base = 'PASS_' pass_base = 'PASS_'
...@@ -71,14 +71,14 @@ def auto_auth(request): ...@@ -71,14 +71,14 @@ def auto_auth(request):
username = name_base + str(number) username = name_base + str(number)
password = pass_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: try:
user = User.objects.get(username=username) user = User.objects.get(username=username)
user = authenticate(username=username, password=password) user = authenticate(username=username, password=password)
login(request, user) login(request, user)
# else create and activate account info
except: except:
# create and activate account info
student.views.create_account(request, username, password) student.views.create_account(request, username, password)
request.user.is_active = True request.user.is_active = True
request.user.save() request.user.save()
......
...@@ -178,6 +178,8 @@ for name, value in ENV_TOKENS.get("CODE_JAIL", {}).items(): ...@@ -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", []) 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 ############### ############################## SECURE AUTH ITEMS ###############
# Secret things: passwords, access keys, etc. # Secret things: passwords, access keys, etc.
......
...@@ -37,8 +37,8 @@ PLATFORM_NAME = "edX" ...@@ -37,8 +37,8 @@ PLATFORM_NAME = "edX"
COURSEWARE_ENABLED = True COURSEWARE_ENABLED = True
ENABLE_JASMINE = False ENABLE_JASMINE = False
AUTOMATIC_AUTH_FOR_LOAD_TESTING = True # only relevant if MITX_FEATURES['AUTOMATIC_AUTH_FOR_LOAD_TESTING'] = True
MAX_AUTO_AUTH_USERS = 2 MAX_AUTO_AUTH_USERS = 20
GENERATE_RANDOM_USER_CREDENTIALS = False GENERATE_RANDOM_USER_CREDENTIALS = False
PERFSTATS = False PERFSTATS = False
...@@ -150,6 +150,9 @@ MITX_FEATURES = { ...@@ -150,6 +150,9 @@ MITX_FEATURES = {
# Allow use of the hint managment instructor view. # Allow use of the hint managment instructor view.
'ENABLE_HINTER_INSTRUCTOR_VIEW': False, 'ENABLE_HINTER_INSTRUCTOR_VIEW': False,
# for load testing
'AUTOMATIC_AUTH_FOR_LOAD_TESTING': False,
} }
# Used for A/B testing # Used for A/B testing
...@@ -233,7 +236,7 @@ TEMPLATE_CONTEXT_PROCESSORS = ( ...@@ -233,7 +236,7 @@ TEMPLATE_CONTEXT_PROCESSORS = (
) )
# add csrf support unless disabled for load testing # 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 TEMPLATE_CONTEXT_PROCESSORS += ('django.core.context_processors.csrf',) # necessary for csrf protection
STUDENT_FILEUPLOAD_MAX_SIZE = 4 * 1000 * 1000 # 4 MB STUDENT_FILEUPLOAD_MAX_SIZE = 4 * 1000 * 1000 # 4 MB
...@@ -491,7 +494,7 @@ MIDDLEWARE_CLASSES = ( ...@@ -491,7 +494,7 @@ MIDDLEWARE_CLASSES = (
) )
# add in csrf middleware unless disabled for load testing # 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',) MIDDLEWARE_CLASSES = MIDDLEWARE_CLASSES + ('django.middleware.csrf.CsrfViewMiddleware',)
############################### Pipeline ####################################### ############################### Pipeline #######################################
......
...@@ -440,7 +440,7 @@ if settings.DEBUG: ...@@ -440,7 +440,7 @@ if settings.DEBUG:
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
# enable automatic login # enable automatic login
if settings.AUTOMATIC_AUTH_FOR_LOAD_TESTING: if settings.MITX_FEATURES.get('AUTOMATIC_AUTH_FOR_LOAD_TESTING'):
urlpatterns += ( urlpatterns += (
url(r'^auto_auth$', 'branding.views.auto_auth'), 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